agent-swarm-kit 1.0.113 → 1.0.114
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 +34 -72
- package/build/index.mjs +34 -72
- package/package.json +1 -1
- package/types.d.ts +9 -49
package/build/index.cjs
CHANGED
|
@@ -11765,23 +11765,19 @@ var SharedStateUtils = /** @class */ (function () {
|
|
|
11765
11765
|
* Retrieves the state for a given client and state name.
|
|
11766
11766
|
* @template T
|
|
11767
11767
|
* @param {Object} payload - The payload containing client and state information.
|
|
11768
|
-
* @param {AgentName} payload.agentName - The agent name.
|
|
11769
11768
|
* @param {StateName} payload.stateName - The state name.
|
|
11770
11769
|
* @returns {Promise<T>} The state data.
|
|
11771
11770
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
11772
11771
|
*/
|
|
11773
|
-
this.getState = function (
|
|
11772
|
+
this.getState = function (stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
11774
11773
|
return __generator(this, function (_a) {
|
|
11775
11774
|
switch (_a.label) {
|
|
11776
11775
|
case 0:
|
|
11777
11776
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
11778
11777
|
swarm$1.loggerService.log(METHOD_NAME_GET$2, {
|
|
11779
|
-
stateName:
|
|
11778
|
+
stateName: stateName,
|
|
11780
11779
|
});
|
|
11781
|
-
|
|
11782
|
-
throw new Error("agent-swarm SharedStateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (getSharedState)"));
|
|
11783
|
-
}
|
|
11784
|
-
return [4 /*yield*/, swarm$1.sharedStatePublicService.getState(METHOD_NAME_GET$2, payload.stateName)];
|
|
11780
|
+
return [4 /*yield*/, swarm$1.sharedStatePublicService.getState(METHOD_NAME_GET$2, stateName)];
|
|
11785
11781
|
case 1: return [2 /*return*/, _a.sent()];
|
|
11786
11782
|
}
|
|
11787
11783
|
});
|
|
@@ -11790,30 +11786,25 @@ var SharedStateUtils = /** @class */ (function () {
|
|
|
11790
11786
|
* Sets the state for a given client and state name.
|
|
11791
11787
|
* @template T
|
|
11792
11788
|
* @param {T | ((prevSharedState: T) => Promise<T>)} dispatchFn - The new state or a function that returns the new state.
|
|
11793
|
-
* @param {
|
|
11794
|
-
* @param {AgentName} payload.agentName - The agent name.
|
|
11795
|
-
* @param {StateName} payload.stateName - The state name.
|
|
11789
|
+
* @param {StateName} stateName - The state name.
|
|
11796
11790
|
* @returns {Promise<void>}
|
|
11797
11791
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
11798
11792
|
*/
|
|
11799
|
-
this.setState = function (dispatchFn,
|
|
11793
|
+
this.setState = function (dispatchFn, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
11800
11794
|
var _this = this;
|
|
11801
11795
|
return __generator(this, function (_a) {
|
|
11802
11796
|
switch (_a.label) {
|
|
11803
11797
|
case 0:
|
|
11804
11798
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
11805
11799
|
swarm$1.loggerService.log(METHOD_NAME_SET, {
|
|
11806
|
-
stateName:
|
|
11800
|
+
stateName: stateName,
|
|
11807
11801
|
});
|
|
11808
|
-
if (!swarm$1.agentValidationService.hasState(payload.agentName, payload.stateName)) {
|
|
11809
|
-
throw new Error("agent-swarm SharedStateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (setState)"));
|
|
11810
|
-
}
|
|
11811
11802
|
if (!(typeof dispatchFn === "function")) return [3 /*break*/, 2];
|
|
11812
|
-
return [4 /*yield*/, swarm$1.sharedStatePublicService.setState(dispatchFn, METHOD_NAME_SET,
|
|
11803
|
+
return [4 /*yield*/, swarm$1.sharedStatePublicService.setState(dispatchFn, METHOD_NAME_SET, stateName)];
|
|
11813
11804
|
case 1: return [2 /*return*/, _a.sent()];
|
|
11814
11805
|
case 2: return [4 /*yield*/, swarm$1.sharedStatePublicService.setState(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
11815
11806
|
return [2 /*return*/, dispatchFn];
|
|
11816
|
-
}); }); }, METHOD_NAME_SET,
|
|
11807
|
+
}); }); }, METHOD_NAME_SET, stateName)];
|
|
11817
11808
|
case 3: return [2 /*return*/, _a.sent()];
|
|
11818
11809
|
}
|
|
11819
11810
|
});
|
|
@@ -11821,24 +11812,19 @@ var SharedStateUtils = /** @class */ (function () {
|
|
|
11821
11812
|
/**
|
|
11822
11813
|
* Set the state to initial value
|
|
11823
11814
|
* @template T
|
|
11824
|
-
* @param {Object} payload - The payload containing client and state information.
|
|
11825
|
-
* @param {AgentName} payload.agentName - The agent name.
|
|
11826
11815
|
* @param {StateName} payload.stateName - The state name.
|
|
11827
11816
|
* @returns {Promise<void>}
|
|
11828
11817
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
11829
11818
|
*/
|
|
11830
|
-
this.clearState = function (
|
|
11819
|
+
this.clearState = function (stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
11831
11820
|
return __generator(this, function (_a) {
|
|
11832
11821
|
switch (_a.label) {
|
|
11833
11822
|
case 0:
|
|
11834
11823
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
11835
11824
|
swarm$1.loggerService.log(METHOD_NAME_SET, {
|
|
11836
|
-
stateName:
|
|
11825
|
+
stateName: stateName,
|
|
11837
11826
|
});
|
|
11838
|
-
|
|
11839
|
-
throw new Error("agent-swarm SharedStateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (clearState)"));
|
|
11840
|
-
}
|
|
11841
|
-
return [4 /*yield*/, swarm$1.sharedStatePublicService.clearState(METHOD_NAME_CLEAR$2, payload.stateName)];
|
|
11827
|
+
return [4 /*yield*/, swarm$1.sharedStatePublicService.clearState(METHOD_NAME_CLEAR$2, stateName)];
|
|
11842
11828
|
case 1: return [2 /*return*/, _a.sent()];
|
|
11843
11829
|
}
|
|
11844
11830
|
});
|
|
@@ -12048,7 +12034,6 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
12048
12034
|
* Takes items from the storage.
|
|
12049
12035
|
* @param {string} search - The search query.
|
|
12050
12036
|
* @param {number} total - The total number of items to take.
|
|
12051
|
-
* @param {AgentName} agentName - The agent name.
|
|
12052
12037
|
* @param {StorageName} storageName - The storage name.
|
|
12053
12038
|
* @returns {Promise<T[]>} - A promise that resolves to an array of items.
|
|
12054
12039
|
* @template T
|
|
@@ -12065,9 +12050,6 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
12065
12050
|
score: payload.score,
|
|
12066
12051
|
});
|
|
12067
12052
|
swarm$1.storageValidationService.validate(payload.storageName, METHOD_NAME_TAKE);
|
|
12068
|
-
if (!swarm$1.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
12069
|
-
throw new Error("agent-swarm SharedStorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (take)"));
|
|
12070
|
-
}
|
|
12071
12053
|
return [4 /*yield*/, swarm$1.sharedStoragePublicService.take(payload.search, payload.total, METHOD_NAME_TAKE, payload.storageName, payload.score)];
|
|
12072
12054
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
12073
12055
|
}
|
|
@@ -12076,25 +12058,21 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
12076
12058
|
/**
|
|
12077
12059
|
* Upserts an item in the storage.
|
|
12078
12060
|
* @param {T} item - The item to upsert.
|
|
12079
|
-
* @param {AgentName} agentName - The agent name.
|
|
12080
12061
|
* @param {StorageName} storageName - The storage name.
|
|
12081
12062
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
12082
12063
|
* @template T
|
|
12083
12064
|
*/
|
|
12084
|
-
this.upsert = function (
|
|
12065
|
+
this.upsert = function (item, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
12085
12066
|
return __generator(this, function (_a) {
|
|
12086
12067
|
switch (_a.label) {
|
|
12087
12068
|
case 0:
|
|
12088
12069
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
12089
12070
|
swarm$1.loggerService.log(METHOD_NAME_UPSERT, {
|
|
12090
|
-
item:
|
|
12091
|
-
storageName:
|
|
12071
|
+
item: item,
|
|
12072
|
+
storageName: storageName,
|
|
12092
12073
|
});
|
|
12093
|
-
swarm$1.storageValidationService.validate(
|
|
12094
|
-
|
|
12095
|
-
throw new Error("agent-swarm SharedStorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (upsert)"));
|
|
12096
|
-
}
|
|
12097
|
-
return [4 /*yield*/, swarm$1.sharedStoragePublicService.upsert(payload.item, METHOD_NAME_UPSERT, payload.storageName)];
|
|
12074
|
+
swarm$1.storageValidationService.validate(storageName, METHOD_NAME_UPSERT);
|
|
12075
|
+
return [4 /*yield*/, swarm$1.sharedStoragePublicService.upsert(item, METHOD_NAME_UPSERT, storageName)];
|
|
12098
12076
|
case 1: return [2 /*return*/, _a.sent()];
|
|
12099
12077
|
}
|
|
12100
12078
|
});
|
|
@@ -12102,24 +12080,20 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
12102
12080
|
/**
|
|
12103
12081
|
* Removes an item from the storage.
|
|
12104
12082
|
* @param {IStorageData["id"]} itemId - The ID of the item to remove.
|
|
12105
|
-
* @param {AgentName} agentName - The agent name.
|
|
12106
12083
|
* @param {StorageName} storageName - The storage name.
|
|
12107
12084
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
12108
12085
|
*/
|
|
12109
|
-
this.remove = function (
|
|
12086
|
+
this.remove = function (itemId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
12110
12087
|
return __generator(this, function (_a) {
|
|
12111
12088
|
switch (_a.label) {
|
|
12112
12089
|
case 0:
|
|
12113
12090
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
12114
12091
|
swarm$1.loggerService.log(METHOD_NAME_REMOVE, {
|
|
12115
|
-
itemId:
|
|
12116
|
-
storageName:
|
|
12092
|
+
itemId: itemId,
|
|
12093
|
+
storageName: storageName,
|
|
12117
12094
|
});
|
|
12118
|
-
swarm$1.storageValidationService.validate(
|
|
12119
|
-
|
|
12120
|
-
throw new Error("agent-swarm SharedStorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (remove)"));
|
|
12121
|
-
}
|
|
12122
|
-
return [4 /*yield*/, swarm$1.sharedStoragePublicService.remove(payload.itemId, METHOD_NAME_REMOVE, payload.storageName)];
|
|
12095
|
+
swarm$1.storageValidationService.validate(storageName, METHOD_NAME_REMOVE);
|
|
12096
|
+
return [4 /*yield*/, swarm$1.sharedStoragePublicService.remove(itemId, METHOD_NAME_REMOVE, storageName)];
|
|
12123
12097
|
case 1: return [2 /*return*/, _a.sent()];
|
|
12124
12098
|
}
|
|
12125
12099
|
});
|
|
@@ -12127,73 +12101,61 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
12127
12101
|
/**
|
|
12128
12102
|
* Gets an item from the storage.
|
|
12129
12103
|
* @param {IStorageData["id"]} itemId - The ID of the item to get.
|
|
12130
|
-
* @param {AgentName} agentName - The agent name.
|
|
12131
12104
|
* @param {StorageName} storageName - The storage name.
|
|
12132
12105
|
* @returns {Promise<T | null>} - A promise that resolves to the item or null if not found.
|
|
12133
12106
|
* @template T
|
|
12134
12107
|
*/
|
|
12135
|
-
this.get = function (
|
|
12108
|
+
this.get = function (itemId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
12136
12109
|
return __generator(this, function (_a) {
|
|
12137
12110
|
switch (_a.label) {
|
|
12138
12111
|
case 0:
|
|
12139
12112
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
12140
12113
|
swarm$1.loggerService.log(METHOD_NAME_GET, {
|
|
12141
|
-
itemId:
|
|
12142
|
-
storageName:
|
|
12114
|
+
itemId: itemId,
|
|
12115
|
+
storageName: storageName,
|
|
12143
12116
|
});
|
|
12144
|
-
swarm$1.storageValidationService.validate(
|
|
12145
|
-
|
|
12146
|
-
throw new Error("agent-swarm SharedStorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (get)"));
|
|
12147
|
-
}
|
|
12148
|
-
return [4 /*yield*/, swarm$1.sharedStoragePublicService.get(payload.itemId, METHOD_NAME_GET, payload.storageName)];
|
|
12117
|
+
swarm$1.storageValidationService.validate(storageName, METHOD_NAME_GET);
|
|
12118
|
+
return [4 /*yield*/, swarm$1.sharedStoragePublicService.get(itemId, METHOD_NAME_GET, storageName)];
|
|
12149
12119
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
12150
12120
|
}
|
|
12151
12121
|
});
|
|
12152
12122
|
}); };
|
|
12153
12123
|
/**
|
|
12154
12124
|
* Lists items from the storage.
|
|
12155
|
-
* @param {AgentName} agentName - The agent name.
|
|
12156
12125
|
* @param {StorageName} storageName - The storage name.
|
|
12157
12126
|
* @param {(item: T) => boolean} [filter] - Optional filter function.
|
|
12158
12127
|
* @returns {Promise<T[]>} - A promise that resolves to an array of items.
|
|
12159
12128
|
* @template T
|
|
12160
12129
|
*/
|
|
12161
|
-
this.list = function (
|
|
12130
|
+
this.list = function (storageName, filter) { return __awaiter(_this, void 0, void 0, function () {
|
|
12162
12131
|
return __generator(this, function (_a) {
|
|
12163
12132
|
switch (_a.label) {
|
|
12164
12133
|
case 0:
|
|
12165
12134
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
12166
12135
|
swarm$1.loggerService.log(METHOD_NAME_LIST, {
|
|
12167
|
-
storageName:
|
|
12136
|
+
storageName: storageName,
|
|
12168
12137
|
});
|
|
12169
|
-
swarm$1.storageValidationService.validate(
|
|
12170
|
-
|
|
12171
|
-
throw new Error("agent-swarm SharedStorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (list)"));
|
|
12172
|
-
}
|
|
12173
|
-
return [4 /*yield*/, swarm$1.sharedStoragePublicService.list(METHOD_NAME_LIST, payload.storageName, payload.filter)];
|
|
12138
|
+
swarm$1.storageValidationService.validate(storageName, METHOD_NAME_LIST);
|
|
12139
|
+
return [4 /*yield*/, swarm$1.sharedStoragePublicService.list(METHOD_NAME_LIST, storageName, filter)];
|
|
12174
12140
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
12175
12141
|
}
|
|
12176
12142
|
});
|
|
12177
12143
|
}); };
|
|
12178
12144
|
/**
|
|
12179
12145
|
* Clears the storage.
|
|
12180
|
-
* @param {AgentName} agentName - The agent name.
|
|
12181
12146
|
* @param {StorageName} storageName - The storage name.
|
|
12182
12147
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
12183
12148
|
*/
|
|
12184
|
-
this.clear = function (
|
|
12149
|
+
this.clear = function (storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
12185
12150
|
return __generator(this, function (_a) {
|
|
12186
12151
|
switch (_a.label) {
|
|
12187
12152
|
case 0:
|
|
12188
12153
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
12189
12154
|
swarm$1.loggerService.log(METHOD_NAME_CLEAR, {
|
|
12190
|
-
storageName:
|
|
12155
|
+
storageName: storageName,
|
|
12191
12156
|
});
|
|
12192
|
-
swarm$1.storageValidationService.validate(
|
|
12193
|
-
|
|
12194
|
-
throw new Error("agent-swarm SharedStorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (clear)"));
|
|
12195
|
-
}
|
|
12196
|
-
return [4 /*yield*/, swarm$1.sharedStoragePublicService.clear(METHOD_NAME_CLEAR, payload.storageName)];
|
|
12157
|
+
swarm$1.storageValidationService.validate(storageName, METHOD_NAME_CLEAR);
|
|
12158
|
+
return [4 /*yield*/, swarm$1.sharedStoragePublicService.clear(METHOD_NAME_CLEAR, storageName)];
|
|
12197
12159
|
case 1: return [2 /*return*/, _a.sent()];
|
|
12198
12160
|
}
|
|
12199
12161
|
});
|
package/build/index.mjs
CHANGED
|
@@ -11763,23 +11763,19 @@ var SharedStateUtils = /** @class */ (function () {
|
|
|
11763
11763
|
* Retrieves the state for a given client and state name.
|
|
11764
11764
|
* @template T
|
|
11765
11765
|
* @param {Object} payload - The payload containing client and state information.
|
|
11766
|
-
* @param {AgentName} payload.agentName - The agent name.
|
|
11767
11766
|
* @param {StateName} payload.stateName - The state name.
|
|
11768
11767
|
* @returns {Promise<T>} The state data.
|
|
11769
11768
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
11770
11769
|
*/
|
|
11771
|
-
this.getState = function (
|
|
11770
|
+
this.getState = function (stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
11772
11771
|
return __generator(this, function (_a) {
|
|
11773
11772
|
switch (_a.label) {
|
|
11774
11773
|
case 0:
|
|
11775
11774
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
11776
11775
|
swarm$1.loggerService.log(METHOD_NAME_GET$2, {
|
|
11777
|
-
stateName:
|
|
11776
|
+
stateName: stateName,
|
|
11778
11777
|
});
|
|
11779
|
-
|
|
11780
|
-
throw new Error("agent-swarm SharedStateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (getSharedState)"));
|
|
11781
|
-
}
|
|
11782
|
-
return [4 /*yield*/, swarm$1.sharedStatePublicService.getState(METHOD_NAME_GET$2, payload.stateName)];
|
|
11778
|
+
return [4 /*yield*/, swarm$1.sharedStatePublicService.getState(METHOD_NAME_GET$2, stateName)];
|
|
11783
11779
|
case 1: return [2 /*return*/, _a.sent()];
|
|
11784
11780
|
}
|
|
11785
11781
|
});
|
|
@@ -11788,30 +11784,25 @@ var SharedStateUtils = /** @class */ (function () {
|
|
|
11788
11784
|
* Sets the state for a given client and state name.
|
|
11789
11785
|
* @template T
|
|
11790
11786
|
* @param {T | ((prevSharedState: T) => Promise<T>)} dispatchFn - The new state or a function that returns the new state.
|
|
11791
|
-
* @param {
|
|
11792
|
-
* @param {AgentName} payload.agentName - The agent name.
|
|
11793
|
-
* @param {StateName} payload.stateName - The state name.
|
|
11787
|
+
* @param {StateName} stateName - The state name.
|
|
11794
11788
|
* @returns {Promise<void>}
|
|
11795
11789
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
11796
11790
|
*/
|
|
11797
|
-
this.setState = function (dispatchFn,
|
|
11791
|
+
this.setState = function (dispatchFn, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
11798
11792
|
var _this = this;
|
|
11799
11793
|
return __generator(this, function (_a) {
|
|
11800
11794
|
switch (_a.label) {
|
|
11801
11795
|
case 0:
|
|
11802
11796
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
11803
11797
|
swarm$1.loggerService.log(METHOD_NAME_SET, {
|
|
11804
|
-
stateName:
|
|
11798
|
+
stateName: stateName,
|
|
11805
11799
|
});
|
|
11806
|
-
if (!swarm$1.agentValidationService.hasState(payload.agentName, payload.stateName)) {
|
|
11807
|
-
throw new Error("agent-swarm SharedStateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (setState)"));
|
|
11808
|
-
}
|
|
11809
11800
|
if (!(typeof dispatchFn === "function")) return [3 /*break*/, 2];
|
|
11810
|
-
return [4 /*yield*/, swarm$1.sharedStatePublicService.setState(dispatchFn, METHOD_NAME_SET,
|
|
11801
|
+
return [4 /*yield*/, swarm$1.sharedStatePublicService.setState(dispatchFn, METHOD_NAME_SET, stateName)];
|
|
11811
11802
|
case 1: return [2 /*return*/, _a.sent()];
|
|
11812
11803
|
case 2: return [4 /*yield*/, swarm$1.sharedStatePublicService.setState(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
11813
11804
|
return [2 /*return*/, dispatchFn];
|
|
11814
|
-
}); }); }, METHOD_NAME_SET,
|
|
11805
|
+
}); }); }, METHOD_NAME_SET, stateName)];
|
|
11815
11806
|
case 3: return [2 /*return*/, _a.sent()];
|
|
11816
11807
|
}
|
|
11817
11808
|
});
|
|
@@ -11819,24 +11810,19 @@ var SharedStateUtils = /** @class */ (function () {
|
|
|
11819
11810
|
/**
|
|
11820
11811
|
* Set the state to initial value
|
|
11821
11812
|
* @template T
|
|
11822
|
-
* @param {Object} payload - The payload containing client and state information.
|
|
11823
|
-
* @param {AgentName} payload.agentName - The agent name.
|
|
11824
11813
|
* @param {StateName} payload.stateName - The state name.
|
|
11825
11814
|
* @returns {Promise<void>}
|
|
11826
11815
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
11827
11816
|
*/
|
|
11828
|
-
this.clearState = function (
|
|
11817
|
+
this.clearState = function (stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
11829
11818
|
return __generator(this, function (_a) {
|
|
11830
11819
|
switch (_a.label) {
|
|
11831
11820
|
case 0:
|
|
11832
11821
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
11833
11822
|
swarm$1.loggerService.log(METHOD_NAME_SET, {
|
|
11834
|
-
stateName:
|
|
11823
|
+
stateName: stateName,
|
|
11835
11824
|
});
|
|
11836
|
-
|
|
11837
|
-
throw new Error("agent-swarm SharedStateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (clearState)"));
|
|
11838
|
-
}
|
|
11839
|
-
return [4 /*yield*/, swarm$1.sharedStatePublicService.clearState(METHOD_NAME_CLEAR$2, payload.stateName)];
|
|
11825
|
+
return [4 /*yield*/, swarm$1.sharedStatePublicService.clearState(METHOD_NAME_CLEAR$2, stateName)];
|
|
11840
11826
|
case 1: return [2 /*return*/, _a.sent()];
|
|
11841
11827
|
}
|
|
11842
11828
|
});
|
|
@@ -12046,7 +12032,6 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
12046
12032
|
* Takes items from the storage.
|
|
12047
12033
|
* @param {string} search - The search query.
|
|
12048
12034
|
* @param {number} total - The total number of items to take.
|
|
12049
|
-
* @param {AgentName} agentName - The agent name.
|
|
12050
12035
|
* @param {StorageName} storageName - The storage name.
|
|
12051
12036
|
* @returns {Promise<T[]>} - A promise that resolves to an array of items.
|
|
12052
12037
|
* @template T
|
|
@@ -12063,9 +12048,6 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
12063
12048
|
score: payload.score,
|
|
12064
12049
|
});
|
|
12065
12050
|
swarm$1.storageValidationService.validate(payload.storageName, METHOD_NAME_TAKE);
|
|
12066
|
-
if (!swarm$1.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
12067
|
-
throw new Error("agent-swarm SharedStorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (take)"));
|
|
12068
|
-
}
|
|
12069
12051
|
return [4 /*yield*/, swarm$1.sharedStoragePublicService.take(payload.search, payload.total, METHOD_NAME_TAKE, payload.storageName, payload.score)];
|
|
12070
12052
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
12071
12053
|
}
|
|
@@ -12074,25 +12056,21 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
12074
12056
|
/**
|
|
12075
12057
|
* Upserts an item in the storage.
|
|
12076
12058
|
* @param {T} item - The item to upsert.
|
|
12077
|
-
* @param {AgentName} agentName - The agent name.
|
|
12078
12059
|
* @param {StorageName} storageName - The storage name.
|
|
12079
12060
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
12080
12061
|
* @template T
|
|
12081
12062
|
*/
|
|
12082
|
-
this.upsert = function (
|
|
12063
|
+
this.upsert = function (item, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
12083
12064
|
return __generator(this, function (_a) {
|
|
12084
12065
|
switch (_a.label) {
|
|
12085
12066
|
case 0:
|
|
12086
12067
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
12087
12068
|
swarm$1.loggerService.log(METHOD_NAME_UPSERT, {
|
|
12088
|
-
item:
|
|
12089
|
-
storageName:
|
|
12069
|
+
item: item,
|
|
12070
|
+
storageName: storageName,
|
|
12090
12071
|
});
|
|
12091
|
-
swarm$1.storageValidationService.validate(
|
|
12092
|
-
|
|
12093
|
-
throw new Error("agent-swarm SharedStorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (upsert)"));
|
|
12094
|
-
}
|
|
12095
|
-
return [4 /*yield*/, swarm$1.sharedStoragePublicService.upsert(payload.item, METHOD_NAME_UPSERT, payload.storageName)];
|
|
12072
|
+
swarm$1.storageValidationService.validate(storageName, METHOD_NAME_UPSERT);
|
|
12073
|
+
return [4 /*yield*/, swarm$1.sharedStoragePublicService.upsert(item, METHOD_NAME_UPSERT, storageName)];
|
|
12096
12074
|
case 1: return [2 /*return*/, _a.sent()];
|
|
12097
12075
|
}
|
|
12098
12076
|
});
|
|
@@ -12100,24 +12078,20 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
12100
12078
|
/**
|
|
12101
12079
|
* Removes an item from the storage.
|
|
12102
12080
|
* @param {IStorageData["id"]} itemId - The ID of the item to remove.
|
|
12103
|
-
* @param {AgentName} agentName - The agent name.
|
|
12104
12081
|
* @param {StorageName} storageName - The storage name.
|
|
12105
12082
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
12106
12083
|
*/
|
|
12107
|
-
this.remove = function (
|
|
12084
|
+
this.remove = function (itemId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
12108
12085
|
return __generator(this, function (_a) {
|
|
12109
12086
|
switch (_a.label) {
|
|
12110
12087
|
case 0:
|
|
12111
12088
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
12112
12089
|
swarm$1.loggerService.log(METHOD_NAME_REMOVE, {
|
|
12113
|
-
itemId:
|
|
12114
|
-
storageName:
|
|
12090
|
+
itemId: itemId,
|
|
12091
|
+
storageName: storageName,
|
|
12115
12092
|
});
|
|
12116
|
-
swarm$1.storageValidationService.validate(
|
|
12117
|
-
|
|
12118
|
-
throw new Error("agent-swarm SharedStorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (remove)"));
|
|
12119
|
-
}
|
|
12120
|
-
return [4 /*yield*/, swarm$1.sharedStoragePublicService.remove(payload.itemId, METHOD_NAME_REMOVE, payload.storageName)];
|
|
12093
|
+
swarm$1.storageValidationService.validate(storageName, METHOD_NAME_REMOVE);
|
|
12094
|
+
return [4 /*yield*/, swarm$1.sharedStoragePublicService.remove(itemId, METHOD_NAME_REMOVE, storageName)];
|
|
12121
12095
|
case 1: return [2 /*return*/, _a.sent()];
|
|
12122
12096
|
}
|
|
12123
12097
|
});
|
|
@@ -12125,73 +12099,61 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
12125
12099
|
/**
|
|
12126
12100
|
* Gets an item from the storage.
|
|
12127
12101
|
* @param {IStorageData["id"]} itemId - The ID of the item to get.
|
|
12128
|
-
* @param {AgentName} agentName - The agent name.
|
|
12129
12102
|
* @param {StorageName} storageName - The storage name.
|
|
12130
12103
|
* @returns {Promise<T | null>} - A promise that resolves to the item or null if not found.
|
|
12131
12104
|
* @template T
|
|
12132
12105
|
*/
|
|
12133
|
-
this.get = function (
|
|
12106
|
+
this.get = function (itemId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
12134
12107
|
return __generator(this, function (_a) {
|
|
12135
12108
|
switch (_a.label) {
|
|
12136
12109
|
case 0:
|
|
12137
12110
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
12138
12111
|
swarm$1.loggerService.log(METHOD_NAME_GET, {
|
|
12139
|
-
itemId:
|
|
12140
|
-
storageName:
|
|
12112
|
+
itemId: itemId,
|
|
12113
|
+
storageName: storageName,
|
|
12141
12114
|
});
|
|
12142
|
-
swarm$1.storageValidationService.validate(
|
|
12143
|
-
|
|
12144
|
-
throw new Error("agent-swarm SharedStorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (get)"));
|
|
12145
|
-
}
|
|
12146
|
-
return [4 /*yield*/, swarm$1.sharedStoragePublicService.get(payload.itemId, METHOD_NAME_GET, payload.storageName)];
|
|
12115
|
+
swarm$1.storageValidationService.validate(storageName, METHOD_NAME_GET);
|
|
12116
|
+
return [4 /*yield*/, swarm$1.sharedStoragePublicService.get(itemId, METHOD_NAME_GET, storageName)];
|
|
12147
12117
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
12148
12118
|
}
|
|
12149
12119
|
});
|
|
12150
12120
|
}); };
|
|
12151
12121
|
/**
|
|
12152
12122
|
* Lists items from the storage.
|
|
12153
|
-
* @param {AgentName} agentName - The agent name.
|
|
12154
12123
|
* @param {StorageName} storageName - The storage name.
|
|
12155
12124
|
* @param {(item: T) => boolean} [filter] - Optional filter function.
|
|
12156
12125
|
* @returns {Promise<T[]>} - A promise that resolves to an array of items.
|
|
12157
12126
|
* @template T
|
|
12158
12127
|
*/
|
|
12159
|
-
this.list = function (
|
|
12128
|
+
this.list = function (storageName, filter) { return __awaiter(_this, void 0, void 0, function () {
|
|
12160
12129
|
return __generator(this, function (_a) {
|
|
12161
12130
|
switch (_a.label) {
|
|
12162
12131
|
case 0:
|
|
12163
12132
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
12164
12133
|
swarm$1.loggerService.log(METHOD_NAME_LIST, {
|
|
12165
|
-
storageName:
|
|
12134
|
+
storageName: storageName,
|
|
12166
12135
|
});
|
|
12167
|
-
swarm$1.storageValidationService.validate(
|
|
12168
|
-
|
|
12169
|
-
throw new Error("agent-swarm SharedStorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (list)"));
|
|
12170
|
-
}
|
|
12171
|
-
return [4 /*yield*/, swarm$1.sharedStoragePublicService.list(METHOD_NAME_LIST, payload.storageName, payload.filter)];
|
|
12136
|
+
swarm$1.storageValidationService.validate(storageName, METHOD_NAME_LIST);
|
|
12137
|
+
return [4 /*yield*/, swarm$1.sharedStoragePublicService.list(METHOD_NAME_LIST, storageName, filter)];
|
|
12172
12138
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
12173
12139
|
}
|
|
12174
12140
|
});
|
|
12175
12141
|
}); };
|
|
12176
12142
|
/**
|
|
12177
12143
|
* Clears the storage.
|
|
12178
|
-
* @param {AgentName} agentName - The agent name.
|
|
12179
12144
|
* @param {StorageName} storageName - The storage name.
|
|
12180
12145
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
12181
12146
|
*/
|
|
12182
|
-
this.clear = function (
|
|
12147
|
+
this.clear = function (storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
12183
12148
|
return __generator(this, function (_a) {
|
|
12184
12149
|
switch (_a.label) {
|
|
12185
12150
|
case 0:
|
|
12186
12151
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
12187
12152
|
swarm$1.loggerService.log(METHOD_NAME_CLEAR, {
|
|
12188
|
-
storageName:
|
|
12153
|
+
storageName: storageName,
|
|
12189
12154
|
});
|
|
12190
|
-
swarm$1.storageValidationService.validate(
|
|
12191
|
-
|
|
12192
|
-
throw new Error("agent-swarm SharedStorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (clear)"));
|
|
12193
|
-
}
|
|
12194
|
-
return [4 /*yield*/, swarm$1.sharedStoragePublicService.clear(METHOD_NAME_CLEAR, payload.storageName)];
|
|
12155
|
+
swarm$1.storageValidationService.validate(storageName, METHOD_NAME_CLEAR);
|
|
12156
|
+
return [4 /*yield*/, swarm$1.sharedStoragePublicService.clear(METHOD_NAME_CLEAR, storageName)];
|
|
12195
12157
|
case 1: return [2 /*return*/, _a.sent()];
|
|
12196
12158
|
}
|
|
12197
12159
|
});
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -4470,42 +4470,28 @@ declare class SharedStateUtils implements TSharedState {
|
|
|
4470
4470
|
* Retrieves the state for a given client and state name.
|
|
4471
4471
|
* @template T
|
|
4472
4472
|
* @param {Object} payload - The payload containing client and state information.
|
|
4473
|
-
* @param {AgentName} payload.agentName - The agent name.
|
|
4474
4473
|
* @param {StateName} payload.stateName - The state name.
|
|
4475
4474
|
* @returns {Promise<T>} The state data.
|
|
4476
4475
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
4477
4476
|
*/
|
|
4478
|
-
getState: <T extends unknown = any>(
|
|
4479
|
-
agentName: AgentName;
|
|
4480
|
-
stateName: StateName;
|
|
4481
|
-
}) => Promise<T>;
|
|
4477
|
+
getState: <T extends unknown = any>(stateName: StateName) => Promise<T>;
|
|
4482
4478
|
/**
|
|
4483
4479
|
* Sets the state for a given client and state name.
|
|
4484
4480
|
* @template T
|
|
4485
4481
|
* @param {T | ((prevSharedState: T) => Promise<T>)} dispatchFn - The new state or a function that returns the new state.
|
|
4486
|
-
* @param {
|
|
4487
|
-
* @param {AgentName} payload.agentName - The agent name.
|
|
4488
|
-
* @param {StateName} payload.stateName - The state name.
|
|
4482
|
+
* @param {StateName} stateName - The state name.
|
|
4489
4483
|
* @returns {Promise<void>}
|
|
4490
4484
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
4491
4485
|
*/
|
|
4492
|
-
setState: <T extends unknown = any>(dispatchFn: T | ((prevSharedState: T) => Promise<T>),
|
|
4493
|
-
agentName: AgentName;
|
|
4494
|
-
stateName: StateName;
|
|
4495
|
-
}) => Promise<void>;
|
|
4486
|
+
setState: <T extends unknown = any>(dispatchFn: T | ((prevSharedState: T) => Promise<T>), stateName: StateName) => Promise<void>;
|
|
4496
4487
|
/**
|
|
4497
4488
|
* Set the state to initial value
|
|
4498
4489
|
* @template T
|
|
4499
|
-
* @param {Object} payload - The payload containing client and state information.
|
|
4500
|
-
* @param {AgentName} payload.agentName - The agent name.
|
|
4501
4490
|
* @param {StateName} payload.stateName - The state name.
|
|
4502
4491
|
* @returns {Promise<void>}
|
|
4503
4492
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
4504
4493
|
*/
|
|
4505
|
-
clearState: <T extends unknown = any>(
|
|
4506
|
-
agentName: AgentName;
|
|
4507
|
-
stateName: StateName;
|
|
4508
|
-
}) => Promise<T>;
|
|
4494
|
+
clearState: <T extends unknown = any>(stateName: StateName) => Promise<T>;
|
|
4509
4495
|
}
|
|
4510
4496
|
/**
|
|
4511
4497
|
* Instance of SharedStateUtils for managing state.
|
|
@@ -4617,7 +4603,6 @@ declare class SharedStorageUtils implements TSharedStorage {
|
|
|
4617
4603
|
* Takes items from the storage.
|
|
4618
4604
|
* @param {string} search - The search query.
|
|
4619
4605
|
* @param {number} total - The total number of items to take.
|
|
4620
|
-
* @param {AgentName} agentName - The agent name.
|
|
4621
4606
|
* @param {StorageName} storageName - The storage name.
|
|
4622
4607
|
* @returns {Promise<T[]>} - A promise that resolves to an array of items.
|
|
4623
4608
|
* @template T
|
|
@@ -4625,71 +4610,46 @@ declare class SharedStorageUtils implements TSharedStorage {
|
|
|
4625
4610
|
take: <T extends IStorageData = IStorageData>(payload: {
|
|
4626
4611
|
search: string;
|
|
4627
4612
|
total: number;
|
|
4628
|
-
agentName: AgentName;
|
|
4629
4613
|
storageName: StorageName;
|
|
4630
4614
|
score?: number;
|
|
4631
4615
|
}) => Promise<T[]>;
|
|
4632
4616
|
/**
|
|
4633
4617
|
* Upserts an item in the storage.
|
|
4634
4618
|
* @param {T} item - The item to upsert.
|
|
4635
|
-
* @param {AgentName} agentName - The agent name.
|
|
4636
4619
|
* @param {StorageName} storageName - The storage name.
|
|
4637
4620
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
4638
4621
|
* @template T
|
|
4639
4622
|
*/
|
|
4640
|
-
upsert: <T extends IStorageData = IStorageData>(
|
|
4641
|
-
item: T;
|
|
4642
|
-
agentName: AgentName;
|
|
4643
|
-
storageName: StorageName;
|
|
4644
|
-
}) => Promise<void>;
|
|
4623
|
+
upsert: <T extends IStorageData = IStorageData>(item: T, storageName: StorageName) => Promise<void>;
|
|
4645
4624
|
/**
|
|
4646
4625
|
* Removes an item from the storage.
|
|
4647
4626
|
* @param {IStorageData["id"]} itemId - The ID of the item to remove.
|
|
4648
|
-
* @param {AgentName} agentName - The agent name.
|
|
4649
4627
|
* @param {StorageName} storageName - The storage name.
|
|
4650
4628
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
4651
4629
|
*/
|
|
4652
|
-
remove: (
|
|
4653
|
-
itemId: IStorageData["id"];
|
|
4654
|
-
agentName: AgentName;
|
|
4655
|
-
storageName: StorageName;
|
|
4656
|
-
}) => Promise<void>;
|
|
4630
|
+
remove: (itemId: IStorageData["id"], storageName: StorageName) => Promise<void>;
|
|
4657
4631
|
/**
|
|
4658
4632
|
* Gets an item from the storage.
|
|
4659
4633
|
* @param {IStorageData["id"]} itemId - The ID of the item to get.
|
|
4660
|
-
* @param {AgentName} agentName - The agent name.
|
|
4661
4634
|
* @param {StorageName} storageName - The storage name.
|
|
4662
4635
|
* @returns {Promise<T | null>} - A promise that resolves to the item or null if not found.
|
|
4663
4636
|
* @template T
|
|
4664
4637
|
*/
|
|
4665
|
-
get: <T extends IStorageData = IStorageData>(
|
|
4666
|
-
itemId: IStorageData["id"];
|
|
4667
|
-
agentName: AgentName;
|
|
4668
|
-
storageName: StorageName;
|
|
4669
|
-
}) => Promise<T | null>;
|
|
4638
|
+
get: <T extends IStorageData = IStorageData>(itemId: IStorageData["id"], storageName: StorageName) => Promise<T | null>;
|
|
4670
4639
|
/**
|
|
4671
4640
|
* Lists items from the storage.
|
|
4672
|
-
* @param {AgentName} agentName - The agent name.
|
|
4673
4641
|
* @param {StorageName} storageName - The storage name.
|
|
4674
4642
|
* @param {(item: T) => boolean} [filter] - Optional filter function.
|
|
4675
4643
|
* @returns {Promise<T[]>} - A promise that resolves to an array of items.
|
|
4676
4644
|
* @template T
|
|
4677
4645
|
*/
|
|
4678
|
-
list: <T extends IStorageData = IStorageData>(
|
|
4679
|
-
agentName: AgentName;
|
|
4680
|
-
storageName: StorageName;
|
|
4681
|
-
filter?: (item: T) => boolean;
|
|
4682
|
-
}) => Promise<T[]>;
|
|
4646
|
+
list: <T extends IStorageData = IStorageData>(storageName: StorageName, filter?: (item: T) => boolean) => Promise<T[]>;
|
|
4683
4647
|
/**
|
|
4684
4648
|
* Clears the storage.
|
|
4685
|
-
* @param {AgentName} agentName - The agent name.
|
|
4686
4649
|
* @param {StorageName} storageName - The storage name.
|
|
4687
4650
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
4688
4651
|
*/
|
|
4689
|
-
clear: (
|
|
4690
|
-
agentName: AgentName;
|
|
4691
|
-
storageName: StorageName;
|
|
4692
|
-
}) => Promise<void>;
|
|
4652
|
+
clear: (storageName: StorageName) => Promise<void>;
|
|
4693
4653
|
}
|
|
4694
4654
|
declare const SharedStorage: SharedStorageUtils;
|
|
4695
4655
|
|