agent-swarm-kit 1.0.122 → 1.0.124
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 +1934 -508
- package/build/index.mjs +1930 -509
- package/package.json +2 -2
- package/types.d.ts +521 -38
package/build/index.cjs
CHANGED
|
@@ -4,6 +4,7 @@ var diScoped = require('di-scoped');
|
|
|
4
4
|
var diKit = require('di-kit');
|
|
5
5
|
var functoolsKit = require('functools-kit');
|
|
6
6
|
var xml2js = require('xml2js');
|
|
7
|
+
var async_hooks = require('async_hooks');
|
|
7
8
|
var lodashEs = require('lodash-es');
|
|
8
9
|
var path = require('path');
|
|
9
10
|
var promises = require('fs/promises');
|
|
@@ -192,6 +193,7 @@ var connectionServices$1 = {
|
|
|
192
193
|
sharedStorageConnectionService: Symbol('sharedStorageConnectionService'),
|
|
193
194
|
stateConnectionService: Symbol('stateConnectionService'),
|
|
194
195
|
sharedStateConnectionService: Symbol('sharedStateConnectionService'),
|
|
196
|
+
policyConnectionService: Symbol('policyConnectionService'),
|
|
195
197
|
};
|
|
196
198
|
var schemaServices$1 = {
|
|
197
199
|
completionSchemaService: Symbol('completionSchemaService'),
|
|
@@ -202,6 +204,7 @@ var schemaServices$1 = {
|
|
|
202
204
|
storageSchemaService: Symbol('storageSchemaService'),
|
|
203
205
|
stateSchemaService: Symbol('stateSchemaService'),
|
|
204
206
|
memorySchemaService: Symbol('memorySchemaService'),
|
|
207
|
+
policySchemaService: Symbol('policySchemaService'),
|
|
205
208
|
};
|
|
206
209
|
var metaServices$1 = {
|
|
207
210
|
agentMetaService: Symbol('agentMetaService'),
|
|
@@ -216,6 +219,7 @@ var publicServices$1 = {
|
|
|
216
219
|
sharedStoragePublicService: Symbol('sharedStoragePublicService'),
|
|
217
220
|
statePublicService: Symbol('statePublicService'),
|
|
218
221
|
sharedStatePublicService: Symbol('sharedStatePublicService'),
|
|
222
|
+
policyPublicService: Symbol('policyPublicService'),
|
|
219
223
|
};
|
|
220
224
|
var validationServices$1 = {
|
|
221
225
|
agentValidationService: Symbol('agentValidationService'),
|
|
@@ -225,6 +229,7 @@ var validationServices$1 = {
|
|
|
225
229
|
completionValidationService: Symbol('completionValidationService'),
|
|
226
230
|
embeddingValidationService: Symbol('embeddingValidationService'),
|
|
227
231
|
storageValidationService: Symbol('storageValidationService'),
|
|
232
|
+
policyValidationService: Symbol('policyValidationService'),
|
|
228
233
|
};
|
|
229
234
|
var TYPES = __assign(__assign(__assign(__assign(__assign(__assign(__assign({}, baseServices$1), contextServices$1), schemaServices$1), connectionServices$1), publicServices$1), validationServices$1), metaServices$1);
|
|
230
235
|
|
|
@@ -954,6 +959,40 @@ var nameToTitle = function (name) {
|
|
|
954
959
|
return __spreadArray(["".concat(word.charAt(0).toUpperCase()).concat(word.slice(1))], __read(rest), false).join(' ');
|
|
955
960
|
};
|
|
956
961
|
|
|
962
|
+
/**
|
|
963
|
+
* A higher-order function that ensures execution outside of existing method and execution contexts.
|
|
964
|
+
*
|
|
965
|
+
* @template T - Generic type extending any function
|
|
966
|
+
* @param {T} run - The function to be executed outside of existing contexts
|
|
967
|
+
* @returns {(...args: Parameters<T>) => ReturnType<T>} A wrapped function that executes outside of any existing contexts
|
|
968
|
+
*
|
|
969
|
+
* @example
|
|
970
|
+
* const myFunction = (arg: string) => console.log(arg);
|
|
971
|
+
* const contextSafeFunction = beginContext(myFunction);
|
|
972
|
+
* contextSafeFunction('test'); // Executes myFunction outside of any existing contexts
|
|
973
|
+
*
|
|
974
|
+
* @remarks
|
|
975
|
+
* This utility function checks for both MethodContext and ExecutionContext.
|
|
976
|
+
* If either context exists, the provided function will be executed outside of those contexts.
|
|
977
|
+
* This is useful for ensuring clean execution environments for certain operations.
|
|
978
|
+
*/
|
|
979
|
+
var beginContext = function (run) {
|
|
980
|
+
return function () {
|
|
981
|
+
var args = [];
|
|
982
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
983
|
+
args[_i] = arguments[_i];
|
|
984
|
+
}
|
|
985
|
+
if (MethodContextService.hasContext() ||
|
|
986
|
+
ExecutionContextService.hasContext()) {
|
|
987
|
+
var resource = new async_hooks.AsyncResource("UNTRACKED");
|
|
988
|
+
var result = resource.runInAsyncScope(function () { return run.apply(void 0, __spreadArray([], __read(args), false)); });
|
|
989
|
+
resource.emitDestroy();
|
|
990
|
+
return result;
|
|
991
|
+
}
|
|
992
|
+
return run.apply(void 0, __spreadArray([], __read(args), false));
|
|
993
|
+
};
|
|
994
|
+
};
|
|
995
|
+
|
|
957
996
|
var _a;
|
|
958
997
|
var LOGGER_INSTANCE_WAIT_FOR_INIT = Symbol("wait-for-init");
|
|
959
998
|
var LOGGER_INSTANCE_WAIT_FOR_FN = function (self) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -1105,7 +1144,7 @@ var LoggerUtils = /** @class */ (function () {
|
|
|
1105
1144
|
* @param {...any[]} args - The log arguments.
|
|
1106
1145
|
* @returns {Promise<void>}
|
|
1107
1146
|
*/
|
|
1108
|
-
this.logClient = function (clientId, topic) {
|
|
1147
|
+
this.logClient = beginContext(function (clientId, topic) {
|
|
1109
1148
|
var args = [];
|
|
1110
1149
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1111
1150
|
args[_i - 2] = arguments[_i];
|
|
@@ -1134,6 +1173,7 @@ var LoggerUtils = /** @class */ (function () {
|
|
|
1134
1173
|
}); }, {
|
|
1135
1174
|
clientId: clientId,
|
|
1136
1175
|
agentName: "",
|
|
1176
|
+
policyName: "",
|
|
1137
1177
|
methodName: "LoggerUtils.logClient",
|
|
1138
1178
|
stateName: "",
|
|
1139
1179
|
storageName: "",
|
|
@@ -1145,7 +1185,7 @@ var LoggerUtils = /** @class */ (function () {
|
|
|
1145
1185
|
}
|
|
1146
1186
|
});
|
|
1147
1187
|
});
|
|
1148
|
-
};
|
|
1188
|
+
});
|
|
1149
1189
|
/**
|
|
1150
1190
|
* @method infoClient
|
|
1151
1191
|
* @description Logs an info message for a specific client.
|
|
@@ -1154,7 +1194,7 @@ var LoggerUtils = /** @class */ (function () {
|
|
|
1154
1194
|
* @param {...any[]} args - The info log arguments.
|
|
1155
1195
|
* @returns {Promise<void>}
|
|
1156
1196
|
*/
|
|
1157
|
-
this.infoClient = function (clientId, topic) {
|
|
1197
|
+
this.infoClient = beginContext(function (clientId, topic) {
|
|
1158
1198
|
var args = [];
|
|
1159
1199
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1160
1200
|
args[_i - 2] = arguments[_i];
|
|
@@ -1183,6 +1223,7 @@ var LoggerUtils = /** @class */ (function () {
|
|
|
1183
1223
|
}); }, {
|
|
1184
1224
|
clientId: clientId,
|
|
1185
1225
|
agentName: "",
|
|
1226
|
+
policyName: "",
|
|
1186
1227
|
methodName: "LoggerUtils.infoClient",
|
|
1187
1228
|
stateName: "",
|
|
1188
1229
|
storageName: "",
|
|
@@ -1194,7 +1235,7 @@ var LoggerUtils = /** @class */ (function () {
|
|
|
1194
1235
|
}
|
|
1195
1236
|
});
|
|
1196
1237
|
});
|
|
1197
|
-
};
|
|
1238
|
+
});
|
|
1198
1239
|
/**
|
|
1199
1240
|
* @method debugClient
|
|
1200
1241
|
* @description Logs a debug message for a specific client.
|
|
@@ -1203,7 +1244,7 @@ var LoggerUtils = /** @class */ (function () {
|
|
|
1203
1244
|
* @param {...any[]} args - The debug log arguments.
|
|
1204
1245
|
* @returns {Promise<void>}
|
|
1205
1246
|
*/
|
|
1206
|
-
this.debugClient = function (clientId, topic) {
|
|
1247
|
+
this.debugClient = beginContext(function (clientId, topic) {
|
|
1207
1248
|
var args = [];
|
|
1208
1249
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1209
1250
|
args[_i - 2] = arguments[_i];
|
|
@@ -1232,6 +1273,7 @@ var LoggerUtils = /** @class */ (function () {
|
|
|
1232
1273
|
}); }, {
|
|
1233
1274
|
clientId: clientId,
|
|
1234
1275
|
agentName: "",
|
|
1276
|
+
policyName: "",
|
|
1235
1277
|
methodName: "LoggerUtils.debugClient",
|
|
1236
1278
|
stateName: "",
|
|
1237
1279
|
storageName: "",
|
|
@@ -1243,7 +1285,7 @@ var LoggerUtils = /** @class */ (function () {
|
|
|
1243
1285
|
}
|
|
1244
1286
|
});
|
|
1245
1287
|
});
|
|
1246
|
-
};
|
|
1288
|
+
});
|
|
1247
1289
|
/**
|
|
1248
1290
|
* @method log
|
|
1249
1291
|
* @description Logs a message.
|
|
@@ -1456,6 +1498,7 @@ var CC_LOGGER_ENABLE_CONSOLE = false;
|
|
|
1456
1498
|
var CC_NAME_TO_TITLE = nameToTitle;
|
|
1457
1499
|
var CC_FN_PLANTUML = function () { return Promise.resolve(""); };
|
|
1458
1500
|
var CC_PROCESS_UUID = functoolsKit.randomString();
|
|
1501
|
+
var CC_BANHAMMER_PLACEHOLDER = "You have been banned! To continue conversation, please contact the administrator.";
|
|
1459
1502
|
var GLOBAL_CONFIG = {
|
|
1460
1503
|
CC_TOOL_CALL_EXCEPTION_PROMPT: CC_TOOL_CALL_EXCEPTION_PROMPT,
|
|
1461
1504
|
CC_EMPTY_OUTPUT_PLACEHOLDERS: CC_EMPTY_OUTPUT_PLACEHOLDERS,
|
|
@@ -1482,6 +1525,7 @@ var GLOBAL_CONFIG = {
|
|
|
1482
1525
|
CC_NAME_TO_TITLE: CC_NAME_TO_TITLE,
|
|
1483
1526
|
CC_FN_PLANTUML: CC_FN_PLANTUML,
|
|
1484
1527
|
CC_PROCESS_UUID: CC_PROCESS_UUID,
|
|
1528
|
+
CC_BANHAMMER_PLACEHOLDER: CC_BANHAMMER_PLACEHOLDER,
|
|
1485
1529
|
};
|
|
1486
1530
|
var setConfig = function (config) {
|
|
1487
1531
|
Object.assign(GLOBAL_CONFIG, config);
|
|
@@ -3735,6 +3779,7 @@ var SwarmSchemaService = /** @class */ (function () {
|
|
|
3735
3779
|
* Validation for swarm schema
|
|
3736
3780
|
*/
|
|
3737
3781
|
this.validateShallow = function (swarmSchema) {
|
|
3782
|
+
var _a;
|
|
3738
3783
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3739
3784
|
_this.loggerService.info("swarmSchemaService validateShallow", {
|
|
3740
3785
|
swarmSchema: swarmSchema,
|
|
@@ -3754,6 +3799,15 @@ var SwarmSchemaService = /** @class */ (function () {
|
|
|
3754
3799
|
if (swarmSchema.agentList.some(function (value) { return typeof value !== "string"; })) {
|
|
3755
3800
|
throw new Error("agent-swarm swarm schema validation failed: missing agentList for swarmName=".concat(swarmSchema.swarmName, " value=[").concat(swarmSchema.agentList, "]"));
|
|
3756
3801
|
}
|
|
3802
|
+
if (swarmSchema.policies && !Array.isArray(swarmSchema.policies)) {
|
|
3803
|
+
throw new Error("agent-swarm swarm schema validation failed: invalid policies for swarmName=".concat(swarmSchema.swarmName, " value=").concat(swarmSchema.policies));
|
|
3804
|
+
}
|
|
3805
|
+
if (swarmSchema.policies && swarmSchema.policies.length !== new Set(swarmSchema.policies).size) {
|
|
3806
|
+
throw new Error("agent-swarm agent schema validation failed: found duplicate policies for swarmName=".concat(swarmSchema.swarmName, " policies=[").concat(swarmSchema.policies, "]"));
|
|
3807
|
+
}
|
|
3808
|
+
if ((_a = swarmSchema.policies) === null || _a === void 0 ? void 0 : _a.some(function (value) { return typeof value !== "string"; })) {
|
|
3809
|
+
throw new Error("agent-swarm swarm schema validation failed: missing policies for swarmName=".concat(swarmSchema.swarmName, " value=[").concat(swarmSchema.policies, "]"));
|
|
3810
|
+
}
|
|
3757
3811
|
};
|
|
3758
3812
|
/**
|
|
3759
3813
|
* Registers a new swarm schema.
|
|
@@ -3852,18 +3906,33 @@ var ClientSession = /** @class */ (function () {
|
|
|
3852
3906
|
*/
|
|
3853
3907
|
ClientSession.prototype.emit = function (message) {
|
|
3854
3908
|
return __awaiter(this, void 0, void 0, function () {
|
|
3855
|
-
|
|
3856
|
-
|
|
3909
|
+
var _a, _b;
|
|
3910
|
+
return __generator(this, function (_c) {
|
|
3911
|
+
switch (_c.label) {
|
|
3857
3912
|
case 0:
|
|
3858
3913
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
3859
3914
|
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " emit"), {
|
|
3860
3915
|
message: message,
|
|
3861
3916
|
});
|
|
3917
|
+
return [4 /*yield*/, functoolsKit.not(this.params.policy.validateOutput(message, this.params.clientId, this.params.swarmName))];
|
|
3918
|
+
case 1:
|
|
3919
|
+
if (!_c.sent()) return [3 /*break*/, 4];
|
|
3920
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
3921
|
+
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " emit method canceled due to the banhammer of a client"), {
|
|
3922
|
+
message: message,
|
|
3923
|
+
});
|
|
3924
|
+
_b = (_a = this._emitSubject).next;
|
|
3925
|
+
return [4 /*yield*/, this.params.policy.getBanMessage(this.params.clientId, this.params.swarmName)];
|
|
3926
|
+
case 2: return [4 /*yield*/, _b.apply(_a, [_c.sent()])];
|
|
3927
|
+
case 3:
|
|
3928
|
+
_c.sent();
|
|
3929
|
+
return [2 /*return*/];
|
|
3930
|
+
case 4:
|
|
3862
3931
|
this.params.onEmit &&
|
|
3863
3932
|
this.params.onEmit(this.params.clientId, this.params.swarmName, message);
|
|
3864
3933
|
return [4 /*yield*/, this._emitSubject.next(message)];
|
|
3865
|
-
case
|
|
3866
|
-
|
|
3934
|
+
case 5:
|
|
3935
|
+
_c.sent();
|
|
3867
3936
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
3868
3937
|
type: "emit",
|
|
3869
3938
|
source: "session-bus",
|
|
@@ -3876,8 +3945,8 @@ var ClientSession = /** @class */ (function () {
|
|
|
3876
3945
|
},
|
|
3877
3946
|
clientId: this.params.clientId,
|
|
3878
3947
|
})];
|
|
3879
|
-
case
|
|
3880
|
-
|
|
3948
|
+
case 6:
|
|
3949
|
+
_c.sent();
|
|
3881
3950
|
return [2 /*return*/];
|
|
3882
3951
|
}
|
|
3883
3952
|
});
|
|
@@ -3900,32 +3969,53 @@ var ClientSession = /** @class */ (function () {
|
|
|
3900
3969
|
message: message,
|
|
3901
3970
|
mode: mode,
|
|
3902
3971
|
});
|
|
3972
|
+
return [4 /*yield*/, functoolsKit.not(this.params.policy.validateInput(message, this.params.clientId, this.params.swarmName))];
|
|
3973
|
+
case 1:
|
|
3974
|
+
if (!_a.sent()) return [3 /*break*/, 3];
|
|
3975
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
3976
|
+
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " execution canceled due to the banhammer of a client"), {
|
|
3977
|
+
message: message,
|
|
3978
|
+
mode: mode,
|
|
3979
|
+
});
|
|
3980
|
+
return [4 /*yield*/, this.params.policy.getBanMessage(this.params.clientId, this.params.swarmName)];
|
|
3981
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
3982
|
+
case 3:
|
|
3903
3983
|
this.params.onExecute &&
|
|
3904
3984
|
this.params.onExecute(this.params.clientId, this.params.swarmName, message, mode);
|
|
3905
3985
|
return [4 /*yield*/, this.params.swarm.getAgent()];
|
|
3906
|
-
case
|
|
3986
|
+
case 4:
|
|
3907
3987
|
agent = _a.sent();
|
|
3908
3988
|
outputAwaiter = this.params.swarm.waitForOutput();
|
|
3909
3989
|
agent.execute(message, mode);
|
|
3910
3990
|
return [4 /*yield*/, outputAwaiter];
|
|
3911
|
-
case
|
|
3991
|
+
case 5:
|
|
3912
3992
|
output = _a.sent();
|
|
3913
|
-
return [4 /*yield*/, this.params.
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3993
|
+
return [4 /*yield*/, functoolsKit.not(this.params.policy.validateOutput(output, this.params.clientId, this.params.swarmName))];
|
|
3994
|
+
case 6:
|
|
3995
|
+
if (!_a.sent()) return [3 /*break*/, 8];
|
|
3996
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
3997
|
+
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " execution output emit canceled due to the banhammer of a client"), {
|
|
3998
|
+
message: message,
|
|
3999
|
+
mode: mode,
|
|
4000
|
+
});
|
|
4001
|
+
return [4 /*yield*/, this.params.policy.getBanMessage(this.params.clientId, this.params.swarmName)];
|
|
4002
|
+
case 7: return [2 /*return*/, _a.sent()];
|
|
4003
|
+
case 8: return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
4004
|
+
type: "execute",
|
|
4005
|
+
source: "session-bus",
|
|
4006
|
+
input: {
|
|
4007
|
+
message: message,
|
|
4008
|
+
mode: mode,
|
|
4009
|
+
},
|
|
4010
|
+
output: {
|
|
4011
|
+
result: output,
|
|
4012
|
+
},
|
|
4013
|
+
context: {
|
|
4014
|
+
swarmName: this.params.swarmName,
|
|
4015
|
+
},
|
|
4016
|
+
clientId: this.params.clientId,
|
|
4017
|
+
})];
|
|
4018
|
+
case 9:
|
|
3929
4019
|
_a.sent();
|
|
3930
4020
|
return [2 /*return*/, output];
|
|
3931
4021
|
}
|
|
@@ -4295,111 +4385,455 @@ var ClientSession = /** @class */ (function () {
|
|
|
4295
4385
|
return ClientSession;
|
|
4296
4386
|
}());
|
|
4297
4387
|
|
|
4388
|
+
var METHOD_NAME_BAN_CLIENT = "PolicyUtils.banClient";
|
|
4389
|
+
var METHOD_NAME_UNBAN_CLIENT = "PolicyUtils.unbanClient";
|
|
4298
4390
|
/**
|
|
4299
|
-
*
|
|
4300
|
-
* @implements {ISession}
|
|
4391
|
+
* NoopPolicy class implements the IPolicy interface with no-op methods.
|
|
4301
4392
|
*/
|
|
4302
|
-
var
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
this.
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4393
|
+
var NoopPolicy = /** @class */ (function () {
|
|
4394
|
+
/**
|
|
4395
|
+
* Constructs a NoopPolicy instance.
|
|
4396
|
+
* @param {string} swarmName - The name of the swarm.
|
|
4397
|
+
*/
|
|
4398
|
+
function NoopPolicy(swarmName) {
|
|
4399
|
+
this.swarmName = swarmName;
|
|
4400
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4401
|
+
swarm$1.loggerService.debug("NoopPolicy CTOR swarmName=".concat(swarmName));
|
|
4402
|
+
}
|
|
4403
|
+
/**
|
|
4404
|
+
* Gets the ban message.
|
|
4405
|
+
* @returns {Promise<string>} The ban message.
|
|
4406
|
+
*/
|
|
4407
|
+
NoopPolicy.prototype.getBanMessage = function () {
|
|
4408
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4409
|
+
swarm$1.loggerService.debug("NoopPolicy getBanMessage swarmName=".concat(this.swarmName));
|
|
4410
|
+
return Promise.resolve(GLOBAL_CONFIG.CC_BANHAMMER_PLACEHOLDER);
|
|
4411
|
+
};
|
|
4412
|
+
/**
|
|
4413
|
+
* Validates the input.
|
|
4414
|
+
* @returns {Promise<boolean>} True if the input is valid, otherwise false.
|
|
4415
|
+
*/
|
|
4416
|
+
NoopPolicy.prototype.validateInput = function () {
|
|
4417
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4418
|
+
swarm$1.loggerService.debug("NoopPolicy validateInput swarmName=".concat(this.swarmName));
|
|
4419
|
+
return Promise.resolve(true);
|
|
4420
|
+
};
|
|
4421
|
+
/**
|
|
4422
|
+
* Validates the output.
|
|
4423
|
+
* @returns {Promise<boolean>} True if the output is valid, otherwise false.
|
|
4424
|
+
*/
|
|
4425
|
+
NoopPolicy.prototype.validateOutput = function () {
|
|
4426
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4427
|
+
swarm$1.loggerService.debug("NoopPolicy validateOutput swarmName=".concat(this.swarmName));
|
|
4428
|
+
return Promise.resolve(true);
|
|
4429
|
+
};
|
|
4430
|
+
/**
|
|
4431
|
+
* Bans a client.
|
|
4432
|
+
* @returns {Promise<void>}
|
|
4433
|
+
*/
|
|
4434
|
+
NoopPolicy.prototype.banClient = function () {
|
|
4435
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4436
|
+
swarm$1.loggerService.debug("NoopPolicy banClient swarmName=".concat(this.swarmName));
|
|
4437
|
+
return Promise.resolve();
|
|
4438
|
+
};
|
|
4439
|
+
/**
|
|
4440
|
+
* Unbans a client.
|
|
4441
|
+
* @returns {Promise<void>}
|
|
4442
|
+
*/
|
|
4443
|
+
NoopPolicy.prototype.unbanClient = function () {
|
|
4444
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4445
|
+
swarm$1.loggerService.debug("NoopPolicy unbanClient swarmName=".concat(this.swarmName));
|
|
4446
|
+
return Promise.resolve();
|
|
4447
|
+
};
|
|
4448
|
+
return NoopPolicy;
|
|
4449
|
+
}());
|
|
4450
|
+
/**
|
|
4451
|
+
* MergePolicy class implements the IPolicy interface and merges multiple policies.
|
|
4452
|
+
*/
|
|
4453
|
+
var MergePolicy = /** @class */ (function () {
|
|
4454
|
+
/**
|
|
4455
|
+
* Constructs a MergePolicy instance.
|
|
4456
|
+
* @param {IPolicy[]} policies - The policies to merge.
|
|
4457
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
4458
|
+
*/
|
|
4459
|
+
function MergePolicy(policies, swarmName) {
|
|
4460
|
+
this.policies = policies;
|
|
4461
|
+
this.swarmName = swarmName;
|
|
4462
|
+
this._targetPolicy = null;
|
|
4463
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4464
|
+
swarm$1.loggerService.debug("MergePolicy CTOR swarmName=".concat(swarmName), {
|
|
4465
|
+
policies: policies,
|
|
4466
|
+
});
|
|
4467
|
+
}
|
|
4468
|
+
/**
|
|
4469
|
+
* Gets the ban message.
|
|
4470
|
+
* @param {SessionId} clientId - The client ID.
|
|
4471
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
4472
|
+
* @returns {Promise<string>} The ban message.
|
|
4473
|
+
*/
|
|
4474
|
+
MergePolicy.prototype.getBanMessage = function (clientId, swarmName) {
|
|
4475
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4476
|
+
var policy;
|
|
4329
4477
|
return __generator(this, function (_a) {
|
|
4330
4478
|
switch (_a.label) {
|
|
4331
4479
|
case 0:
|
|
4332
|
-
GLOBAL_CONFIG.
|
|
4333
|
-
|
|
4334
|
-
|
|
4480
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4481
|
+
swarm$1.loggerService.debug("MergePolicy getBanMessage swarmName=".concat(swarmName), {
|
|
4482
|
+
clientId: clientId,
|
|
4335
4483
|
});
|
|
4336
|
-
return [
|
|
4484
|
+
if (!this._targetPolicy) return [3 /*break*/, 2];
|
|
4485
|
+
policy = this._targetPolicy;
|
|
4486
|
+
this._targetPolicy = null;
|
|
4487
|
+
return [4 /*yield*/, policy.getBanMessage(clientId, swarmName)];
|
|
4337
4488
|
case 1: return [2 /*return*/, _a.sent()];
|
|
4489
|
+
case 2: return [2 /*return*/, GLOBAL_CONFIG.CC_BANHAMMER_PLACEHOLDER];
|
|
4338
4490
|
}
|
|
4339
4491
|
});
|
|
4340
|
-
});
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4492
|
+
});
|
|
4493
|
+
};
|
|
4494
|
+
/**
|
|
4495
|
+
* Validates the input.
|
|
4496
|
+
* @param {string} incoming - The incoming data.
|
|
4497
|
+
* @param {SessionId} clientId - The client ID.
|
|
4498
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
4499
|
+
* @returns {Promise<boolean>} True if the input is valid, otherwise false.
|
|
4500
|
+
*/
|
|
4501
|
+
MergePolicy.prototype.validateInput = function (incoming, clientId, swarmName) {
|
|
4502
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4503
|
+
var _a, _b, policy, e_1_1;
|
|
4504
|
+
var e_1, _c;
|
|
4505
|
+
return __generator(this, function (_d) {
|
|
4506
|
+
switch (_d.label) {
|
|
4349
4507
|
case 0:
|
|
4350
|
-
GLOBAL_CONFIG.
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
mode: mode,
|
|
4508
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4509
|
+
swarm$1.loggerService.debug("MergePolicy validateInput swarmName=".concat(swarmName), {
|
|
4510
|
+
clientId: clientId,
|
|
4354
4511
|
});
|
|
4355
|
-
|
|
4356
|
-
case 1:
|
|
4512
|
+
_d.label = 1;
|
|
4513
|
+
case 1:
|
|
4514
|
+
_d.trys.push([1, 6, 7, 8]);
|
|
4515
|
+
_a = __values(this.policies), _b = _a.next();
|
|
4516
|
+
_d.label = 2;
|
|
4517
|
+
case 2:
|
|
4518
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
4519
|
+
policy = _b.value;
|
|
4520
|
+
return [4 /*yield*/, functoolsKit.not(policy.validateInput(incoming, clientId, swarmName))];
|
|
4521
|
+
case 3:
|
|
4522
|
+
if (_d.sent()) {
|
|
4523
|
+
this._targetPolicy = policy;
|
|
4524
|
+
return [2 /*return*/, false];
|
|
4525
|
+
}
|
|
4526
|
+
_d.label = 4;
|
|
4527
|
+
case 4:
|
|
4528
|
+
_b = _a.next();
|
|
4529
|
+
return [3 /*break*/, 2];
|
|
4530
|
+
case 5: return [3 /*break*/, 8];
|
|
4531
|
+
case 6:
|
|
4532
|
+
e_1_1 = _d.sent();
|
|
4533
|
+
e_1 = { error: e_1_1 };
|
|
4534
|
+
return [3 /*break*/, 8];
|
|
4535
|
+
case 7:
|
|
4536
|
+
try {
|
|
4537
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
4538
|
+
}
|
|
4539
|
+
finally { if (e_1) throw e_1.error; }
|
|
4540
|
+
return [7 /*endfinally*/];
|
|
4541
|
+
case 8:
|
|
4542
|
+
this._targetPolicy = null;
|
|
4543
|
+
return [2 /*return*/, true];
|
|
4357
4544
|
}
|
|
4358
4545
|
});
|
|
4359
|
-
});
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4546
|
+
});
|
|
4547
|
+
};
|
|
4548
|
+
/**
|
|
4549
|
+
* Validates the output.
|
|
4550
|
+
* @param {string} outgoing - The outgoing data.
|
|
4551
|
+
* @param {SessionId} clientId - The client ID.
|
|
4552
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
4553
|
+
* @returns {Promise<boolean>} True if the output is valid, otherwise false.
|
|
4554
|
+
*/
|
|
4555
|
+
MergePolicy.prototype.validateOutput = function (outgoing, clientId, swarmName) {
|
|
4556
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4557
|
+
var _a, _b, policy, e_2_1;
|
|
4558
|
+
var e_2, _c;
|
|
4559
|
+
return __generator(this, function (_d) {
|
|
4560
|
+
switch (_d.label) {
|
|
4368
4561
|
case 0:
|
|
4369
|
-
GLOBAL_CONFIG.
|
|
4370
|
-
|
|
4371
|
-
|
|
4562
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4563
|
+
swarm$1.loggerService.debug("MergePolicy validateOutput swarmName=".concat(swarmName), {
|
|
4564
|
+
clientId: clientId,
|
|
4372
4565
|
});
|
|
4373
|
-
|
|
4374
|
-
case 1:
|
|
4566
|
+
_d.label = 1;
|
|
4567
|
+
case 1:
|
|
4568
|
+
_d.trys.push([1, 6, 7, 8]);
|
|
4569
|
+
_a = __values(this.policies), _b = _a.next();
|
|
4570
|
+
_d.label = 2;
|
|
4571
|
+
case 2:
|
|
4572
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
4573
|
+
policy = _b.value;
|
|
4574
|
+
return [4 /*yield*/, functoolsKit.not(policy.validateOutput(outgoing, clientId, swarmName))];
|
|
4575
|
+
case 3:
|
|
4576
|
+
if (_d.sent()) {
|
|
4577
|
+
this._targetPolicy = policy;
|
|
4578
|
+
return [2 /*return*/, false];
|
|
4579
|
+
}
|
|
4580
|
+
_d.label = 4;
|
|
4581
|
+
case 4:
|
|
4582
|
+
_b = _a.next();
|
|
4583
|
+
return [3 /*break*/, 2];
|
|
4584
|
+
case 5: return [3 /*break*/, 8];
|
|
4585
|
+
case 6:
|
|
4586
|
+
e_2_1 = _d.sent();
|
|
4587
|
+
e_2 = { error: e_2_1 };
|
|
4588
|
+
return [3 /*break*/, 8];
|
|
4589
|
+
case 7:
|
|
4590
|
+
try {
|
|
4591
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
4592
|
+
}
|
|
4593
|
+
finally { if (e_2) throw e_2.error; }
|
|
4594
|
+
return [7 /*endfinally*/];
|
|
4595
|
+
case 8:
|
|
4596
|
+
this._targetPolicy = null;
|
|
4597
|
+
return [2 /*return*/, true];
|
|
4375
4598
|
}
|
|
4376
4599
|
});
|
|
4377
|
-
});
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
case
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4600
|
+
});
|
|
4601
|
+
};
|
|
4602
|
+
/**
|
|
4603
|
+
* Bans a client.
|
|
4604
|
+
* @param {SessionId} clientId - The client ID.
|
|
4605
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
4606
|
+
* @returns {Promise<void>}
|
|
4607
|
+
*/
|
|
4608
|
+
MergePolicy.prototype.banClient = function (clientId, swarmName) {
|
|
4609
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4610
|
+
var _a, _b, policy;
|
|
4611
|
+
return __generator(this, function (_c) {
|
|
4612
|
+
switch (_c.label) {
|
|
4613
|
+
case 0:
|
|
4614
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4615
|
+
swarm$1.loggerService.debug("MergePolicy banClient swarmName=".concat(swarmName), {
|
|
4616
|
+
clientId: clientId,
|
|
4617
|
+
});
|
|
4618
|
+
if (!this._targetPolicy) return [3 /*break*/, 2];
|
|
4619
|
+
return [4 /*yield*/, this._targetPolicy.banClient(clientId, swarmName)];
|
|
4620
|
+
case 1:
|
|
4621
|
+
_c.sent();
|
|
4622
|
+
return [2 /*return*/];
|
|
4623
|
+
case 2:
|
|
4624
|
+
_a = __read(this.policies, 1), _b = _a[0], policy = _b === void 0 ? null : _b;
|
|
4625
|
+
if (!policy) return [3 /*break*/, 4];
|
|
4626
|
+
return [4 /*yield*/, policy.banClient(clientId, swarmName)];
|
|
4627
|
+
case 3:
|
|
4628
|
+
_c.sent();
|
|
4629
|
+
_c.label = 4;
|
|
4630
|
+
case 4: return [2 /*return*/];
|
|
4631
|
+
}
|
|
4632
|
+
});
|
|
4633
|
+
});
|
|
4634
|
+
};
|
|
4635
|
+
/**
|
|
4636
|
+
* Unbans a client.
|
|
4637
|
+
* @param {SessionId} clientId - The client ID.
|
|
4638
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
4639
|
+
* @returns {Promise<void>}
|
|
4640
|
+
*/
|
|
4641
|
+
MergePolicy.prototype.unbanClient = function (clientId, swarmName) {
|
|
4642
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4643
|
+
var _a, _b, policy;
|
|
4644
|
+
return __generator(this, function (_c) {
|
|
4645
|
+
switch (_c.label) {
|
|
4646
|
+
case 0:
|
|
4647
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4648
|
+
swarm$1.loggerService.debug("MergePolicy unbanClient swarmName=".concat(swarmName), {
|
|
4649
|
+
clientId: clientId,
|
|
4650
|
+
});
|
|
4651
|
+
if (!this._targetPolicy) return [3 /*break*/, 2];
|
|
4652
|
+
return [4 /*yield*/, this._targetPolicy.unbanClient(clientId, swarmName)];
|
|
4653
|
+
case 1:
|
|
4654
|
+
_c.sent();
|
|
4655
|
+
return [2 /*return*/];
|
|
4656
|
+
case 2:
|
|
4657
|
+
_a = __read(this.policies, 1), _b = _a[0], policy = _b === void 0 ? null : _b;
|
|
4658
|
+
if (!policy) return [3 /*break*/, 4];
|
|
4659
|
+
return [4 /*yield*/, policy.unbanClient(clientId, swarmName)];
|
|
4660
|
+
case 3:
|
|
4661
|
+
_c.sent();
|
|
4662
|
+
_c.label = 4;
|
|
4663
|
+
case 4: return [2 /*return*/];
|
|
4664
|
+
}
|
|
4665
|
+
});
|
|
4666
|
+
});
|
|
4667
|
+
};
|
|
4668
|
+
return MergePolicy;
|
|
4669
|
+
}());
|
|
4670
|
+
/**
|
|
4671
|
+
* PolicyUtils class provides utility methods for banning and unbanning clients.
|
|
4672
|
+
*/
|
|
4673
|
+
var PolicyUtils = /** @class */ (function () {
|
|
4674
|
+
function PolicyUtils() {
|
|
4675
|
+
var _this = this;
|
|
4676
|
+
/**
|
|
4677
|
+
* Bans a client.
|
|
4678
|
+
* @param {Object} payload - The payload containing clientId, swarmName, and policyName.
|
|
4679
|
+
* @param {string} payload.clientId - The client ID.
|
|
4680
|
+
* @param {SwarmName} payload.swarmName - The name of the swarm.
|
|
4681
|
+
* @param {PolicyName} payload.policyName - The name of the policy.
|
|
4682
|
+
* @returns {Promise<void>}
|
|
4683
|
+
*/
|
|
4684
|
+
this.banClient = beginContext(function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
4685
|
+
return __generator(this, function (_a) {
|
|
4686
|
+
switch (_a.label) {
|
|
4687
|
+
case 0:
|
|
4688
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
4689
|
+
swarm$1.loggerService.log(METHOD_NAME_BAN_CLIENT, payload);
|
|
4690
|
+
swarm$1.sessionValidationService.validate(payload.clientId, METHOD_NAME_BAN_CLIENT);
|
|
4691
|
+
swarm$1.swarmValidationService.validate(payload.swarmName, METHOD_NAME_BAN_CLIENT);
|
|
4692
|
+
swarm$1.policyValidationService.validate(payload.policyName, METHOD_NAME_BAN_CLIENT);
|
|
4693
|
+
return [4 /*yield*/, swarm$1.policyPublicService.banClient(payload.swarmName, METHOD_NAME_BAN_CLIENT, payload.clientId, payload.policyName)];
|
|
4694
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
4695
|
+
}
|
|
4696
|
+
});
|
|
4697
|
+
}); });
|
|
4698
|
+
/**
|
|
4699
|
+
* Unbans a client.
|
|
4700
|
+
* @param {Object} payload - The payload containing clientId, swarmName, and policyName.
|
|
4701
|
+
* @param {string} payload.clientId - The client ID.
|
|
4702
|
+
* @param {SwarmName} payload.swarmName - The name of the swarm.
|
|
4703
|
+
* @param {PolicyName} payload.policyName - The name of the policy.
|
|
4704
|
+
* @returns {Promise<void>}
|
|
4705
|
+
*/
|
|
4706
|
+
this.unbanClient = beginContext(function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
4707
|
+
return __generator(this, function (_a) {
|
|
4708
|
+
switch (_a.label) {
|
|
4709
|
+
case 0:
|
|
4710
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
4711
|
+
swarm$1.loggerService.log(METHOD_NAME_UNBAN_CLIENT, payload);
|
|
4712
|
+
swarm$1.sessionValidationService.validate(payload.clientId, METHOD_NAME_UNBAN_CLIENT);
|
|
4713
|
+
swarm$1.swarmValidationService.validate(payload.swarmName, METHOD_NAME_UNBAN_CLIENT);
|
|
4714
|
+
swarm$1.policyValidationService.validate(payload.policyName, METHOD_NAME_UNBAN_CLIENT);
|
|
4715
|
+
return [4 /*yield*/, swarm$1.policyPublicService.unbanClient(payload.swarmName, METHOD_NAME_UNBAN_CLIENT, payload.clientId, payload.policyName)];
|
|
4716
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
4717
|
+
}
|
|
4718
|
+
});
|
|
4719
|
+
}); });
|
|
4720
|
+
}
|
|
4721
|
+
return PolicyUtils;
|
|
4722
|
+
}());
|
|
4723
|
+
/**
|
|
4724
|
+
* An instance of PolicyUtils.
|
|
4725
|
+
* @type {PolicyUtils}
|
|
4726
|
+
*/
|
|
4727
|
+
var Policy = new PolicyUtils();
|
|
4728
|
+
|
|
4729
|
+
/**
|
|
4730
|
+
* Service for managing session connections.
|
|
4731
|
+
* @implements {ISession}
|
|
4732
|
+
*/
|
|
4733
|
+
var SessionConnectionService = /** @class */ (function () {
|
|
4734
|
+
function SessionConnectionService() {
|
|
4735
|
+
var _this = this;
|
|
4736
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
4737
|
+
this.busService = inject(TYPES.busService);
|
|
4738
|
+
this.methodContextService = inject(TYPES.methodContextService);
|
|
4739
|
+
this.swarmConnectionService = inject(TYPES.swarmConnectionService);
|
|
4740
|
+
this.policyConnectionService = inject(TYPES.policyConnectionService);
|
|
4741
|
+
this.swarmSchemaService = inject(TYPES.swarmSchemaService);
|
|
4742
|
+
/**
|
|
4743
|
+
* Retrieves a memoized session based on clientId and swarmName.
|
|
4744
|
+
* @param {string} clientId - The client ID.
|
|
4745
|
+
* @param {string} swarmName - The swarm name.
|
|
4746
|
+
* @returns {ClientSession} The client session.
|
|
4747
|
+
*/
|
|
4748
|
+
this.getSession = functoolsKit.memoize(function (_a) {
|
|
4749
|
+
var _b = __read(_a, 2), clientId = _b[0], swarmName = _b[1];
|
|
4750
|
+
return "".concat(clientId, "-").concat(swarmName);
|
|
4751
|
+
}, function (clientId, swarmName) {
|
|
4752
|
+
var _a = _this.swarmSchemaService.get(swarmName), callbacks = _a.callbacks, policies = _a.policies;
|
|
4753
|
+
return new ClientSession(__assign({ clientId: clientId, policy: policies
|
|
4754
|
+
? new MergePolicy(policies.map(_this.policyConnectionService.getPolicy), swarmName)
|
|
4755
|
+
: new NoopPolicy(swarmName), logger: _this.loggerService, bus: _this.busService, swarm: _this.swarmConnectionService.getSwarm(clientId, swarmName), swarmName: swarmName }, callbacks));
|
|
4756
|
+
});
|
|
4757
|
+
/**
|
|
4758
|
+
* Emits a message to the session.
|
|
4759
|
+
* @param {string} content - The content to emit.
|
|
4760
|
+
* @returns {Promise<void>} A promise that resolves when the message is emitted.
|
|
4761
|
+
*/
|
|
4762
|
+
this.emit = function (content) { return __awaiter(_this, void 0, void 0, function () {
|
|
4763
|
+
return __generator(this, function (_a) {
|
|
4764
|
+
switch (_a.label) {
|
|
4765
|
+
case 0:
|
|
4766
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4767
|
+
this.loggerService.info("sessionConnectionService emit", {
|
|
4768
|
+
content: content,
|
|
4769
|
+
});
|
|
4770
|
+
return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).emit(content)];
|
|
4771
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
4772
|
+
}
|
|
4773
|
+
});
|
|
4774
|
+
}); };
|
|
4775
|
+
/**
|
|
4776
|
+
* Executes a command in the session.
|
|
4777
|
+
* @param {string} content - The content to execute.
|
|
4778
|
+
* @returns {Promise<string>} A promise that resolves with the execution result.
|
|
4779
|
+
*/
|
|
4780
|
+
this.execute = function (content, mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
4781
|
+
return __generator(this, function (_a) {
|
|
4782
|
+
switch (_a.label) {
|
|
4783
|
+
case 0:
|
|
4784
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4785
|
+
this.loggerService.info("sessionConnectionService execute", {
|
|
4786
|
+
content: content,
|
|
4787
|
+
mode: mode,
|
|
4788
|
+
});
|
|
4789
|
+
return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).execute(content, mode)];
|
|
4790
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
4791
|
+
}
|
|
4792
|
+
});
|
|
4793
|
+
}); };
|
|
4794
|
+
/**
|
|
4795
|
+
* Run the completion stateless
|
|
4796
|
+
* @param {string} content - The content to execute.
|
|
4797
|
+
* @returns {Promise<string>} A promise that resolves with the execution result.
|
|
4798
|
+
*/
|
|
4799
|
+
this.run = function (content) { return __awaiter(_this, void 0, void 0, function () {
|
|
4800
|
+
return __generator(this, function (_a) {
|
|
4801
|
+
switch (_a.label) {
|
|
4802
|
+
case 0:
|
|
4803
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4804
|
+
this.loggerService.info("sessionConnectionService run", {
|
|
4805
|
+
content: content,
|
|
4806
|
+
});
|
|
4807
|
+
return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).run(content)];
|
|
4808
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
4809
|
+
}
|
|
4810
|
+
});
|
|
4811
|
+
}); };
|
|
4812
|
+
/**
|
|
4813
|
+
* Connects to the session using the provided connector.
|
|
4814
|
+
* @param {SendMessageFn} connector - The function to send messages.
|
|
4815
|
+
* @returns {ReceiveMessageFn} The function to receive messages.
|
|
4816
|
+
*/
|
|
4817
|
+
this.connect = function (connector, clientId, swarmName) {
|
|
4818
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4819
|
+
_this.loggerService.info("sessionConnectionService connect");
|
|
4820
|
+
return _this.getSession(clientId, swarmName).connect(connector);
|
|
4821
|
+
};
|
|
4822
|
+
/**
|
|
4823
|
+
* Commits tool output to the session.
|
|
4824
|
+
* @param {string} toolId - The `tool_call_id` for openai history
|
|
4825
|
+
* @param {string} content - The content to commit.
|
|
4826
|
+
* @returns {Promise<void>} A promise that resolves when the content is committed.
|
|
4827
|
+
*/
|
|
4828
|
+
this.commitToolOutput = function (toolId, content) { return __awaiter(_this, void 0, void 0, function () {
|
|
4829
|
+
return __generator(this, function (_a) {
|
|
4830
|
+
switch (_a.label) {
|
|
4831
|
+
case 0:
|
|
4832
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4833
|
+
this.loggerService.info("sessionConnectionService commitToolOutput", {
|
|
4834
|
+
content: content,
|
|
4835
|
+
toolId: toolId,
|
|
4836
|
+
});
|
|
4403
4837
|
return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).commitToolOutput(toolId, content)];
|
|
4404
4838
|
case 1: return [2 /*return*/, _a.sent()];
|
|
4405
4839
|
}
|
|
@@ -4554,6 +4988,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
4554
4988
|
methodName: methodName,
|
|
4555
4989
|
clientId: clientId,
|
|
4556
4990
|
agentName: agentName,
|
|
4991
|
+
policyName: "",
|
|
4557
4992
|
swarmName: "",
|
|
4558
4993
|
storageName: "",
|
|
4559
4994
|
stateName: "",
|
|
@@ -4593,6 +5028,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
4593
5028
|
methodName: methodName,
|
|
4594
5029
|
clientId: clientId,
|
|
4595
5030
|
agentName: agentName,
|
|
5031
|
+
policyName: "",
|
|
4596
5032
|
swarmName: "",
|
|
4597
5033
|
storageName: "",
|
|
4598
5034
|
stateName: "",
|
|
@@ -4631,6 +5067,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
4631
5067
|
methodName: methodName,
|
|
4632
5068
|
clientId: clientId,
|
|
4633
5069
|
agentName: agentName,
|
|
5070
|
+
policyName: "",
|
|
4634
5071
|
swarmName: "",
|
|
4635
5072
|
storageName: "",
|
|
4636
5073
|
stateName: "",
|
|
@@ -4667,6 +5104,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
4667
5104
|
methodName: methodName,
|
|
4668
5105
|
clientId: clientId,
|
|
4669
5106
|
agentName: agentName,
|
|
5107
|
+
policyName: "",
|
|
4670
5108
|
swarmName: "",
|
|
4671
5109
|
storageName: "",
|
|
4672
5110
|
stateName: "",
|
|
@@ -4707,6 +5145,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
4707
5145
|
methodName: methodName,
|
|
4708
5146
|
clientId: clientId,
|
|
4709
5147
|
agentName: agentName,
|
|
5148
|
+
policyName: "",
|
|
4710
5149
|
swarmName: "",
|
|
4711
5150
|
storageName: "",
|
|
4712
5151
|
stateName: "",
|
|
@@ -4745,6 +5184,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
4745
5184
|
methodName: methodName,
|
|
4746
5185
|
clientId: clientId,
|
|
4747
5186
|
agentName: agentName,
|
|
5187
|
+
policyName: "",
|
|
4748
5188
|
swarmName: "",
|
|
4749
5189
|
storageName: "",
|
|
4750
5190
|
stateName: "",
|
|
@@ -4783,6 +5223,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
4783
5223
|
methodName: methodName,
|
|
4784
5224
|
clientId: clientId,
|
|
4785
5225
|
agentName: agentName,
|
|
5226
|
+
policyName: "",
|
|
4786
5227
|
swarmName: "",
|
|
4787
5228
|
storageName: "",
|
|
4788
5229
|
stateName: "",
|
|
@@ -4821,6 +5262,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
4821
5262
|
methodName: methodName,
|
|
4822
5263
|
clientId: clientId,
|
|
4823
5264
|
agentName: agentName,
|
|
5265
|
+
policyName: "",
|
|
4824
5266
|
swarmName: "",
|
|
4825
5267
|
storageName: "",
|
|
4826
5268
|
stateName: "",
|
|
@@ -4857,6 +5299,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
4857
5299
|
methodName: methodName,
|
|
4858
5300
|
clientId: clientId,
|
|
4859
5301
|
agentName: agentName,
|
|
5302
|
+
policyName: "",
|
|
4860
5303
|
swarmName: "",
|
|
4861
5304
|
storageName: "",
|
|
4862
5305
|
stateName: "",
|
|
@@ -4893,6 +5336,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
4893
5336
|
methodName: methodName,
|
|
4894
5337
|
clientId: clientId,
|
|
4895
5338
|
agentName: agentName,
|
|
5339
|
+
policyName: "",
|
|
4896
5340
|
swarmName: "",
|
|
4897
5341
|
storageName: "",
|
|
4898
5342
|
stateName: "",
|
|
@@ -4929,6 +5373,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
4929
5373
|
methodName: methodName,
|
|
4930
5374
|
clientId: clientId,
|
|
4931
5375
|
agentName: agentName,
|
|
5376
|
+
policyName: "",
|
|
4932
5377
|
swarmName: "",
|
|
4933
5378
|
storageName: "",
|
|
4934
5379
|
stateName: "",
|
|
@@ -4965,6 +5410,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
4965
5410
|
methodName: methodName,
|
|
4966
5411
|
clientId: clientId,
|
|
4967
5412
|
agentName: agentName,
|
|
5413
|
+
policyName: "",
|
|
4968
5414
|
swarmName: "",
|
|
4969
5415
|
storageName: "",
|
|
4970
5416
|
stateName: "",
|
|
@@ -5015,6 +5461,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
5015
5461
|
methodName: methodName,
|
|
5016
5462
|
clientId: clientId,
|
|
5017
5463
|
agentName: agentName,
|
|
5464
|
+
policyName: "",
|
|
5018
5465
|
swarmName: "",
|
|
5019
5466
|
storageName: "",
|
|
5020
5467
|
stateName: "",
|
|
@@ -5052,6 +5499,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
5052
5499
|
methodName: methodName,
|
|
5053
5500
|
clientId: clientId,
|
|
5054
5501
|
agentName: agentName,
|
|
5502
|
+
policyName: "",
|
|
5055
5503
|
swarmName: "",
|
|
5056
5504
|
storageName: "",
|
|
5057
5505
|
stateName: "",
|
|
@@ -5088,6 +5536,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
5088
5536
|
methodName: methodName,
|
|
5089
5537
|
clientId: clientId,
|
|
5090
5538
|
agentName: agentName,
|
|
5539
|
+
policyName: "",
|
|
5091
5540
|
swarmName: "",
|
|
5092
5541
|
storageName: "",
|
|
5093
5542
|
stateName: "",
|
|
@@ -5123,6 +5572,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
5123
5572
|
methodName: methodName,
|
|
5124
5573
|
clientId: clientId,
|
|
5125
5574
|
agentName: agentName,
|
|
5575
|
+
policyName: "",
|
|
5126
5576
|
swarmName: "",
|
|
5127
5577
|
storageName: "",
|
|
5128
5578
|
stateName: "",
|
|
@@ -5175,6 +5625,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
5175
5625
|
methodName: methodName,
|
|
5176
5626
|
clientId: clientId,
|
|
5177
5627
|
swarmName: swarmName,
|
|
5628
|
+
policyName: "",
|
|
5178
5629
|
agentName: "",
|
|
5179
5630
|
storageName: "",
|
|
5180
5631
|
stateName: "",
|
|
@@ -5213,6 +5664,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
5213
5664
|
methodName: methodName,
|
|
5214
5665
|
clientId: clientId,
|
|
5215
5666
|
swarmName: swarmName,
|
|
5667
|
+
policyName: "",
|
|
5216
5668
|
agentName: "",
|
|
5217
5669
|
storageName: "",
|
|
5218
5670
|
stateName: "",
|
|
@@ -5250,6 +5702,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
5250
5702
|
methodName: methodName,
|
|
5251
5703
|
clientId: clientId,
|
|
5252
5704
|
swarmName: swarmName,
|
|
5705
|
+
policyName: "",
|
|
5253
5706
|
agentName: "",
|
|
5254
5707
|
storageName: "",
|
|
5255
5708
|
stateName: "",
|
|
@@ -5349,6 +5802,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
5349
5802
|
methodName: methodName,
|
|
5350
5803
|
clientId: clientId,
|
|
5351
5804
|
swarmName: swarmName,
|
|
5805
|
+
policyName: "",
|
|
5352
5806
|
agentName: "",
|
|
5353
5807
|
storageName: "",
|
|
5354
5808
|
stateName: "",
|
|
@@ -5387,6 +5841,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
5387
5841
|
methodName: methodName,
|
|
5388
5842
|
clientId: clientId,
|
|
5389
5843
|
swarmName: swarmName,
|
|
5844
|
+
policyName: "",
|
|
5390
5845
|
agentName: "",
|
|
5391
5846
|
storageName: "",
|
|
5392
5847
|
stateName: "",
|
|
@@ -5425,6 +5880,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
5425
5880
|
methodName: methodName,
|
|
5426
5881
|
clientId: clientId,
|
|
5427
5882
|
swarmName: swarmName,
|
|
5883
|
+
policyName: "",
|
|
5428
5884
|
agentName: "",
|
|
5429
5885
|
storageName: "",
|
|
5430
5886
|
stateName: "",
|
|
@@ -5463,6 +5919,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
5463
5919
|
methodName: methodName,
|
|
5464
5920
|
clientId: clientId,
|
|
5465
5921
|
swarmName: swarmName,
|
|
5922
|
+
policyName: "",
|
|
5466
5923
|
agentName: "",
|
|
5467
5924
|
storageName: "",
|
|
5468
5925
|
stateName: "",
|
|
@@ -5498,6 +5955,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
5498
5955
|
methodName: methodName,
|
|
5499
5956
|
clientId: clientId,
|
|
5500
5957
|
swarmName: swarmName,
|
|
5958
|
+
policyName: "",
|
|
5501
5959
|
agentName: "",
|
|
5502
5960
|
storageName: "",
|
|
5503
5961
|
stateName: "",
|
|
@@ -5533,6 +5991,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
5533
5991
|
methodName: methodName,
|
|
5534
5992
|
clientId: clientId,
|
|
5535
5993
|
swarmName: swarmName,
|
|
5994
|
+
policyName: "",
|
|
5536
5995
|
agentName: "",
|
|
5537
5996
|
storageName: "",
|
|
5538
5997
|
stateName: "",
|
|
@@ -5569,6 +6028,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
5569
6028
|
methodName: methodName,
|
|
5570
6029
|
clientId: clientId,
|
|
5571
6030
|
swarmName: swarmName,
|
|
6031
|
+
policyName: "",
|
|
5572
6032
|
agentName: "",
|
|
5573
6033
|
storageName: "",
|
|
5574
6034
|
stateName: "",
|
|
@@ -5614,6 +6074,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
5614
6074
|
methodName: methodName,
|
|
5615
6075
|
clientId: clientId,
|
|
5616
6076
|
swarmName: swarmName,
|
|
6077
|
+
policyName: "",
|
|
5617
6078
|
agentName: "",
|
|
5618
6079
|
storageName: "",
|
|
5619
6080
|
stateName: "",
|
|
@@ -5649,6 +6110,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
5649
6110
|
methodName: methodName,
|
|
5650
6111
|
clientId: clientId,
|
|
5651
6112
|
swarmName: swarmName,
|
|
6113
|
+
policyName: "",
|
|
5652
6114
|
agentName: "",
|
|
5653
6115
|
storageName: "",
|
|
5654
6116
|
stateName: "",
|
|
@@ -5685,6 +6147,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
5685
6147
|
methodName: methodName,
|
|
5686
6148
|
clientId: clientId,
|
|
5687
6149
|
swarmName: swarmName,
|
|
6150
|
+
policyName: "",
|
|
5688
6151
|
agentName: "",
|
|
5689
6152
|
storageName: "",
|
|
5690
6153
|
stateName: "",
|
|
@@ -5721,6 +6184,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
5721
6184
|
methodName: methodName,
|
|
5722
6185
|
clientId: clientId,
|
|
5723
6186
|
swarmName: swarmName,
|
|
6187
|
+
policyName: "",
|
|
5724
6188
|
agentName: "",
|
|
5725
6189
|
storageName: "",
|
|
5726
6190
|
stateName: "",
|
|
@@ -5756,6 +6220,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
5756
6220
|
methodName: methodName,
|
|
5757
6221
|
clientId: clientId,
|
|
5758
6222
|
swarmName: swarmName,
|
|
6223
|
+
policyName: "",
|
|
5759
6224
|
agentName: "",
|
|
5760
6225
|
storageName: "",
|
|
5761
6226
|
stateName: "",
|
|
@@ -5796,6 +6261,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
5796
6261
|
methodName: methodName,
|
|
5797
6262
|
clientId: clientId,
|
|
5798
6263
|
swarmName: swarmName,
|
|
6264
|
+
policyName: "",
|
|
5799
6265
|
agentName: "",
|
|
5800
6266
|
storageName: "",
|
|
5801
6267
|
stateName: "",
|
|
@@ -5834,6 +6300,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
5834
6300
|
methodName: methodName,
|
|
5835
6301
|
clientId: clientId,
|
|
5836
6302
|
swarmName: swarmName,
|
|
6303
|
+
policyName: "",
|
|
5837
6304
|
agentName: "",
|
|
5838
6305
|
storageName: "",
|
|
5839
6306
|
stateName: "",
|
|
@@ -5870,6 +6337,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
5870
6337
|
methodName: methodName,
|
|
5871
6338
|
clientId: clientId,
|
|
5872
6339
|
swarmName: swarmName,
|
|
6340
|
+
policyName: "",
|
|
5873
6341
|
agentName: "",
|
|
5874
6342
|
storageName: "",
|
|
5875
6343
|
stateName: "",
|
|
@@ -6448,6 +6916,7 @@ var SwarmValidationService = /** @class */ (function () {
|
|
|
6448
6916
|
var _this = this;
|
|
6449
6917
|
this.loggerService = inject(TYPES.loggerService);
|
|
6450
6918
|
this.agentValidationService = inject(TYPES.agentValidationService);
|
|
6919
|
+
this.policyValidationService = inject(TYPES.policyValidationService);
|
|
6451
6920
|
this._swarmMap = new Map();
|
|
6452
6921
|
/**
|
|
6453
6922
|
* Adds a new swarm to the swarm map.
|
|
@@ -6502,6 +6971,7 @@ var SwarmValidationService = /** @class */ (function () {
|
|
|
6502
6971
|
var _b = __read(_a, 1), swarmName = _b[0];
|
|
6503
6972
|
return swarmName;
|
|
6504
6973
|
}, function (swarmName, source) {
|
|
6974
|
+
var _a;
|
|
6505
6975
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
6506
6976
|
_this.loggerService.info("swarmValidationService validate", {
|
|
6507
6977
|
swarmName: swarmName,
|
|
@@ -6517,6 +6987,9 @@ var SwarmValidationService = /** @class */ (function () {
|
|
|
6517
6987
|
swarm.agentList.forEach(function (agentName) {
|
|
6518
6988
|
return _this.agentValidationService.validate(agentName, source);
|
|
6519
6989
|
});
|
|
6990
|
+
(_a = swarm.policies) === null || _a === void 0 ? void 0 : _a.forEach(function (policyName) {
|
|
6991
|
+
return _this.policyValidationService.validate(policyName, source);
|
|
6992
|
+
});
|
|
6520
6993
|
return {};
|
|
6521
6994
|
});
|
|
6522
6995
|
}
|
|
@@ -7306,6 +7779,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
7306
7779
|
methodName: methodName,
|
|
7307
7780
|
clientId: clientId,
|
|
7308
7781
|
storageName: storageName,
|
|
7782
|
+
policyName: "",
|
|
7309
7783
|
agentName: "",
|
|
7310
7784
|
swarmName: "",
|
|
7311
7785
|
stateName: "",
|
|
@@ -7341,6 +7815,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
7341
7815
|
methodName: methodName,
|
|
7342
7816
|
clientId: clientId,
|
|
7343
7817
|
storageName: storageName,
|
|
7818
|
+
policyName: "",
|
|
7344
7819
|
agentName: "",
|
|
7345
7820
|
swarmName: "",
|
|
7346
7821
|
stateName: "",
|
|
@@ -7376,6 +7851,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
7376
7851
|
methodName: methodName,
|
|
7377
7852
|
clientId: clientId,
|
|
7378
7853
|
storageName: storageName,
|
|
7854
|
+
policyName: "",
|
|
7379
7855
|
agentName: "",
|
|
7380
7856
|
swarmName: "",
|
|
7381
7857
|
stateName: "",
|
|
@@ -7412,6 +7888,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
7412
7888
|
methodName: methodName,
|
|
7413
7889
|
clientId: clientId,
|
|
7414
7890
|
storageName: storageName,
|
|
7891
|
+
policyName: "",
|
|
7415
7892
|
agentName: "",
|
|
7416
7893
|
swarmName: "",
|
|
7417
7894
|
stateName: "",
|
|
@@ -7447,6 +7924,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
7447
7924
|
methodName: methodName,
|
|
7448
7925
|
clientId: clientId,
|
|
7449
7926
|
storageName: storageName,
|
|
7927
|
+
policyName: "",
|
|
7450
7928
|
agentName: "",
|
|
7451
7929
|
swarmName: "",
|
|
7452
7930
|
stateName: "",
|
|
@@ -7481,6 +7959,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
7481
7959
|
methodName: methodName,
|
|
7482
7960
|
clientId: clientId,
|
|
7483
7961
|
storageName: storageName,
|
|
7962
|
+
policyName: "",
|
|
7484
7963
|
agentName: "",
|
|
7485
7964
|
swarmName: "",
|
|
7486
7965
|
stateName: "",
|
|
@@ -7516,6 +7995,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
7516
7995
|
methodName: methodName,
|
|
7517
7996
|
clientId: clientId,
|
|
7518
7997
|
storageName: storageName,
|
|
7998
|
+
policyName: "",
|
|
7519
7999
|
agentName: "",
|
|
7520
8000
|
swarmName: "",
|
|
7521
8001
|
stateName: "",
|
|
@@ -8127,6 +8607,7 @@ var StatePublicService = /** @class */ (function () {
|
|
|
8127
8607
|
methodName: methodName,
|
|
8128
8608
|
clientId: clientId,
|
|
8129
8609
|
stateName: stateName,
|
|
8610
|
+
policyName: "",
|
|
8130
8611
|
agentName: "",
|
|
8131
8612
|
swarmName: "",
|
|
8132
8613
|
storageName: "",
|
|
@@ -8163,6 +8644,7 @@ var StatePublicService = /** @class */ (function () {
|
|
|
8163
8644
|
methodName: methodName,
|
|
8164
8645
|
clientId: clientId,
|
|
8165
8646
|
stateName: stateName,
|
|
8647
|
+
policyName: "",
|
|
8166
8648
|
agentName: "",
|
|
8167
8649
|
swarmName: "",
|
|
8168
8650
|
storageName: "",
|
|
@@ -8198,6 +8680,7 @@ var StatePublicService = /** @class */ (function () {
|
|
|
8198
8680
|
methodName: methodName,
|
|
8199
8681
|
clientId: clientId,
|
|
8200
8682
|
stateName: stateName,
|
|
8683
|
+
policyName: "",
|
|
8201
8684
|
agentName: "",
|
|
8202
8685
|
swarmName: "",
|
|
8203
8686
|
storageName: "",
|
|
@@ -8234,6 +8717,7 @@ var StatePublicService = /** @class */ (function () {
|
|
|
8234
8717
|
methodName: methodName,
|
|
8235
8718
|
clientId: clientId,
|
|
8236
8719
|
stateName: stateName,
|
|
8720
|
+
policyName: "",
|
|
8237
8721
|
agentName: "",
|
|
8238
8722
|
swarmName: "",
|
|
8239
8723
|
storageName: "",
|
|
@@ -8638,6 +9122,7 @@ var DocService = /** @class */ (function () {
|
|
|
8638
9122
|
this.agentValidationService = inject(TYPES.agentValidationService);
|
|
8639
9123
|
this.swarmSchemaService = inject(TYPES.swarmSchemaService);
|
|
8640
9124
|
this.agentSchemaService = inject(TYPES.agentSchemaService);
|
|
9125
|
+
this.policySchemaService = inject(TYPES.policySchemaService);
|
|
8641
9126
|
this.toolSchemaService = inject(TYPES.toolSchemaService);
|
|
8642
9127
|
this.storageSchemaService = inject(TYPES.storageSchemaService);
|
|
8643
9128
|
this.stateSchemaService = inject(TYPES.stateSchemaService);
|
|
@@ -8650,7 +9135,7 @@ var DocService = /** @class */ (function () {
|
|
|
8650
9135
|
* @returns {Promise<void>}
|
|
8651
9136
|
*/
|
|
8652
9137
|
this.writeSwarmDoc = functoolsKit.execpool(function (swarmSchema, dirName) { return __awaiter(_this, void 0, void 0, function () {
|
|
8653
|
-
var result, umlSchema, umlName, umlSvg, docDescription, i, docDescription, callbackList, i;
|
|
9138
|
+
var result, umlSchema, umlName, umlSvg, docDescription, i, docDescription, i, docDescription, callbackList, i;
|
|
8654
9139
|
return __generator(this, function (_a) {
|
|
8655
9140
|
switch (_a.label) {
|
|
8656
9141
|
case 0:
|
|
@@ -8707,6 +9192,26 @@ var DocService = /** @class */ (function () {
|
|
|
8707
9192
|
result.push("");
|
|
8708
9193
|
}
|
|
8709
9194
|
}
|
|
9195
|
+
if (swarmSchema.policies) {
|
|
9196
|
+
result.push("## Banhammer policies");
|
|
9197
|
+
result.push("");
|
|
9198
|
+
for (i = 0; i !== swarmSchema.policies.length; i++) {
|
|
9199
|
+
if (!swarmSchema.policies[i]) {
|
|
9200
|
+
continue;
|
|
9201
|
+
}
|
|
9202
|
+
result.push("".concat(i + 1, ". ").concat(swarmSchema.policies[i]));
|
|
9203
|
+
docDescription = this.policySchemaService.get(swarmSchema.policies[i]).docDescription;
|
|
9204
|
+
if (docDescription) {
|
|
9205
|
+
result.push("");
|
|
9206
|
+
result.push("\t".concat(docDescription));
|
|
9207
|
+
}
|
|
9208
|
+
result.push("");
|
|
9209
|
+
}
|
|
9210
|
+
if (!swarmSchema.policies.length) {
|
|
9211
|
+
result.push("");
|
|
9212
|
+
result.push("*Empty policies*");
|
|
9213
|
+
}
|
|
9214
|
+
}
|
|
8710
9215
|
if (swarmSchema.callbacks) {
|
|
8711
9216
|
result.push("## Used callbacks");
|
|
8712
9217
|
result.push("");
|
|
@@ -9452,6 +9957,7 @@ var SharedStatePublicService = /** @class */ (function () {
|
|
|
9452
9957
|
methodName: methodName,
|
|
9453
9958
|
clientId: "",
|
|
9454
9959
|
stateName: stateName,
|
|
9960
|
+
policyName: "",
|
|
9455
9961
|
agentName: "",
|
|
9456
9962
|
swarmName: "",
|
|
9457
9963
|
storageName: "",
|
|
@@ -9486,6 +9992,7 @@ var SharedStatePublicService = /** @class */ (function () {
|
|
|
9486
9992
|
methodName: methodName,
|
|
9487
9993
|
clientId: "",
|
|
9488
9994
|
stateName: stateName,
|
|
9995
|
+
policyName: "",
|
|
9489
9996
|
agentName: "",
|
|
9490
9997
|
swarmName: "",
|
|
9491
9998
|
storageName: "",
|
|
@@ -9519,6 +10026,7 @@ var SharedStatePublicService = /** @class */ (function () {
|
|
|
9519
10026
|
methodName: methodName,
|
|
9520
10027
|
clientId: "",
|
|
9521
10028
|
stateName: stateName,
|
|
10029
|
+
policyName: "",
|
|
9522
10030
|
agentName: "",
|
|
9523
10031
|
swarmName: "",
|
|
9524
10032
|
storageName: "",
|
|
@@ -9569,6 +10077,7 @@ var SharedStoragePublicService = /** @class */ (function () {
|
|
|
9569
10077
|
methodName: methodName,
|
|
9570
10078
|
clientId: "",
|
|
9571
10079
|
storageName: storageName,
|
|
10080
|
+
policyName: "",
|
|
9572
10081
|
agentName: "",
|
|
9573
10082
|
swarmName: "",
|
|
9574
10083
|
stateName: "",
|
|
@@ -9603,6 +10112,7 @@ var SharedStoragePublicService = /** @class */ (function () {
|
|
|
9603
10112
|
methodName: methodName,
|
|
9604
10113
|
clientId: "",
|
|
9605
10114
|
storageName: storageName,
|
|
10115
|
+
policyName: "",
|
|
9606
10116
|
agentName: "",
|
|
9607
10117
|
swarmName: "",
|
|
9608
10118
|
stateName: "",
|
|
@@ -9637,6 +10147,7 @@ var SharedStoragePublicService = /** @class */ (function () {
|
|
|
9637
10147
|
methodName: methodName,
|
|
9638
10148
|
clientId: "",
|
|
9639
10149
|
storageName: storageName,
|
|
10150
|
+
policyName: "",
|
|
9640
10151
|
agentName: "",
|
|
9641
10152
|
swarmName: "",
|
|
9642
10153
|
stateName: "",
|
|
@@ -9672,6 +10183,7 @@ var SharedStoragePublicService = /** @class */ (function () {
|
|
|
9672
10183
|
methodName: methodName,
|
|
9673
10184
|
clientId: "",
|
|
9674
10185
|
storageName: storageName,
|
|
10186
|
+
policyName: "",
|
|
9675
10187
|
agentName: "",
|
|
9676
10188
|
swarmName: "",
|
|
9677
10189
|
stateName: "",
|
|
@@ -9706,6 +10218,7 @@ var SharedStoragePublicService = /** @class */ (function () {
|
|
|
9706
10218
|
methodName: methodName,
|
|
9707
10219
|
clientId: "",
|
|
9708
10220
|
storageName: storageName,
|
|
10221
|
+
policyName: "",
|
|
9709
10222
|
agentName: "",
|
|
9710
10223
|
swarmName: "",
|
|
9711
10224
|
stateName: "",
|
|
@@ -9739,6 +10252,7 @@ var SharedStoragePublicService = /** @class */ (function () {
|
|
|
9739
10252
|
methodName: methodName,
|
|
9740
10253
|
clientId: "",
|
|
9741
10254
|
storageName: storageName,
|
|
10255
|
+
policyName: "",
|
|
9742
10256
|
agentName: "",
|
|
9743
10257
|
swarmName: "",
|
|
9744
10258
|
stateName: "",
|
|
@@ -10236,68 +10750,818 @@ var PerfService = /** @class */ (function () {
|
|
|
10236
10750
|
return PerfService;
|
|
10237
10751
|
}());
|
|
10238
10752
|
|
|
10239
|
-
|
|
10240
|
-
|
|
10241
|
-
|
|
10242
|
-
|
|
10243
|
-
|
|
10244
|
-
|
|
10245
|
-
|
|
10246
|
-
|
|
10247
|
-
|
|
10248
|
-
|
|
10249
|
-
|
|
10250
|
-
|
|
10251
|
-
|
|
10252
|
-
|
|
10253
|
-
|
|
10254
|
-
|
|
10255
|
-
|
|
10256
|
-
|
|
10257
|
-
|
|
10258
|
-
|
|
10259
|
-
|
|
10260
|
-
|
|
10261
|
-
|
|
10262
|
-
|
|
10263
|
-
|
|
10264
|
-
|
|
10265
|
-
|
|
10266
|
-
|
|
10267
|
-
|
|
10268
|
-
|
|
10269
|
-
{
|
|
10270
|
-
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
|
|
10274
|
-
|
|
10275
|
-
|
|
10276
|
-
|
|
10277
|
-
|
|
10278
|
-
|
|
10279
|
-
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
}
|
|
10283
|
-
|
|
10284
|
-
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
|
|
10291
|
-
|
|
10292
|
-
|
|
10293
|
-
|
|
10294
|
-
|
|
10295
|
-
|
|
10296
|
-
|
|
10297
|
-
|
|
10298
|
-
}
|
|
10299
|
-
|
|
10300
|
-
|
|
10753
|
+
/**
|
|
10754
|
+
* Service for managing policy schemas.
|
|
10755
|
+
*/
|
|
10756
|
+
var PolicySchemaService = /** @class */ (function () {
|
|
10757
|
+
function PolicySchemaService() {
|
|
10758
|
+
var _this = this;
|
|
10759
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
10760
|
+
this.registry = new functoolsKit.ToolRegistry("policySchemaService");
|
|
10761
|
+
/**
|
|
10762
|
+
* Validation for policy schema
|
|
10763
|
+
*/
|
|
10764
|
+
this.validateShallow = function (policySchema) {
|
|
10765
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
10766
|
+
_this.loggerService.info("policySchemaService validateShallow", {
|
|
10767
|
+
policySchema: policySchema,
|
|
10768
|
+
});
|
|
10769
|
+
if (typeof policySchema.policyName !== "string") {
|
|
10770
|
+
throw new Error("agent-swarm policy schema validation failed: missing policyName");
|
|
10771
|
+
}
|
|
10772
|
+
if (typeof policySchema.getBannedClients !== "function") {
|
|
10773
|
+
throw new Error("agent-swarm policy schema validation failed: missing getBannedClients policyName=".concat(policySchema.policyName));
|
|
10774
|
+
}
|
|
10775
|
+
};
|
|
10776
|
+
/**
|
|
10777
|
+
* Registers a new policy schema.
|
|
10778
|
+
* @param {PolicyName} key - The name of the policy.
|
|
10779
|
+
* @param {IPolicySchema} value - The schema of the policy.
|
|
10780
|
+
*/
|
|
10781
|
+
this.register = function (key, value) {
|
|
10782
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
10783
|
+
_this.loggerService.info("policySchemaService register", { key: key });
|
|
10784
|
+
_this.validateShallow(value);
|
|
10785
|
+
_this.registry = _this.registry.register(key, value);
|
|
10786
|
+
};
|
|
10787
|
+
/**
|
|
10788
|
+
* Retrieves an policy schema by name.
|
|
10789
|
+
* @param {PolicyName} key - The name of the policy.
|
|
10790
|
+
* @returns {IPolicySchema} The schema of the policy.
|
|
10791
|
+
*/
|
|
10792
|
+
this.get = function (key) {
|
|
10793
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
10794
|
+
_this.loggerService.info("policySchemaService get", { key: key });
|
|
10795
|
+
return _this.registry.get(key);
|
|
10796
|
+
};
|
|
10797
|
+
}
|
|
10798
|
+
return PolicySchemaService;
|
|
10799
|
+
}());
|
|
10800
|
+
|
|
10801
|
+
/**
|
|
10802
|
+
* Service for validating policys within the agent-swarm.
|
|
10803
|
+
*/
|
|
10804
|
+
var PolicyValidationService = /** @class */ (function () {
|
|
10805
|
+
function PolicyValidationService() {
|
|
10806
|
+
var _this = this;
|
|
10807
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
10808
|
+
this._policyMap = new Map();
|
|
10809
|
+
/**
|
|
10810
|
+
* Adds a new policy to the validation service.
|
|
10811
|
+
* @param {PolicyName} policyName - The name of the policy to add.
|
|
10812
|
+
* @param {IPolicySchema} policySchema - The schema of the policy to add.
|
|
10813
|
+
* @throws Will throw an error if the policy already exists.
|
|
10814
|
+
*/
|
|
10815
|
+
this.addPolicy = function (policyName, policySchema) {
|
|
10816
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
10817
|
+
_this.loggerService.info("policyValidationService addPolicy", {
|
|
10818
|
+
policyName: policyName,
|
|
10819
|
+
policySchema: policySchema,
|
|
10820
|
+
});
|
|
10821
|
+
if (_this._policyMap.has(policyName)) {
|
|
10822
|
+
throw new Error("agent-swarm policy ".concat(policyName, " already exist"));
|
|
10823
|
+
}
|
|
10824
|
+
_this._policyMap.set(policyName, policySchema);
|
|
10825
|
+
};
|
|
10826
|
+
/**
|
|
10827
|
+
* Validates if a policy exists in the validation service.
|
|
10828
|
+
* @param {PolicyName} policyName - The name of the policy to validate.
|
|
10829
|
+
* @param {string} source - The source of the validation request.
|
|
10830
|
+
* @throws Will throw an error if the policy is not found.
|
|
10831
|
+
*/
|
|
10832
|
+
this.validate = functoolsKit.memoize(function (_a) {
|
|
10833
|
+
var _b = __read(_a, 1), policyName = _b[0];
|
|
10834
|
+
return policyName;
|
|
10835
|
+
}, function (policyName, source) {
|
|
10836
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
10837
|
+
_this.loggerService.info("policyValidationService validate", {
|
|
10838
|
+
policyName: policyName,
|
|
10839
|
+
source: source,
|
|
10840
|
+
});
|
|
10841
|
+
if (!_this._policyMap.has(policyName)) {
|
|
10842
|
+
throw new Error("agent-swarm policy ".concat(policyName, " not found source=").concat(source));
|
|
10843
|
+
}
|
|
10844
|
+
return {};
|
|
10845
|
+
});
|
|
10846
|
+
}
|
|
10847
|
+
return PolicyValidationService;
|
|
10848
|
+
}());
|
|
10849
|
+
|
|
10850
|
+
/**
|
|
10851
|
+
* Service for handling public policy operations.
|
|
10852
|
+
*/
|
|
10853
|
+
var PolicyPublicService = /** @class */ (function () {
|
|
10854
|
+
function PolicyPublicService() {
|
|
10855
|
+
var _this = this;
|
|
10856
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
10857
|
+
this.policyConnectionService = inject(TYPES.policyConnectionService);
|
|
10858
|
+
/**
|
|
10859
|
+
* Retrieves the ban message for a client in a specific swarm.
|
|
10860
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
10861
|
+
* @param {string} methodName - The name of the method.
|
|
10862
|
+
* @param {string} clientId - The ID of the client.
|
|
10863
|
+
* @param {PolicyName} policyName - The name of the policy.
|
|
10864
|
+
* @returns {Promise<string>} The ban message.
|
|
10865
|
+
*/
|
|
10866
|
+
this.getBanMessage = function (swarmName, methodName, clientId, policyName) { return __awaiter(_this, void 0, void 0, function () {
|
|
10867
|
+
var _this = this;
|
|
10868
|
+
return __generator(this, function (_a) {
|
|
10869
|
+
switch (_a.label) {
|
|
10870
|
+
case 0:
|
|
10871
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
10872
|
+
this.loggerService.info("policyPublicService getBanMessage", {
|
|
10873
|
+
methodName: methodName,
|
|
10874
|
+
clientId: clientId,
|
|
10875
|
+
swarmName: swarmName,
|
|
10876
|
+
policyName: policyName,
|
|
10877
|
+
});
|
|
10878
|
+
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
10879
|
+
return __generator(this, function (_a) {
|
|
10880
|
+
switch (_a.label) {
|
|
10881
|
+
case 0: return [4 /*yield*/, this.policyConnectionService.getBanMessage(clientId, swarmName)];
|
|
10882
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
10883
|
+
}
|
|
10884
|
+
});
|
|
10885
|
+
}); }, {
|
|
10886
|
+
methodName: methodName,
|
|
10887
|
+
clientId: clientId,
|
|
10888
|
+
agentName: "",
|
|
10889
|
+
swarmName: swarmName,
|
|
10890
|
+
policyName: policyName,
|
|
10891
|
+
storageName: "",
|
|
10892
|
+
stateName: "",
|
|
10893
|
+
})];
|
|
10894
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
10895
|
+
}
|
|
10896
|
+
});
|
|
10897
|
+
}); };
|
|
10898
|
+
/**
|
|
10899
|
+
* Validates the input for a specific policy.
|
|
10900
|
+
* @param {string} incoming - The incoming data to validate.
|
|
10901
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
10902
|
+
* @param {string} methodName - The name of the method.
|
|
10903
|
+
* @param {string} clientId - The ID of the client.
|
|
10904
|
+
* @param {PolicyName} policyName - The name of the policy.
|
|
10905
|
+
* @returns {Promise<boolean>} The result of the validation.
|
|
10906
|
+
*/
|
|
10907
|
+
this.validateInput = function (incoming, swarmName, methodName, clientId, policyName) { return __awaiter(_this, void 0, void 0, function () {
|
|
10908
|
+
var _this = this;
|
|
10909
|
+
return __generator(this, function (_a) {
|
|
10910
|
+
switch (_a.label) {
|
|
10911
|
+
case 0:
|
|
10912
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
10913
|
+
this.loggerService.info("policyPublicService validateInput", {
|
|
10914
|
+
incoming: incoming,
|
|
10915
|
+
methodName: methodName,
|
|
10916
|
+
clientId: clientId,
|
|
10917
|
+
swarmName: swarmName,
|
|
10918
|
+
policyName: policyName,
|
|
10919
|
+
});
|
|
10920
|
+
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
10921
|
+
return __generator(this, function (_a) {
|
|
10922
|
+
switch (_a.label) {
|
|
10923
|
+
case 0: return [4 /*yield*/, this.policyConnectionService.validateInput(incoming, clientId, swarmName)];
|
|
10924
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
10925
|
+
}
|
|
10926
|
+
});
|
|
10927
|
+
}); }, {
|
|
10928
|
+
methodName: methodName,
|
|
10929
|
+
clientId: clientId,
|
|
10930
|
+
agentName: "",
|
|
10931
|
+
swarmName: swarmName,
|
|
10932
|
+
policyName: policyName,
|
|
10933
|
+
storageName: "",
|
|
10934
|
+
stateName: "",
|
|
10935
|
+
})];
|
|
10936
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
10937
|
+
}
|
|
10938
|
+
});
|
|
10939
|
+
}); };
|
|
10940
|
+
/**
|
|
10941
|
+
* Validates the output for a specific policy.
|
|
10942
|
+
* @param {string} outgoing - The outgoing data to validate.
|
|
10943
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
10944
|
+
* @param {string} methodName - The name of the method.
|
|
10945
|
+
* @param {string} clientId - The ID of the client.
|
|
10946
|
+
* @param {PolicyName} policyName - The name of the policy.
|
|
10947
|
+
* @returns {Promise<boolean>} The result of the validation.
|
|
10948
|
+
*/
|
|
10949
|
+
this.validateOutput = function (outgoing, swarmName, methodName, clientId, policyName) { return __awaiter(_this, void 0, void 0, function () {
|
|
10950
|
+
var _this = this;
|
|
10951
|
+
return __generator(this, function (_a) {
|
|
10952
|
+
switch (_a.label) {
|
|
10953
|
+
case 0:
|
|
10954
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
10955
|
+
this.loggerService.info("policyPublicService validateOutput", {
|
|
10956
|
+
outgoing: outgoing,
|
|
10957
|
+
methodName: methodName,
|
|
10958
|
+
clientId: clientId,
|
|
10959
|
+
swarmName: swarmName,
|
|
10960
|
+
policyName: policyName,
|
|
10961
|
+
});
|
|
10962
|
+
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
10963
|
+
return __generator(this, function (_a) {
|
|
10964
|
+
switch (_a.label) {
|
|
10965
|
+
case 0: return [4 /*yield*/, this.policyConnectionService.validateOutput(outgoing, clientId, swarmName)];
|
|
10966
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
10967
|
+
}
|
|
10968
|
+
});
|
|
10969
|
+
}); }, {
|
|
10970
|
+
methodName: methodName,
|
|
10971
|
+
clientId: clientId,
|
|
10972
|
+
agentName: "",
|
|
10973
|
+
swarmName: swarmName,
|
|
10974
|
+
policyName: policyName,
|
|
10975
|
+
storageName: "",
|
|
10976
|
+
stateName: "",
|
|
10977
|
+
})];
|
|
10978
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
10979
|
+
}
|
|
10980
|
+
});
|
|
10981
|
+
}); };
|
|
10982
|
+
/**
|
|
10983
|
+
* Bans a client from a specific swarm.
|
|
10984
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
10985
|
+
* @param {string} methodName - The name of the method.
|
|
10986
|
+
* @param {string} clientId - The ID of the client.
|
|
10987
|
+
* @param {PolicyName} policyName - The name of the policy.
|
|
10988
|
+
* @returns {Promise<void>}
|
|
10989
|
+
*/
|
|
10990
|
+
this.banClient = function (swarmName, methodName, clientId, policyName) { return __awaiter(_this, void 0, void 0, function () {
|
|
10991
|
+
var _this = this;
|
|
10992
|
+
return __generator(this, function (_a) {
|
|
10993
|
+
switch (_a.label) {
|
|
10994
|
+
case 0:
|
|
10995
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
10996
|
+
this.loggerService.info("policyPublicService banClient", {
|
|
10997
|
+
methodName: methodName,
|
|
10998
|
+
clientId: clientId,
|
|
10999
|
+
swarmName: swarmName,
|
|
11000
|
+
policyName: policyName,
|
|
11001
|
+
});
|
|
11002
|
+
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
11003
|
+
return __generator(this, function (_a) {
|
|
11004
|
+
switch (_a.label) {
|
|
11005
|
+
case 0: return [4 /*yield*/, this.policyConnectionService.banClient(clientId, swarmName)];
|
|
11006
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
11007
|
+
}
|
|
11008
|
+
});
|
|
11009
|
+
}); }, {
|
|
11010
|
+
methodName: methodName,
|
|
11011
|
+
clientId: clientId,
|
|
11012
|
+
agentName: "",
|
|
11013
|
+
swarmName: swarmName,
|
|
11014
|
+
policyName: policyName,
|
|
11015
|
+
storageName: "",
|
|
11016
|
+
stateName: "",
|
|
11017
|
+
})];
|
|
11018
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
11019
|
+
}
|
|
11020
|
+
});
|
|
11021
|
+
}); };
|
|
11022
|
+
/**
|
|
11023
|
+
* Unbans a client from a specific swarm.
|
|
11024
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
11025
|
+
* @param {string} methodName - The name of the method.
|
|
11026
|
+
* @param {string} clientId - The ID of the client.
|
|
11027
|
+
* @param {PolicyName} policyName - The name of the policy.
|
|
11028
|
+
* @returns {Promise<void>}
|
|
11029
|
+
*/
|
|
11030
|
+
this.unbanClient = function (swarmName, methodName, clientId, policyName) { return __awaiter(_this, void 0, void 0, function () {
|
|
11031
|
+
var _this = this;
|
|
11032
|
+
return __generator(this, function (_a) {
|
|
11033
|
+
switch (_a.label) {
|
|
11034
|
+
case 0:
|
|
11035
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
11036
|
+
this.loggerService.info("policyPublicService unbanClient", {
|
|
11037
|
+
methodName: methodName,
|
|
11038
|
+
clientId: clientId,
|
|
11039
|
+
swarmName: swarmName,
|
|
11040
|
+
policyName: policyName,
|
|
11041
|
+
});
|
|
11042
|
+
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
11043
|
+
return __generator(this, function (_a) {
|
|
11044
|
+
switch (_a.label) {
|
|
11045
|
+
case 0: return [4 /*yield*/, this.policyConnectionService.unbanClient(clientId, swarmName)];
|
|
11046
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
11047
|
+
}
|
|
11048
|
+
});
|
|
11049
|
+
}); }, {
|
|
11050
|
+
methodName: methodName,
|
|
11051
|
+
clientId: clientId,
|
|
11052
|
+
agentName: "",
|
|
11053
|
+
swarmName: swarmName,
|
|
11054
|
+
policyName: policyName,
|
|
11055
|
+
storageName: "",
|
|
11056
|
+
stateName: "",
|
|
11057
|
+
})];
|
|
11058
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
11059
|
+
}
|
|
11060
|
+
});
|
|
11061
|
+
}); };
|
|
11062
|
+
}
|
|
11063
|
+
return PolicyPublicService;
|
|
11064
|
+
}());
|
|
11065
|
+
|
|
11066
|
+
var BAN_NEED_FETCH = Symbol("ban-need-fetch");
|
|
11067
|
+
/**
|
|
11068
|
+
* Class representing a client policy.
|
|
11069
|
+
* @implements {IPolicy}
|
|
11070
|
+
*/
|
|
11071
|
+
var ClientPolicy = /** @class */ (function () {
|
|
11072
|
+
/**
|
|
11073
|
+
* Creates an instance of ClientPolicy.
|
|
11074
|
+
* @param {IPolicyParams} params - The policy parameters.
|
|
11075
|
+
*/
|
|
11076
|
+
function ClientPolicy(params) {
|
|
11077
|
+
var _a;
|
|
11078
|
+
this.params = params;
|
|
11079
|
+
this._banSet = BAN_NEED_FETCH;
|
|
11080
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
11081
|
+
this.params.logger.debug("ClientPolicy policyName=".concat(this.params.policyName, " CTOR"), {
|
|
11082
|
+
params: params,
|
|
11083
|
+
});
|
|
11084
|
+
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onInit) {
|
|
11085
|
+
this.params.callbacks.onInit(params.policyName);
|
|
11086
|
+
}
|
|
11087
|
+
}
|
|
11088
|
+
/**
|
|
11089
|
+
* Gets the ban message for a client.
|
|
11090
|
+
* @param {SessionId} clientId - The client ID.
|
|
11091
|
+
* @param {SwarmName} swarmName - The swarm name.
|
|
11092
|
+
* @returns {Promise<string>} The ban message.
|
|
11093
|
+
*/
|
|
11094
|
+
ClientPolicy.prototype.getBanMessage = function (clientId, swarmName) {
|
|
11095
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11096
|
+
var banMessage;
|
|
11097
|
+
return __generator(this, function (_a) {
|
|
11098
|
+
switch (_a.label) {
|
|
11099
|
+
case 0:
|
|
11100
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
11101
|
+
this.params.logger.debug("ClientPolicy policyName=".concat(this.params.policyName, " getBanMessage"), {
|
|
11102
|
+
clientId: clientId,
|
|
11103
|
+
swarmName: swarmName,
|
|
11104
|
+
});
|
|
11105
|
+
if (!this.params.getBanMessage) {
|
|
11106
|
+
return [2 /*return*/, this.params.banMessage];
|
|
11107
|
+
}
|
|
11108
|
+
banMessage = null;
|
|
11109
|
+
return [4 /*yield*/, this.params.getBanMessage(clientId, this.params.policyName, swarmName)];
|
|
11110
|
+
case 1:
|
|
11111
|
+
if ((banMessage = _a.sent())) {
|
|
11112
|
+
return [2 /*return*/, banMessage];
|
|
11113
|
+
}
|
|
11114
|
+
return [2 /*return*/, this.params.banMessage];
|
|
11115
|
+
}
|
|
11116
|
+
});
|
|
11117
|
+
});
|
|
11118
|
+
};
|
|
11119
|
+
/**
|
|
11120
|
+
* Validates the input from a client.
|
|
11121
|
+
* @param {string} incoming - The incoming message.
|
|
11122
|
+
* @param {SessionId} clientId - The client ID.
|
|
11123
|
+
* @param {SwarmName} swarmName - The swarm name.
|
|
11124
|
+
* @returns {Promise<boolean>} Whether the input is valid.
|
|
11125
|
+
*/
|
|
11126
|
+
ClientPolicy.prototype.validateInput = function (incoming, clientId, swarmName) {
|
|
11127
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11128
|
+
var _a, _b;
|
|
11129
|
+
var _c;
|
|
11130
|
+
return __generator(this, function (_d) {
|
|
11131
|
+
switch (_d.label) {
|
|
11132
|
+
case 0:
|
|
11133
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
11134
|
+
this.params.logger.debug("ClientPolicy policyName=".concat(this.params.policyName, " validateInput"), {
|
|
11135
|
+
incoming: incoming,
|
|
11136
|
+
clientId: clientId,
|
|
11137
|
+
swarmName: swarmName,
|
|
11138
|
+
});
|
|
11139
|
+
if ((_c = this.params.callbacks) === null || _c === void 0 ? void 0 : _c.onValidateInput) {
|
|
11140
|
+
this.params.callbacks.onValidateInput(incoming, clientId, swarmName, this.params.policyName);
|
|
11141
|
+
}
|
|
11142
|
+
return [4 /*yield*/, this.params.bus.emit(clientId, {
|
|
11143
|
+
type: "validate-input",
|
|
11144
|
+
source: "policy-bus",
|
|
11145
|
+
input: {
|
|
11146
|
+
incoming: incoming,
|
|
11147
|
+
},
|
|
11148
|
+
output: {},
|
|
11149
|
+
context: {
|
|
11150
|
+
policyName: this.params.policyName,
|
|
11151
|
+
swarmName: swarmName,
|
|
11152
|
+
},
|
|
11153
|
+
clientId: clientId,
|
|
11154
|
+
})];
|
|
11155
|
+
case 1:
|
|
11156
|
+
_d.sent();
|
|
11157
|
+
if (!(this._banSet === BAN_NEED_FETCH)) return [3 /*break*/, 3];
|
|
11158
|
+
_a = this;
|
|
11159
|
+
_b = Set.bind;
|
|
11160
|
+
return [4 /*yield*/, this.params.getBannedClients(this.params.policyName, swarmName)];
|
|
11161
|
+
case 2:
|
|
11162
|
+
_a._banSet = new (_b.apply(Set, [void 0, _d.sent()]))();
|
|
11163
|
+
_d.label = 3;
|
|
11164
|
+
case 3:
|
|
11165
|
+
if (this._banSet.has(clientId)) {
|
|
11166
|
+
return [2 /*return*/, false];
|
|
11167
|
+
}
|
|
11168
|
+
if (!this.params.validateInput) {
|
|
11169
|
+
return [2 /*return*/, true];
|
|
11170
|
+
}
|
|
11171
|
+
return [4 /*yield*/, this.params.validateInput(incoming, clientId, this.params.policyName, swarmName)];
|
|
11172
|
+
case 4:
|
|
11173
|
+
if (_d.sent()) {
|
|
11174
|
+
return [2 /*return*/, true];
|
|
11175
|
+
}
|
|
11176
|
+
return [4 /*yield*/, this.banClient(clientId, swarmName)];
|
|
11177
|
+
case 5:
|
|
11178
|
+
_d.sent();
|
|
11179
|
+
return [2 /*return*/, false];
|
|
11180
|
+
}
|
|
11181
|
+
});
|
|
11182
|
+
});
|
|
11183
|
+
};
|
|
11184
|
+
/**
|
|
11185
|
+
* Validates the output to a client.
|
|
11186
|
+
* @param {string} outgoing - The outgoing message.
|
|
11187
|
+
* @param {SessionId} clientId - The client ID.
|
|
11188
|
+
* @param {SwarmName} swarmName - The swarm name.
|
|
11189
|
+
* @returns {Promise<boolean>} Whether the output is valid.
|
|
11190
|
+
*/
|
|
11191
|
+
ClientPolicy.prototype.validateOutput = function (outgoing, clientId, swarmName) {
|
|
11192
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11193
|
+
var _a, _b;
|
|
11194
|
+
var _c;
|
|
11195
|
+
return __generator(this, function (_d) {
|
|
11196
|
+
switch (_d.label) {
|
|
11197
|
+
case 0:
|
|
11198
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
11199
|
+
this.params.logger.debug("ClientPolicy policyName=".concat(this.params.policyName, " validateOutput"), {
|
|
11200
|
+
clientId: clientId,
|
|
11201
|
+
swarmName: swarmName,
|
|
11202
|
+
outgoing: outgoing,
|
|
11203
|
+
});
|
|
11204
|
+
if ((_c = this.params.callbacks) === null || _c === void 0 ? void 0 : _c.onValidateOutput) {
|
|
11205
|
+
this.params.callbacks.onValidateOutput(outgoing, clientId, swarmName, this.params.policyName);
|
|
11206
|
+
}
|
|
11207
|
+
return [4 /*yield*/, this.params.bus.emit(clientId, {
|
|
11208
|
+
type: "validate-output",
|
|
11209
|
+
source: "policy-bus",
|
|
11210
|
+
input: {
|
|
11211
|
+
outgoing: outgoing,
|
|
11212
|
+
},
|
|
11213
|
+
output: {},
|
|
11214
|
+
context: {
|
|
11215
|
+
policyName: this.params.policyName,
|
|
11216
|
+
swarmName: swarmName,
|
|
11217
|
+
},
|
|
11218
|
+
clientId: clientId,
|
|
11219
|
+
})];
|
|
11220
|
+
case 1:
|
|
11221
|
+
_d.sent();
|
|
11222
|
+
if (!(this._banSet === BAN_NEED_FETCH)) return [3 /*break*/, 3];
|
|
11223
|
+
_a = this;
|
|
11224
|
+
_b = Set.bind;
|
|
11225
|
+
return [4 /*yield*/, this.params.getBannedClients(this.params.policyName, swarmName)];
|
|
11226
|
+
case 2:
|
|
11227
|
+
_a._banSet = new (_b.apply(Set, [void 0, _d.sent()]))();
|
|
11228
|
+
_d.label = 3;
|
|
11229
|
+
case 3:
|
|
11230
|
+
if (this._banSet.has(clientId)) {
|
|
11231
|
+
return [2 /*return*/, false];
|
|
11232
|
+
}
|
|
11233
|
+
if (!this.params.validateOutput) {
|
|
11234
|
+
return [2 /*return*/, true];
|
|
11235
|
+
}
|
|
11236
|
+
return [4 /*yield*/, this.params.validateOutput(outgoing, clientId, this.params.policyName, swarmName)];
|
|
11237
|
+
case 4:
|
|
11238
|
+
if (_d.sent()) {
|
|
11239
|
+
return [2 /*return*/, true];
|
|
11240
|
+
}
|
|
11241
|
+
return [4 /*yield*/, this.banClient(clientId, swarmName)];
|
|
11242
|
+
case 5:
|
|
11243
|
+
_d.sent();
|
|
11244
|
+
return [2 /*return*/, false];
|
|
11245
|
+
}
|
|
11246
|
+
});
|
|
11247
|
+
});
|
|
11248
|
+
};
|
|
11249
|
+
/**
|
|
11250
|
+
* Bans a client.
|
|
11251
|
+
* @param {SessionId} clientId - The client ID.
|
|
11252
|
+
* @param {SwarmName} swarmName - The swarm name.
|
|
11253
|
+
* @returns {Promise<void>}
|
|
11254
|
+
*/
|
|
11255
|
+
ClientPolicy.prototype.banClient = function (clientId, swarmName) {
|
|
11256
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11257
|
+
var _a, _b;
|
|
11258
|
+
var _c;
|
|
11259
|
+
return __generator(this, function (_d) {
|
|
11260
|
+
switch (_d.label) {
|
|
11261
|
+
case 0:
|
|
11262
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
11263
|
+
this.params.logger.debug("ClientPolicy policyName=".concat(this.params.policyName, " banClient"), {
|
|
11264
|
+
clientId: clientId,
|
|
11265
|
+
swarmName: swarmName,
|
|
11266
|
+
});
|
|
11267
|
+
if ((_c = this.params.callbacks) === null || _c === void 0 ? void 0 : _c.onBanClient) {
|
|
11268
|
+
this.params.callbacks.onBanClient(clientId, swarmName, this.params.policyName);
|
|
11269
|
+
}
|
|
11270
|
+
return [4 /*yield*/, this.params.bus.emit(clientId, {
|
|
11271
|
+
type: "ban-client",
|
|
11272
|
+
source: "policy-bus",
|
|
11273
|
+
input: {},
|
|
11274
|
+
output: {},
|
|
11275
|
+
context: {
|
|
11276
|
+
policyName: this.params.policyName,
|
|
11277
|
+
swarmName: swarmName,
|
|
11278
|
+
},
|
|
11279
|
+
clientId: clientId,
|
|
11280
|
+
})];
|
|
11281
|
+
case 1:
|
|
11282
|
+
_d.sent();
|
|
11283
|
+
if (!(this._banSet === BAN_NEED_FETCH)) return [3 /*break*/, 3];
|
|
11284
|
+
_a = this;
|
|
11285
|
+
_b = Set.bind;
|
|
11286
|
+
return [4 /*yield*/, this.params.getBannedClients(this.params.policyName, swarmName)];
|
|
11287
|
+
case 2:
|
|
11288
|
+
_a._banSet = new (_b.apply(Set, [void 0, _d.sent()]))();
|
|
11289
|
+
_d.label = 3;
|
|
11290
|
+
case 3:
|
|
11291
|
+
if (this._banSet.has(clientId)) {
|
|
11292
|
+
return [2 /*return*/];
|
|
11293
|
+
}
|
|
11294
|
+
this._banSet = new Set(this._banSet).add(clientId);
|
|
11295
|
+
if (!this.params.setBannedClients) return [3 /*break*/, 5];
|
|
11296
|
+
return [4 /*yield*/, this.params.setBannedClients(__spreadArray([], __read(this._banSet), false), this.params.policyName, swarmName)];
|
|
11297
|
+
case 4:
|
|
11298
|
+
_d.sent();
|
|
11299
|
+
_d.label = 5;
|
|
11300
|
+
case 5: return [2 /*return*/];
|
|
11301
|
+
}
|
|
11302
|
+
});
|
|
11303
|
+
});
|
|
11304
|
+
};
|
|
11305
|
+
/**
|
|
11306
|
+
* Unbans a client.
|
|
11307
|
+
* @param {SessionId} clientId - The client ID.
|
|
11308
|
+
* @param {SwarmName} swarmName - The swarm name.
|
|
11309
|
+
* @returns {Promise<void>}
|
|
11310
|
+
*/
|
|
11311
|
+
ClientPolicy.prototype.unbanClient = function (clientId, swarmName) {
|
|
11312
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11313
|
+
var _a, _b, banSet;
|
|
11314
|
+
var _c;
|
|
11315
|
+
return __generator(this, function (_d) {
|
|
11316
|
+
switch (_d.label) {
|
|
11317
|
+
case 0:
|
|
11318
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
11319
|
+
this.params.logger.debug("ClientPolicy policyName=".concat(this.params.policyName, " unbanClient"), {
|
|
11320
|
+
clientId: clientId,
|
|
11321
|
+
swarmName: swarmName,
|
|
11322
|
+
});
|
|
11323
|
+
if ((_c = this.params.callbacks) === null || _c === void 0 ? void 0 : _c.onUnbanClient) {
|
|
11324
|
+
this.params.callbacks.onUnbanClient(clientId, swarmName, this.params.policyName);
|
|
11325
|
+
}
|
|
11326
|
+
return [4 /*yield*/, this.params.bus.emit(clientId, {
|
|
11327
|
+
type: "unban-client",
|
|
11328
|
+
source: "policy-bus",
|
|
11329
|
+
input: {},
|
|
11330
|
+
output: {},
|
|
11331
|
+
context: {
|
|
11332
|
+
policyName: this.params.policyName,
|
|
11333
|
+
swarmName: swarmName,
|
|
11334
|
+
},
|
|
11335
|
+
clientId: clientId,
|
|
11336
|
+
})];
|
|
11337
|
+
case 1:
|
|
11338
|
+
_d.sent();
|
|
11339
|
+
if (!(this._banSet === BAN_NEED_FETCH)) return [3 /*break*/, 3];
|
|
11340
|
+
_a = this;
|
|
11341
|
+
_b = Set.bind;
|
|
11342
|
+
return [4 /*yield*/, this.params.getBannedClients(this.params.policyName, swarmName)];
|
|
11343
|
+
case 2:
|
|
11344
|
+
_a._banSet = new (_b.apply(Set, [void 0, _d.sent()]))();
|
|
11345
|
+
_d.label = 3;
|
|
11346
|
+
case 3:
|
|
11347
|
+
if (!this._banSet.has(clientId)) {
|
|
11348
|
+
return [2 /*return*/];
|
|
11349
|
+
}
|
|
11350
|
+
{
|
|
11351
|
+
banSet = new Set(this._banSet);
|
|
11352
|
+
banSet.delete(clientId);
|
|
11353
|
+
this._banSet = banSet;
|
|
11354
|
+
}
|
|
11355
|
+
if (!this.params.setBannedClients) return [3 /*break*/, 5];
|
|
11356
|
+
return [4 /*yield*/, this.params.setBannedClients(__spreadArray([], __read(this._banSet), false), this.params.policyName, swarmName)];
|
|
11357
|
+
case 4:
|
|
11358
|
+
_d.sent();
|
|
11359
|
+
_d.label = 5;
|
|
11360
|
+
case 5: return [2 /*return*/];
|
|
11361
|
+
}
|
|
11362
|
+
});
|
|
11363
|
+
});
|
|
11364
|
+
};
|
|
11365
|
+
return ClientPolicy;
|
|
11366
|
+
}());
|
|
11367
|
+
|
|
11368
|
+
/**
|
|
11369
|
+
* Service for managing policy connections.
|
|
11370
|
+
* @implements {IPolicy}
|
|
11371
|
+
*/
|
|
11372
|
+
var PolicyConnectionService = /** @class */ (function () {
|
|
11373
|
+
function PolicyConnectionService() {
|
|
11374
|
+
var _this = this;
|
|
11375
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
11376
|
+
this.busService = inject(TYPES.busService);
|
|
11377
|
+
this.methodContextService = inject(TYPES.methodContextService);
|
|
11378
|
+
this.policySchemaService = inject(TYPES.policySchemaService);
|
|
11379
|
+
/**
|
|
11380
|
+
* Retrieves a policy based on the policy name.
|
|
11381
|
+
* @param {PolicyName} policyName - The name of the policy.
|
|
11382
|
+
* @returns {ClientPolicy} The client policy.
|
|
11383
|
+
*/
|
|
11384
|
+
this.getPolicy = functoolsKit.memoize(function (_a) {
|
|
11385
|
+
var _b = __read(_a, 1), policyName = _b[0];
|
|
11386
|
+
return "".concat(policyName);
|
|
11387
|
+
}, function (policyName) {
|
|
11388
|
+
var schema = _this.policySchemaService.get(policyName);
|
|
11389
|
+
return new ClientPolicy(__assign({ policyName: policyName, bus: _this.busService, logger: _this.loggerService }, schema));
|
|
11390
|
+
});
|
|
11391
|
+
/**
|
|
11392
|
+
* Retrieves the ban message for a client in a swarm.
|
|
11393
|
+
* @param {SessionId} clientId - The ID of the client.
|
|
11394
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
11395
|
+
* @returns {Promise<string>} The ban message.
|
|
11396
|
+
*/
|
|
11397
|
+
this.getBanMessage = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
11398
|
+
return __generator(this, function (_a) {
|
|
11399
|
+
switch (_a.label) {
|
|
11400
|
+
case 0:
|
|
11401
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
11402
|
+
this.loggerService.info("policyConnectionService getBanMessage", {
|
|
11403
|
+
clientId: clientId,
|
|
11404
|
+
swarmName: swarmName,
|
|
11405
|
+
});
|
|
11406
|
+
return [4 /*yield*/, this.getPolicy(this.methodContextService.context.policyName).getBanMessage(clientId, swarmName)];
|
|
11407
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
11408
|
+
}
|
|
11409
|
+
});
|
|
11410
|
+
}); };
|
|
11411
|
+
/**
|
|
11412
|
+
* Validates the input for a client in a swarm.
|
|
11413
|
+
* @param {string} incoming - The incoming input.
|
|
11414
|
+
* @param {SessionId} clientId - The ID of the client.
|
|
11415
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
11416
|
+
* @returns {Promise<boolean>} Whether the input is valid.
|
|
11417
|
+
*/
|
|
11418
|
+
this.validateInput = function (incoming, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
11419
|
+
return __generator(this, function (_a) {
|
|
11420
|
+
switch (_a.label) {
|
|
11421
|
+
case 0:
|
|
11422
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
11423
|
+
this.loggerService.info("policyConnectionService validateInput", {
|
|
11424
|
+
incoming: incoming,
|
|
11425
|
+
clientId: clientId,
|
|
11426
|
+
swarmName: swarmName,
|
|
11427
|
+
});
|
|
11428
|
+
return [4 /*yield*/, this.getPolicy(this.methodContextService.context.policyName).validateInput(incoming, clientId, swarmName)];
|
|
11429
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
11430
|
+
}
|
|
11431
|
+
});
|
|
11432
|
+
}); };
|
|
11433
|
+
/**
|
|
11434
|
+
* Validates the output for a client in a swarm.
|
|
11435
|
+
* @param {string} outgoing - The outgoing output.
|
|
11436
|
+
* @param {SessionId} clientId - The ID of the client.
|
|
11437
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
11438
|
+
* @returns {Promise<boolean>} Whether the output is valid.
|
|
11439
|
+
*/
|
|
11440
|
+
this.validateOutput = function (outgoing, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
11441
|
+
return __generator(this, function (_a) {
|
|
11442
|
+
switch (_a.label) {
|
|
11443
|
+
case 0:
|
|
11444
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
11445
|
+
this.loggerService.info("policyConnectionService validateOutput", {
|
|
11446
|
+
outgoing: outgoing,
|
|
11447
|
+
clientId: clientId,
|
|
11448
|
+
swarmName: swarmName,
|
|
11449
|
+
});
|
|
11450
|
+
return [4 /*yield*/, this.getPolicy(this.methodContextService.context.policyName).validateOutput(outgoing, clientId, swarmName)];
|
|
11451
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
11452
|
+
}
|
|
11453
|
+
});
|
|
11454
|
+
}); };
|
|
11455
|
+
/**
|
|
11456
|
+
* Bans a client from a swarm.
|
|
11457
|
+
* @param {SessionId} clientId - The ID of the client.
|
|
11458
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
11459
|
+
* @returns {Promise<void>}
|
|
11460
|
+
*/
|
|
11461
|
+
this.banClient = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
11462
|
+
return __generator(this, function (_a) {
|
|
11463
|
+
switch (_a.label) {
|
|
11464
|
+
case 0:
|
|
11465
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
11466
|
+
this.loggerService.info("policyConnectionService banClient", {
|
|
11467
|
+
clientId: clientId,
|
|
11468
|
+
swarmName: swarmName,
|
|
11469
|
+
});
|
|
11470
|
+
return [4 /*yield*/, this.getPolicy(this.methodContextService.context.policyName).banClient(clientId, swarmName)];
|
|
11471
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
11472
|
+
}
|
|
11473
|
+
});
|
|
11474
|
+
}); };
|
|
11475
|
+
/**
|
|
11476
|
+
* Unbans a client from a swarm.
|
|
11477
|
+
* @param {SessionId} clientId - The ID of the client.
|
|
11478
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
11479
|
+
* @returns {Promise<void>}
|
|
11480
|
+
*/
|
|
11481
|
+
this.unbanClient = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
11482
|
+
return __generator(this, function (_a) {
|
|
11483
|
+
switch (_a.label) {
|
|
11484
|
+
case 0:
|
|
11485
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
11486
|
+
this.loggerService.info("policyConnectionService unbanClient", {
|
|
11487
|
+
clientId: clientId,
|
|
11488
|
+
swarmName: swarmName,
|
|
11489
|
+
});
|
|
11490
|
+
return [4 /*yield*/, this.getPolicy(this.methodContextService.context.policyName).unbanClient(clientId, swarmName)];
|
|
11491
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
11492
|
+
}
|
|
11493
|
+
});
|
|
11494
|
+
}); };
|
|
11495
|
+
}
|
|
11496
|
+
return PolicyConnectionService;
|
|
11497
|
+
}());
|
|
11498
|
+
|
|
11499
|
+
{
|
|
11500
|
+
provide(TYPES.docService, function () { return new DocService(); });
|
|
11501
|
+
provide(TYPES.busService, function () { return new BusService(); });
|
|
11502
|
+
provide(TYPES.perfService, function () { return new PerfService(); });
|
|
11503
|
+
provide(TYPES.loggerService, function () { return new LoggerService(); });
|
|
11504
|
+
}
|
|
11505
|
+
{
|
|
11506
|
+
provide(TYPES.methodContextService, function () { return new MethodContextService(); });
|
|
11507
|
+
provide(TYPES.executionContextService, function () { return new ExecutionContextService(); });
|
|
11508
|
+
}
|
|
11509
|
+
{
|
|
11510
|
+
provide(TYPES.agentConnectionService, function () { return new AgentConnectionService(); });
|
|
11511
|
+
provide(TYPES.historyConnectionService, function () { return new HistoryConnectionService(); });
|
|
11512
|
+
provide(TYPES.swarmConnectionService, function () { return new SwarmConnectionService(); });
|
|
11513
|
+
provide(TYPES.sessionConnectionService, function () { return new SessionConnectionService(); });
|
|
11514
|
+
provide(TYPES.storageConnectionService, function () { return new StorageConnectionService(); });
|
|
11515
|
+
provide(TYPES.sharedStorageConnectionService, function () { return new SharedStorageConnectionService(); });
|
|
11516
|
+
provide(TYPES.stateConnectionService, function () { return new StateConnectionService(); });
|
|
11517
|
+
provide(TYPES.sharedStateConnectionService, function () { return new SharedStateConnectionService(); });
|
|
11518
|
+
provide(TYPES.policyConnectionService, function () { return new PolicyConnectionService(); });
|
|
11519
|
+
}
|
|
11520
|
+
{
|
|
11521
|
+
provide(TYPES.agentSchemaService, function () { return new AgentSchemaService(); });
|
|
11522
|
+
provide(TYPES.toolSchemaService, function () { return new ToolSchemaService(); });
|
|
11523
|
+
provide(TYPES.swarmSchemaService, function () { return new SwarmSchemaService(); });
|
|
11524
|
+
provide(TYPES.completionSchemaService, function () { return new CompletionSchemaService(); });
|
|
11525
|
+
provide(TYPES.embeddingSchemaService, function () { return new EmbeddingSchemaService(); });
|
|
11526
|
+
provide(TYPES.storageSchemaService, function () { return new StorageSchemaService(); });
|
|
11527
|
+
provide(TYPES.stateSchemaService, function () { return new StateSchemaService(); });
|
|
11528
|
+
provide(TYPES.memorySchemaService, function () { return new MemorySchemaService(); });
|
|
11529
|
+
provide(TYPES.policySchemaService, function () { return new PolicySchemaService(); });
|
|
11530
|
+
}
|
|
11531
|
+
{
|
|
11532
|
+
provide(TYPES.agentPublicService, function () { return new AgentPublicService(); });
|
|
11533
|
+
provide(TYPES.historyPublicService, function () { return new HistoryPublicService(); });
|
|
11534
|
+
provide(TYPES.sessionPublicService, function () { return new SessionPublicService(); });
|
|
11535
|
+
provide(TYPES.swarmPublicService, function () { return new SwarmPublicService(); });
|
|
11536
|
+
provide(TYPES.storagePublicService, function () { return new StoragePublicService(); });
|
|
11537
|
+
provide(TYPES.sharedStoragePublicService, function () { return new SharedStoragePublicService(); });
|
|
11538
|
+
provide(TYPES.statePublicService, function () { return new StatePublicService(); });
|
|
11539
|
+
provide(TYPES.sharedStatePublicService, function () { return new SharedStatePublicService(); });
|
|
11540
|
+
provide(TYPES.policyPublicService, function () { return new PolicyPublicService(); });
|
|
11541
|
+
}
|
|
11542
|
+
{
|
|
11543
|
+
provide(TYPES.swarmMetaService, function () { return new SwarmMetaService(); });
|
|
11544
|
+
provide(TYPES.agentMetaService, function () { return new AgentMetaService(); });
|
|
11545
|
+
}
|
|
11546
|
+
{
|
|
11547
|
+
provide(TYPES.agentValidationService, function () { return new AgentValidationService(); });
|
|
11548
|
+
provide(TYPES.completionValidationService, function () { return new CompletionValidationService(); });
|
|
11549
|
+
provide(TYPES.sessionValidationService, function () { return new SessionValidationService(); });
|
|
11550
|
+
provide(TYPES.swarmValidationService, function () { return new SwarmValidationService(); });
|
|
11551
|
+
provide(TYPES.toolValidationService, function () { return new ToolValidationService(); });
|
|
11552
|
+
provide(TYPES.storageValidationService, function () { return new StorageValidationService(); });
|
|
11553
|
+
provide(TYPES.embeddingValidationService, function () { return new EmbeddingValidationService(); });
|
|
11554
|
+
provide(TYPES.policyValidationService, function () { return new PolicyValidationService(); });
|
|
11555
|
+
}
|
|
11556
|
+
|
|
11557
|
+
var baseServices = {
|
|
11558
|
+
docService: inject(TYPES.docService),
|
|
11559
|
+
busService: inject(TYPES.busService),
|
|
11560
|
+
perfService: inject(TYPES.perfService),
|
|
11561
|
+
loggerService: inject(TYPES.loggerService),
|
|
11562
|
+
};
|
|
11563
|
+
var contextServices = {
|
|
11564
|
+
methodContextService: inject(TYPES.methodContextService),
|
|
10301
11565
|
executionContextService: inject(TYPES.executionContextService),
|
|
10302
11566
|
};
|
|
10303
11567
|
var connectionServices = {
|
|
@@ -10309,6 +11573,7 @@ var connectionServices = {
|
|
|
10309
11573
|
sharedStorageConnectionService: inject(TYPES.sharedStorageConnectionService),
|
|
10310
11574
|
stateConnectionService: inject(TYPES.stateConnectionService),
|
|
10311
11575
|
sharedStateConnectionService: inject(TYPES.sharedStateConnectionService),
|
|
11576
|
+
policyConnectionService: inject(TYPES.policyConnectionService),
|
|
10312
11577
|
};
|
|
10313
11578
|
var schemaServices = {
|
|
10314
11579
|
agentSchemaService: inject(TYPES.agentSchemaService),
|
|
@@ -10319,6 +11584,7 @@ var schemaServices = {
|
|
|
10319
11584
|
storageSchemaService: inject(TYPES.storageSchemaService),
|
|
10320
11585
|
stateSchemaService: inject(TYPES.stateSchemaService),
|
|
10321
11586
|
memorySchemaService: inject(TYPES.memorySchemaService),
|
|
11587
|
+
policySchemaService: inject(TYPES.policySchemaService),
|
|
10322
11588
|
};
|
|
10323
11589
|
var publicServices = {
|
|
10324
11590
|
agentPublicService: inject(TYPES.agentPublicService),
|
|
@@ -10329,6 +11595,7 @@ var publicServices = {
|
|
|
10329
11595
|
sharedStoragePublicService: inject(TYPES.sharedStoragePublicService),
|
|
10330
11596
|
statePublicService: inject(TYPES.statePublicService),
|
|
10331
11597
|
sharedStatePublicService: inject(TYPES.sharedStatePublicService),
|
|
11598
|
+
policyPublicService: inject(TYPES.policyPublicService),
|
|
10332
11599
|
};
|
|
10333
11600
|
var metaServices = {
|
|
10334
11601
|
agentMetaService: inject(TYPES.agentMetaService),
|
|
@@ -10342,12 +11609,13 @@ var validationServices = {
|
|
|
10342
11609
|
completionValidationService: inject(TYPES.completionValidationService),
|
|
10343
11610
|
storageValidationService: inject(TYPES.storageValidationService),
|
|
10344
11611
|
embeddingValidationService: inject(TYPES.embeddingValidationService),
|
|
11612
|
+
policyValidationService: inject(TYPES.policyValidationService),
|
|
10345
11613
|
};
|
|
10346
11614
|
var swarm = __assign(__assign(__assign(__assign(__assign(__assign(__assign({}, baseServices), contextServices), connectionServices), schemaServices), publicServices), metaServices), validationServices);
|
|
10347
11615
|
init();
|
|
10348
11616
|
var swarm$1 = swarm;
|
|
10349
11617
|
|
|
10350
|
-
var METHOD_NAME$
|
|
11618
|
+
var METHOD_NAME$R = "cli.dumpDocs";
|
|
10351
11619
|
/**
|
|
10352
11620
|
* Dumps the documentation for the agents and swarms.
|
|
10353
11621
|
*
|
|
@@ -10355,10 +11623,10 @@ var METHOD_NAME$Q = "cli.dumpDocs";
|
|
|
10355
11623
|
* @param {function} [PlantUML] - An optional function to process PlantUML diagrams.
|
|
10356
11624
|
* @returns {Promise<void>} - A promise that resolves when the documentation has been dumped.
|
|
10357
11625
|
*/
|
|
10358
|
-
var dumpDocs = function (dirName, PlantUML) {
|
|
11626
|
+
var dumpDocs = beginContext(function (dirName, PlantUML) {
|
|
10359
11627
|
if (dirName === void 0) { dirName = "./docs/chat"; }
|
|
10360
11628
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
10361
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
11629
|
+
swarm$1.loggerService.log(METHOD_NAME$R, {
|
|
10362
11630
|
dirName: dirName,
|
|
10363
11631
|
});
|
|
10364
11632
|
if (PlantUML) {
|
|
@@ -10369,12 +11637,12 @@ var dumpDocs = function (dirName, PlantUML) {
|
|
|
10369
11637
|
swarm$1.agentValidationService
|
|
10370
11638
|
.getAgentList()
|
|
10371
11639
|
.forEach(function (agentName) {
|
|
10372
|
-
return swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
11640
|
+
return swarm$1.agentValidationService.validate(agentName, METHOD_NAME$R);
|
|
10373
11641
|
});
|
|
10374
11642
|
swarm$1.swarmValidationService
|
|
10375
11643
|
.getSwarmList()
|
|
10376
11644
|
.forEach(function (swarmName) {
|
|
10377
|
-
return swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
11645
|
+
return swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$R);
|
|
10378
11646
|
});
|
|
10379
11647
|
swarm$1.agentValidationService.getAgentList().forEach(function (agentName) {
|
|
10380
11648
|
var dependsOn = swarm$1.agentSchemaService.get(agentName).dependsOn;
|
|
@@ -10383,48 +11651,48 @@ var dumpDocs = function (dirName, PlantUML) {
|
|
|
10383
11651
|
}
|
|
10384
11652
|
});
|
|
10385
11653
|
return swarm$1.docService.dumpDocs(dirName);
|
|
10386
|
-
};
|
|
11654
|
+
});
|
|
10387
11655
|
|
|
10388
|
-
var METHOD_NAME$
|
|
11656
|
+
var METHOD_NAME$Q = "cli.dumpAgent";
|
|
10389
11657
|
/**
|
|
10390
11658
|
* Dumps the agent information into PlantUML format.
|
|
10391
11659
|
*
|
|
10392
11660
|
* @param {SwarmName} swarmName - The name of the swarm to be dumped.
|
|
10393
11661
|
* @returns {string} The UML representation of the swarm.
|
|
10394
11662
|
*/
|
|
10395
|
-
var dumpAgent = function (agentName, _a) {
|
|
11663
|
+
var dumpAgent = beginContext(function (agentName, _a) {
|
|
10396
11664
|
var _b = _a === void 0 ? {} : _a, _c = _b.withSubtree, withSubtree = _c === void 0 ? false : _c;
|
|
10397
11665
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
10398
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
11666
|
+
swarm$1.loggerService.log(METHOD_NAME$Q, {
|
|
10399
11667
|
agentName: agentName,
|
|
10400
11668
|
});
|
|
10401
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
11669
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$Q);
|
|
10402
11670
|
return swarm$1.agentMetaService.toUML(agentName, withSubtree);
|
|
10403
|
-
};
|
|
11671
|
+
});
|
|
10404
11672
|
|
|
10405
|
-
var METHOD_NAME$
|
|
11673
|
+
var METHOD_NAME$P = "cli.dumpSwarm";
|
|
10406
11674
|
/**
|
|
10407
11675
|
* Dumps the swarm information into PlantUML format.
|
|
10408
11676
|
*
|
|
10409
11677
|
* @param {SwarmName} swarmName - The name of the swarm to be dumped.
|
|
10410
11678
|
* @returns {string} The UML representation of the swarm.
|
|
10411
11679
|
*/
|
|
10412
|
-
var dumpSwarm = function (swarmName) {
|
|
11680
|
+
var dumpSwarm = beginContext(function (swarmName) {
|
|
10413
11681
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
10414
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
11682
|
+
swarm$1.loggerService.log(METHOD_NAME$P, {
|
|
10415
11683
|
swarmName: swarmName,
|
|
10416
11684
|
});
|
|
10417
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
11685
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$P);
|
|
10418
11686
|
return swarm$1.swarmMetaService.toUML(swarmName);
|
|
10419
|
-
};
|
|
11687
|
+
});
|
|
10420
11688
|
|
|
10421
|
-
var METHOD_NAME$
|
|
11689
|
+
var METHOD_NAME$O = "cli.dumpPerfomance";
|
|
10422
11690
|
var METHOD_NAME_INTERNAL$1 = "cli.dumpPerfomance.internal";
|
|
10423
11691
|
var METHOD_NAME_INTERVAL = "cli.dumpPerfomance.interval";
|
|
10424
11692
|
/**
|
|
10425
11693
|
* The internal HOF for handling the performance dump
|
|
10426
11694
|
*/
|
|
10427
|
-
var dumpPerfomanceInternal =
|
|
11695
|
+
var dumpPerfomanceInternal = beginContext(function () {
|
|
10428
11696
|
var args_1 = [];
|
|
10429
11697
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
10430
11698
|
args_1[_i] = arguments[_i];
|
|
@@ -10441,12 +11709,6 @@ var dumpPerfomanceInternal = functoolsKit.trycatch(function () {
|
|
|
10441
11709
|
}
|
|
10442
11710
|
});
|
|
10443
11711
|
});
|
|
10444
|
-
}, {
|
|
10445
|
-
fallback: function (error) {
|
|
10446
|
-
swarm$1.loggerService.log("agent-swarm dumpPerfomanceInternal exception error=".concat(functoolsKit.getErrorMessage(error)), {
|
|
10447
|
-
errorData: functoolsKit.errorData(error),
|
|
10448
|
-
});
|
|
10449
|
-
},
|
|
10450
11712
|
});
|
|
10451
11713
|
/**
|
|
10452
11714
|
* Dumps the performance data using the swarm's document service.
|
|
@@ -10465,7 +11727,7 @@ var dumpPerfomance = function () {
|
|
|
10465
11727
|
return __generator(this, function (_a) {
|
|
10466
11728
|
switch (_a.label) {
|
|
10467
11729
|
case 0:
|
|
10468
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$
|
|
11730
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$O);
|
|
10469
11731
|
return [4 /*yield*/, dumpPerfomanceInternal(dirName)];
|
|
10470
11732
|
case 1:
|
|
10471
11733
|
_a.sent();
|
|
@@ -10481,15 +11743,15 @@ var dumpPerfomance = function () {
|
|
|
10481
11743
|
* @param {string} [dirName="./logs/meta"] - The directory name where the performance data will be dumped.
|
|
10482
11744
|
* @param {number} [interval=30000] - The interval in milliseconds at which to run the dumpPerfomance function.
|
|
10483
11745
|
*/
|
|
10484
|
-
dumpPerfomance.runInterval = function (dirName, interval) {
|
|
11746
|
+
dumpPerfomance.runInterval = beginContext(function (dirName, interval) {
|
|
10485
11747
|
if (dirName === void 0) { dirName = "./logs/meta"; }
|
|
10486
11748
|
if (interval === void 0) { interval = 30000; }
|
|
10487
11749
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
10488
11750
|
swarm$1.loggerService.log(METHOD_NAME_INTERVAL);
|
|
10489
11751
|
return functoolsKit.Source.fromInterval(interval).connect(function () { return dumpPerfomance(dirName); });
|
|
10490
|
-
};
|
|
11752
|
+
});
|
|
10491
11753
|
|
|
10492
|
-
var validateClientId$
|
|
11754
|
+
var validateClientId$h = function (clientId) {
|
|
10493
11755
|
if (clientId === "*") {
|
|
10494
11756
|
return;
|
|
10495
11757
|
}
|
|
@@ -10503,20 +11765,20 @@ var validateClientId$f = function (clientId) {
|
|
|
10503
11765
|
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
10504
11766
|
* @param {function} fn - The callback function to handle the event.
|
|
10505
11767
|
*/
|
|
10506
|
-
var listenExecutionEvent = function (clientId, fn) {
|
|
11768
|
+
var listenExecutionEvent = beginContext(function (clientId, fn) {
|
|
10507
11769
|
swarm$1.loggerService.log("middleware listenExecutionEvent", {
|
|
10508
11770
|
clientId: clientId,
|
|
10509
11771
|
});
|
|
10510
|
-
validateClientId$
|
|
11772
|
+
validateClientId$h(clientId);
|
|
10511
11773
|
return swarm$1.busService.subscribe(clientId, "execution-bus", functoolsKit.queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
10512
11774
|
switch (_a.label) {
|
|
10513
11775
|
case 0: return [4 /*yield*/, fn(e)];
|
|
10514
11776
|
case 1: return [2 /*return*/, _a.sent()];
|
|
10515
11777
|
}
|
|
10516
11778
|
}); }); }));
|
|
10517
|
-
};
|
|
11779
|
+
});
|
|
10518
11780
|
|
|
10519
|
-
var METHOD_NAME$
|
|
11781
|
+
var METHOD_NAME$N = "cli.dumpClientPerformance";
|
|
10520
11782
|
var METHOD_NAME_INTERNAL = "cli.dumpClientPerformance.internal";
|
|
10521
11783
|
var METHOD_NAME_EXECUTE = "cli.dumpClientPerformance.execute";
|
|
10522
11784
|
/**
|
|
@@ -10526,7 +11788,7 @@ var METHOD_NAME_EXECUTE = "cli.dumpClientPerformance.execute";
|
|
|
10526
11788
|
* @param {string} [dirName="./logs/client"] - The directory name where the performance data will be dumped.
|
|
10527
11789
|
* @returns {Promise<void>} A promise that resolves when the performance data has been dumped.
|
|
10528
11790
|
*/
|
|
10529
|
-
var dumpClientPerformanceInternal =
|
|
11791
|
+
var dumpClientPerformanceInternal = beginContext(function (clientId_1) {
|
|
10530
11792
|
var args_1 = [];
|
|
10531
11793
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
10532
11794
|
args_1[_i - 1] = arguments[_i];
|
|
@@ -10543,12 +11805,6 @@ var dumpClientPerformanceInternal = functoolsKit.trycatch(function (clientId_1)
|
|
|
10543
11805
|
}
|
|
10544
11806
|
});
|
|
10545
11807
|
});
|
|
10546
|
-
}, {
|
|
10547
|
-
fallback: function (error) {
|
|
10548
|
-
swarm$1.loggerService.log("agent-swarm dumpClientPerformanceInternal exception error=".concat(functoolsKit.getErrorMessage(error)), {
|
|
10549
|
-
errorData: functoolsKit.errorData(error),
|
|
10550
|
-
});
|
|
10551
|
-
},
|
|
10552
11808
|
});
|
|
10553
11809
|
/**
|
|
10554
11810
|
* Dumps the performance data using the swarm's document service.
|
|
@@ -10568,7 +11824,7 @@ var dumpClientPerformance = function (clientId_1) {
|
|
|
10568
11824
|
return __generator(this, function (_a) {
|
|
10569
11825
|
switch (_a.label) {
|
|
10570
11826
|
case 0:
|
|
10571
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$
|
|
11827
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$N);
|
|
10572
11828
|
return [4 /*yield*/, dumpClientPerformanceInternal(clientId, dirName)];
|
|
10573
11829
|
case 1:
|
|
10574
11830
|
_a.sent();
|
|
@@ -10584,7 +11840,7 @@ var dumpClientPerformance = function (clientId_1) {
|
|
|
10584
11840
|
* @param {string} [dirName="./logs/client"] - The directory name where the performance data will be dumped.
|
|
10585
11841
|
* @returns {Promise<void>} A promise that resolves when the listener has been set up.
|
|
10586
11842
|
*/
|
|
10587
|
-
dumpClientPerformance.runAfterExecute = function () {
|
|
11843
|
+
dumpClientPerformance.runAfterExecute = beginContext(function () {
|
|
10588
11844
|
var args_1 = [];
|
|
10589
11845
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
10590
11846
|
args_1[_i] = arguments[_i];
|
|
@@ -10610,26 +11866,26 @@ dumpClientPerformance.runAfterExecute = function () {
|
|
|
10610
11866
|
}); })];
|
|
10611
11867
|
});
|
|
10612
11868
|
});
|
|
10613
|
-
};
|
|
11869
|
+
});
|
|
10614
11870
|
|
|
10615
|
-
var METHOD_NAME$
|
|
11871
|
+
var METHOD_NAME$M = "function.setup.addAgent";
|
|
10616
11872
|
/**
|
|
10617
11873
|
* Adds a new agent to the agent registry. The swarm takes only those agents which was registered
|
|
10618
11874
|
*
|
|
10619
11875
|
* @param {IAgentSchema} agentSchema - The schema of the agent to be added.
|
|
10620
11876
|
* @returns {string} The name of the added agent.
|
|
10621
11877
|
*/
|
|
10622
|
-
var addAgent = function (agentSchema) {
|
|
11878
|
+
var addAgent = beginContext(function (agentSchema) {
|
|
10623
11879
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
10624
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
11880
|
+
swarm$1.loggerService.log(METHOD_NAME$M, {
|
|
10625
11881
|
agentSchema: agentSchema,
|
|
10626
11882
|
});
|
|
10627
11883
|
swarm$1.agentValidationService.addAgent(agentSchema.agentName, agentSchema);
|
|
10628
11884
|
swarm$1.agentSchemaService.register(agentSchema.agentName, agentSchema);
|
|
10629
11885
|
return agentSchema.agentName;
|
|
10630
|
-
};
|
|
11886
|
+
});
|
|
10631
11887
|
|
|
10632
|
-
var METHOD_NAME$
|
|
11888
|
+
var METHOD_NAME$L = "function.setup.addCompletion";
|
|
10633
11889
|
/**
|
|
10634
11890
|
* Adds a completion engine for agents. Agents could use different models and
|
|
10635
11891
|
* framewords for completion like: mock, gpt4all, ollama, openai
|
|
@@ -10637,34 +11893,34 @@ var METHOD_NAME$K = "function.setup.addCompletion";
|
|
|
10637
11893
|
* @param {ICompletionSchema} completionSchema - The completion schema to be added.
|
|
10638
11894
|
* @returns {string} The name of the completion that was added.
|
|
10639
11895
|
*/
|
|
10640
|
-
var addCompletion = function (completionSchema) {
|
|
11896
|
+
var addCompletion = beginContext(function (completionSchema) {
|
|
10641
11897
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
10642
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
11898
|
+
swarm$1.loggerService.log(METHOD_NAME$L, {
|
|
10643
11899
|
completionSchema: completionSchema,
|
|
10644
11900
|
});
|
|
10645
11901
|
swarm$1.completionValidationService.addCompletion(completionSchema.completionName);
|
|
10646
11902
|
swarm$1.completionSchemaService.register(completionSchema.completionName, completionSchema);
|
|
10647
11903
|
return completionSchema.completionName;
|
|
10648
|
-
};
|
|
11904
|
+
});
|
|
10649
11905
|
|
|
10650
|
-
var METHOD_NAME$
|
|
11906
|
+
var METHOD_NAME$K = "function.setup.addSwarm";
|
|
10651
11907
|
/**
|
|
10652
11908
|
* Adds a new swarm to the system. The swarm is a root for starting client session
|
|
10653
11909
|
*
|
|
10654
11910
|
* @param {ISwarmSchema} swarmSchema - The schema of the swarm to be added.
|
|
10655
11911
|
* @returns {string} The name of the added swarm.
|
|
10656
11912
|
*/
|
|
10657
|
-
var addSwarm = function (swarmSchema) {
|
|
11913
|
+
var addSwarm = beginContext(function (swarmSchema) {
|
|
10658
11914
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
10659
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
11915
|
+
swarm$1.loggerService.log(METHOD_NAME$K, {
|
|
10660
11916
|
swarmSchema: swarmSchema,
|
|
10661
11917
|
});
|
|
10662
11918
|
swarm$1.swarmValidationService.addSwarm(swarmSchema.swarmName, swarmSchema);
|
|
10663
11919
|
swarm$1.swarmSchemaService.register(swarmSchema.swarmName, swarmSchema);
|
|
10664
11920
|
return swarmSchema.swarmName;
|
|
10665
|
-
};
|
|
11921
|
+
});
|
|
10666
11922
|
|
|
10667
|
-
var METHOD_NAME$
|
|
11923
|
+
var METHOD_NAME$J = "function.setup.addTool";
|
|
10668
11924
|
/**
|
|
10669
11925
|
* Adds a new tool for agents in a swarm. Tool should be registered in `addAgent`
|
|
10670
11926
|
* declaration
|
|
@@ -10672,26 +11928,26 @@ var METHOD_NAME$I = "function.setup.addTool";
|
|
|
10672
11928
|
* @param {IAgentTool} toolSchema - The schema of the tool to be added.
|
|
10673
11929
|
* @returns {string} The name of the tool that was added.
|
|
10674
11930
|
*/
|
|
10675
|
-
var addTool = function (toolSchema) {
|
|
11931
|
+
var addTool = beginContext(function (toolSchema) {
|
|
10676
11932
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
10677
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
11933
|
+
swarm$1.loggerService.log(METHOD_NAME$J, {
|
|
10678
11934
|
toolSchema: toolSchema,
|
|
10679
11935
|
});
|
|
10680
11936
|
swarm$1.toolValidationService.addTool(toolSchema.toolName, toolSchema);
|
|
10681
11937
|
swarm$1.toolSchemaService.register(toolSchema.toolName, toolSchema);
|
|
10682
11938
|
return toolSchema.toolName;
|
|
10683
|
-
};
|
|
11939
|
+
});
|
|
10684
11940
|
|
|
10685
|
-
var METHOD_NAME$
|
|
11941
|
+
var METHOD_NAME$I = "function.setup.addState";
|
|
10686
11942
|
/**
|
|
10687
11943
|
* Adds a new state to the state registry. The swarm takes only those states which was registered
|
|
10688
11944
|
*
|
|
10689
11945
|
* @param {IStateSchema} stateSchema - The schema of the state to be added.
|
|
10690
11946
|
* @returns {string} The name of the added state.
|
|
10691
11947
|
*/
|
|
10692
|
-
var addState = function (stateSchema) {
|
|
11948
|
+
var addState = beginContext(function (stateSchema) {
|
|
10693
11949
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
10694
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
11950
|
+
swarm$1.loggerService.log(METHOD_NAME$I, {
|
|
10695
11951
|
stateSchema: stateSchema,
|
|
10696
11952
|
});
|
|
10697
11953
|
swarm$1.stateSchemaService.register(stateSchema.stateName, stateSchema);
|
|
@@ -10701,35 +11957,35 @@ var addState = function (stateSchema) {
|
|
|
10701
11957
|
.waitForInit();
|
|
10702
11958
|
}
|
|
10703
11959
|
return stateSchema.stateName;
|
|
10704
|
-
};
|
|
11960
|
+
});
|
|
10705
11961
|
|
|
10706
|
-
var METHOD_NAME$
|
|
11962
|
+
var METHOD_NAME$H = "function.setup.addEmbedding";
|
|
10707
11963
|
/**
|
|
10708
11964
|
* Adds a new embedding to the embedding registry. The swarm takes only those embeddings which was registered
|
|
10709
11965
|
*
|
|
10710
11966
|
* @param {IEmbeddingSchema} embeddingSchema - The schema of the embedding to be added.
|
|
10711
11967
|
* @returns {string} The name of the added embedding.
|
|
10712
11968
|
*/
|
|
10713
|
-
var addEmbedding = function (embeddingSchema) {
|
|
11969
|
+
var addEmbedding = beginContext(function (embeddingSchema) {
|
|
10714
11970
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
10715
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
11971
|
+
swarm$1.loggerService.log(METHOD_NAME$H, {
|
|
10716
11972
|
embeddingSchema: embeddingSchema,
|
|
10717
11973
|
});
|
|
10718
11974
|
swarm$1.embeddingValidationService.addEmbedding(embeddingSchema.embeddingName, embeddingSchema);
|
|
10719
11975
|
swarm$1.embeddingSchemaService.register(embeddingSchema.embeddingName, embeddingSchema);
|
|
10720
11976
|
return embeddingSchema.embeddingName;
|
|
10721
|
-
};
|
|
11977
|
+
});
|
|
10722
11978
|
|
|
10723
|
-
var METHOD_NAME$
|
|
11979
|
+
var METHOD_NAME$G = "function.setup.addStorage";
|
|
10724
11980
|
/**
|
|
10725
11981
|
* Adds a new storage to the storage registry. The swarm takes only those storages which was registered
|
|
10726
11982
|
*
|
|
10727
11983
|
* @param {IStorageSchema} storageSchema - The schema of the storage to be added.
|
|
10728
11984
|
* @returns {string} The name of the added storage.
|
|
10729
11985
|
*/
|
|
10730
|
-
var addStorage = function (storageSchema) {
|
|
11986
|
+
var addStorage = beginContext(function (storageSchema) {
|
|
10731
11987
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
10732
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
11988
|
+
swarm$1.loggerService.log(METHOD_NAME$G, {
|
|
10733
11989
|
storageSchema: storageSchema,
|
|
10734
11990
|
});
|
|
10735
11991
|
swarm$1.storageValidationService.addStorage(storageSchema.storageName, storageSchema);
|
|
@@ -10740,7 +11996,25 @@ var addStorage = function (storageSchema) {
|
|
|
10740
11996
|
.waitForInit();
|
|
10741
11997
|
}
|
|
10742
11998
|
return storageSchema.storageName;
|
|
10743
|
-
};
|
|
11999
|
+
});
|
|
12000
|
+
|
|
12001
|
+
var METHOD_NAME$F = "function.setup.addPolicy";
|
|
12002
|
+
/**
|
|
12003
|
+
* Adds a new policy for agents in a swarm. Policy should be registered in `addPolicy`
|
|
12004
|
+
* declaration
|
|
12005
|
+
*
|
|
12006
|
+
* @param {IPolicySchema} policySchema - The schema of the policy to be added.
|
|
12007
|
+
* @returns {string} The name of the policy that was added.
|
|
12008
|
+
*/
|
|
12009
|
+
var addPolicy = beginContext(function (policySchema) {
|
|
12010
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
12011
|
+
swarm$1.loggerService.log(METHOD_NAME$F, {
|
|
12012
|
+
policySchema: policySchema,
|
|
12013
|
+
});
|
|
12014
|
+
swarm$1.policyValidationService.addPolicy(policySchema.policyName, policySchema);
|
|
12015
|
+
swarm$1.policySchemaService.register(policySchema.policyName, policySchema);
|
|
12016
|
+
return policySchema.policyName;
|
|
12017
|
+
});
|
|
10744
12018
|
|
|
10745
12019
|
var METHOD_NAME$E = "function.commit.commitToolOutput";
|
|
10746
12020
|
/**
|
|
@@ -10751,7 +12025,7 @@ var METHOD_NAME$E = "function.commit.commitToolOutput";
|
|
|
10751
12025
|
* @param {AgentName} agentName - The name of the agent committing the output.
|
|
10752
12026
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
10753
12027
|
*/
|
|
10754
|
-
var commitToolOutput = function (toolId, content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12028
|
+
var commitToolOutput = beginContext(function (toolId, content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
10755
12029
|
var swarmName, currentAgentName;
|
|
10756
12030
|
return __generator(this, function (_a) {
|
|
10757
12031
|
switch (_a.label) {
|
|
@@ -10786,7 +12060,7 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
|
|
|
10786
12060
|
return [2 /*return*/];
|
|
10787
12061
|
}
|
|
10788
12062
|
});
|
|
10789
|
-
}); };
|
|
12063
|
+
}); });
|
|
10790
12064
|
|
|
10791
12065
|
var METHOD_NAME$D = "function.commit.commitSystemMessage";
|
|
10792
12066
|
/**
|
|
@@ -10797,7 +12071,7 @@ var METHOD_NAME$D = "function.commit.commitSystemMessage";
|
|
|
10797
12071
|
* @param {string} agentName - The name of the agent.
|
|
10798
12072
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
10799
12073
|
*/
|
|
10800
|
-
var commitSystemMessage = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12074
|
+
var commitSystemMessage = beginContext(function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
10801
12075
|
var swarmName, currentAgentName;
|
|
10802
12076
|
return __generator(this, function (_a) {
|
|
10803
12077
|
switch (_a.label) {
|
|
@@ -10830,7 +12104,7 @@ var commitSystemMessage = function (content, clientId, agentName) { return __awa
|
|
|
10830
12104
|
return [2 /*return*/];
|
|
10831
12105
|
}
|
|
10832
12106
|
});
|
|
10833
|
-
}); };
|
|
12107
|
+
}); });
|
|
10834
12108
|
|
|
10835
12109
|
var METHOD_NAME$C = "function.commit.commitFlush";
|
|
10836
12110
|
/**
|
|
@@ -10840,7 +12114,7 @@ var METHOD_NAME$C = "function.commit.commitFlush";
|
|
|
10840
12114
|
* @param {string} agentName - The name of the agent.
|
|
10841
12115
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
10842
12116
|
*/
|
|
10843
|
-
var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12117
|
+
var commitFlush = beginContext(function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
10844
12118
|
var swarmName, currentAgentName;
|
|
10845
12119
|
return __generator(this, function (_a) {
|
|
10846
12120
|
switch (_a.label) {
|
|
@@ -10872,7 +12146,7 @@ var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void
|
|
|
10872
12146
|
return [2 /*return*/];
|
|
10873
12147
|
}
|
|
10874
12148
|
});
|
|
10875
|
-
}); };
|
|
12149
|
+
}); });
|
|
10876
12150
|
|
|
10877
12151
|
var METHOD_NAME$B = "function.commit.commitSystemMessage";
|
|
10878
12152
|
/**
|
|
@@ -10883,7 +12157,7 @@ var METHOD_NAME$B = "function.commit.commitSystemMessage";
|
|
|
10883
12157
|
* @param {string} agentName - The name of the agent.
|
|
10884
12158
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
10885
12159
|
*/
|
|
10886
|
-
var commitUserMessage = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12160
|
+
var commitUserMessage = beginContext(function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
10887
12161
|
var swarmName, currentAgentName;
|
|
10888
12162
|
return __generator(this, function (_a) {
|
|
10889
12163
|
switch (_a.label) {
|
|
@@ -10916,7 +12190,7 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
|
|
|
10916
12190
|
return [2 /*return*/];
|
|
10917
12191
|
}
|
|
10918
12192
|
});
|
|
10919
|
-
}); };
|
|
12193
|
+
}); });
|
|
10920
12194
|
|
|
10921
12195
|
var METHOD_NAME$A = "function.commit.commitToolOutputForce";
|
|
10922
12196
|
/**
|
|
@@ -10926,7 +12200,7 @@ var METHOD_NAME$A = "function.commit.commitToolOutputForce";
|
|
|
10926
12200
|
* @param {string} clientId - The client ID associated with the session.
|
|
10927
12201
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
10928
12202
|
*/
|
|
10929
|
-
var commitToolOutputForce = function (toolId, content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12203
|
+
var commitToolOutputForce = beginContext(function (toolId, content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
10930
12204
|
var swarmName;
|
|
10931
12205
|
return __generator(this, function (_a) {
|
|
10932
12206
|
switch (_a.label) {
|
|
@@ -10946,7 +12220,7 @@ var commitToolOutputForce = function (toolId, content, clientId) { return __awai
|
|
|
10946
12220
|
return [2 /*return*/];
|
|
10947
12221
|
}
|
|
10948
12222
|
});
|
|
10949
|
-
}); };
|
|
12223
|
+
}); });
|
|
10950
12224
|
|
|
10951
12225
|
var METHOD_NAME$z = "function.commit.commitSystemMessageForce";
|
|
10952
12226
|
/**
|
|
@@ -10956,7 +12230,7 @@ var METHOD_NAME$z = "function.commit.commitSystemMessageForce";
|
|
|
10956
12230
|
* @param {string} clientId - The ID of the client.
|
|
10957
12231
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
10958
12232
|
*/
|
|
10959
|
-
var commitSystemMessageForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12233
|
+
var commitSystemMessageForce = beginContext(function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
10960
12234
|
var swarmName;
|
|
10961
12235
|
return __generator(this, function (_a) {
|
|
10962
12236
|
switch (_a.label) {
|
|
@@ -10975,7 +12249,7 @@ var commitSystemMessageForce = function (content, clientId) { return __awaiter(v
|
|
|
10975
12249
|
return [2 /*return*/];
|
|
10976
12250
|
}
|
|
10977
12251
|
});
|
|
10978
|
-
}); };
|
|
12252
|
+
}); });
|
|
10979
12253
|
|
|
10980
12254
|
var METHOD_NAME$y = "function.commit.commitFlushForce";
|
|
10981
12255
|
/**
|
|
@@ -10984,7 +12258,7 @@ var METHOD_NAME$y = "function.commit.commitFlushForce";
|
|
|
10984
12258
|
* @param {string} clientId - The ID of the client.
|
|
10985
12259
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
10986
12260
|
*/
|
|
10987
|
-
var commitFlushForce = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12261
|
+
var commitFlushForce = beginContext(function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
10988
12262
|
var swarmName;
|
|
10989
12263
|
return __generator(this, function (_a) {
|
|
10990
12264
|
switch (_a.label) {
|
|
@@ -11003,7 +12277,7 @@ var commitFlushForce = function (clientId) { return __awaiter(void 0, void 0, vo
|
|
|
11003
12277
|
return [2 /*return*/];
|
|
11004
12278
|
}
|
|
11005
12279
|
});
|
|
11006
|
-
}); };
|
|
12280
|
+
}); });
|
|
11007
12281
|
|
|
11008
12282
|
var METHOD_NAME$x = "function.commit.commitSystemMessage";
|
|
11009
12283
|
/**
|
|
@@ -11013,7 +12287,7 @@ var METHOD_NAME$x = "function.commit.commitSystemMessage";
|
|
|
11013
12287
|
* @param {string} clientId - The ID of the client.
|
|
11014
12288
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
11015
12289
|
*/
|
|
11016
|
-
var commitUserMessageForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12290
|
+
var commitUserMessageForce = beginContext(function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11017
12291
|
var swarmName;
|
|
11018
12292
|
return __generator(this, function (_a) {
|
|
11019
12293
|
switch (_a.label) {
|
|
@@ -11032,7 +12306,7 @@ var commitUserMessageForce = function (content, clientId) { return __awaiter(voi
|
|
|
11032
12306
|
return [2 /*return*/];
|
|
11033
12307
|
}
|
|
11034
12308
|
});
|
|
11035
|
-
}); };
|
|
12309
|
+
}); });
|
|
11036
12310
|
|
|
11037
12311
|
var METHOD_NAME$w = "function.commit.commitAssistantMessage";
|
|
11038
12312
|
/**
|
|
@@ -11043,7 +12317,7 @@ var METHOD_NAME$w = "function.commit.commitAssistantMessage";
|
|
|
11043
12317
|
* @param {string} agentName - The name of the agent.
|
|
11044
12318
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
11045
12319
|
*/
|
|
11046
|
-
var commitAssistantMessage = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12320
|
+
var commitAssistantMessage = beginContext(function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11047
12321
|
var swarmName, currentAgentName;
|
|
11048
12322
|
return __generator(this, function (_a) {
|
|
11049
12323
|
switch (_a.label) {
|
|
@@ -11076,7 +12350,7 @@ var commitAssistantMessage = function (content, clientId, agentName) { return __
|
|
|
11076
12350
|
return [2 /*return*/];
|
|
11077
12351
|
}
|
|
11078
12352
|
});
|
|
11079
|
-
}); };
|
|
12353
|
+
}); });
|
|
11080
12354
|
|
|
11081
12355
|
var METHOD_NAME$v = "function.commit.commitAssistantMessageForce";
|
|
11082
12356
|
/**
|
|
@@ -11086,7 +12360,7 @@ var METHOD_NAME$v = "function.commit.commitAssistantMessageForce";
|
|
|
11086
12360
|
* @param {string} clientId - The ID of the client.
|
|
11087
12361
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
11088
12362
|
*/
|
|
11089
|
-
var commitAssistantMessageForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12363
|
+
var commitAssistantMessageForce = beginContext(function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11090
12364
|
var swarmName;
|
|
11091
12365
|
return __generator(this, function (_a) {
|
|
11092
12366
|
switch (_a.label) {
|
|
@@ -11105,7 +12379,7 @@ var commitAssistantMessageForce = function (content, clientId) { return __awaite
|
|
|
11105
12379
|
return [2 /*return*/];
|
|
11106
12380
|
}
|
|
11107
12381
|
});
|
|
11108
|
-
}); };
|
|
12382
|
+
}); });
|
|
11109
12383
|
|
|
11110
12384
|
var METHOD_NAME$u = "function.commit.cancelOutput";
|
|
11111
12385
|
/**
|
|
@@ -11115,7 +12389,7 @@ var METHOD_NAME$u = "function.commit.cancelOutput";
|
|
|
11115
12389
|
* @param {string} agentName - The name of the agent.
|
|
11116
12390
|
* @returns {Promise<void>} - A promise that resolves when the output is canceled
|
|
11117
12391
|
*/
|
|
11118
|
-
var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12392
|
+
var cancelOutput = beginContext(function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11119
12393
|
var swarmName, currentAgentName;
|
|
11120
12394
|
return __generator(this, function (_a) {
|
|
11121
12395
|
switch (_a.label) {
|
|
@@ -11147,7 +12421,7 @@ var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, voi
|
|
|
11147
12421
|
return [2 /*return*/];
|
|
11148
12422
|
}
|
|
11149
12423
|
});
|
|
11150
|
-
}); };
|
|
12424
|
+
}); });
|
|
11151
12425
|
|
|
11152
12426
|
var METHOD_NAME$t = "function.commit.cancelOutputForce";
|
|
11153
12427
|
/**
|
|
@@ -11157,7 +12431,7 @@ var METHOD_NAME$t = "function.commit.cancelOutputForce";
|
|
|
11157
12431
|
* @param {string} agentName - The name of the agent.
|
|
11158
12432
|
* @returns {Promise<void>} - A promise that resolves when the output is canceled
|
|
11159
12433
|
*/
|
|
11160
|
-
var cancelOutputForce = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12434
|
+
var cancelOutputForce = beginContext(function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11161
12435
|
var swarmName;
|
|
11162
12436
|
return __generator(this, function (_a) {
|
|
11163
12437
|
switch (_a.label) {
|
|
@@ -11175,7 +12449,7 @@ var cancelOutputForce = function (clientId) { return __awaiter(void 0, void 0, v
|
|
|
11175
12449
|
return [2 /*return*/];
|
|
11176
12450
|
}
|
|
11177
12451
|
});
|
|
11178
|
-
}); };
|
|
12452
|
+
}); });
|
|
11179
12453
|
|
|
11180
12454
|
var METHOD_NAME$s = "function.commit.commitStopTools";
|
|
11181
12455
|
/**
|
|
@@ -11185,7 +12459,7 @@ var METHOD_NAME$s = "function.commit.commitStopTools";
|
|
|
11185
12459
|
* @param {string} agentName - The name of the agent.
|
|
11186
12460
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
11187
12461
|
*/
|
|
11188
|
-
var commitStopTools = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12462
|
+
var commitStopTools = beginContext(function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11189
12463
|
var swarmName, currentAgentName;
|
|
11190
12464
|
return __generator(this, function (_a) {
|
|
11191
12465
|
switch (_a.label) {
|
|
@@ -11217,7 +12491,7 @@ var commitStopTools = function (clientId, agentName) { return __awaiter(void 0,
|
|
|
11217
12491
|
return [2 /*return*/];
|
|
11218
12492
|
}
|
|
11219
12493
|
});
|
|
11220
|
-
}); };
|
|
12494
|
+
}); });
|
|
11221
12495
|
|
|
11222
12496
|
var METHOD_NAME$r = "function.commit.commitStopToolsForce";
|
|
11223
12497
|
/**
|
|
@@ -11226,7 +12500,7 @@ var METHOD_NAME$r = "function.commit.commitStopToolsForce";
|
|
|
11226
12500
|
* @param {string} clientId - The ID of the client.
|
|
11227
12501
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
11228
12502
|
*/
|
|
11229
|
-
var commitStopToolsForce = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12503
|
+
var commitStopToolsForce = beginContext(function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11230
12504
|
var swarmName;
|
|
11231
12505
|
return __generator(this, function (_a) {
|
|
11232
12506
|
switch (_a.label) {
|
|
@@ -11245,7 +12519,7 @@ var commitStopToolsForce = function (clientId) { return __awaiter(void 0, void 0
|
|
|
11245
12519
|
return [2 /*return*/];
|
|
11246
12520
|
}
|
|
11247
12521
|
});
|
|
11248
|
-
}); };
|
|
12522
|
+
}); });
|
|
11249
12523
|
|
|
11250
12524
|
var METHOD_NAME$q = "function.target.emitForce";
|
|
11251
12525
|
/**
|
|
@@ -11258,7 +12532,7 @@ var METHOD_NAME$q = "function.target.emitForce";
|
|
|
11258
12532
|
* @throws Will throw an error if the session mode is not "makeConnection".
|
|
11259
12533
|
* @returns {Promise<void>} A promise that resolves when the content is emitted.
|
|
11260
12534
|
*/
|
|
11261
|
-
var emitForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12535
|
+
var emitForce = beginContext(function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11262
12536
|
var swarmName;
|
|
11263
12537
|
return __generator(this, function (_a) {
|
|
11264
12538
|
switch (_a.label) {
|
|
@@ -11268,7 +12542,8 @@ var emitForce = function (content, clientId) { return __awaiter(void 0, void 0,
|
|
|
11268
12542
|
content: content,
|
|
11269
12543
|
clientId: clientId,
|
|
11270
12544
|
});
|
|
11271
|
-
if (swarm$1.sessionValidationService.getSessionMode(clientId) !==
|
|
12545
|
+
if (swarm$1.sessionValidationService.getSessionMode(clientId) !==
|
|
12546
|
+
"makeConnection") {
|
|
11272
12547
|
throw new Error("agent-swarm-kit emitForce session is not makeConnection clientId=".concat(clientId));
|
|
11273
12548
|
}
|
|
11274
12549
|
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$q);
|
|
@@ -11278,7 +12553,7 @@ var emitForce = function (content, clientId) { return __awaiter(void 0, void 0,
|
|
|
11278
12553
|
case 1: return [2 /*return*/, _a.sent()];
|
|
11279
12554
|
}
|
|
11280
12555
|
});
|
|
11281
|
-
}); };
|
|
12556
|
+
}); });
|
|
11282
12557
|
|
|
11283
12558
|
var METHOD_NAME$p = "function.target.executeForce";
|
|
11284
12559
|
/**
|
|
@@ -11291,7 +12566,7 @@ var METHOD_NAME$p = "function.target.executeForce";
|
|
|
11291
12566
|
* @param {string} clientId - The ID of the client requesting execution.
|
|
11292
12567
|
* @returns {Promise<void>} - A promise that resolves when the execution is complete.
|
|
11293
12568
|
*/
|
|
11294
|
-
var executeForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12569
|
+
var executeForce = beginContext(function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11295
12570
|
var executionId, swarmName;
|
|
11296
12571
|
return __generator(this, function (_a) {
|
|
11297
12572
|
executionId = functoolsKit.randomString();
|
|
@@ -11334,7 +12609,7 @@ var executeForce = function (content, clientId) { return __awaiter(void 0, void
|
|
|
11334
12609
|
executionId: executionId,
|
|
11335
12610
|
})];
|
|
11336
12611
|
});
|
|
11337
|
-
}); };
|
|
12612
|
+
}); });
|
|
11338
12613
|
|
|
11339
12614
|
var METHOD_NAME$o = "function.target.disposeConnection";
|
|
11340
12615
|
/**
|
|
@@ -11344,7 +12619,7 @@ var METHOD_NAME$o = "function.target.disposeConnection";
|
|
|
11344
12619
|
* @param {SwarmName} swarmName - The name of the swarm.
|
|
11345
12620
|
* @returns {Promise<void>} A promise that resolves when the connection is disposed.
|
|
11346
12621
|
*/
|
|
11347
|
-
var disposeConnection = function (clientId_1, swarmName_1) {
|
|
12622
|
+
var disposeConnection = beginContext(function (clientId_1, swarmName_1) {
|
|
11348
12623
|
var args_1 = [];
|
|
11349
12624
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
11350
12625
|
args_1[_i - 2] = arguments[_i];
|
|
@@ -11456,7 +12731,7 @@ var disposeConnection = function (clientId_1, swarmName_1) {
|
|
|
11456
12731
|
}
|
|
11457
12732
|
});
|
|
11458
12733
|
});
|
|
11459
|
-
};
|
|
12734
|
+
});
|
|
11460
12735
|
|
|
11461
12736
|
var METHOD_NAME$n = "function.target.makeAutoDispose";
|
|
11462
12737
|
var DEFAULT_TIMEOUT = 15 * 60;
|
|
@@ -11468,7 +12743,7 @@ var DEFAULT_TIMEOUT = 15 * 60;
|
|
|
11468
12743
|
* @param {Partial<IMakeDisposeParams>} [params={}] - Optional parameters for auto-dispose.
|
|
11469
12744
|
* @returns {Object} An object with tick and stop methods to control the auto-dispose.
|
|
11470
12745
|
*/
|
|
11471
|
-
var makeAutoDispose = function (clientId, swarmName, _a) {
|
|
12746
|
+
var makeAutoDispose = beginContext(function (clientId, swarmName, _a) {
|
|
11472
12747
|
var _b = _a === void 0 ? {} : _a, _c = _b.timeoutSeconds, timeoutSeconds = _c === void 0 ? DEFAULT_TIMEOUT : _c, onDestroy = _b.onDestroy;
|
|
11473
12748
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
11474
12749
|
swarm$1.loggerService.log(METHOD_NAME$n, {
|
|
@@ -11516,7 +12791,7 @@ var makeAutoDispose = function (clientId, swarmName, _a) {
|
|
|
11516
12791
|
onDestroy && onDestroy(clientId, swarmName);
|
|
11517
12792
|
},
|
|
11518
12793
|
};
|
|
11519
|
-
};
|
|
12794
|
+
});
|
|
11520
12795
|
|
|
11521
12796
|
var METHOD_NAME$m = "function.target.execute";
|
|
11522
12797
|
/**
|
|
@@ -11528,7 +12803,7 @@ var METHOD_NAME$m = "function.target.execute";
|
|
|
11528
12803
|
* @param {AgentName} agentName - The name of the agent executing the command.
|
|
11529
12804
|
* @returns {Promise<void>} - A promise that resolves when the execution is complete.
|
|
11530
12805
|
*/
|
|
11531
|
-
var execute = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12806
|
+
var execute = beginContext(function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11532
12807
|
var executionId, swarmName, currentAgentName;
|
|
11533
12808
|
return __generator(this, function (_a) {
|
|
11534
12809
|
switch (_a.label) {
|
|
@@ -11575,7 +12850,10 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
|
|
|
11575
12850
|
case 2:
|
|
11576
12851
|
result = _a.sent();
|
|
11577
12852
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
11578
|
-
swarm$1.busService.commitExecutionEnd(clientId, {
|
|
12853
|
+
swarm$1.busService.commitExecutionEnd(clientId, {
|
|
12854
|
+
agentName: agentName,
|
|
12855
|
+
swarmName: swarmName,
|
|
12856
|
+
});
|
|
11579
12857
|
return [2 /*return*/, result];
|
|
11580
12858
|
case 3:
|
|
11581
12859
|
if (!isFinished) {
|
|
@@ -11591,7 +12869,7 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
|
|
|
11591
12869
|
})];
|
|
11592
12870
|
}
|
|
11593
12871
|
});
|
|
11594
|
-
}); };
|
|
12872
|
+
}); });
|
|
11595
12873
|
|
|
11596
12874
|
var METHOD_NAME$l = "function.target.emit";
|
|
11597
12875
|
/**
|
|
@@ -11604,7 +12882,7 @@ var METHOD_NAME$l = "function.target.emit";
|
|
|
11604
12882
|
* @throws Will throw an error if the session mode is not "makeConnection".
|
|
11605
12883
|
* @returns {Promise<void>} A promise that resolves when the content is emitted.
|
|
11606
12884
|
*/
|
|
11607
|
-
var emit = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12885
|
+
var emit = beginContext(function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11608
12886
|
var swarmName, currentAgentName;
|
|
11609
12887
|
return __generator(this, function (_a) {
|
|
11610
12888
|
switch (_a.label) {
|
|
@@ -11615,7 +12893,8 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
|
|
|
11615
12893
|
clientId: clientId,
|
|
11616
12894
|
agentName: agentName,
|
|
11617
12895
|
});
|
|
11618
|
-
if (swarm$1.sessionValidationService.getSessionMode(clientId) !==
|
|
12896
|
+
if (swarm$1.sessionValidationService.getSessionMode(clientId) !==
|
|
12897
|
+
"makeConnection") {
|
|
11619
12898
|
throw new Error("agent-swarm-kit emit session is not makeConnection clientId=".concat(clientId));
|
|
11620
12899
|
}
|
|
11621
12900
|
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$l);
|
|
@@ -11638,7 +12917,7 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
|
|
|
11638
12917
|
case 2: return [2 /*return*/, _a.sent()];
|
|
11639
12918
|
}
|
|
11640
12919
|
});
|
|
11641
|
-
}); };
|
|
12920
|
+
}); });
|
|
11642
12921
|
|
|
11643
12922
|
var METHOD_NAME$k = "function.target.runStateless";
|
|
11644
12923
|
/**
|
|
@@ -11650,7 +12929,7 @@ var METHOD_NAME$k = "function.target.runStateless";
|
|
|
11650
12929
|
* @param {AgentName} agentName - The name of the agent running the command.
|
|
11651
12930
|
* @returns {Promise<string>} - A promise that resolves the run result
|
|
11652
12931
|
*/
|
|
11653
|
-
var runStateless = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12932
|
+
var runStateless = beginContext(function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11654
12933
|
var executionId, swarmName, currentAgentName;
|
|
11655
12934
|
return __generator(this, function (_a) {
|
|
11656
12935
|
switch (_a.label) {
|
|
@@ -11716,7 +12995,7 @@ var runStateless = function (content, clientId, agentName) { return __awaiter(vo
|
|
|
11716
12995
|
})];
|
|
11717
12996
|
}
|
|
11718
12997
|
});
|
|
11719
|
-
}); };
|
|
12998
|
+
}); });
|
|
11720
12999
|
|
|
11721
13000
|
var METHOD_NAME$j = "function.target.runStatelessForce";
|
|
11722
13001
|
/**
|
|
@@ -11729,7 +13008,7 @@ var METHOD_NAME$j = "function.target.runStatelessForce";
|
|
|
11729
13008
|
* @param {string} clientId - The ID of the client requesting run.
|
|
11730
13009
|
* @returns {Promise<string>} - A promise that resolves the run result
|
|
11731
13010
|
*/
|
|
11732
|
-
var runStatelessForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13011
|
+
var runStatelessForce = beginContext(function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11733
13012
|
var executionId, swarmName;
|
|
11734
13013
|
return __generator(this, function (_a) {
|
|
11735
13014
|
executionId = functoolsKit.randomString();
|
|
@@ -11772,7 +13051,7 @@ var runStatelessForce = function (content, clientId) { return __awaiter(void 0,
|
|
|
11772
13051
|
executionId: executionId,
|
|
11773
13052
|
})];
|
|
11774
13053
|
});
|
|
11775
|
-
}); };
|
|
13054
|
+
}); });
|
|
11776
13055
|
|
|
11777
13056
|
var METHOD_NAME$i = "function.common.getAgentName";
|
|
11778
13057
|
/**
|
|
@@ -11782,7 +13061,7 @@ var METHOD_NAME$i = "function.common.getAgentName";
|
|
|
11782
13061
|
* @returns {Promise<string>} The name of the agent.
|
|
11783
13062
|
* @throws Will throw an error if the client ID is invalid or if the swarm validation fails.
|
|
11784
13063
|
*/
|
|
11785
|
-
var getAgentName = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13064
|
+
var getAgentName = beginContext(function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11786
13065
|
var swarmName;
|
|
11787
13066
|
return __generator(this, function (_a) {
|
|
11788
13067
|
switch (_a.label) {
|
|
@@ -11798,20 +13077,12 @@ var getAgentName = function (clientId) { return __awaiter(void 0, void 0, void 0
|
|
|
11798
13077
|
case 1: return [2 /*return*/, _a.sent()];
|
|
11799
13078
|
}
|
|
11800
13079
|
});
|
|
11801
|
-
}); };
|
|
13080
|
+
}); });
|
|
11802
13081
|
|
|
11803
13082
|
var SCHEDULED_DELAY$1 = 1000;
|
|
11804
13083
|
var RATE_DELAY = 10000;
|
|
11805
13084
|
var METHOD_NAME$h = "function.target.makeConnection";
|
|
11806
|
-
|
|
11807
|
-
* A connection factory for a client to a swarm and returns a function to send messages.
|
|
11808
|
-
*
|
|
11809
|
-
* @param {ReceiveMessageFn} connector - The function to receive messages.
|
|
11810
|
-
* @param {string} clientId - The unique identifier of the client.
|
|
11811
|
-
* @param {SwarmName} swarmName - The name of the swarm.
|
|
11812
|
-
* @returns {SendMessageFn} - A function to send messages to the swarm.
|
|
11813
|
-
*/
|
|
11814
|
-
var makeConnection = function (connector, clientId, swarmName) {
|
|
13085
|
+
var makeConnectionInternal = beginContext(function (connector, clientId, swarmName) {
|
|
11815
13086
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
11816
13087
|
swarm$1.loggerService.log(METHOD_NAME$h, {
|
|
11817
13088
|
clientId: clientId,
|
|
@@ -11820,7 +13091,7 @@ var makeConnection = function (connector, clientId, swarmName) {
|
|
|
11820
13091
|
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$h);
|
|
11821
13092
|
swarm$1.sessionValidationService.addSession(clientId, swarmName, "makeConnection");
|
|
11822
13093
|
var send = swarm$1.sessionPublicService.connect(connector, METHOD_NAME$h, clientId, swarmName);
|
|
11823
|
-
return functoolsKit.queued(function (outgoing) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13094
|
+
return functoolsKit.queued(beginContext(function (outgoing) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11824
13095
|
var _a;
|
|
11825
13096
|
var _b;
|
|
11826
13097
|
return __generator(this, function (_c) {
|
|
@@ -11838,8 +13109,17 @@ var makeConnection = function (connector, clientId, swarmName) {
|
|
|
11838
13109
|
case 2: return [2 /*return*/, _c.sent()];
|
|
11839
13110
|
}
|
|
11840
13111
|
});
|
|
11841
|
-
}); });
|
|
11842
|
-
};
|
|
13112
|
+
}); }));
|
|
13113
|
+
});
|
|
13114
|
+
/**
|
|
13115
|
+
* A connection factory for a client to a swarm and returns a function to send messages.
|
|
13116
|
+
*
|
|
13117
|
+
* @param {ReceiveMessageFn} connector - The function to receive messages.
|
|
13118
|
+
* @param {string} clientId - The unique identifier of the client.
|
|
13119
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
13120
|
+
* @returns {SendMessageFn} - A function to send messages to the swarm.
|
|
13121
|
+
*/
|
|
13122
|
+
var makeConnection = function (connector, clientId, swarmName) { return makeConnectionInternal(connector, clientId, swarmName); };
|
|
11843
13123
|
/**
|
|
11844
13124
|
* A scheduled connection factory for a client to a swarm and returns a function to send messages.
|
|
11845
13125
|
*
|
|
@@ -11849,7 +13129,7 @@ var makeConnection = function (connector, clientId, swarmName) {
|
|
|
11849
13129
|
* @param {Partial<IMakeConnectionConfig>} [config] - The configuration for scheduling.
|
|
11850
13130
|
* @returns {SendMessageFn} - A function to send scheduled messages to the swarm.
|
|
11851
13131
|
*/
|
|
11852
|
-
makeConnection.scheduled = function (connector, clientId, swarmName, _a) {
|
|
13132
|
+
makeConnection.scheduled = beginContext(function (connector, clientId, swarmName, _a) {
|
|
11853
13133
|
var _b = _a === void 0 ? {} : _a, _c = _b.delay, delay = _c === void 0 ? SCHEDULED_DELAY$1 : _c;
|
|
11854
13134
|
var send = makeConnection(connector, clientId, swarmName);
|
|
11855
13135
|
/**
|
|
@@ -11858,7 +13138,7 @@ makeConnection.scheduled = function (connector, clientId, swarmName, _a) {
|
|
|
11858
13138
|
* @param {string} content - The message content to be sent.
|
|
11859
13139
|
* @returns {Promise<void>} - A promise that resolves when the message is sent.
|
|
11860
13140
|
*/
|
|
11861
|
-
var wrappedSend = functoolsKit.schedule(function (content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13141
|
+
var wrappedSend = functoolsKit.schedule(beginContext(function (content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11862
13142
|
return __generator(this, function (_a) {
|
|
11863
13143
|
switch (_a.label) {
|
|
11864
13144
|
case 0:
|
|
@@ -11869,14 +13149,14 @@ makeConnection.scheduled = function (connector, clientId, swarmName, _a) {
|
|
|
11869
13149
|
case 1: return [2 /*return*/, _a.sent()];
|
|
11870
13150
|
}
|
|
11871
13151
|
});
|
|
11872
|
-
}); }, {
|
|
13152
|
+
}); }), {
|
|
11873
13153
|
/**
|
|
11874
13154
|
* A function that is called when a message is scheduled.
|
|
11875
13155
|
*
|
|
11876
13156
|
* @param {[string]} content - The message content to be scheduled.
|
|
11877
13157
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
11878
13158
|
*/
|
|
11879
|
-
onSchedule: function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
13159
|
+
onSchedule: beginContext(function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
11880
13160
|
var _c, _d;
|
|
11881
13161
|
var _e = __read(_b, 1), content = _e[0];
|
|
11882
13162
|
return __generator(this, function (_f) {
|
|
@@ -11895,7 +13175,7 @@ makeConnection.scheduled = function (connector, clientId, swarmName, _a) {
|
|
|
11895
13175
|
return [2 /*return*/];
|
|
11896
13176
|
}
|
|
11897
13177
|
});
|
|
11898
|
-
}); },
|
|
13178
|
+
}); }),
|
|
11899
13179
|
/**
|
|
11900
13180
|
* The delay for message scheduler
|
|
11901
13181
|
*/
|
|
@@ -11915,7 +13195,7 @@ makeConnection.scheduled = function (connector, clientId, swarmName, _a) {
|
|
|
11915
13195
|
}
|
|
11916
13196
|
});
|
|
11917
13197
|
}); };
|
|
11918
|
-
};
|
|
13198
|
+
});
|
|
11919
13199
|
/**
|
|
11920
13200
|
* A rate-limited connection factory for a client to a swarm and returns a function to send messages.
|
|
11921
13201
|
*
|
|
@@ -11926,7 +13206,7 @@ makeConnection.scheduled = function (connector, clientId, swarmName, _a) {
|
|
|
11926
13206
|
* @param {number} [config.delay=RATE_DELAY] - The delay in milliseconds for rate limiting messages.
|
|
11927
13207
|
* @returns {SendMessageFn} - A function to send rate-limited messages to the swarm.
|
|
11928
13208
|
*/
|
|
11929
|
-
makeConnection.rate = function (connector, clientId, swarmName, _a) {
|
|
13209
|
+
makeConnection.rate = beginContext(function (connector, clientId, swarmName, _a) {
|
|
11930
13210
|
var _b = _a === void 0 ? {} : _a, _c = _b.delay, delay = _c === void 0 ? RATE_DELAY : _c;
|
|
11931
13211
|
var send = makeConnection(connector, clientId, swarmName);
|
|
11932
13212
|
/**
|
|
@@ -11935,7 +13215,7 @@ makeConnection.rate = function (connector, clientId, swarmName, _a) {
|
|
|
11935
13215
|
* @param {string} content - The message content to be sent.
|
|
11936
13216
|
* @returns {Promise<void>} - A promise that resolves when the message is sent.
|
|
11937
13217
|
*/
|
|
11938
|
-
var wrappedSend = functoolsKit.rate(function (content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13218
|
+
var wrappedSend = functoolsKit.rate(beginContext(function (content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
11939
13219
|
return __generator(this, function (_a) {
|
|
11940
13220
|
switch (_a.label) {
|
|
11941
13221
|
case 0:
|
|
@@ -11946,7 +13226,7 @@ makeConnection.rate = function (connector, clientId, swarmName, _a) {
|
|
|
11946
13226
|
case 1: return [2 /*return*/, _a.sent()];
|
|
11947
13227
|
}
|
|
11948
13228
|
});
|
|
11949
|
-
}); }, {
|
|
13229
|
+
}); }), {
|
|
11950
13230
|
key: function () { return clientId; },
|
|
11951
13231
|
rateName: "makeConnection.rate clientId=".concat(clientId),
|
|
11952
13232
|
delay: delay,
|
|
@@ -11968,15 +13248,15 @@ makeConnection.rate = function (connector, clientId, swarmName, _a) {
|
|
|
11968
13248
|
case 2:
|
|
11969
13249
|
error_1 = _a.sent();
|
|
11970
13250
|
if ((error_1 === null || error_1 === void 0 ? void 0 : error_1.type) === "rate-error") {
|
|
11971
|
-
console.warn("agent-swarm rate limit reached for clientId=".concat(clientId));
|
|
11972
|
-
return [2 /*return
|
|
13251
|
+
console.warn("agent-swarm makeConnection.rate rate limit reached for clientId=".concat(clientId));
|
|
13252
|
+
return [2 /*return*/, ""];
|
|
11973
13253
|
}
|
|
11974
13254
|
throw error_1;
|
|
11975
13255
|
case 3: return [2 /*return*/];
|
|
11976
13256
|
}
|
|
11977
13257
|
});
|
|
11978
13258
|
}); };
|
|
11979
|
-
};
|
|
13259
|
+
});
|
|
11980
13260
|
|
|
11981
13261
|
var METHOD_NAME$g = "function.target.complete";
|
|
11982
13262
|
var COMPLETE_TTL = 15 * 60 * 1000;
|
|
@@ -12031,7 +13311,7 @@ var createGc$3 = functoolsKit.singleshot(function () { return __awaiter(void 0,
|
|
|
12031
13311
|
* @param {SwarmName} swarmName - The swarm name.
|
|
12032
13312
|
* @returns {Promise<string>} The result of the complete function.
|
|
12033
13313
|
*/
|
|
12034
|
-
var complete = function (content, clientId, swarmName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13314
|
+
var complete = beginContext(function (content, clientId, swarmName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12035
13315
|
var executionId, run;
|
|
12036
13316
|
return __generator(this, function (_a) {
|
|
12037
13317
|
switch (_a.label) {
|
|
@@ -12079,20 +13359,11 @@ var complete = function (content, clientId, swarmName) { return __awaiter(void 0
|
|
|
12079
13359
|
})];
|
|
12080
13360
|
}
|
|
12081
13361
|
});
|
|
12082
|
-
}); };
|
|
13362
|
+
}); });
|
|
12083
13363
|
|
|
12084
13364
|
var SCHEDULED_DELAY = 1000;
|
|
12085
13365
|
var METHOD_NAME$f = "function.target.session";
|
|
12086
|
-
|
|
12087
|
-
* Creates a session for the given client and swarm.
|
|
12088
|
-
*
|
|
12089
|
-
* @param {string} clientId - The ID of the client.
|
|
12090
|
-
* @param {SwarmName} swarmName - The name of the swarm.
|
|
12091
|
-
* @returns {Object} An object containing the session methods.
|
|
12092
|
-
* @returns {TComplete} complete - A function to complete the session with content.
|
|
12093
|
-
* @returns {Function} dispose - A function to dispose of the session.
|
|
12094
|
-
*/
|
|
12095
|
-
var session = function (clientId, swarmName) {
|
|
13366
|
+
var sessionInternal = beginContext(function (clientId, swarmName) {
|
|
12096
13367
|
var executionId = functoolsKit.randomString();
|
|
12097
13368
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
12098
13369
|
swarm$1.loggerService.log(METHOD_NAME$f, {
|
|
@@ -12109,7 +13380,7 @@ var session = function (clientId, swarmName) {
|
|
|
12109
13380
|
* @param {string} content - The content to complete the session with.
|
|
12110
13381
|
* @returns {Promise<string>} A promise that resolves with the result of the session execution.
|
|
12111
13382
|
*/
|
|
12112
|
-
complete: functoolsKit.queued(function (content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13383
|
+
complete: functoolsKit.queued(beginContext(function (content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12113
13384
|
return __generator(this, function (_a) {
|
|
12114
13385
|
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$f);
|
|
12115
13386
|
return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -12144,34 +13415,134 @@ var session = function (clientId, swarmName) {
|
|
|
12144
13415
|
executionId: executionId,
|
|
12145
13416
|
})];
|
|
12146
13417
|
});
|
|
12147
|
-
}); }),
|
|
13418
|
+
}); })),
|
|
13419
|
+
/**
|
|
13420
|
+
* Disposes of the session.
|
|
13421
|
+
*
|
|
13422
|
+
* @returns {Promise<void>} A promise that resolves when the session is disposed.
|
|
13423
|
+
*/
|
|
13424
|
+
dispose: beginContext(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
13425
|
+
return __generator(this, function (_a) {
|
|
13426
|
+
switch (_a.label) {
|
|
13427
|
+
case 0: return [4 /*yield*/, disposeConnection(clientId, swarmName, METHOD_NAME$f)];
|
|
13428
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
13429
|
+
}
|
|
13430
|
+
});
|
|
13431
|
+
}); }),
|
|
13432
|
+
};
|
|
13433
|
+
});
|
|
13434
|
+
/**
|
|
13435
|
+
* Creates a session for the given client and swarm.
|
|
13436
|
+
*
|
|
13437
|
+
* @param {string} clientId - The ID of the client.
|
|
13438
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
13439
|
+
* @returns {Object} An object containing the session methods.
|
|
13440
|
+
* @returns {TComplete} complete - A function to complete the session with content.
|
|
13441
|
+
* @returns {Function} dispose - A function to dispose of the session.
|
|
13442
|
+
*/
|
|
13443
|
+
var session = function (clientId, swarmName) {
|
|
13444
|
+
return sessionInternal(clientId, swarmName);
|
|
13445
|
+
};
|
|
13446
|
+
/**
|
|
13447
|
+
* Creates a scheduled session for the given client and swarm.
|
|
13448
|
+
*
|
|
13449
|
+
* @param {string} clientId - The ID of the client.
|
|
13450
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
13451
|
+
* @param {Partial<ISessionConfig>} [config] - The configuration for the scheduled session.
|
|
13452
|
+
* @param {number} [config.delay] - The delay for the scheduled session.
|
|
13453
|
+
* @returns {Object} An object containing the scheduled session methods.
|
|
13454
|
+
* @returns {TComplete} complete - A function to complete the session with content.
|
|
13455
|
+
* @returns {Function} dispose - A function to dispose of the session.
|
|
13456
|
+
*/
|
|
13457
|
+
session.scheduled = function (clientId, swarmName, _a) {
|
|
13458
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.delay, delay = _c === void 0 ? SCHEDULED_DELAY : _c;
|
|
13459
|
+
var _d = session(clientId, swarmName), complete = _d.complete, dispose = _d.dispose;
|
|
13460
|
+
var isMounted = true;
|
|
13461
|
+
/**
|
|
13462
|
+
* Completes the scheduled session with the given content.
|
|
13463
|
+
*
|
|
13464
|
+
* @param {string} content - The content to complete the session with.
|
|
13465
|
+
* @returns {Promise<string>} A promise that resolves with the result of the session execution.
|
|
13466
|
+
*/
|
|
13467
|
+
var wrappedComplete = functoolsKit.schedule(beginContext(function (content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13468
|
+
return __generator(this, function (_a) {
|
|
13469
|
+
switch (_a.label) {
|
|
13470
|
+
case 0:
|
|
13471
|
+
if (!isMounted) {
|
|
13472
|
+
return [2 /*return*/];
|
|
13473
|
+
}
|
|
13474
|
+
return [4 /*yield*/, complete(content)];
|
|
13475
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
13476
|
+
}
|
|
13477
|
+
});
|
|
13478
|
+
}); }), {
|
|
13479
|
+
onSchedule: beginContext(function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
13480
|
+
var _c, _d;
|
|
13481
|
+
var _e = __read(_b, 1), content = _e[0];
|
|
13482
|
+
return __generator(this, function (_f) {
|
|
13483
|
+
switch (_f.label) {
|
|
13484
|
+
case 0:
|
|
13485
|
+
if (!isMounted) {
|
|
13486
|
+
return [2 /*return*/];
|
|
13487
|
+
}
|
|
13488
|
+
_c = commitUserMessage;
|
|
13489
|
+
_d = [content,
|
|
13490
|
+
clientId];
|
|
13491
|
+
return [4 /*yield*/, getAgentName(clientId)];
|
|
13492
|
+
case 1: return [4 /*yield*/, _c.apply(void 0, _d.concat([_f.sent()]))];
|
|
13493
|
+
case 2:
|
|
13494
|
+
_f.sent();
|
|
13495
|
+
return [2 /*return*/];
|
|
13496
|
+
}
|
|
13497
|
+
});
|
|
13498
|
+
}); }),
|
|
13499
|
+
delay: delay,
|
|
13500
|
+
});
|
|
13501
|
+
return {
|
|
13502
|
+
/**
|
|
13503
|
+
* Completes the scheduled session with the given content.
|
|
13504
|
+
*
|
|
13505
|
+
* @param {string} content - The content to complete the session with.
|
|
13506
|
+
* @returns {Promise<string>} A promise that resolves with the result of the session execution.
|
|
13507
|
+
*/
|
|
13508
|
+
complete: function (content) {
|
|
13509
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
13510
|
+
return __generator(this, function (_a) {
|
|
13511
|
+
switch (_a.label) {
|
|
13512
|
+
case 0: return [4 /*yield*/, wrappedComplete(content)];
|
|
13513
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
13514
|
+
}
|
|
13515
|
+
});
|
|
13516
|
+
});
|
|
13517
|
+
},
|
|
12148
13518
|
/**
|
|
12149
|
-
* Disposes of the session.
|
|
13519
|
+
* Disposes of the scheduled session.
|
|
12150
13520
|
*
|
|
12151
13521
|
* @returns {Promise<void>} A promise that resolves when the session is disposed.
|
|
12152
13522
|
*/
|
|
12153
|
-
dispose: function () {
|
|
12154
|
-
return
|
|
12155
|
-
|
|
12156
|
-
|
|
12157
|
-
|
|
12158
|
-
|
|
13523
|
+
dispose: function () {
|
|
13524
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
13525
|
+
return __generator(this, function (_a) {
|
|
13526
|
+
switch (_a.label) {
|
|
13527
|
+
case 0:
|
|
13528
|
+
isMounted = false;
|
|
13529
|
+
return [4 /*yield*/, dispose()];
|
|
13530
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
13531
|
+
}
|
|
13532
|
+
});
|
|
12159
13533
|
});
|
|
12160
|
-
}
|
|
13534
|
+
},
|
|
12161
13535
|
};
|
|
12162
13536
|
};
|
|
12163
13537
|
/**
|
|
12164
|
-
*
|
|
13538
|
+
* A rate-limited connection factory for a client to a swarm and returns a function to send messages.
|
|
12165
13539
|
*
|
|
12166
|
-
* @param {string} clientId - The
|
|
13540
|
+
* @param {string} clientId - The unique identifier of the client.
|
|
12167
13541
|
* @param {SwarmName} swarmName - The name of the swarm.
|
|
12168
|
-
* @param {Partial<ISessionConfig>} [config] - The configuration for
|
|
12169
|
-
* @param {number} [config.delay] - The delay for
|
|
12170
|
-
* @returns {Object} An object containing the scheduled session methods.
|
|
12171
|
-
* @returns {TComplete} complete - A function to complete the session with content.
|
|
12172
|
-
* @returns {Function} dispose - A function to dispose of the session.
|
|
13542
|
+
* @param {Partial<ISessionConfig>} [config] - The configuration for rate limiting.
|
|
13543
|
+
* @param {number} [config.delay=SCHEDULED_DELAY] - The delay in milliseconds for rate limiting messages.
|
|
12173
13544
|
*/
|
|
12174
|
-
session.
|
|
13545
|
+
session.rate = function (clientId, swarmName, _a) {
|
|
12175
13546
|
var _b = _a === void 0 ? {} : _a, _c = _b.delay, delay = _c === void 0 ? SCHEDULED_DELAY : _c;
|
|
12176
13547
|
var _d = session(clientId, swarmName), complete = _d.complete, dispose = _d.dispose;
|
|
12177
13548
|
var isMounted = true;
|
|
@@ -12181,7 +13552,7 @@ session.scheduled = function (clientId, swarmName, _a) {
|
|
|
12181
13552
|
* @param {string} content - The content to complete the session with.
|
|
12182
13553
|
* @returns {Promise<string>} A promise that resolves with the result of the session execution.
|
|
12183
13554
|
*/
|
|
12184
|
-
var wrappedComplete = functoolsKit.
|
|
13555
|
+
var wrappedComplete = functoolsKit.rate(beginContext(function (content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12185
13556
|
return __generator(this, function (_a) {
|
|
12186
13557
|
switch (_a.label) {
|
|
12187
13558
|
case 0:
|
|
@@ -12192,27 +13563,9 @@ session.scheduled = function (clientId, swarmName, _a) {
|
|
|
12192
13563
|
case 1: return [2 /*return*/, _a.sent()];
|
|
12193
13564
|
}
|
|
12194
13565
|
});
|
|
12195
|
-
}); }, {
|
|
12196
|
-
|
|
12197
|
-
|
|
12198
|
-
var _e = __read(_b, 1), content = _e[0];
|
|
12199
|
-
return __generator(this, function (_f) {
|
|
12200
|
-
switch (_f.label) {
|
|
12201
|
-
case 0:
|
|
12202
|
-
if (!isMounted) {
|
|
12203
|
-
return [2 /*return*/];
|
|
12204
|
-
}
|
|
12205
|
-
_c = commitUserMessage;
|
|
12206
|
-
_d = [content,
|
|
12207
|
-
clientId];
|
|
12208
|
-
return [4 /*yield*/, getAgentName(clientId)];
|
|
12209
|
-
case 1: return [4 /*yield*/, _c.apply(void 0, _d.concat([_f.sent()]))];
|
|
12210
|
-
case 2:
|
|
12211
|
-
_f.sent();
|
|
12212
|
-
return [2 /*return*/];
|
|
12213
|
-
}
|
|
12214
|
-
});
|
|
12215
|
-
}); },
|
|
13566
|
+
}); }), {
|
|
13567
|
+
key: function () { return clientId; },
|
|
13568
|
+
rateName: "makeConnection.rate clientId=".concat(clientId),
|
|
12216
13569
|
delay: delay,
|
|
12217
13570
|
});
|
|
12218
13571
|
return {
|
|
@@ -12224,10 +13577,21 @@ session.scheduled = function (clientId, swarmName, _a) {
|
|
|
12224
13577
|
*/
|
|
12225
13578
|
complete: function (content) {
|
|
12226
13579
|
return __awaiter(this, void 0, void 0, function () {
|
|
13580
|
+
var error_1;
|
|
12227
13581
|
return __generator(this, function (_a) {
|
|
12228
13582
|
switch (_a.label) {
|
|
12229
|
-
case 0:
|
|
13583
|
+
case 0:
|
|
13584
|
+
_a.trys.push([0, 2, , 3]);
|
|
13585
|
+
return [4 /*yield*/, wrappedComplete(content)];
|
|
12230
13586
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13587
|
+
case 2:
|
|
13588
|
+
error_1 = _a.sent();
|
|
13589
|
+
if ((error_1 === null || error_1 === void 0 ? void 0 : error_1.type) === "rate-error") {
|
|
13590
|
+
console.warn("agent-swarm session.rate rate limit reached for clientId=".concat(clientId));
|
|
13591
|
+
return [2 /*return*/, ""];
|
|
13592
|
+
}
|
|
13593
|
+
throw error_1;
|
|
13594
|
+
case 3: return [2 /*return*/];
|
|
12231
13595
|
}
|
|
12232
13596
|
});
|
|
12233
13597
|
});
|
|
@@ -12260,7 +13624,7 @@ var METHOD_NAME$e = "function.common.getAgentHistory";
|
|
|
12260
13624
|
* @param {AgentName} agentName - The name of the agent.
|
|
12261
13625
|
* @returns {Promise<Array>} - A promise that resolves to an array containing the agent's history.
|
|
12262
13626
|
*/
|
|
12263
|
-
var getAgentHistory = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13627
|
+
var getAgentHistory = beginContext(function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12264
13628
|
var prompt, history;
|
|
12265
13629
|
return __generator(this, function (_a) {
|
|
12266
13630
|
switch (_a.label) {
|
|
@@ -12279,7 +13643,7 @@ var getAgentHistory = function (clientId, agentName) { return __awaiter(void 0,
|
|
|
12279
13643
|
return [2 /*return*/, __spreadArray([], __read(history), false)];
|
|
12280
13644
|
}
|
|
12281
13645
|
});
|
|
12282
|
-
}); };
|
|
13646
|
+
}); });
|
|
12283
13647
|
|
|
12284
13648
|
var METHOD_NAME$d = "function.common.getSessionMode";
|
|
12285
13649
|
/**
|
|
@@ -12287,7 +13651,7 @@ var METHOD_NAME$d = "function.common.getSessionMode";
|
|
|
12287
13651
|
*
|
|
12288
13652
|
* @param {string} clientId - The client ID of the session.
|
|
12289
13653
|
*/
|
|
12290
|
-
var getSessionMode = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13654
|
+
var getSessionMode = beginContext(function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12291
13655
|
var swarmName;
|
|
12292
13656
|
return __generator(this, function (_a) {
|
|
12293
13657
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
@@ -12299,7 +13663,7 @@ var getSessionMode = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
12299
13663
|
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$d);
|
|
12300
13664
|
return [2 /*return*/, swarm$1.sessionValidationService.getSessionMode(clientId)];
|
|
12301
13665
|
});
|
|
12302
|
-
}); };
|
|
13666
|
+
}); });
|
|
12303
13667
|
|
|
12304
13668
|
var METHOD_NAME$c = "function.common.getSessionContext";
|
|
12305
13669
|
/**
|
|
@@ -12336,7 +13700,7 @@ var METHOD_NAME$b = "function.history.getRawHistory";
|
|
|
12336
13700
|
* @param {string} clientId - The ID of the client whose history is to be retrieved.
|
|
12337
13701
|
* @returns {Promise<Array>} A promise that resolves to an array containing the raw history.
|
|
12338
13702
|
*/
|
|
12339
|
-
var getRawHistory = function (clientId_1) {
|
|
13703
|
+
var getRawHistory = beginContext(function (clientId_1) {
|
|
12340
13704
|
var args_1 = [];
|
|
12341
13705
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
12342
13706
|
args_1[_i - 1] = arguments[_i];
|
|
@@ -12364,7 +13728,7 @@ var getRawHistory = function (clientId_1) {
|
|
|
12364
13728
|
}
|
|
12365
13729
|
});
|
|
12366
13730
|
});
|
|
12367
|
-
};
|
|
13731
|
+
});
|
|
12368
13732
|
|
|
12369
13733
|
var METHOD_NAME$a = "function.history.getLastUserMessage";
|
|
12370
13734
|
/**
|
|
@@ -12373,7 +13737,7 @@ var METHOD_NAME$a = "function.history.getLastUserMessage";
|
|
|
12373
13737
|
* @param {string} clientId - The ID of the client whose message history is being retrieved.
|
|
12374
13738
|
* @returns {Promise<string | null>} - The content of the last user message, or null if no user message is found.
|
|
12375
13739
|
*/
|
|
12376
|
-
var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13740
|
+
var getLastUserMessage = beginContext(function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12377
13741
|
var history, last;
|
|
12378
13742
|
return __generator(this, function (_a) {
|
|
12379
13743
|
switch (_a.label) {
|
|
@@ -12392,7 +13756,7 @@ var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0,
|
|
|
12392
13756
|
return [2 /*return*/, last ? last.content : null];
|
|
12393
13757
|
}
|
|
12394
13758
|
});
|
|
12395
|
-
}); };
|
|
13759
|
+
}); });
|
|
12396
13760
|
|
|
12397
13761
|
var METHOD_NAME$9 = "function.history.getUserHistory";
|
|
12398
13762
|
/**
|
|
@@ -12401,7 +13765,7 @@ var METHOD_NAME$9 = "function.history.getUserHistory";
|
|
|
12401
13765
|
* @param {string} clientId - The ID of the client whose history is to be retrieved.
|
|
12402
13766
|
* @returns {Promise<Array>} A promise that resolves to an array of history objects filtered by user role.
|
|
12403
13767
|
*/
|
|
12404
|
-
var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13768
|
+
var getUserHistory = beginContext(function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12405
13769
|
var history;
|
|
12406
13770
|
return __generator(this, function (_a) {
|
|
12407
13771
|
switch (_a.label) {
|
|
@@ -12419,7 +13783,7 @@ var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
12419
13783
|
})];
|
|
12420
13784
|
}
|
|
12421
13785
|
});
|
|
12422
|
-
}); };
|
|
13786
|
+
}); });
|
|
12423
13787
|
|
|
12424
13788
|
var METHOD_NAME$8 = "function.history.getAssistantHistory";
|
|
12425
13789
|
/**
|
|
@@ -12428,7 +13792,7 @@ var METHOD_NAME$8 = "function.history.getAssistantHistory";
|
|
|
12428
13792
|
* @param {string} clientId - The ID of the client.
|
|
12429
13793
|
* @returns {Promise<Array>} - A promise that resolves to an array of history objects where the role is "assistant".
|
|
12430
13794
|
*/
|
|
12431
|
-
var getAssistantHistory = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13795
|
+
var getAssistantHistory = beginContext(function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12432
13796
|
var history;
|
|
12433
13797
|
return __generator(this, function (_a) {
|
|
12434
13798
|
switch (_a.label) {
|
|
@@ -12446,7 +13810,7 @@ var getAssistantHistory = function (clientId) { return __awaiter(void 0, void 0,
|
|
|
12446
13810
|
})];
|
|
12447
13811
|
}
|
|
12448
13812
|
});
|
|
12449
|
-
}); };
|
|
13813
|
+
}); });
|
|
12450
13814
|
|
|
12451
13815
|
var METHOD_NAME$7 = "function.history.getLastAssistantMessage";
|
|
12452
13816
|
/**
|
|
@@ -12455,7 +13819,7 @@ var METHOD_NAME$7 = "function.history.getLastAssistantMessage";
|
|
|
12455
13819
|
* @param {string} clientId - The ID of the client whose message history is being retrieved.
|
|
12456
13820
|
* @returns {Promise<string | null>} - The content of the last assistant message, or null if no user message is found.
|
|
12457
13821
|
*/
|
|
12458
|
-
var getLastAssistantMessage = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13822
|
+
var getLastAssistantMessage = beginContext(function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12459
13823
|
var history, last;
|
|
12460
13824
|
return __generator(this, function (_a) {
|
|
12461
13825
|
switch (_a.label) {
|
|
@@ -12474,7 +13838,7 @@ var getLastAssistantMessage = function (clientId) { return __awaiter(void 0, voi
|
|
|
12474
13838
|
return [2 /*return*/, last ? last.content : null];
|
|
12475
13839
|
}
|
|
12476
13840
|
});
|
|
12477
|
-
}); };
|
|
13841
|
+
}); });
|
|
12478
13842
|
|
|
12479
13843
|
var METHOD_NAME$6 = "function.history.getLastSystemMessage";
|
|
12480
13844
|
/**
|
|
@@ -12483,7 +13847,7 @@ var METHOD_NAME$6 = "function.history.getLastSystemMessage";
|
|
|
12483
13847
|
* @param {string} clientId - The ID of the client whose message history is being retrieved.
|
|
12484
13848
|
* @returns {Promise<string | null>} - The content of the last system message, or null if no user message is found.
|
|
12485
13849
|
*/
|
|
12486
|
-
var getLastSystemMessage = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
13850
|
+
var getLastSystemMessage = beginContext(function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12487
13851
|
var history, last;
|
|
12488
13852
|
return __generator(this, function (_a) {
|
|
12489
13853
|
switch (_a.label) {
|
|
@@ -12502,7 +13866,7 @@ var getLastSystemMessage = function (clientId) { return __awaiter(void 0, void 0
|
|
|
12502
13866
|
return [2 /*return*/, last ? last.content : null];
|
|
12503
13867
|
}
|
|
12504
13868
|
});
|
|
12505
|
-
}); };
|
|
13869
|
+
}); });
|
|
12506
13870
|
|
|
12507
13871
|
var METHOD_NAME$5 = "function.event.listenEvent";
|
|
12508
13872
|
var DISALLOWED_EVENT_SOURCE_LIST$2 = new Set([
|
|
@@ -12512,7 +13876,8 @@ var DISALLOWED_EVENT_SOURCE_LIST$2 = new Set([
|
|
|
12512
13876
|
"state-bus",
|
|
12513
13877
|
"storage-bus",
|
|
12514
13878
|
"swarm-bus",
|
|
12515
|
-
"execution-bus"
|
|
13879
|
+
"execution-bus",
|
|
13880
|
+
"policy-bus",
|
|
12516
13881
|
]);
|
|
12517
13882
|
/**
|
|
12518
13883
|
* Emits an event to the swarm bus service.
|
|
@@ -12522,7 +13887,7 @@ var DISALLOWED_EVENT_SOURCE_LIST$2 = new Set([
|
|
|
12522
13887
|
* @param {T} payload - The payload of the event.
|
|
12523
13888
|
* @returns {boolean} - Returns true if the event was successfully emitted.
|
|
12524
13889
|
*/
|
|
12525
|
-
var event = function (clientId, topicName, payload) {
|
|
13890
|
+
var event = beginContext(function (clientId, topicName, payload) {
|
|
12526
13891
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
12527
13892
|
swarm$1.loggerService.log(METHOD_NAME$5, {
|
|
12528
13893
|
clientId: clientId,
|
|
@@ -12535,7 +13900,7 @@ var event = function (clientId, topicName, payload) {
|
|
|
12535
13900
|
payload: payload,
|
|
12536
13901
|
clientId: clientId,
|
|
12537
13902
|
});
|
|
12538
|
-
};
|
|
13903
|
+
});
|
|
12539
13904
|
|
|
12540
13905
|
var METHOD_NAME$4 = "function.event.listenEvent";
|
|
12541
13906
|
var DISALLOWED_EVENT_SOURCE_LIST$1 = new Set([
|
|
@@ -12545,9 +13910,10 @@ var DISALLOWED_EVENT_SOURCE_LIST$1 = new Set([
|
|
|
12545
13910
|
"state-bus",
|
|
12546
13911
|
"storage-bus",
|
|
12547
13912
|
"swarm-bus",
|
|
12548
|
-
"execution-bus"
|
|
13913
|
+
"execution-bus",
|
|
13914
|
+
"policy-bus",
|
|
12549
13915
|
]);
|
|
12550
|
-
var validateClientId$
|
|
13916
|
+
var validateClientId$g = function (clientId) {
|
|
12551
13917
|
if (clientId === "*") {
|
|
12552
13918
|
return;
|
|
12553
13919
|
}
|
|
@@ -12562,7 +13928,7 @@ var validateClientId$e = function (clientId) {
|
|
|
12562
13928
|
* @param {string} clientId - The ID of the client to listen for events from.
|
|
12563
13929
|
* @param {(data: T) => void} fn - The callback function to execute when the event is received. The data payload is passed as an argument to this function.
|
|
12564
13930
|
*/
|
|
12565
|
-
var listenEvent = function (clientId, topicName, fn) {
|
|
13931
|
+
var listenEvent = beginContext(function (clientId, topicName, fn) {
|
|
12566
13932
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
12567
13933
|
swarm$1.loggerService.log(METHOD_NAME$4, {
|
|
12568
13934
|
clientId: clientId,
|
|
@@ -12570,7 +13936,7 @@ var listenEvent = function (clientId, topicName, fn) {
|
|
|
12570
13936
|
if (DISALLOWED_EVENT_SOURCE_LIST$1.has(topicName)) {
|
|
12571
13937
|
throw new Error("agent-swarm listenEvent topic is reserved topicName=".concat(topicName));
|
|
12572
13938
|
}
|
|
12573
|
-
validateClientId$
|
|
13939
|
+
validateClientId$g(clientId);
|
|
12574
13940
|
return swarm$1.busService.subscribe(clientId, topicName, functoolsKit.queued(function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
12575
13941
|
var payload = _b.payload;
|
|
12576
13942
|
return __generator(this, function (_c) {
|
|
@@ -12580,7 +13946,7 @@ var listenEvent = function (clientId, topicName, fn) {
|
|
|
12580
13946
|
}
|
|
12581
13947
|
});
|
|
12582
13948
|
}); }));
|
|
12583
|
-
};
|
|
13949
|
+
});
|
|
12584
13950
|
|
|
12585
13951
|
var METHOD_NAME$3 = "function.event.listenEventOnce";
|
|
12586
13952
|
var DISALLOWED_EVENT_SOURCE_LIST = new Set([
|
|
@@ -12590,9 +13956,10 @@ var DISALLOWED_EVENT_SOURCE_LIST = new Set([
|
|
|
12590
13956
|
"state-bus",
|
|
12591
13957
|
"storage-bus",
|
|
12592
13958
|
"swarm-bus",
|
|
12593
|
-
"execution-bus"
|
|
13959
|
+
"execution-bus",
|
|
13960
|
+
"policy-bus",
|
|
12594
13961
|
]);
|
|
12595
|
-
var validateClientId$
|
|
13962
|
+
var validateClientId$f = function (clientId) {
|
|
12596
13963
|
if (clientId === "*") {
|
|
12597
13964
|
return;
|
|
12598
13965
|
}
|
|
@@ -12607,7 +13974,7 @@ var validateClientId$d = function (clientId) {
|
|
|
12607
13974
|
* @param {string} clientId - The ID of the client to listen for events from.
|
|
12608
13975
|
* @param {(data: T) => void} fn - The callback function to execute when the event is received. The data payload is passed as an argument to this function.
|
|
12609
13976
|
*/
|
|
12610
|
-
var listenEventOnce = function (clientId, topicName, filterFn, fn) {
|
|
13977
|
+
var listenEventOnce = beginContext(function (clientId, topicName, filterFn, fn) {
|
|
12611
13978
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
12612
13979
|
swarm$1.loggerService.log(METHOD_NAME$3, {
|
|
12613
13980
|
clientId: clientId,
|
|
@@ -12615,7 +13982,7 @@ var listenEventOnce = function (clientId, topicName, filterFn, fn) {
|
|
|
12615
13982
|
if (DISALLOWED_EVENT_SOURCE_LIST.has(topicName)) {
|
|
12616
13983
|
throw new Error("agent-swarm listenEventOnce topic is reserved topicName=".concat(topicName));
|
|
12617
13984
|
}
|
|
12618
|
-
validateClientId$
|
|
13985
|
+
validateClientId$f(clientId);
|
|
12619
13986
|
return swarm$1.busService.once(clientId, topicName, function (_a) {
|
|
12620
13987
|
var payload = _a.payload;
|
|
12621
13988
|
return filterFn(payload);
|
|
@@ -12628,7 +13995,7 @@ var listenEventOnce = function (clientId, topicName, filterFn, fn) {
|
|
|
12628
13995
|
}
|
|
12629
13996
|
});
|
|
12630
13997
|
}); }));
|
|
12631
|
-
};
|
|
13998
|
+
});
|
|
12632
13999
|
|
|
12633
14000
|
var METHOD_NAME$2 = "function.navigate.changeToAgent";
|
|
12634
14001
|
/**
|
|
@@ -12717,7 +14084,7 @@ var createGc$2 = functoolsKit.singleshot(function () { return __awaiter(void 0,
|
|
|
12717
14084
|
* @param {string} clientId - The client ID.
|
|
12718
14085
|
* @returns {Promise<void>} - A promise that resolves when the agent is changed.
|
|
12719
14086
|
*/
|
|
12720
|
-
var changeToAgent = function (agentName, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
14087
|
+
var changeToAgent = beginContext(function (agentName, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12721
14088
|
var swarmName, activeAgent, run;
|
|
12722
14089
|
return __generator(this, function (_a) {
|
|
12723
14090
|
switch (_a.label) {
|
|
@@ -12744,7 +14111,7 @@ var changeToAgent = function (agentName, clientId) { return __awaiter(void 0, vo
|
|
|
12744
14111
|
case 3: return [2 /*return*/, _a.sent()];
|
|
12745
14112
|
}
|
|
12746
14113
|
});
|
|
12747
|
-
}); };
|
|
14114
|
+
}); });
|
|
12748
14115
|
|
|
12749
14116
|
var METHOD_NAME$1 = "function.navigate.changeToPrevAgent";
|
|
12750
14117
|
/**
|
|
@@ -12832,7 +14199,7 @@ var createGc$1 = functoolsKit.singleshot(function () { return __awaiter(void 0,
|
|
|
12832
14199
|
* @param {string} clientId - The client ID.
|
|
12833
14200
|
* @returns {Promise<void>} - A promise that resolves when the agent is changed.
|
|
12834
14201
|
*/
|
|
12835
|
-
var changeToPrevAgent = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
14202
|
+
var changeToPrevAgent = beginContext(function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12836
14203
|
var swarmName, agentName, run;
|
|
12837
14204
|
return __generator(this, function (_a) {
|
|
12838
14205
|
switch (_a.label) {
|
|
@@ -12857,7 +14224,7 @@ var changeToPrevAgent = function (clientId) { return __awaiter(void 0, void 0, v
|
|
|
12857
14224
|
case 3: return [2 /*return*/, _a.sent()];
|
|
12858
14225
|
}
|
|
12859
14226
|
});
|
|
12860
|
-
}); };
|
|
14227
|
+
}); });
|
|
12861
14228
|
|
|
12862
14229
|
var METHOD_NAME = "function.navigate.changeToDefaultAgent";
|
|
12863
14230
|
/**
|
|
@@ -12945,7 +14312,7 @@ var createGc = functoolsKit.singleshot(function () { return __awaiter(void 0, vo
|
|
|
12945
14312
|
* @param {string} clientId - The client ID.
|
|
12946
14313
|
* @returns {Promise<void>} - A promise that resolves when the agent is changed.
|
|
12947
14314
|
*/
|
|
12948
|
-
var changeToDefaultAgent = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
14315
|
+
var changeToDefaultAgent = beginContext(function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
12949
14316
|
var swarmName, agentName, run;
|
|
12950
14317
|
return __generator(this, function (_a) {
|
|
12951
14318
|
switch (_a.label) {
|
|
@@ -12968,9 +14335,9 @@ var changeToDefaultAgent = function (clientId) { return __awaiter(void 0, void 0
|
|
|
12968
14335
|
case 2: return [2 /*return*/, _a.sent()];
|
|
12969
14336
|
}
|
|
12970
14337
|
});
|
|
12971
|
-
}); };
|
|
14338
|
+
}); });
|
|
12972
14339
|
|
|
12973
|
-
var validateClientId$
|
|
14340
|
+
var validateClientId$e = function (clientId) {
|
|
12974
14341
|
if (clientId === "*") {
|
|
12975
14342
|
return;
|
|
12976
14343
|
}
|
|
@@ -12984,20 +14351,20 @@ var validateClientId$c = function (clientId) {
|
|
|
12984
14351
|
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
12985
14352
|
* @param {function} fn - The callback function to handle the event.
|
|
12986
14353
|
*/
|
|
12987
|
-
var listenAgentEvent = function (clientId, fn) {
|
|
14354
|
+
var listenAgentEvent = beginContext(function (clientId, fn) {
|
|
12988
14355
|
swarm$1.loggerService.log("middleware listenAgentEvent", {
|
|
12989
14356
|
clientId: clientId,
|
|
12990
14357
|
});
|
|
12991
|
-
validateClientId$
|
|
14358
|
+
validateClientId$e(clientId);
|
|
12992
14359
|
return swarm$1.busService.subscribe(clientId, "agent-bus", functoolsKit.queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
12993
14360
|
switch (_a.label) {
|
|
12994
14361
|
case 0: return [4 /*yield*/, fn(e)];
|
|
12995
14362
|
case 1: return [2 /*return*/, _a.sent()];
|
|
12996
14363
|
}
|
|
12997
14364
|
}); }); }));
|
|
12998
|
-
};
|
|
14365
|
+
});
|
|
12999
14366
|
|
|
13000
|
-
var validateClientId$
|
|
14367
|
+
var validateClientId$d = function (clientId) {
|
|
13001
14368
|
if (clientId === "*") {
|
|
13002
14369
|
return;
|
|
13003
14370
|
}
|
|
@@ -13011,20 +14378,20 @@ var validateClientId$b = function (clientId) {
|
|
|
13011
14378
|
* @param {string} clientId - The ID of the client to subscribe to.
|
|
13012
14379
|
* @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
|
|
13013
14380
|
*/
|
|
13014
|
-
var listenHistoryEvent = function (clientId, fn) {
|
|
14381
|
+
var listenHistoryEvent = beginContext(function (clientId, fn) {
|
|
13015
14382
|
swarm$1.loggerService.log("middleware listenHistoryEvent", {
|
|
13016
14383
|
clientId: clientId,
|
|
13017
14384
|
});
|
|
13018
|
-
validateClientId$
|
|
14385
|
+
validateClientId$d(clientId);
|
|
13019
14386
|
return swarm$1.busService.subscribe(clientId, "history-bus", functoolsKit.queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
13020
14387
|
switch (_a.label) {
|
|
13021
14388
|
case 0: return [4 /*yield*/, fn(e)];
|
|
13022
14389
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13023
14390
|
}
|
|
13024
14391
|
}); }); }));
|
|
13025
|
-
};
|
|
14392
|
+
});
|
|
13026
14393
|
|
|
13027
|
-
var validateClientId$
|
|
14394
|
+
var validateClientId$c = function (clientId) {
|
|
13028
14395
|
if (clientId === "*") {
|
|
13029
14396
|
return;
|
|
13030
14397
|
}
|
|
@@ -13038,20 +14405,20 @@ var validateClientId$a = function (clientId) {
|
|
|
13038
14405
|
* @param {string} clientId - The ID of the client to subscribe to session events for.
|
|
13039
14406
|
* @param {function} fn - The callback function to handle the session events.
|
|
13040
14407
|
*/
|
|
13041
|
-
var listenSessionEvent = function (clientId, fn) {
|
|
14408
|
+
var listenSessionEvent = beginContext(function (clientId, fn) {
|
|
13042
14409
|
swarm$1.loggerService.log("middleware listenSessionEvent", {
|
|
13043
14410
|
clientId: clientId,
|
|
13044
14411
|
});
|
|
13045
|
-
validateClientId$
|
|
14412
|
+
validateClientId$c(clientId);
|
|
13046
14413
|
return swarm$1.busService.subscribe(clientId, "session-bus", functoolsKit.queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
13047
14414
|
switch (_a.label) {
|
|
13048
14415
|
case 0: return [4 /*yield*/, fn(e)];
|
|
13049
14416
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13050
14417
|
}
|
|
13051
14418
|
}); }); }));
|
|
13052
|
-
};
|
|
14419
|
+
});
|
|
13053
14420
|
|
|
13054
|
-
var validateClientId$
|
|
14421
|
+
var validateClientId$b = function (clientId) {
|
|
13055
14422
|
if (clientId === "*") {
|
|
13056
14423
|
return;
|
|
13057
14424
|
}
|
|
@@ -13065,20 +14432,20 @@ var validateClientId$9 = function (clientId) {
|
|
|
13065
14432
|
* @param {string} clientId - The ID of the client to subscribe to.
|
|
13066
14433
|
* @param {function} fn - The callback function to handle the event.
|
|
13067
14434
|
*/
|
|
13068
|
-
var listenStateEvent = function (clientId, fn) {
|
|
14435
|
+
var listenStateEvent = beginContext(function (clientId, fn) {
|
|
13069
14436
|
swarm$1.loggerService.log("middleware listenStateEvent", {
|
|
13070
14437
|
clientId: clientId,
|
|
13071
14438
|
});
|
|
13072
|
-
validateClientId$
|
|
14439
|
+
validateClientId$b(clientId);
|
|
13073
14440
|
return swarm$1.busService.subscribe(clientId, "state-bus", functoolsKit.queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
13074
14441
|
switch (_a.label) {
|
|
13075
14442
|
case 0: return [4 /*yield*/, fn(e)];
|
|
13076
14443
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13077
14444
|
}
|
|
13078
14445
|
}); }); }));
|
|
13079
|
-
};
|
|
14446
|
+
});
|
|
13080
14447
|
|
|
13081
|
-
var validateClientId$
|
|
14448
|
+
var validateClientId$a = function (clientId) {
|
|
13082
14449
|
if (clientId === "*") {
|
|
13083
14450
|
return;
|
|
13084
14451
|
}
|
|
@@ -13092,20 +14459,20 @@ var validateClientId$8 = function (clientId) {
|
|
|
13092
14459
|
* @param {string} clientId - The ID of the client to subscribe to storage events for.
|
|
13093
14460
|
* @param {function} fn - The callback function to handle the storage event.
|
|
13094
14461
|
*/
|
|
13095
|
-
var listenStorageEvent = function (clientId, fn) {
|
|
14462
|
+
var listenStorageEvent = beginContext(function (clientId, fn) {
|
|
13096
14463
|
swarm$1.loggerService.log("middleware listenStorageEvent", {
|
|
13097
14464
|
clientId: clientId,
|
|
13098
14465
|
});
|
|
13099
|
-
validateClientId$
|
|
14466
|
+
validateClientId$a(clientId);
|
|
13100
14467
|
return swarm$1.busService.subscribe(clientId, "storage-bus", functoolsKit.queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
13101
14468
|
switch (_a.label) {
|
|
13102
14469
|
case 0: return [4 /*yield*/, fn(e)];
|
|
13103
14470
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13104
14471
|
}
|
|
13105
14472
|
}); }); }));
|
|
13106
|
-
};
|
|
14473
|
+
});
|
|
13107
14474
|
|
|
13108
|
-
var validateClientId$
|
|
14475
|
+
var validateClientId$9 = function (clientId) {
|
|
13109
14476
|
if (clientId === "*") {
|
|
13110
14477
|
return;
|
|
13111
14478
|
}
|
|
@@ -13119,20 +14486,47 @@ var validateClientId$7 = function (clientId) {
|
|
|
13119
14486
|
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
13120
14487
|
* @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
|
|
13121
14488
|
*/
|
|
13122
|
-
var listenSwarmEvent = function (clientId, fn) {
|
|
14489
|
+
var listenSwarmEvent = beginContext(function (clientId, fn) {
|
|
13123
14490
|
swarm$1.loggerService.log("middleware listenSwarmEvent", {
|
|
13124
14491
|
clientId: clientId,
|
|
13125
14492
|
});
|
|
13126
|
-
validateClientId$
|
|
14493
|
+
validateClientId$9(clientId);
|
|
13127
14494
|
return swarm$1.busService.subscribe(clientId, "swarm-bus", functoolsKit.queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
13128
14495
|
switch (_a.label) {
|
|
13129
14496
|
case 0: return [4 /*yield*/, fn(e)];
|
|
13130
14497
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13131
14498
|
}
|
|
13132
14499
|
}); }); }));
|
|
14500
|
+
});
|
|
14501
|
+
|
|
14502
|
+
var validateClientId$8 = function (clientId) {
|
|
14503
|
+
if (clientId === "*") {
|
|
14504
|
+
return;
|
|
14505
|
+
}
|
|
14506
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
14507
|
+
throw new Error("agent-swarm listenPolicyEvent session not found for clientId=".concat(clientId));
|
|
14508
|
+
}
|
|
13133
14509
|
};
|
|
14510
|
+
/**
|
|
14511
|
+
* Hook to subscribe to swarm events for a specific client.
|
|
14512
|
+
*
|
|
14513
|
+
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
14514
|
+
* @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
|
|
14515
|
+
*/
|
|
14516
|
+
var listenPolicyEvent = beginContext(function (clientId, fn) {
|
|
14517
|
+
swarm$1.loggerService.log("middleware listenPolicyEvent", {
|
|
14518
|
+
clientId: clientId,
|
|
14519
|
+
});
|
|
14520
|
+
validateClientId$8(clientId);
|
|
14521
|
+
return swarm$1.busService.subscribe(clientId, "policy-bus", functoolsKit.queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
14522
|
+
switch (_a.label) {
|
|
14523
|
+
case 0: return [4 /*yield*/, fn(e)];
|
|
14524
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
14525
|
+
}
|
|
14526
|
+
}); }); }));
|
|
14527
|
+
});
|
|
13134
14528
|
|
|
13135
|
-
var validateClientId$
|
|
14529
|
+
var validateClientId$7 = function (clientId) {
|
|
13136
14530
|
if (clientId === "*") {
|
|
13137
14531
|
return;
|
|
13138
14532
|
}
|
|
@@ -13146,20 +14540,20 @@ var validateClientId$6 = function (clientId) {
|
|
|
13146
14540
|
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
13147
14541
|
* @param {function} fn - The callback function to handle the event.
|
|
13148
14542
|
*/
|
|
13149
|
-
var listenAgentEventOnce = function (clientId, filterFn, fn) {
|
|
14543
|
+
var listenAgentEventOnce = beginContext(function (clientId, filterFn, fn) {
|
|
13150
14544
|
swarm$1.loggerService.log("middleware listenAgentEventOnce", {
|
|
13151
14545
|
clientId: clientId,
|
|
13152
14546
|
});
|
|
13153
|
-
validateClientId$
|
|
14547
|
+
validateClientId$7(clientId);
|
|
13154
14548
|
return swarm$1.busService.once(clientId, "agent-bus", filterFn, functoolsKit.queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
13155
14549
|
switch (_a.label) {
|
|
13156
14550
|
case 0: return [4 /*yield*/, fn(e)];
|
|
13157
14551
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13158
14552
|
}
|
|
13159
14553
|
}); }); }));
|
|
13160
|
-
};
|
|
14554
|
+
});
|
|
13161
14555
|
|
|
13162
|
-
var validateClientId$
|
|
14556
|
+
var validateClientId$6 = function (clientId) {
|
|
13163
14557
|
if (clientId === "*") {
|
|
13164
14558
|
return;
|
|
13165
14559
|
}
|
|
@@ -13173,20 +14567,20 @@ var validateClientId$5 = function (clientId) {
|
|
|
13173
14567
|
* @param {string} clientId - The ID of the client to subscribe to.
|
|
13174
14568
|
* @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
|
|
13175
14569
|
*/
|
|
13176
|
-
var listenHistoryEventOnce = function (clientId, filterFn, fn) {
|
|
14570
|
+
var listenHistoryEventOnce = beginContext(function (clientId, filterFn, fn) {
|
|
13177
14571
|
swarm$1.loggerService.log("middleware listenHistoryEventOnce", {
|
|
13178
14572
|
clientId: clientId,
|
|
13179
14573
|
});
|
|
13180
|
-
validateClientId$
|
|
14574
|
+
validateClientId$6(clientId);
|
|
13181
14575
|
return swarm$1.busService.once(clientId, "history-bus", filterFn, functoolsKit.queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
13182
14576
|
switch (_a.label) {
|
|
13183
14577
|
case 0: return [4 /*yield*/, fn(e)];
|
|
13184
14578
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13185
14579
|
}
|
|
13186
14580
|
}); }); }));
|
|
13187
|
-
};
|
|
14581
|
+
});
|
|
13188
14582
|
|
|
13189
|
-
var validateClientId$
|
|
14583
|
+
var validateClientId$5 = function (clientId) {
|
|
13190
14584
|
if (clientId === "*") {
|
|
13191
14585
|
return;
|
|
13192
14586
|
}
|
|
@@ -13200,20 +14594,20 @@ var validateClientId$4 = function (clientId) {
|
|
|
13200
14594
|
* @param {string} clientId - The ID of the client to subscribe to session events for.
|
|
13201
14595
|
* @param {function} fn - The callback function to handle the session events.
|
|
13202
14596
|
*/
|
|
13203
|
-
var listenSessionEventOnce = function (clientId, filterFn, fn) {
|
|
14597
|
+
var listenSessionEventOnce = beginContext(function (clientId, filterFn, fn) {
|
|
13204
14598
|
swarm$1.loggerService.log("middleware listenSessionEventOnce", {
|
|
13205
14599
|
clientId: clientId,
|
|
13206
14600
|
});
|
|
13207
|
-
validateClientId$
|
|
14601
|
+
validateClientId$5(clientId);
|
|
13208
14602
|
return swarm$1.busService.once(clientId, "session-bus", filterFn, functoolsKit.queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
13209
14603
|
switch (_a.label) {
|
|
13210
14604
|
case 0: return [4 /*yield*/, fn(e)];
|
|
13211
14605
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13212
14606
|
}
|
|
13213
14607
|
}); }); }));
|
|
13214
|
-
};
|
|
14608
|
+
});
|
|
13215
14609
|
|
|
13216
|
-
var validateClientId$
|
|
14610
|
+
var validateClientId$4 = function (clientId) {
|
|
13217
14611
|
if (clientId === "*") {
|
|
13218
14612
|
return;
|
|
13219
14613
|
}
|
|
@@ -13227,20 +14621,20 @@ var validateClientId$3 = function (clientId) {
|
|
|
13227
14621
|
* @param {string} clientId - The ID of the client to subscribe to.
|
|
13228
14622
|
* @param {function} fn - The callback function to handle the event.
|
|
13229
14623
|
*/
|
|
13230
|
-
var listenStateEventOnce = function (clientId, filterFn, fn) {
|
|
14624
|
+
var listenStateEventOnce = beginContext(function (clientId, filterFn, fn) {
|
|
13231
14625
|
swarm$1.loggerService.log("middleware listenStateEventOnce", {
|
|
13232
14626
|
clientId: clientId,
|
|
13233
14627
|
});
|
|
13234
|
-
validateClientId$
|
|
14628
|
+
validateClientId$4(clientId);
|
|
13235
14629
|
return swarm$1.busService.once(clientId, "state-bus", filterFn, functoolsKit.queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
13236
14630
|
switch (_a.label) {
|
|
13237
14631
|
case 0: return [4 /*yield*/, fn(e)];
|
|
13238
14632
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13239
14633
|
}
|
|
13240
14634
|
}); }); }));
|
|
13241
|
-
};
|
|
14635
|
+
});
|
|
13242
14636
|
|
|
13243
|
-
var validateClientId$
|
|
14637
|
+
var validateClientId$3 = function (clientId) {
|
|
13244
14638
|
if (clientId === "*") {
|
|
13245
14639
|
return;
|
|
13246
14640
|
}
|
|
@@ -13254,20 +14648,20 @@ var validateClientId$2 = function (clientId) {
|
|
|
13254
14648
|
* @param {string} clientId - The ID of the client to subscribe to storage events for.
|
|
13255
14649
|
* @param {function} fn - The callback function to handle the storage event.
|
|
13256
14650
|
*/
|
|
13257
|
-
var listenStorageEventOnce = function (clientId, filterFn, fn) {
|
|
14651
|
+
var listenStorageEventOnce = beginContext(function (clientId, filterFn, fn) {
|
|
13258
14652
|
swarm$1.loggerService.log("middleware listenStorageEventOnce", {
|
|
13259
14653
|
clientId: clientId,
|
|
13260
14654
|
});
|
|
13261
|
-
validateClientId$
|
|
14655
|
+
validateClientId$3(clientId);
|
|
13262
14656
|
return swarm$1.busService.once(clientId, "storage-bus", filterFn, functoolsKit.queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
13263
14657
|
switch (_a.label) {
|
|
13264
14658
|
case 0: return [4 /*yield*/, fn(e)];
|
|
13265
14659
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13266
14660
|
}
|
|
13267
14661
|
}); }); }));
|
|
13268
|
-
};
|
|
14662
|
+
});
|
|
13269
14663
|
|
|
13270
|
-
var validateClientId$
|
|
14664
|
+
var validateClientId$2 = function (clientId) {
|
|
13271
14665
|
if (clientId === "*") {
|
|
13272
14666
|
return;
|
|
13273
14667
|
}
|
|
@@ -13281,20 +14675,20 @@ var validateClientId$1 = function (clientId) {
|
|
|
13281
14675
|
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
13282
14676
|
* @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
|
|
13283
14677
|
*/
|
|
13284
|
-
var listenSwarmEventOnce = function (clientId, filterFn, fn) {
|
|
14678
|
+
var listenSwarmEventOnce = beginContext(function (clientId, filterFn, fn) {
|
|
13285
14679
|
swarm$1.loggerService.log("middleware listenSwarmEventOnce", {
|
|
13286
14680
|
clientId: clientId,
|
|
13287
14681
|
});
|
|
13288
|
-
validateClientId$
|
|
14682
|
+
validateClientId$2(clientId);
|
|
13289
14683
|
return swarm$1.busService.once(clientId, "swarm-bus", filterFn, functoolsKit.queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
13290
14684
|
switch (_a.label) {
|
|
13291
14685
|
case 0: return [4 /*yield*/, fn(e)];
|
|
13292
14686
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13293
14687
|
}
|
|
13294
14688
|
}); }); }));
|
|
13295
|
-
};
|
|
14689
|
+
});
|
|
13296
14690
|
|
|
13297
|
-
var validateClientId = function (clientId) {
|
|
14691
|
+
var validateClientId$1 = function (clientId) {
|
|
13298
14692
|
if (clientId === "*") {
|
|
13299
14693
|
return;
|
|
13300
14694
|
}
|
|
@@ -13308,18 +14702,45 @@ var validateClientId = function (clientId) {
|
|
|
13308
14702
|
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
13309
14703
|
* @param {function} fn - The callback function to handle the event.
|
|
13310
14704
|
*/
|
|
13311
|
-
var listenExecutionEventOnce = function (clientId, filterFn, fn) {
|
|
14705
|
+
var listenExecutionEventOnce = beginContext(function (clientId, filterFn, fn) {
|
|
13312
14706
|
swarm$1.loggerService.log("middleware listenExecutionEventOnce", {
|
|
13313
14707
|
clientId: clientId,
|
|
13314
14708
|
});
|
|
13315
|
-
validateClientId(clientId);
|
|
14709
|
+
validateClientId$1(clientId);
|
|
13316
14710
|
return swarm$1.busService.once(clientId, "execution-bus", filterFn, functoolsKit.queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
13317
14711
|
switch (_a.label) {
|
|
13318
14712
|
case 0: return [4 /*yield*/, fn(e)];
|
|
13319
14713
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13320
14714
|
}
|
|
13321
14715
|
}); }); }));
|
|
14716
|
+
});
|
|
14717
|
+
|
|
14718
|
+
var validateClientId = function (clientId) {
|
|
14719
|
+
if (clientId === "*") {
|
|
14720
|
+
return;
|
|
14721
|
+
}
|
|
14722
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
14723
|
+
throw new Error("agent-swarm listenPolicyEventOnce session not found for clientId=".concat(clientId));
|
|
14724
|
+
}
|
|
13322
14725
|
};
|
|
14726
|
+
/**
|
|
14727
|
+
* Hook to subscribe to swarm events for a specific client.
|
|
14728
|
+
*
|
|
14729
|
+
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
14730
|
+
* @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
|
|
14731
|
+
*/
|
|
14732
|
+
var listenPolicyEventOnce = beginContext(function (clientId, filterFn, fn) {
|
|
14733
|
+
swarm$1.loggerService.log("middleware listenPolicyEventOnce", {
|
|
14734
|
+
clientId: clientId,
|
|
14735
|
+
});
|
|
14736
|
+
validateClientId(clientId);
|
|
14737
|
+
return swarm$1.busService.once(clientId, "policy-bus", filterFn, functoolsKit.queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
14738
|
+
switch (_a.label) {
|
|
14739
|
+
case 0: return [4 /*yield*/, fn(e)];
|
|
14740
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
14741
|
+
}
|
|
14742
|
+
}); }); }));
|
|
14743
|
+
});
|
|
13323
14744
|
|
|
13324
14745
|
var METHOD_NAME_GET$3 = "StateUtils.getState";
|
|
13325
14746
|
var METHOD_NAME_SET$1 = "StateUtils.setState";
|
|
@@ -13341,7 +14762,7 @@ var StateUtils = /** @class */ (function () {
|
|
|
13341
14762
|
* @returns {Promise<T>} The state data.
|
|
13342
14763
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
13343
14764
|
*/
|
|
13344
|
-
this.getState = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
14765
|
+
this.getState = beginContext(function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
13345
14766
|
return __generator(this, function (_a) {
|
|
13346
14767
|
switch (_a.label) {
|
|
13347
14768
|
case 0:
|
|
@@ -13358,7 +14779,7 @@ var StateUtils = /** @class */ (function () {
|
|
|
13358
14779
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13359
14780
|
}
|
|
13360
14781
|
});
|
|
13361
|
-
}); };
|
|
14782
|
+
}); });
|
|
13362
14783
|
/**
|
|
13363
14784
|
* Sets the state for a given client and state name.
|
|
13364
14785
|
* @template T
|
|
@@ -13370,7 +14791,7 @@ var StateUtils = /** @class */ (function () {
|
|
|
13370
14791
|
* @returns {Promise<void>}
|
|
13371
14792
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
13372
14793
|
*/
|
|
13373
|
-
this.setState = function (dispatchFn, payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
14794
|
+
this.setState = beginContext(function (dispatchFn, payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
13374
14795
|
var _this = this;
|
|
13375
14796
|
return __generator(this, function (_a) {
|
|
13376
14797
|
switch (_a.label) {
|
|
@@ -13393,7 +14814,7 @@ var StateUtils = /** @class */ (function () {
|
|
|
13393
14814
|
case 3: return [2 /*return*/, _a.sent()];
|
|
13394
14815
|
}
|
|
13395
14816
|
});
|
|
13396
|
-
}); };
|
|
14817
|
+
}); });
|
|
13397
14818
|
/**
|
|
13398
14819
|
* Set the state to initial value
|
|
13399
14820
|
* @template T
|
|
@@ -13404,7 +14825,7 @@ var StateUtils = /** @class */ (function () {
|
|
|
13404
14825
|
* @returns {Promise<void>}
|
|
13405
14826
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
13406
14827
|
*/
|
|
13407
|
-
this.clearState = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
14828
|
+
this.clearState = beginContext(function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
13408
14829
|
return __generator(this, function (_a) {
|
|
13409
14830
|
switch (_a.label) {
|
|
13410
14831
|
case 0:
|
|
@@ -13421,7 +14842,7 @@ var StateUtils = /** @class */ (function () {
|
|
|
13421
14842
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13422
14843
|
}
|
|
13423
14844
|
});
|
|
13424
|
-
}); };
|
|
14845
|
+
}); });
|
|
13425
14846
|
}
|
|
13426
14847
|
return StateUtils;
|
|
13427
14848
|
}());
|
|
@@ -13449,7 +14870,7 @@ var SharedStateUtils = /** @class */ (function () {
|
|
|
13449
14870
|
* @returns {Promise<T>} The state data.
|
|
13450
14871
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
13451
14872
|
*/
|
|
13452
|
-
this.getState = function (stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
14873
|
+
this.getState = beginContext(function (stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
13453
14874
|
return __generator(this, function (_a) {
|
|
13454
14875
|
switch (_a.label) {
|
|
13455
14876
|
case 0:
|
|
@@ -13461,7 +14882,7 @@ var SharedStateUtils = /** @class */ (function () {
|
|
|
13461
14882
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13462
14883
|
}
|
|
13463
14884
|
});
|
|
13464
|
-
}); };
|
|
14885
|
+
}); });
|
|
13465
14886
|
/**
|
|
13466
14887
|
* Sets the state for a given client and state name.
|
|
13467
14888
|
* @template T
|
|
@@ -13470,7 +14891,7 @@ var SharedStateUtils = /** @class */ (function () {
|
|
|
13470
14891
|
* @returns {Promise<void>}
|
|
13471
14892
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
13472
14893
|
*/
|
|
13473
|
-
this.setState = function (dispatchFn, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
14894
|
+
this.setState = beginContext(function (dispatchFn, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
13474
14895
|
var _this = this;
|
|
13475
14896
|
return __generator(this, function (_a) {
|
|
13476
14897
|
switch (_a.label) {
|
|
@@ -13488,7 +14909,7 @@ var SharedStateUtils = /** @class */ (function () {
|
|
|
13488
14909
|
case 3: return [2 /*return*/, _a.sent()];
|
|
13489
14910
|
}
|
|
13490
14911
|
});
|
|
13491
|
-
}); };
|
|
14912
|
+
}); });
|
|
13492
14913
|
/**
|
|
13493
14914
|
* Set the state to initial value
|
|
13494
14915
|
* @template T
|
|
@@ -13496,7 +14917,7 @@ var SharedStateUtils = /** @class */ (function () {
|
|
|
13496
14917
|
* @returns {Promise<void>}
|
|
13497
14918
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
13498
14919
|
*/
|
|
13499
|
-
this.clearState = function (stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
14920
|
+
this.clearState = beginContext(function (stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
13500
14921
|
return __generator(this, function (_a) {
|
|
13501
14922
|
switch (_a.label) {
|
|
13502
14923
|
case 0:
|
|
@@ -13508,7 +14929,7 @@ var SharedStateUtils = /** @class */ (function () {
|
|
|
13508
14929
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13509
14930
|
}
|
|
13510
14931
|
});
|
|
13511
|
-
}); };
|
|
14932
|
+
}); });
|
|
13512
14933
|
}
|
|
13513
14934
|
return SharedStateUtils;
|
|
13514
14935
|
}());
|
|
@@ -13537,7 +14958,7 @@ var StorageUtils = /** @class */ (function () {
|
|
|
13537
14958
|
* @returns {Promise<T[]>} - A promise that resolves to an array of items.
|
|
13538
14959
|
* @template T
|
|
13539
14960
|
*/
|
|
13540
|
-
this.take = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
14961
|
+
this.take = beginContext(function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
13541
14962
|
return __generator(this, function (_a) {
|
|
13542
14963
|
switch (_a.label) {
|
|
13543
14964
|
case 0:
|
|
@@ -13555,10 +14976,10 @@ var StorageUtils = /** @class */ (function () {
|
|
|
13555
14976
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (take)"));
|
|
13556
14977
|
}
|
|
13557
14978
|
return [4 /*yield*/, swarm$1.storagePublicService.take(payload.search, payload.total, METHOD_NAME_TAKE$1, payload.clientId, payload.storageName, payload.score)];
|
|
13558
|
-
case 1: return [2 /*return*/,
|
|
14979
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
13559
14980
|
}
|
|
13560
14981
|
});
|
|
13561
|
-
}); };
|
|
14982
|
+
}); });
|
|
13562
14983
|
/**
|
|
13563
14984
|
* Upserts an item in the storage.
|
|
13564
14985
|
* @param {T} item - The item to upsert.
|
|
@@ -13568,7 +14989,7 @@ var StorageUtils = /** @class */ (function () {
|
|
|
13568
14989
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
13569
14990
|
* @template T
|
|
13570
14991
|
*/
|
|
13571
|
-
this.upsert = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
14992
|
+
this.upsert = beginContext(function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
13572
14993
|
return __generator(this, function (_a) {
|
|
13573
14994
|
switch (_a.label) {
|
|
13574
14995
|
case 0:
|
|
@@ -13587,7 +15008,7 @@ var StorageUtils = /** @class */ (function () {
|
|
|
13587
15008
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13588
15009
|
}
|
|
13589
15010
|
});
|
|
13590
|
-
}); };
|
|
15011
|
+
}); });
|
|
13591
15012
|
/**
|
|
13592
15013
|
* Removes an item from the storage.
|
|
13593
15014
|
* @param {IStorageData["id"]} itemId - The ID of the item to remove.
|
|
@@ -13596,7 +15017,7 @@ var StorageUtils = /** @class */ (function () {
|
|
|
13596
15017
|
* @param {StorageName} storageName - The storage name.
|
|
13597
15018
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
13598
15019
|
*/
|
|
13599
|
-
this.remove = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
15020
|
+
this.remove = beginContext(function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
13600
15021
|
return __generator(this, function (_a) {
|
|
13601
15022
|
switch (_a.label) {
|
|
13602
15023
|
case 0:
|
|
@@ -13615,7 +15036,7 @@ var StorageUtils = /** @class */ (function () {
|
|
|
13615
15036
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13616
15037
|
}
|
|
13617
15038
|
});
|
|
13618
|
-
}); };
|
|
15039
|
+
}); });
|
|
13619
15040
|
/**
|
|
13620
15041
|
* Gets an item from the storage.
|
|
13621
15042
|
* @param {IStorageData["id"]} itemId - The ID of the item to get.
|
|
@@ -13625,7 +15046,7 @@ var StorageUtils = /** @class */ (function () {
|
|
|
13625
15046
|
* @returns {Promise<T | null>} - A promise that resolves to the item or null if not found.
|
|
13626
15047
|
* @template T
|
|
13627
15048
|
*/
|
|
13628
|
-
this.get = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
15049
|
+
this.get = beginContext(function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
13629
15050
|
return __generator(this, function (_a) {
|
|
13630
15051
|
switch (_a.label) {
|
|
13631
15052
|
case 0:
|
|
@@ -13640,10 +15061,10 @@ var StorageUtils = /** @class */ (function () {
|
|
|
13640
15061
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (get)"));
|
|
13641
15062
|
}
|
|
13642
15063
|
return [4 /*yield*/, swarm$1.storagePublicService.get(payload.itemId, METHOD_NAME_GET$1, payload.clientId, payload.storageName)];
|
|
13643
|
-
case 1: return [2 /*return*/,
|
|
15064
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
13644
15065
|
}
|
|
13645
15066
|
});
|
|
13646
|
-
}); };
|
|
15067
|
+
}); });
|
|
13647
15068
|
/**
|
|
13648
15069
|
* Lists items from the storage.
|
|
13649
15070
|
* @param {string} clientId - The client ID.
|
|
@@ -13653,7 +15074,7 @@ var StorageUtils = /** @class */ (function () {
|
|
|
13653
15074
|
* @returns {Promise<T[]>} - A promise that resolves to an array of items.
|
|
13654
15075
|
* @template T
|
|
13655
15076
|
*/
|
|
13656
|
-
this.list = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
15077
|
+
this.list = beginContext(function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
13657
15078
|
return __generator(this, function (_a) {
|
|
13658
15079
|
switch (_a.label) {
|
|
13659
15080
|
case 0:
|
|
@@ -13667,10 +15088,10 @@ var StorageUtils = /** @class */ (function () {
|
|
|
13667
15088
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (list)"));
|
|
13668
15089
|
}
|
|
13669
15090
|
return [4 /*yield*/, swarm$1.storagePublicService.list(METHOD_NAME_LIST$1, payload.clientId, payload.storageName, payload.filter)];
|
|
13670
|
-
case 1: return [2 /*return*/,
|
|
15091
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
13671
15092
|
}
|
|
13672
15093
|
});
|
|
13673
|
-
}); };
|
|
15094
|
+
}); });
|
|
13674
15095
|
/**
|
|
13675
15096
|
* Clears the storage.
|
|
13676
15097
|
* @param {string} clientId - The client ID.
|
|
@@ -13678,7 +15099,7 @@ var StorageUtils = /** @class */ (function () {
|
|
|
13678
15099
|
* @param {StorageName} storageName - The storage name.
|
|
13679
15100
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
13680
15101
|
*/
|
|
13681
|
-
this.clear = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
15102
|
+
this.clear = beginContext(function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
13682
15103
|
return __generator(this, function (_a) {
|
|
13683
15104
|
switch (_a.label) {
|
|
13684
15105
|
case 0:
|
|
@@ -13695,7 +15116,7 @@ var StorageUtils = /** @class */ (function () {
|
|
|
13695
15116
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13696
15117
|
}
|
|
13697
15118
|
});
|
|
13698
|
-
}); };
|
|
15119
|
+
}); });
|
|
13699
15120
|
}
|
|
13700
15121
|
return StorageUtils;
|
|
13701
15122
|
}());
|
|
@@ -13718,7 +15139,7 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
13718
15139
|
* @returns {Promise<T[]>} - A promise that resolves to an array of items.
|
|
13719
15140
|
* @template T
|
|
13720
15141
|
*/
|
|
13721
|
-
this.take = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
15142
|
+
this.take = beginContext(function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
13722
15143
|
return __generator(this, function (_a) {
|
|
13723
15144
|
switch (_a.label) {
|
|
13724
15145
|
case 0:
|
|
@@ -13731,10 +15152,10 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
13731
15152
|
});
|
|
13732
15153
|
swarm$1.storageValidationService.validate(payload.storageName, METHOD_NAME_TAKE);
|
|
13733
15154
|
return [4 /*yield*/, swarm$1.sharedStoragePublicService.take(payload.search, payload.total, METHOD_NAME_TAKE, payload.storageName, payload.score)];
|
|
13734
|
-
case 1: return [2 /*return*/,
|
|
15155
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
13735
15156
|
}
|
|
13736
15157
|
});
|
|
13737
|
-
}); };
|
|
15158
|
+
}); });
|
|
13738
15159
|
/**
|
|
13739
15160
|
* Upserts an item in the storage.
|
|
13740
15161
|
* @param {T} item - The item to upsert.
|
|
@@ -13742,7 +15163,7 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
13742
15163
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
13743
15164
|
* @template T
|
|
13744
15165
|
*/
|
|
13745
|
-
this.upsert = function (item, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
15166
|
+
this.upsert = beginContext(function (item, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
13746
15167
|
return __generator(this, function (_a) {
|
|
13747
15168
|
switch (_a.label) {
|
|
13748
15169
|
case 0:
|
|
@@ -13756,14 +15177,14 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
13756
15177
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13757
15178
|
}
|
|
13758
15179
|
});
|
|
13759
|
-
}); };
|
|
15180
|
+
}); });
|
|
13760
15181
|
/**
|
|
13761
15182
|
* Removes an item from the storage.
|
|
13762
15183
|
* @param {IStorageData["id"]} itemId - The ID of the item to remove.
|
|
13763
15184
|
* @param {StorageName} storageName - The storage name.
|
|
13764
15185
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
13765
15186
|
*/
|
|
13766
|
-
this.remove = function (itemId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
15187
|
+
this.remove = beginContext(function (itemId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
13767
15188
|
return __generator(this, function (_a) {
|
|
13768
15189
|
switch (_a.label) {
|
|
13769
15190
|
case 0:
|
|
@@ -13777,7 +15198,7 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
13777
15198
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13778
15199
|
}
|
|
13779
15200
|
});
|
|
13780
|
-
}); };
|
|
15201
|
+
}); });
|
|
13781
15202
|
/**
|
|
13782
15203
|
* Gets an item from the storage.
|
|
13783
15204
|
* @param {IStorageData["id"]} itemId - The ID of the item to get.
|
|
@@ -13785,7 +15206,7 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
13785
15206
|
* @returns {Promise<T | null>} - A promise that resolves to the item or null if not found.
|
|
13786
15207
|
* @template T
|
|
13787
15208
|
*/
|
|
13788
|
-
this.get = function (itemId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
15209
|
+
this.get = beginContext(function (itemId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
13789
15210
|
return __generator(this, function (_a) {
|
|
13790
15211
|
switch (_a.label) {
|
|
13791
15212
|
case 0:
|
|
@@ -13796,10 +15217,10 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
13796
15217
|
});
|
|
13797
15218
|
swarm$1.storageValidationService.validate(storageName, METHOD_NAME_GET);
|
|
13798
15219
|
return [4 /*yield*/, swarm$1.sharedStoragePublicService.get(itemId, METHOD_NAME_GET, storageName)];
|
|
13799
|
-
case 1: return [2 /*return*/,
|
|
15220
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
13800
15221
|
}
|
|
13801
15222
|
});
|
|
13802
|
-
}); };
|
|
15223
|
+
}); });
|
|
13803
15224
|
/**
|
|
13804
15225
|
* Lists items from the storage.
|
|
13805
15226
|
* @param {StorageName} storageName - The storage name.
|
|
@@ -13807,7 +15228,7 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
13807
15228
|
* @returns {Promise<T[]>} - A promise that resolves to an array of items.
|
|
13808
15229
|
* @template T
|
|
13809
15230
|
*/
|
|
13810
|
-
this.list = function (storageName, filter) { return __awaiter(_this, void 0, void 0, function () {
|
|
15231
|
+
this.list = beginContext(function (storageName, filter) { return __awaiter(_this, void 0, void 0, function () {
|
|
13811
15232
|
return __generator(this, function (_a) {
|
|
13812
15233
|
switch (_a.label) {
|
|
13813
15234
|
case 0:
|
|
@@ -13817,16 +15238,16 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
13817
15238
|
});
|
|
13818
15239
|
swarm$1.storageValidationService.validate(storageName, METHOD_NAME_LIST);
|
|
13819
15240
|
return [4 /*yield*/, swarm$1.sharedStoragePublicService.list(METHOD_NAME_LIST, storageName, filter)];
|
|
13820
|
-
case 1: return [2 /*return*/,
|
|
15241
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
13821
15242
|
}
|
|
13822
15243
|
});
|
|
13823
|
-
}); };
|
|
15244
|
+
}); });
|
|
13824
15245
|
/**
|
|
13825
15246
|
* Clears the storage.
|
|
13826
15247
|
* @param {StorageName} storageName - The storage name.
|
|
13827
15248
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
13828
15249
|
*/
|
|
13829
|
-
this.clear = function (storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
15250
|
+
this.clear = beginContext(function (storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
13830
15251
|
return __generator(this, function (_a) {
|
|
13831
15252
|
switch (_a.label) {
|
|
13832
15253
|
case 0:
|
|
@@ -13839,7 +15260,7 @@ var SharedStorageUtils = /** @class */ (function () {
|
|
|
13839
15260
|
case 1: return [2 /*return*/, _a.sent()];
|
|
13840
15261
|
}
|
|
13841
15262
|
});
|
|
13842
|
-
}); };
|
|
15263
|
+
}); });
|
|
13843
15264
|
}
|
|
13844
15265
|
return SharedStorageUtils;
|
|
13845
15266
|
}());
|
|
@@ -13895,7 +15316,7 @@ var SchemaUtils = /** @class */ (function () {
|
|
|
13895
15316
|
* @param {T} value - The value to write to the session memory.
|
|
13896
15317
|
* @returns {T} The actual value from the session memory.
|
|
13897
15318
|
*/
|
|
13898
|
-
this.writeSessionMemory = function (clientId, value) {
|
|
15319
|
+
this.writeSessionMemory = beginContext(function (clientId, value) {
|
|
13899
15320
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13900
15321
|
swarm$1.loggerService.log(METHOD_NAME_WRITE, {
|
|
13901
15322
|
clientId: clientId,
|
|
@@ -13903,7 +15324,7 @@ var SchemaUtils = /** @class */ (function () {
|
|
|
13903
15324
|
});
|
|
13904
15325
|
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME_WRITE);
|
|
13905
15326
|
return swarm$1.memorySchemaService.writeValue(clientId, value);
|
|
13906
|
-
};
|
|
15327
|
+
});
|
|
13907
15328
|
/**
|
|
13908
15329
|
* Reads a value from the session memory for a given client.
|
|
13909
15330
|
*
|
|
@@ -13911,14 +15332,14 @@ var SchemaUtils = /** @class */ (function () {
|
|
|
13911
15332
|
* @param {string} clientId - The ID of the client.
|
|
13912
15333
|
* @returns {T} The value read from the session memory.
|
|
13913
15334
|
*/
|
|
13914
|
-
this.readSessionMemory = function (clientId) {
|
|
15335
|
+
this.readSessionMemory = beginContext(function (clientId) {
|
|
13915
15336
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13916
15337
|
swarm$1.loggerService.log(METHOD_NAME_READ, {
|
|
13917
15338
|
clientId: clientId,
|
|
13918
15339
|
});
|
|
13919
15340
|
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME_READ);
|
|
13920
15341
|
return swarm$1.memorySchemaService.readValue(clientId);
|
|
13921
|
-
};
|
|
15342
|
+
});
|
|
13922
15343
|
/**
|
|
13923
15344
|
* Serializes an object or an array of objects into a formatted string.
|
|
13924
15345
|
*
|
|
@@ -13974,6 +15395,7 @@ exports.Logger = Logger;
|
|
|
13974
15395
|
exports.LoggerAdapter = LoggerAdapter;
|
|
13975
15396
|
exports.LoggerInstance = LoggerInstance;
|
|
13976
15397
|
exports.MethodContextService = MethodContextService;
|
|
15398
|
+
exports.Policy = Policy;
|
|
13977
15399
|
exports.Schema = Schema;
|
|
13978
15400
|
exports.SharedState = SharedState;
|
|
13979
15401
|
exports.SharedStorage = SharedStorage;
|
|
@@ -13982,10 +15404,12 @@ exports.Storage = Storage;
|
|
|
13982
15404
|
exports.addAgent = addAgent;
|
|
13983
15405
|
exports.addCompletion = addCompletion;
|
|
13984
15406
|
exports.addEmbedding = addEmbedding;
|
|
15407
|
+
exports.addPolicy = addPolicy;
|
|
13985
15408
|
exports.addState = addState;
|
|
13986
15409
|
exports.addStorage = addStorage;
|
|
13987
15410
|
exports.addSwarm = addSwarm;
|
|
13988
15411
|
exports.addTool = addTool;
|
|
15412
|
+
exports.beginContext = beginContext;
|
|
13989
15413
|
exports.cancelOutput = cancelOutput;
|
|
13990
15414
|
exports.cancelOutputForce = cancelOutputForce;
|
|
13991
15415
|
exports.changeToAgent = changeToAgent;
|
|
@@ -14033,6 +15457,8 @@ exports.listenExecutionEvent = listenExecutionEvent;
|
|
|
14033
15457
|
exports.listenExecutionEventOnce = listenExecutionEventOnce;
|
|
14034
15458
|
exports.listenHistoryEvent = listenHistoryEvent;
|
|
14035
15459
|
exports.listenHistoryEventOnce = listenHistoryEventOnce;
|
|
15460
|
+
exports.listenPolicyEvent = listenPolicyEvent;
|
|
15461
|
+
exports.listenPolicyEventOnce = listenPolicyEventOnce;
|
|
14036
15462
|
exports.listenSessionEvent = listenSessionEvent;
|
|
14037
15463
|
exports.listenSessionEventOnce = listenSessionEventOnce;
|
|
14038
15464
|
exports.listenStateEvent = listenStateEvent;
|