agent-swarm-kit 1.0.78 → 1.0.80
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 +1385 -991
- package/build/index.mjs +1386 -993
- package/package.json +3 -2
- package/types.d.ts +26 -4
package/build/index.cjs
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var diScoped = require('di-scoped');
|
|
4
4
|
var diKit = require('di-kit');
|
|
5
5
|
var functoolsKit = require('functools-kit');
|
|
6
|
-
var lodashEs = require('lodash-es');
|
|
7
6
|
var xml2js = require('xml2js');
|
|
7
|
+
var lodashEs = require('lodash-es');
|
|
8
8
|
|
|
9
9
|
/******************************************************************************
|
|
10
10
|
Copyright (c) Microsoft Corporation.
|
|
@@ -325,36 +325,6 @@ var LoggerService = /** @class */ (function () {
|
|
|
325
325
|
return LoggerService;
|
|
326
326
|
}());
|
|
327
327
|
|
|
328
|
-
/**
|
|
329
|
-
* Service for managing agent schemas.
|
|
330
|
-
*/
|
|
331
|
-
var AgentSchemaService = /** @class */ (function () {
|
|
332
|
-
function AgentSchemaService() {
|
|
333
|
-
var _this = this;
|
|
334
|
-
this.loggerService = inject(TYPES.loggerService);
|
|
335
|
-
this.registry = new functoolsKit.ToolRegistry("agentSchemaService");
|
|
336
|
-
/**
|
|
337
|
-
* Registers a new agent schema.
|
|
338
|
-
* @param {AgentName} key - The name of the agent.
|
|
339
|
-
* @param {IAgentSchema} value - The schema of the agent.
|
|
340
|
-
*/
|
|
341
|
-
this.register = function (key, value) {
|
|
342
|
-
_this.loggerService.info("agentSchemaService register", { key: key });
|
|
343
|
-
_this.registry = _this.registry.register(key, value);
|
|
344
|
-
};
|
|
345
|
-
/**
|
|
346
|
-
* Retrieves an agent schema by name.
|
|
347
|
-
* @param {AgentName} key - The name of the agent.
|
|
348
|
-
* @returns {IAgentSchema} The schema of the agent.
|
|
349
|
-
*/
|
|
350
|
-
this.get = function (key) {
|
|
351
|
-
_this.loggerService.info("agentSchemaService get", { key: key });
|
|
352
|
-
return _this.registry.get(key);
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
return AgentSchemaService;
|
|
356
|
-
}());
|
|
357
|
-
|
|
358
328
|
/**
|
|
359
329
|
* Validates that the given output string is not empty.
|
|
360
330
|
*
|
|
@@ -459,6 +429,17 @@ var removeXmlTags = function (input) {
|
|
|
459
429
|
.trim();
|
|
460
430
|
};
|
|
461
431
|
|
|
432
|
+
var INSTANCE_METHOD_NAME_WAIT_FOR_INIT = "HistoryInstance.waitForInit";
|
|
433
|
+
var INSTANCE_METHOD_NAME_CTOR = "HistoryInstance.CTOR";
|
|
434
|
+
var INSTANCE_METHOD_NAME_ITERATE_CONDITION = "HistoryInstance.iterate condition";
|
|
435
|
+
var INSTANCE_METHOD_NAME_ITERATE = "HistoryInstance.iterate";
|
|
436
|
+
var INSTANCE_METHOD_NAME_PUSH = "HistoryInstance.push";
|
|
437
|
+
var INSTANCE_METHOD_NAME_DISPOSE = "HistoryInstance.dispose";
|
|
438
|
+
var METHOD_NAME_USE_HISTORY_ADAPTER = "HistoryUtils.useHistoryAdapter";
|
|
439
|
+
var METHOD_NAME_USE_HISTORY_CALLBACKS = "HistoryUtils.useHistoryCallbacks";
|
|
440
|
+
var METHOD_NAME_ITERATE = "HistoryUtils.iterate";
|
|
441
|
+
var METHOD_NAME_PUSH = "HistoryUtils.push";
|
|
442
|
+
var METHOD_NAME_DISPOSE = "HistoryUtils.dispose";
|
|
462
443
|
/**
|
|
463
444
|
* Class representing a History Instance
|
|
464
445
|
*/
|
|
@@ -482,10 +463,11 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
482
463
|
return __generator(this, function (_b) {
|
|
483
464
|
switch (_b.label) {
|
|
484
465
|
case 0:
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
466
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
467
|
+
swarm.loggerService.log(INSTANCE_METHOD_NAME_WAIT_FOR_INIT, {
|
|
468
|
+
clientId: this.clientId,
|
|
469
|
+
agentName: agentName,
|
|
470
|
+
});
|
|
489
471
|
if (!this.callbacks.getData) return [3 /*break*/, 2];
|
|
490
472
|
_a = this;
|
|
491
473
|
return [4 /*yield*/, this.callbacks.getData(this.clientId, agentName)];
|
|
@@ -504,10 +486,11 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
504
486
|
*/
|
|
505
487
|
this.push = function (value, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
506
488
|
return __generator(this, function (_a) {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
489
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
490
|
+
swarm.loggerService.log(INSTANCE_METHOD_NAME_PUSH, {
|
|
491
|
+
clientId: this.clientId,
|
|
492
|
+
agentName: agentName,
|
|
493
|
+
});
|
|
511
494
|
this.callbacks.onPush &&
|
|
512
495
|
this.callbacks.onPush(value, this.clientId, agentName);
|
|
513
496
|
this._array.push(value);
|
|
@@ -523,10 +506,11 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
523
506
|
*/
|
|
524
507
|
this.dispose = function (agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
525
508
|
return __generator(this, function (_a) {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
509
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
510
|
+
swarm.loggerService.log(INSTANCE_METHOD_NAME_DISPOSE, {
|
|
511
|
+
clientId: this.clientId,
|
|
512
|
+
agentName: agentName,
|
|
513
|
+
});
|
|
530
514
|
if (agentName === null) {
|
|
531
515
|
this.callbacks.onDispose && this.callbacks.onDispose(this.clientId);
|
|
532
516
|
this._array = [];
|
|
@@ -534,9 +518,10 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
534
518
|
return [2 /*return*/, Promise.resolve()];
|
|
535
519
|
});
|
|
536
520
|
}); };
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
521
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
522
|
+
swarm.loggerService.log(INSTANCE_METHOD_NAME_CTOR, {
|
|
523
|
+
clientId: this.clientId,
|
|
524
|
+
});
|
|
540
525
|
if (callbacks.onInit) {
|
|
541
526
|
callbacks.onInit(clientId);
|
|
542
527
|
}
|
|
@@ -551,10 +536,11 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
551
536
|
return __generator(this, function (_g) {
|
|
552
537
|
switch (_g.label) {
|
|
553
538
|
case 0:
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
539
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
540
|
+
swarm.loggerService.log(INSTANCE_METHOD_NAME_ITERATE_CONDITION, {
|
|
541
|
+
clientId: this.clientId,
|
|
542
|
+
agentName: agentName,
|
|
543
|
+
});
|
|
558
544
|
if (!this.callbacks.onRead) return [3 /*break*/, 12];
|
|
559
545
|
this.callbacks.onReadBegin &&
|
|
560
546
|
this.callbacks.onReadBegin(this.clientId, agentName);
|
|
@@ -649,10 +635,11 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
649
635
|
return __generator(this, function (_g) {
|
|
650
636
|
switch (_g.label) {
|
|
651
637
|
case 0:
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
638
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
639
|
+
swarm.loggerService.log(INSTANCE_METHOD_NAME_ITERATE, {
|
|
640
|
+
clientId: this.clientId,
|
|
641
|
+
agentName: agentName,
|
|
642
|
+
});
|
|
656
643
|
if (!this.callbacks.onRead) return [3 /*break*/, 11];
|
|
657
644
|
this.callbacks.onReadBegin &&
|
|
658
645
|
this.callbacks.onReadBegin(this.clientId, agentName);
|
|
@@ -748,7 +735,8 @@ var HistoryUtils = /** @class */ (function () {
|
|
|
748
735
|
* @param Ctor - The constructor for the history instance.
|
|
749
736
|
*/
|
|
750
737
|
this.useHistoryAdapter = function (Ctor) {
|
|
751
|
-
|
|
738
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
739
|
+
swarm.loggerService.log(METHOD_NAME_USE_HISTORY_ADAPTER);
|
|
752
740
|
_this.HistoryFactory = Ctor;
|
|
753
741
|
};
|
|
754
742
|
/**
|
|
@@ -756,7 +744,8 @@ var HistoryUtils = /** @class */ (function () {
|
|
|
756
744
|
* @param Callbacks - The callbacks dictionary.
|
|
757
745
|
*/
|
|
758
746
|
this.useHistoryCallbacks = function (Callbacks) {
|
|
759
|
-
|
|
747
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
748
|
+
swarm.loggerService.log(METHOD_NAME_USE_HISTORY_CALLBACKS);
|
|
760
749
|
Object.assign(_this.HistoryCallbacks, Callbacks);
|
|
761
750
|
};
|
|
762
751
|
/**
|
|
@@ -771,11 +760,12 @@ var HistoryUtils = /** @class */ (function () {
|
|
|
771
760
|
return __generator(this, function (_a) {
|
|
772
761
|
switch (_a.label) {
|
|
773
762
|
case 0:
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
763
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
764
|
+
swarm.loggerService.log(METHOD_NAME_PUSH, {
|
|
765
|
+
clientId: clientId,
|
|
766
|
+
agentName: agentName,
|
|
767
|
+
value: value,
|
|
768
|
+
});
|
|
779
769
|
isInitial = this.getHistory.has(clientId);
|
|
780
770
|
return [4 /*yield*/, this.getHistory(clientId)];
|
|
781
771
|
case 1:
|
|
@@ -799,10 +789,11 @@ var HistoryUtils = /** @class */ (function () {
|
|
|
799
789
|
return __generator(this, function (_a) {
|
|
800
790
|
switch (_a.label) {
|
|
801
791
|
case 0:
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
792
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
793
|
+
swarm.loggerService.log(METHOD_NAME_DISPOSE, {
|
|
794
|
+
clientId: clientId,
|
|
795
|
+
agentName: agentName,
|
|
796
|
+
});
|
|
806
797
|
isInitial = this.getHistory.has(clientId);
|
|
807
798
|
return [4 /*yield*/, this.getHistory(clientId)];
|
|
808
799
|
case 1:
|
|
@@ -834,10 +825,11 @@ var HistoryUtils = /** @class */ (function () {
|
|
|
834
825
|
return __generator(this, function (_g) {
|
|
835
826
|
switch (_g.label) {
|
|
836
827
|
case 0:
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
828
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
829
|
+
swarm.loggerService.log(METHOD_NAME_ITERATE, {
|
|
830
|
+
clientId: clientId,
|
|
831
|
+
agentName: agentName,
|
|
832
|
+
});
|
|
841
833
|
isInitial = this.getHistory.has(clientId);
|
|
842
834
|
return [4 /*yield*/, __await(this.getHistory(clientId))];
|
|
843
835
|
case 1:
|
|
@@ -897,6 +889,25 @@ var HistoryAdapter = new HistoryUtils();
|
|
|
897
889
|
*/
|
|
898
890
|
var History = HistoryAdapter;
|
|
899
891
|
|
|
892
|
+
/**
|
|
893
|
+
* Convert a name to title case.
|
|
894
|
+
*
|
|
895
|
+
* @param name - The name to convert to title case.
|
|
896
|
+
* @return The name converted to title case.
|
|
897
|
+
*/
|
|
898
|
+
var nameToTitle = function (name) {
|
|
899
|
+
var _a;
|
|
900
|
+
if (!name) {
|
|
901
|
+
return undefined;
|
|
902
|
+
}
|
|
903
|
+
if (name.includes(".")) {
|
|
904
|
+
var tokens = name.split(".");
|
|
905
|
+
_a = __read(tokens.reverse(), 1), name = _a[0];
|
|
906
|
+
}
|
|
907
|
+
var _b = __read(name.split('_')), word = _b[0], rest = _b.slice(1);
|
|
908
|
+
return __spreadArray(["".concat(word.charAt(0).toUpperCase()).concat(word.slice(1))], __read(rest), false).join(' ');
|
|
909
|
+
};
|
|
910
|
+
|
|
900
911
|
/**
|
|
901
912
|
* @description `ask for agent function` in `llama3.1:8b` to troubleshoot (need CC_OLLAMA_EMIT_TOOL_PROTOCOL to be turned off)
|
|
902
913
|
*/
|
|
@@ -954,6 +965,10 @@ var CC_AGENT_OUTPUT_MAP = function (message) { return message; };
|
|
|
954
965
|
var CC_AGENT_SYSTEM_PROMPT = undefined;
|
|
955
966
|
var CC_STORAGE_SEARCH_SIMILARITY = 0.65;
|
|
956
967
|
var CC_STORAGE_SEARCH_POOL = 5;
|
|
968
|
+
var CC_LOGGER_ENABLE_INFO = false;
|
|
969
|
+
var CC_LOGGER_ENABLE_DEBUG = true;
|
|
970
|
+
var CC_LOGGER_ENABLE_LOG = true;
|
|
971
|
+
var CC_NAME_TO_TITLE = nameToTitle;
|
|
957
972
|
var GLOBAL_CONFIG = {
|
|
958
973
|
CC_TOOL_CALL_EXCEPTION_PROMPT: CC_TOOL_CALL_EXCEPTION_PROMPT,
|
|
959
974
|
CC_EMPTY_OUTPUT_PLACEHOLDERS: CC_EMPTY_OUTPUT_PLACEHOLDERS,
|
|
@@ -970,11 +985,47 @@ var GLOBAL_CONFIG = {
|
|
|
970
985
|
CC_AGENT_DISALLOWED_SYMBOLS: CC_AGENT_DISALLOWED_SYMBOLS,
|
|
971
986
|
CC_STORAGE_SEARCH_SIMILARITY: CC_STORAGE_SEARCH_SIMILARITY,
|
|
972
987
|
CC_STORAGE_SEARCH_POOL: CC_STORAGE_SEARCH_POOL,
|
|
988
|
+
CC_LOGGER_ENABLE_INFO: CC_LOGGER_ENABLE_INFO,
|
|
989
|
+
CC_LOGGER_ENABLE_DEBUG: CC_LOGGER_ENABLE_DEBUG,
|
|
990
|
+
CC_LOGGER_ENABLE_LOG: CC_LOGGER_ENABLE_LOG,
|
|
991
|
+
CC_NAME_TO_TITLE: CC_NAME_TO_TITLE,
|
|
973
992
|
};
|
|
974
993
|
var setConfig = function (config) {
|
|
975
994
|
Object.assign(GLOBAL_CONFIG, config);
|
|
976
995
|
};
|
|
977
996
|
|
|
997
|
+
/**
|
|
998
|
+
* Service for managing agent schemas.
|
|
999
|
+
*/
|
|
1000
|
+
var AgentSchemaService = /** @class */ (function () {
|
|
1001
|
+
function AgentSchemaService() {
|
|
1002
|
+
var _this = this;
|
|
1003
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
1004
|
+
this.registry = new functoolsKit.ToolRegistry("agentSchemaService");
|
|
1005
|
+
/**
|
|
1006
|
+
* Registers a new agent schema.
|
|
1007
|
+
* @param {AgentName} key - The name of the agent.
|
|
1008
|
+
* @param {IAgentSchema} value - The schema of the agent.
|
|
1009
|
+
*/
|
|
1010
|
+
this.register = function (key, value) {
|
|
1011
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
1012
|
+
_this.loggerService.info("agentSchemaService register", { key: key });
|
|
1013
|
+
_this.registry = _this.registry.register(key, value);
|
|
1014
|
+
};
|
|
1015
|
+
/**
|
|
1016
|
+
* Retrieves an agent schema by name.
|
|
1017
|
+
* @param {AgentName} key - The name of the agent.
|
|
1018
|
+
* @returns {IAgentSchema} The schema of the agent.
|
|
1019
|
+
*/
|
|
1020
|
+
this.get = function (key) {
|
|
1021
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
1022
|
+
_this.loggerService.info("agentSchemaService get", { key: key });
|
|
1023
|
+
return _this.registry.get(key);
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
return AgentSchemaService;
|
|
1027
|
+
}());
|
|
1028
|
+
|
|
978
1029
|
var AGENT_CHANGE_SYMBOL = Symbol("agent-change");
|
|
979
1030
|
var getPlaceholder = function () {
|
|
980
1031
|
return GLOBAL_CONFIG.CC_EMPTY_OUTPUT_PLACEHOLDERS[Math.floor(Math.random() * GLOBAL_CONFIG.CC_EMPTY_OUTPUT_PLACEHOLDERS.length)];
|
|
@@ -1008,7 +1059,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1008
1059
|
case 0: return [4 /*yield*/, this.params.transform(rawResult, this.params.clientId, this.params.agentName)];
|
|
1009
1060
|
case 1:
|
|
1010
1061
|
result = _a.sent();
|
|
1011
|
-
|
|
1062
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1063
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " _emitOuput"), { mode: mode, result: result, rawResult: rawResult });
|
|
1012
1064
|
validation = null;
|
|
1013
1065
|
return [4 /*yield*/, this.params.validate(result)];
|
|
1014
1066
|
case 2:
|
|
@@ -1085,7 +1137,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1085
1137
|
return __generator(this, function (_a) {
|
|
1086
1138
|
switch (_a.label) {
|
|
1087
1139
|
case 0:
|
|
1088
|
-
|
|
1140
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1141
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " _resurrectModel"));
|
|
1089
1142
|
this.params.onResurrect &&
|
|
1090
1143
|
this.params.onResurrect(this.params.clientId, this.params.agentName, mode, reason);
|
|
1091
1144
|
return [4 /*yield*/, this.params.history.push({
|
|
@@ -1117,7 +1170,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1117
1170
|
return [4 /*yield*/, this.params.validate(result)];
|
|
1118
1171
|
case 6:
|
|
1119
1172
|
if (!(validation = _a.sent())) return [3 /*break*/, 8];
|
|
1120
|
-
|
|
1173
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1174
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " _resurrectModel validation error: ").concat(validation));
|
|
1121
1175
|
content = getPlaceholder();
|
|
1122
1176
|
return [4 /*yield*/, this.params.history.push({
|
|
1123
1177
|
agentName: this.params.agentName,
|
|
@@ -1143,7 +1197,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1143
1197
|
return __generator(this, function (_a) {
|
|
1144
1198
|
switch (_a.label) {
|
|
1145
1199
|
case 0:
|
|
1146
|
-
|
|
1200
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1201
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " waitForOutput"));
|
|
1147
1202
|
return [4 /*yield*/, this._outputSubject.toPromise()];
|
|
1148
1203
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1149
1204
|
}
|
|
@@ -1159,7 +1214,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1159
1214
|
return __generator(this, function (_d) {
|
|
1160
1215
|
switch (_d.label) {
|
|
1161
1216
|
case 0:
|
|
1162
|
-
|
|
1217
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1218
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " getCompletion"));
|
|
1163
1219
|
return [4 /*yield*/, this.params.history.toArrayForAgent(this.params.prompt, this.params.system)];
|
|
1164
1220
|
case 1:
|
|
1165
1221
|
messages = _d.sent();
|
|
@@ -1190,7 +1246,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1190
1246
|
return __generator(this, function (_a) {
|
|
1191
1247
|
switch (_a.label) {
|
|
1192
1248
|
case 0:
|
|
1193
|
-
|
|
1249
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1250
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " commitUserMessage"), { message: message });
|
|
1194
1251
|
this.params.onUserMessage &&
|
|
1195
1252
|
this.params.onUserMessage(this.params.clientId, this.params.agentName, message);
|
|
1196
1253
|
return [4 /*yield*/, this.params.history.push({
|
|
@@ -1227,7 +1284,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1227
1284
|
return __generator(this, function (_a) {
|
|
1228
1285
|
switch (_a.label) {
|
|
1229
1286
|
case 0:
|
|
1230
|
-
|
|
1287
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1288
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " commitFlush"));
|
|
1231
1289
|
this.params.onFlush &&
|
|
1232
1290
|
this.params.onFlush(this.params.clientId, this.params.agentName);
|
|
1233
1291
|
return [4 /*yield*/, this.params.history.push({
|
|
@@ -1262,7 +1320,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1262
1320
|
return __generator(this, function (_a) {
|
|
1263
1321
|
switch (_a.label) {
|
|
1264
1322
|
case 0:
|
|
1265
|
-
|
|
1323
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1324
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " commitAgentChange"));
|
|
1266
1325
|
return [4 /*yield*/, this._agentChangeSubject.next(AGENT_CHANGE_SYMBOL)];
|
|
1267
1326
|
case 1:
|
|
1268
1327
|
_a.sent();
|
|
@@ -1291,7 +1350,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1291
1350
|
return __generator(this, function (_a) {
|
|
1292
1351
|
switch (_a.label) {
|
|
1293
1352
|
case 0:
|
|
1294
|
-
|
|
1353
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1354
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " commitSystemMessage"), { message: message });
|
|
1295
1355
|
this.params.onSystemMessage &&
|
|
1296
1356
|
this.params.onSystemMessage(this.params.clientId, this.params.agentName, message);
|
|
1297
1357
|
return [4 /*yield*/, this.params.history.push({
|
|
@@ -1329,7 +1389,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1329
1389
|
return __generator(this, function (_a) {
|
|
1330
1390
|
switch (_a.label) {
|
|
1331
1391
|
case 0:
|
|
1332
|
-
|
|
1392
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1393
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " commitToolOutput"), { content: content, toolId: toolId });
|
|
1333
1394
|
this.params.onToolOutput &&
|
|
1334
1395
|
this.params.onToolOutput(toolId, this.params.clientId, this.params.agentName, content);
|
|
1335
1396
|
return [4 /*yield*/, this.params.history.push({
|
|
@@ -1375,7 +1436,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1375
1436
|
return __generator(this, function (_h) {
|
|
1376
1437
|
switch (_h.label) {
|
|
1377
1438
|
case 0:
|
|
1378
|
-
|
|
1439
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1440
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute begin"), { incoming: incoming, mode: mode });
|
|
1379
1441
|
this.params.onExecute &&
|
|
1380
1442
|
this.params.onExecute(this.params.clientId, this.params.agentName, incoming, mode);
|
|
1381
1443
|
return [4 /*yield*/, this.params.history.push({
|
|
@@ -1393,7 +1455,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1393
1455
|
case 3:
|
|
1394
1456
|
message = _h.sent();
|
|
1395
1457
|
if (!message.tool_calls) return [3 /*break*/, 9];
|
|
1396
|
-
|
|
1458
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1459
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " tool call begin"));
|
|
1397
1460
|
toolCalls = message.tool_calls.map(function (call) {
|
|
1398
1461
|
var _a, _b;
|
|
1399
1462
|
return ({
|
|
@@ -1413,11 +1476,13 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1413
1476
|
tool = toolCalls[idx];
|
|
1414
1477
|
targetFn = (_a = this_1.params.tools) === null || _a === void 0 ? void 0 : _a.find(function (t) { return t.function.name === tool.function.name; });
|
|
1415
1478
|
if (!!targetFn) return [3 /*break*/, 3];
|
|
1416
|
-
|
|
1479
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1480
|
+
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " functionName=").concat(tool.function.name, " tool function not found"), this_1.params.tools);
|
|
1417
1481
|
return [4 /*yield*/, this_1._resurrectModel(mode, "No target function for ".concat(tool.function.name))];
|
|
1418
1482
|
case 1:
|
|
1419
1483
|
result_2 = _j.sent();
|
|
1420
|
-
|
|
1484
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1485
|
+
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_2));
|
|
1421
1486
|
return [4 /*yield*/, this_1._emitOuput(mode, result_2)];
|
|
1422
1487
|
case 2:
|
|
1423
1488
|
_j.sent();
|
|
@@ -1433,11 +1498,13 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1433
1498
|
}))];
|
|
1434
1499
|
case 4:
|
|
1435
1500
|
if (!_j.sent()) return [3 /*break*/, 7];
|
|
1436
|
-
|
|
1501
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1502
|
+
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " functionName=").concat(tool.function.name, " tool validation not passed"));
|
|
1437
1503
|
return [4 /*yield*/, this_1._resurrectModel(mode, "Function validation failed: name=".concat(tool.function.name, " arguments=").concat(JSON.stringify(tool.function.arguments)))];
|
|
1438
1504
|
case 5:
|
|
1439
1505
|
result_3 = _j.sent();
|
|
1440
|
-
|
|
1506
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1507
|
+
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_3));
|
|
1441
1508
|
return [4 /*yield*/, this_1._emitOuput(mode, result_3)];
|
|
1442
1509
|
case 6:
|
|
1443
1510
|
_j.sent();
|
|
@@ -1474,7 +1541,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1474
1541
|
((_b = targetFn.callbacks) === null || _b === void 0 ? void 0 : _b.onCallError(tool.id, _this.params.clientId, _this.params.agentName, tool.function.arguments, error));
|
|
1475
1542
|
_this._toolErrorSubject.next();
|
|
1476
1543
|
});
|
|
1477
|
-
|
|
1544
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1545
|
+
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " functionName=").concat(tool.function.name, " tool call executing"));
|
|
1478
1546
|
return [4 /*yield*/, Promise.race([
|
|
1479
1547
|
this_1._agentChangeSubject.toPromise(),
|
|
1480
1548
|
this_1._toolCommitSubject.toPromise(),
|
|
@@ -1483,9 +1551,11 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1483
1551
|
])];
|
|
1484
1552
|
case 8:
|
|
1485
1553
|
status = _j.sent();
|
|
1486
|
-
|
|
1554
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1555
|
+
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " functionName=").concat(tool.function.name, " tool call end"));
|
|
1487
1556
|
if (status === AGENT_CHANGE_SYMBOL) {
|
|
1488
|
-
|
|
1557
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1558
|
+
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " functionName=").concat(tool.function.name, " the next tool execution stopped due to the agent changed"));
|
|
1489
1559
|
((_f = this_1.params.callbacks) === null || _f === void 0 ? void 0 : _f.onAfterToolCalls) &&
|
|
1490
1560
|
this_1.params.callbacks.onAfterToolCalls(this_1.params.clientId, this_1.params.agentName, toolCalls);
|
|
1491
1561
|
return [2 /*return*/, { value: void 0 }];
|
|
@@ -1514,7 +1584,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1514
1584
|
return [2 /*return*/];
|
|
1515
1585
|
case 9:
|
|
1516
1586
|
if (!message.tool_calls) {
|
|
1517
|
-
|
|
1587
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1588
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute no tool calls detected"));
|
|
1518
1589
|
}
|
|
1519
1590
|
return [4 /*yield*/, this.params.transform(message.content, this.params.clientId, this.params.agentName)];
|
|
1520
1591
|
case 10:
|
|
@@ -1526,7 +1597,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1526
1597
|
return [4 /*yield*/, this.params.validate(result)];
|
|
1527
1598
|
case 12:
|
|
1528
1599
|
if (!(validation = _h.sent())) return [3 /*break*/, 15];
|
|
1529
|
-
|
|
1600
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1601
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute invalid tool call detected: ").concat(validation), { result: result });
|
|
1530
1602
|
return [4 /*yield*/, this._resurrectModel(mode, "Invalid model output: ".concat(result))];
|
|
1531
1603
|
case 13:
|
|
1532
1604
|
result1 = _h.sent();
|
|
@@ -1535,7 +1607,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1535
1607
|
_h.sent();
|
|
1536
1608
|
return [2 /*return*/];
|
|
1537
1609
|
case 15:
|
|
1538
|
-
|
|
1610
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1611
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute end result=").concat(result));
|
|
1539
1612
|
return [4 /*yield*/, this._emitOuput(mode, result)];
|
|
1540
1613
|
case 16:
|
|
1541
1614
|
_h.sent();
|
|
@@ -1549,15 +1622,17 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1549
1622
|
*/
|
|
1550
1623
|
this.dispose = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1551
1624
|
return __generator(this, function (_a) {
|
|
1552
|
-
|
|
1625
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1626
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " dispose"));
|
|
1553
1627
|
this.params.onDispose &&
|
|
1554
1628
|
this.params.onDispose(this.params.clientId, this.params.agentName);
|
|
1555
1629
|
return [2 /*return*/];
|
|
1556
1630
|
});
|
|
1557
1631
|
}); };
|
|
1558
|
-
|
|
1559
|
-
params
|
|
1560
|
-
|
|
1632
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1633
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " CTOR"), {
|
|
1634
|
+
params: params,
|
|
1635
|
+
});
|
|
1561
1636
|
this.params.onInit && this.params.onInit(params.clientId, params.agentName);
|
|
1562
1637
|
}
|
|
1563
1638
|
return ClientAgent;
|
|
@@ -1613,10 +1688,11 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1613
1688
|
return __generator(this, function (_a) {
|
|
1614
1689
|
switch (_a.label) {
|
|
1615
1690
|
case 0:
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1691
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
1692
|
+
this.loggerService.info("agentConnectionService execute", {
|
|
1693
|
+
input: input,
|
|
1694
|
+
mode: mode,
|
|
1695
|
+
});
|
|
1620
1696
|
return [4 /*yield*/, this.getAgent(this.methodContextService.context.clientId, this.methodContextService.context.agentName).execute(input, mode)];
|
|
1621
1697
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1622
1698
|
}
|
|
@@ -1630,7 +1706,8 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1630
1706
|
return __generator(this, function (_a) {
|
|
1631
1707
|
switch (_a.label) {
|
|
1632
1708
|
case 0:
|
|
1633
|
-
|
|
1709
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
1710
|
+
this.loggerService.info("agentConnectionService waitForOutput");
|
|
1634
1711
|
return [4 /*yield*/, this.getAgent(this.methodContextService.context.clientId, this.methodContextService.context.agentName).waitForOutput()];
|
|
1635
1712
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1636
1713
|
}
|
|
@@ -1646,10 +1723,11 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1646
1723
|
return __generator(this, function (_a) {
|
|
1647
1724
|
switch (_a.label) {
|
|
1648
1725
|
case 0:
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1726
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
1727
|
+
this.loggerService.info("agentConnectionService commitToolOutput", {
|
|
1728
|
+
content: content,
|
|
1729
|
+
toolId: toolId,
|
|
1730
|
+
});
|
|
1653
1731
|
return [4 /*yield*/, this.getAgent(this.methodContextService.context.clientId, this.methodContextService.context.agentName).commitToolOutput(toolId, content)];
|
|
1654
1732
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1655
1733
|
}
|
|
@@ -1664,9 +1742,10 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1664
1742
|
return __generator(this, function (_a) {
|
|
1665
1743
|
switch (_a.label) {
|
|
1666
1744
|
case 0:
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1745
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
1746
|
+
this.loggerService.info("agentConnectionService commitSystemMessage", {
|
|
1747
|
+
message: message,
|
|
1748
|
+
});
|
|
1670
1749
|
return [4 /*yield*/, this.getAgent(this.methodContextService.context.clientId, this.methodContextService.context.agentName).commitSystemMessage(message)];
|
|
1671
1750
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1672
1751
|
}
|
|
@@ -1681,9 +1760,10 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1681
1760
|
return __generator(this, function (_a) {
|
|
1682
1761
|
switch (_a.label) {
|
|
1683
1762
|
case 0:
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1763
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
1764
|
+
this.loggerService.info("agentConnectionService commitUserMessage", {
|
|
1765
|
+
message: message,
|
|
1766
|
+
});
|
|
1687
1767
|
return [4 /*yield*/, this.getAgent(this.methodContextService.context.clientId, this.methodContextService.context.agentName).commitUserMessage(message)];
|
|
1688
1768
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1689
1769
|
}
|
|
@@ -1697,7 +1777,8 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1697
1777
|
return __generator(this, function (_a) {
|
|
1698
1778
|
switch (_a.label) {
|
|
1699
1779
|
case 0:
|
|
1700
|
-
|
|
1780
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
1781
|
+
this.loggerService.info("agentConnectionService commitAgentChange");
|
|
1701
1782
|
return [4 /*yield*/, this.getAgent(this.methodContextService.context.clientId, this.methodContextService.context.agentName).commitAgentChange()];
|
|
1702
1783
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1703
1784
|
}
|
|
@@ -1711,7 +1792,8 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1711
1792
|
return __generator(this, function (_a) {
|
|
1712
1793
|
switch (_a.label) {
|
|
1713
1794
|
case 0:
|
|
1714
|
-
|
|
1795
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
1796
|
+
this.loggerService.info("agentConnectionService commitFlush");
|
|
1715
1797
|
return [4 /*yield*/, this.getAgent(this.methodContextService.context.clientId, this.methodContextService.context.agentName).commitFlush()];
|
|
1716
1798
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1717
1799
|
}
|
|
@@ -1726,7 +1808,8 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1726
1808
|
return __generator(this, function (_a) {
|
|
1727
1809
|
switch (_a.label) {
|
|
1728
1810
|
case 0:
|
|
1729
|
-
|
|
1811
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
1812
|
+
this.loggerService.info("agentConnectionService dispose");
|
|
1730
1813
|
key = "".concat(this.methodContextService.context.clientId, "-").concat(this.methodContextService.context.agentName);
|
|
1731
1814
|
if (!this.getAgent.has(key)) {
|
|
1732
1815
|
return [2 /*return*/];
|
|
@@ -1765,7 +1848,8 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1765
1848
|
return __generator(this, function (_a) {
|
|
1766
1849
|
switch (_a.label) {
|
|
1767
1850
|
case 0:
|
|
1768
|
-
|
|
1851
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1852
|
+
this.params.logger.debug("ClientHistory agentName=".concat(this.params.agentName, " push"), { message: message });
|
|
1769
1853
|
return [4 /*yield*/, this.params.items.push(message, this.params.clientId, this.params.agentName)];
|
|
1770
1854
|
case 1:
|
|
1771
1855
|
_a.sent();
|
|
@@ -1773,7 +1857,7 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1773
1857
|
type: "push",
|
|
1774
1858
|
source: "history-bus",
|
|
1775
1859
|
input: {
|
|
1776
|
-
message: message
|
|
1860
|
+
message: message,
|
|
1777
1861
|
},
|
|
1778
1862
|
output: {},
|
|
1779
1863
|
context: {
|
|
@@ -1797,7 +1881,8 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1797
1881
|
return __generator(this, function (_g) {
|
|
1798
1882
|
switch (_g.label) {
|
|
1799
1883
|
case 0:
|
|
1800
|
-
|
|
1884
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1885
|
+
this.params.logger.debug("ClientHistory agentName=".concat(this.params.agentName, " toArrayForRaw"));
|
|
1801
1886
|
result = [];
|
|
1802
1887
|
_g.label = 1;
|
|
1803
1888
|
case 1:
|
|
@@ -1850,7 +1935,8 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1850
1935
|
return __generator(this, function (_h) {
|
|
1851
1936
|
switch (_h.label) {
|
|
1852
1937
|
case 0:
|
|
1853
|
-
|
|
1938
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1939
|
+
this.params.logger.debug("ClientHistory agentName=".concat(this.params.agentName, " toArrayForAgent"));
|
|
1854
1940
|
commonMessagesRaw = [];
|
|
1855
1941
|
systemMessagesRaw = [];
|
|
1856
1942
|
_h.label = 1;
|
|
@@ -1991,7 +2077,8 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1991
2077
|
return __generator(this, function (_a) {
|
|
1992
2078
|
switch (_a.label) {
|
|
1993
2079
|
case 0:
|
|
1994
|
-
|
|
2080
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2081
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " dispose"));
|
|
1995
2082
|
return [4 /*yield*/, this.params.items.dispose(this.params.clientId, this.params.agentName)];
|
|
1996
2083
|
case 1:
|
|
1997
2084
|
_a.sent();
|
|
@@ -1999,9 +2086,10 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1999
2086
|
}
|
|
2000
2087
|
});
|
|
2001
2088
|
}); };
|
|
2002
|
-
|
|
2003
|
-
params
|
|
2004
|
-
|
|
2089
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2090
|
+
this.params.logger.debug("ClientHistory agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " CTOR"), {
|
|
2091
|
+
params: params,
|
|
2092
|
+
});
|
|
2005
2093
|
this._filterCondition = GLOBAL_CONFIG.CC_AGENT_HISTORY_FILTER(this.params.agentName);
|
|
2006
2094
|
}
|
|
2007
2095
|
return ClientHistory;
|
|
@@ -2046,9 +2134,10 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
2046
2134
|
return __generator(this, function (_a) {
|
|
2047
2135
|
switch (_a.label) {
|
|
2048
2136
|
case 0:
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2137
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
2138
|
+
this.loggerService.info("historyConnectionService push", {
|
|
2139
|
+
message: message,
|
|
2140
|
+
});
|
|
2052
2141
|
return [4 /*yield*/, this.getHistory(this.methodContextService.context.clientId, this.methodContextService.context.agentName).push(message)];
|
|
2053
2142
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2054
2143
|
}
|
|
@@ -2063,9 +2152,10 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
2063
2152
|
return __generator(this, function (_a) {
|
|
2064
2153
|
switch (_a.label) {
|
|
2065
2154
|
case 0:
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2155
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
2156
|
+
this.loggerService.info("historyConnectionService toArrayForAgent", {
|
|
2157
|
+
prompt: prompt,
|
|
2158
|
+
});
|
|
2069
2159
|
return [4 /*yield*/, this.getHistory(this.methodContextService.context.clientId, this.methodContextService.context.agentName).toArrayForAgent(prompt)];
|
|
2070
2160
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2071
2161
|
}
|
|
@@ -2079,7 +2169,8 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
2079
2169
|
return __generator(this, function (_a) {
|
|
2080
2170
|
switch (_a.label) {
|
|
2081
2171
|
case 0:
|
|
2082
|
-
|
|
2172
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
2173
|
+
this.loggerService.info("historyConnectionService toArrayForRaw");
|
|
2083
2174
|
return [4 /*yield*/, this.getHistory(this.methodContextService.context.clientId, this.methodContextService.context.agentName).toArrayForRaw()];
|
|
2084
2175
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2085
2176
|
}
|
|
@@ -2094,7 +2185,8 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
2094
2185
|
return __generator(this, function (_a) {
|
|
2095
2186
|
switch (_a.label) {
|
|
2096
2187
|
case 0:
|
|
2097
|
-
|
|
2188
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
2189
|
+
this.loggerService.info("historyConnectionService dispose");
|
|
2098
2190
|
key = "".concat(this.methodContextService.context.clientId, "-").concat(this.methodContextService.context.agentName);
|
|
2099
2191
|
if (!this.getHistory.has(key)) {
|
|
2100
2192
|
return [2 /*return*/];
|
|
@@ -2126,7 +2218,8 @@ var ToolSchemaService = /** @class */ (function () {
|
|
|
2126
2218
|
* @param {IAgentTool} value - The tool to register.
|
|
2127
2219
|
*/
|
|
2128
2220
|
this.register = function (key, value) {
|
|
2129
|
-
|
|
2221
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
2222
|
+
_this.loggerService.info("toolSchemaService register");
|
|
2130
2223
|
_this.registry = _this.registry.register(key, value);
|
|
2131
2224
|
};
|
|
2132
2225
|
/**
|
|
@@ -2135,7 +2228,8 @@ var ToolSchemaService = /** @class */ (function () {
|
|
|
2135
2228
|
* @returns {IAgentTool} The tool associated with the given key.
|
|
2136
2229
|
*/
|
|
2137
2230
|
this.get = function (key) {
|
|
2138
|
-
|
|
2231
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
2232
|
+
_this.loggerService.info("toolSchemaService get", { key: key });
|
|
2139
2233
|
return _this.registry.get(key);
|
|
2140
2234
|
};
|
|
2141
2235
|
}
|
|
@@ -2167,7 +2261,8 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2167
2261
|
return __generator(this, function (_d) {
|
|
2168
2262
|
switch (_d.label) {
|
|
2169
2263
|
case 0:
|
|
2170
|
-
|
|
2264
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2265
|
+
this.params.logger.debug("ClientSwarm swarmName=".concat(this.params.swarmName, " clientId=").concat(this.params.clientId, " cancelOutput"));
|
|
2171
2266
|
_b = (_a = this._cancelOutputSubject).next;
|
|
2172
2267
|
_c = {};
|
|
2173
2268
|
return [4 /*yield*/, this.getAgentName()];
|
|
@@ -2202,7 +2297,8 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2202
2297
|
return __generator(this, function (_c) {
|
|
2203
2298
|
switch (_c.label) {
|
|
2204
2299
|
case 0:
|
|
2205
|
-
|
|
2300
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2301
|
+
this.params.logger.debug("ClientSwarm swarmName=".concat(this.params.swarmName, " clientId=").concat(this.params.clientId, " waitForOutput"));
|
|
2206
2302
|
_a = __read(functoolsKit.createAwaiter(), 2), awaiter = _a[0], resolve = _a[1].resolve;
|
|
2207
2303
|
getOutput = functoolsKit.cancelable(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2208
2304
|
var _this = this;
|
|
@@ -2248,6 +2344,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2248
2344
|
case 2:
|
|
2249
2345
|
expectAgent = _c.sent();
|
|
2250
2346
|
agentName !== expectAgent &&
|
|
2347
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2251
2348
|
this.params.logger.debug("ClientSwarm swarmName=".concat(this.params.swarmName, " clientId=").concat(this.params.clientId, " waitForAgent agent miss"), { agentName: agentName, expectAgent: expectAgent });
|
|
2252
2349
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2253
2350
|
type: "wait-for-output",
|
|
@@ -2276,7 +2373,8 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2276
2373
|
return __generator(this, function (_b) {
|
|
2277
2374
|
switch (_b.label) {
|
|
2278
2375
|
case 0:
|
|
2279
|
-
|
|
2376
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2377
|
+
this.params.logger.debug("ClientSwarm swarmName=".concat(this.params.swarmName, " clientId=").concat(this.params.clientId, " getAgentName"));
|
|
2280
2378
|
if (!(this._activeAgent === AGENT_NEED_FETCH)) return [3 /*break*/, 2];
|
|
2281
2379
|
_a = this;
|
|
2282
2380
|
return [4 /*yield*/, GLOBAL_CONFIG.CC_SWARM_DEFAULT_AGENT(this.params.clientId, this.params.swarmName, this.params.defaultAgent)];
|
|
@@ -2310,7 +2408,8 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2310
2408
|
return __generator(this, function (_a) {
|
|
2311
2409
|
switch (_a.label) {
|
|
2312
2410
|
case 0:
|
|
2313
|
-
|
|
2411
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2412
|
+
this.params.logger.debug("ClientSwarm swarmName=".concat(this.params.swarmName, " clientId=").concat(this.params.clientId, " getAgent"));
|
|
2314
2413
|
return [4 /*yield*/, this.getAgentName()];
|
|
2315
2414
|
case 1:
|
|
2316
2415
|
agent = _a.sent();
|
|
@@ -2343,7 +2442,8 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2343
2442
|
return __generator(this, function (_a) {
|
|
2344
2443
|
switch (_a.label) {
|
|
2345
2444
|
case 0:
|
|
2346
|
-
|
|
2445
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2446
|
+
this.params.logger.debug("ClientSwarm swarmName=".concat(this.params.swarmName, " clientId=").concat(this.params.clientId, " setAgentRef agentName=").concat(agentName));
|
|
2347
2447
|
if (!this.params.agentMap[agentName]) {
|
|
2348
2448
|
throw new Error("agent-swarm agent ".concat(agentName, " not in the swarm"));
|
|
2349
2449
|
}
|
|
@@ -2378,7 +2478,8 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2378
2478
|
return __generator(this, function (_a) {
|
|
2379
2479
|
switch (_a.label) {
|
|
2380
2480
|
case 0:
|
|
2381
|
-
|
|
2481
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2482
|
+
this.params.logger.debug("ClientSwarm swarmName=".concat(this.params.swarmName, " clientId=").concat(this.params.clientId, " setAgentName agentName=").concat(agentName));
|
|
2382
2483
|
this._activeAgent = agentName;
|
|
2383
2484
|
return [4 /*yield*/, this.params.onAgentChanged(this.params.clientId, agentName, this.params.swarmName)];
|
|
2384
2485
|
case 1:
|
|
@@ -2401,9 +2502,10 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2401
2502
|
}
|
|
2402
2503
|
});
|
|
2403
2504
|
}); };
|
|
2404
|
-
|
|
2405
|
-
params
|
|
2406
|
-
|
|
2505
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2506
|
+
this.params.logger.debug("ClientSwarm swarmName=".concat(this.params.swarmName, " clientId=").concat(this.params.clientId, " CTOR"), {
|
|
2507
|
+
params: params,
|
|
2508
|
+
});
|
|
2407
2509
|
}
|
|
2408
2510
|
Object.defineProperty(ClientSwarm.prototype, "_agentList", {
|
|
2409
2511
|
get: function () {
|
|
@@ -2487,7 +2589,8 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2487
2589
|
return __generator(this, function (_a) {
|
|
2488
2590
|
switch (_a.label) {
|
|
2489
2591
|
case 0:
|
|
2490
|
-
|
|
2592
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
2593
|
+
this.loggerService.info("swarmConnectionService cancelOutput");
|
|
2491
2594
|
return [4 /*yield*/, this.getSwarm(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).cancelOutput()];
|
|
2492
2595
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2493
2596
|
}
|
|
@@ -2501,7 +2604,8 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2501
2604
|
return __generator(this, function (_a) {
|
|
2502
2605
|
switch (_a.label) {
|
|
2503
2606
|
case 0:
|
|
2504
|
-
|
|
2607
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
2608
|
+
this.loggerService.info("swarmConnectionService waitForOutput");
|
|
2505
2609
|
return [4 /*yield*/, this.getSwarm(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).waitForOutput()];
|
|
2506
2610
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2507
2611
|
}
|
|
@@ -2515,7 +2619,8 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2515
2619
|
return __generator(this, function (_a) {
|
|
2516
2620
|
switch (_a.label) {
|
|
2517
2621
|
case 0:
|
|
2518
|
-
|
|
2622
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
2623
|
+
this.loggerService.info("swarmConnectionService getAgentName");
|
|
2519
2624
|
return [4 /*yield*/, this.getSwarm(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).getAgentName()];
|
|
2520
2625
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2521
2626
|
}
|
|
@@ -2529,7 +2634,8 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2529
2634
|
return __generator(this, function (_a) {
|
|
2530
2635
|
switch (_a.label) {
|
|
2531
2636
|
case 0:
|
|
2532
|
-
|
|
2637
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
2638
|
+
this.loggerService.info("swarmConnectionService getAgent");
|
|
2533
2639
|
return [4 /*yield*/, this.getSwarm(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).getAgent()];
|
|
2534
2640
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2535
2641
|
}
|
|
@@ -2545,9 +2651,10 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2545
2651
|
return __generator(this, function (_a) {
|
|
2546
2652
|
switch (_a.label) {
|
|
2547
2653
|
case 0:
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2654
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
2655
|
+
this.loggerService.info("swarmConnectionService setAgentRef", {
|
|
2656
|
+
agentName: agentName,
|
|
2657
|
+
});
|
|
2551
2658
|
return [4 /*yield*/, this.getSwarm(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).setAgentRef(agentName, agent)];
|
|
2552
2659
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2553
2660
|
}
|
|
@@ -2562,9 +2669,10 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2562
2669
|
return __generator(this, function (_a) {
|
|
2563
2670
|
switch (_a.label) {
|
|
2564
2671
|
case 0:
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2672
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
2673
|
+
this.loggerService.info("swarmConnectionService setAgentName", {
|
|
2674
|
+
agentName: agentName,
|
|
2675
|
+
});
|
|
2568
2676
|
return [4 /*yield*/, this.getSwarm(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).setAgentName(agentName)];
|
|
2569
2677
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2570
2678
|
}
|
|
@@ -2577,7 +2685,8 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2577
2685
|
this.dispose = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2578
2686
|
var key;
|
|
2579
2687
|
return __generator(this, function (_a) {
|
|
2580
|
-
|
|
2688
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
2689
|
+
this.loggerService.info("swarmConnectionService dispose");
|
|
2581
2690
|
key = "".concat(this.methodContextService.context.clientId, "-").concat(this.methodContextService.context.swarmName);
|
|
2582
2691
|
if (!this.getSwarm.has(key)) {
|
|
2583
2692
|
return [2 /*return*/];
|
|
@@ -2604,7 +2713,8 @@ var SwarmSchemaService = /** @class */ (function () {
|
|
|
2604
2713
|
* @param {ISwarmSchema} value - The schema of the swarm.
|
|
2605
2714
|
*/
|
|
2606
2715
|
this.register = function (key, value) {
|
|
2607
|
-
|
|
2716
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
2717
|
+
_this.loggerService.info("swarmSchemaService register", { key: key });
|
|
2608
2718
|
_this.registry = _this.registry.register(key, value);
|
|
2609
2719
|
};
|
|
2610
2720
|
/**
|
|
@@ -2613,7 +2723,8 @@ var SwarmSchemaService = /** @class */ (function () {
|
|
|
2613
2723
|
* @returns {ISwarmSchema} The schema of the swarm.
|
|
2614
2724
|
*/
|
|
2615
2725
|
this.get = function (key) {
|
|
2616
|
-
|
|
2726
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
2727
|
+
_this.loggerService.info("swarmSchemaService get", { key: key });
|
|
2617
2728
|
return _this.registry.get(key);
|
|
2618
2729
|
};
|
|
2619
2730
|
}
|
|
@@ -2634,7 +2745,8 @@ var CompletionSchemaService = /** @class */ (function () {
|
|
|
2634
2745
|
* @param {ICompletionSchema} value - The schema to register.
|
|
2635
2746
|
*/
|
|
2636
2747
|
this.register = function (key, value) {
|
|
2637
|
-
|
|
2748
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
2749
|
+
_this.loggerService.info("completionSchemaService register", { key: key });
|
|
2638
2750
|
_this.registry = _this.registry.register(key, value);
|
|
2639
2751
|
};
|
|
2640
2752
|
/**
|
|
@@ -2643,7 +2755,8 @@ var CompletionSchemaService = /** @class */ (function () {
|
|
|
2643
2755
|
* @returns {ICompletionSchema} The retrieved schema.
|
|
2644
2756
|
*/
|
|
2645
2757
|
this.get = function (key) {
|
|
2646
|
-
|
|
2758
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
2759
|
+
_this.loggerService.info("completionSchemaService get", { key: key });
|
|
2647
2760
|
return _this.registry.get(key);
|
|
2648
2761
|
};
|
|
2649
2762
|
}
|
|
@@ -2671,9 +2784,10 @@ var ClientSession = /** @class */ (function () {
|
|
|
2671
2784
|
return __generator(this, function (_a) {
|
|
2672
2785
|
switch (_a.label) {
|
|
2673
2786
|
case 0:
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2787
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2788
|
+
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " emit"), {
|
|
2789
|
+
message: message,
|
|
2790
|
+
});
|
|
2677
2791
|
this.params.onEmit &&
|
|
2678
2792
|
this.params.onEmit(this.params.clientId, this.params.swarmName, message);
|
|
2679
2793
|
return [4 /*yield*/, this._emitSubject.next(message)];
|
|
@@ -2683,7 +2797,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
2683
2797
|
type: "emit",
|
|
2684
2798
|
source: "session-bus",
|
|
2685
2799
|
input: {
|
|
2686
|
-
message: message
|
|
2800
|
+
message: message,
|
|
2687
2801
|
},
|
|
2688
2802
|
output: {},
|
|
2689
2803
|
context: {
|
|
@@ -2708,10 +2822,11 @@ var ClientSession = /** @class */ (function () {
|
|
|
2708
2822
|
return __generator(this, function (_a) {
|
|
2709
2823
|
switch (_a.label) {
|
|
2710
2824
|
case 0:
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2825
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2826
|
+
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " execute"), {
|
|
2827
|
+
message: message,
|
|
2828
|
+
mode: mode,
|
|
2829
|
+
});
|
|
2715
2830
|
this.params.onExecute &&
|
|
2716
2831
|
this.params.onExecute(this.params.clientId, this.params.swarmName, message, mode);
|
|
2717
2832
|
return [4 /*yield*/, this.params.swarm.getAgent()];
|
|
@@ -2754,10 +2869,11 @@ var ClientSession = /** @class */ (function () {
|
|
|
2754
2869
|
return __generator(this, function (_a) {
|
|
2755
2870
|
switch (_a.label) {
|
|
2756
2871
|
case 0:
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2872
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2873
|
+
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " commitToolOutput"), {
|
|
2874
|
+
content: content,
|
|
2875
|
+
toolId: toolId,
|
|
2876
|
+
});
|
|
2761
2877
|
return [4 /*yield*/, this.params.swarm.getAgent()];
|
|
2762
2878
|
case 1:
|
|
2763
2879
|
agent = _a.sent();
|
|
@@ -2793,9 +2909,10 @@ var ClientSession = /** @class */ (function () {
|
|
|
2793
2909
|
return __generator(this, function (_a) {
|
|
2794
2910
|
switch (_a.label) {
|
|
2795
2911
|
case 0:
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2912
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2913
|
+
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " commitUserMessage"), {
|
|
2914
|
+
message: message,
|
|
2915
|
+
});
|
|
2799
2916
|
return [4 /*yield*/, this.params.swarm.getAgent()];
|
|
2800
2917
|
case 1:
|
|
2801
2918
|
agent = _a.sent();
|
|
@@ -2829,7 +2946,8 @@ var ClientSession = /** @class */ (function () {
|
|
|
2829
2946
|
return __generator(this, function (_a) {
|
|
2830
2947
|
switch (_a.label) {
|
|
2831
2948
|
case 0:
|
|
2832
|
-
|
|
2949
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2950
|
+
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " commitFlush"));
|
|
2833
2951
|
return [4 /*yield*/, this.params.swarm.getAgent()];
|
|
2834
2952
|
case 1:
|
|
2835
2953
|
agent = _a.sent();
|
|
@@ -2862,9 +2980,10 @@ var ClientSession = /** @class */ (function () {
|
|
|
2862
2980
|
return __generator(this, function (_a) {
|
|
2863
2981
|
switch (_a.label) {
|
|
2864
2982
|
case 0:
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2983
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2984
|
+
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " commitSystemMessage"), {
|
|
2985
|
+
message: message,
|
|
2986
|
+
});
|
|
2868
2987
|
return [4 /*yield*/, this.params.swarm.getAgent()];
|
|
2869
2988
|
case 1:
|
|
2870
2989
|
agent = _a.sent();
|
|
@@ -2875,7 +2994,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
2875
2994
|
type: "commit-system-message",
|
|
2876
2995
|
source: "session-bus",
|
|
2877
2996
|
input: {
|
|
2878
|
-
message: message
|
|
2997
|
+
message: message,
|
|
2879
2998
|
},
|
|
2880
2999
|
output: {},
|
|
2881
3000
|
context: {
|
|
@@ -2895,7 +3014,8 @@ var ClientSession = /** @class */ (function () {
|
|
|
2895
3014
|
* @returns {ReceiveMessageFn} - The function to receive messages.
|
|
2896
3015
|
*/
|
|
2897
3016
|
this.connect = function (connector) {
|
|
2898
|
-
|
|
3017
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
3018
|
+
_this.params.logger.debug("ClientSession clientId=".concat(_this.params.clientId, " connect"));
|
|
2899
3019
|
_this.params.onConnect &&
|
|
2900
3020
|
_this.params.onConnect(_this.params.clientId, _this.params.swarmName);
|
|
2901
3021
|
_this._emitSubject.subscribe(function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -2932,7 +3052,8 @@ var ClientSession = /** @class */ (function () {
|
|
|
2932
3052
|
return __generator(this, function (_c) {
|
|
2933
3053
|
switch (_c.label) {
|
|
2934
3054
|
case 0:
|
|
2935
|
-
|
|
3055
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
3056
|
+
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " connect call"));
|
|
2936
3057
|
return [4 /*yield*/, this.execute(incoming.data, "user")];
|
|
2937
3058
|
case 1:
|
|
2938
3059
|
data = _c.sent();
|
|
@@ -2960,15 +3081,17 @@ var ClientSession = /** @class */ (function () {
|
|
|
2960
3081
|
*/
|
|
2961
3082
|
this.dispose = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2962
3083
|
return __generator(this, function (_a) {
|
|
2963
|
-
|
|
3084
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
3085
|
+
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " dispose"));
|
|
2964
3086
|
this.params.onDispose &&
|
|
2965
3087
|
this.params.onDispose(this.params.clientId, this.params.swarmName);
|
|
2966
3088
|
return [2 /*return*/];
|
|
2967
3089
|
});
|
|
2968
3090
|
}); };
|
|
2969
|
-
|
|
2970
|
-
params
|
|
2971
|
-
|
|
3091
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
3092
|
+
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " CTOR"), {
|
|
3093
|
+
params: params,
|
|
3094
|
+
});
|
|
2972
3095
|
this.params.onInit && this.params.onInit(params.clientId, params.swarmName);
|
|
2973
3096
|
}
|
|
2974
3097
|
return ClientSession;
|
|
@@ -3008,9 +3131,10 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3008
3131
|
return __generator(this, function (_a) {
|
|
3009
3132
|
switch (_a.label) {
|
|
3010
3133
|
case 0:
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3134
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3135
|
+
this.loggerService.info("sessionConnectionService emit", {
|
|
3136
|
+
content: content,
|
|
3137
|
+
});
|
|
3014
3138
|
return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).emit(content)];
|
|
3015
3139
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3016
3140
|
}
|
|
@@ -3025,10 +3149,11 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3025
3149
|
return __generator(this, function (_a) {
|
|
3026
3150
|
switch (_a.label) {
|
|
3027
3151
|
case 0:
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3152
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3153
|
+
this.loggerService.info("sessionConnectionService execute", {
|
|
3154
|
+
content: content,
|
|
3155
|
+
mode: mode,
|
|
3156
|
+
});
|
|
3032
3157
|
return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).execute(content, mode)];
|
|
3033
3158
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3034
3159
|
}
|
|
@@ -3040,7 +3165,8 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3040
3165
|
* @returns {ReceiveMessageFn} The function to receive messages.
|
|
3041
3166
|
*/
|
|
3042
3167
|
this.connect = function (connector, clientId, swarmName) {
|
|
3043
|
-
|
|
3168
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3169
|
+
_this.loggerService.info("sessionConnectionService connect");
|
|
3044
3170
|
return _this.getSession(clientId, swarmName).connect(connector);
|
|
3045
3171
|
};
|
|
3046
3172
|
/**
|
|
@@ -3053,10 +3179,11 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3053
3179
|
return __generator(this, function (_a) {
|
|
3054
3180
|
switch (_a.label) {
|
|
3055
3181
|
case 0:
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3182
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3183
|
+
this.loggerService.info("sessionConnectionService commitToolOutput", {
|
|
3184
|
+
content: content,
|
|
3185
|
+
toolId: toolId,
|
|
3186
|
+
});
|
|
3060
3187
|
return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).commitToolOutput(toolId, content)];
|
|
3061
3188
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3062
3189
|
}
|
|
@@ -3071,9 +3198,10 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3071
3198
|
return __generator(this, function (_a) {
|
|
3072
3199
|
switch (_a.label) {
|
|
3073
3200
|
case 0:
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3201
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3202
|
+
this.loggerService.info("sessionConnectionService commitSystemMessage", {
|
|
3203
|
+
message: message,
|
|
3204
|
+
});
|
|
3077
3205
|
return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).commitSystemMessage(message)];
|
|
3078
3206
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3079
3207
|
}
|
|
@@ -3088,9 +3216,10 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3088
3216
|
return __generator(this, function (_a) {
|
|
3089
3217
|
switch (_a.label) {
|
|
3090
3218
|
case 0:
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3219
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3220
|
+
this.loggerService.info("sessionConnectionService commitUserMessage", {
|
|
3221
|
+
message: message,
|
|
3222
|
+
});
|
|
3094
3223
|
return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).commitUserMessage(message)];
|
|
3095
3224
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3096
3225
|
}
|
|
@@ -3105,7 +3234,8 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3105
3234
|
return __generator(this, function (_a) {
|
|
3106
3235
|
switch (_a.label) {
|
|
3107
3236
|
case 0:
|
|
3108
|
-
|
|
3237
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3238
|
+
this.loggerService.info("sessionConnectionService commitFlush");
|
|
3109
3239
|
return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).commitFlush()];
|
|
3110
3240
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3111
3241
|
}
|
|
@@ -3120,7 +3250,8 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3120
3250
|
return __generator(this, function (_a) {
|
|
3121
3251
|
switch (_a.label) {
|
|
3122
3252
|
case 0:
|
|
3123
|
-
|
|
3253
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3254
|
+
this.loggerService.info("sessionConnectionService dispose");
|
|
3124
3255
|
key = "".concat(this.methodContextService.context.clientId, "-").concat(this.methodContextService.context.swarmName);
|
|
3125
3256
|
if (!this.getSession.has(key)) {
|
|
3126
3257
|
return [2 /*return*/];
|
|
@@ -3156,11 +3287,12 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3156
3287
|
return __generator(this, function (_a) {
|
|
3157
3288
|
switch (_a.label) {
|
|
3158
3289
|
case 0:
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3290
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3291
|
+
this.loggerService.info("agentPublicService createAgentRef", {
|
|
3292
|
+
methodName: methodName,
|
|
3293
|
+
clientId: clientId,
|
|
3294
|
+
agentName: agentName,
|
|
3295
|
+
});
|
|
3164
3296
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3165
3297
|
return __generator(this, function (_a) {
|
|
3166
3298
|
switch (_a.label) {
|
|
@@ -3192,13 +3324,14 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3192
3324
|
return __generator(this, function (_a) {
|
|
3193
3325
|
switch (_a.label) {
|
|
3194
3326
|
case 0:
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3327
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3328
|
+
this.loggerService.info("agentPublicService execute", {
|
|
3329
|
+
methodName: methodName,
|
|
3330
|
+
input: input,
|
|
3331
|
+
clientId: clientId,
|
|
3332
|
+
agentName: agentName,
|
|
3333
|
+
mode: mode,
|
|
3334
|
+
});
|
|
3202
3335
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3203
3336
|
return __generator(this, function (_a) {
|
|
3204
3337
|
switch (_a.label) {
|
|
@@ -3229,11 +3362,12 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3229
3362
|
return __generator(this, function (_a) {
|
|
3230
3363
|
switch (_a.label) {
|
|
3231
3364
|
case 0:
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3365
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3366
|
+
this.loggerService.info("agentPublicService waitForOutput", {
|
|
3367
|
+
methodName: methodName,
|
|
3368
|
+
clientId: clientId,
|
|
3369
|
+
agentName: agentName,
|
|
3370
|
+
});
|
|
3237
3371
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3238
3372
|
return __generator(this, function (_a) {
|
|
3239
3373
|
switch (_a.label) {
|
|
@@ -3266,13 +3400,14 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3266
3400
|
return __generator(this, function (_a) {
|
|
3267
3401
|
switch (_a.label) {
|
|
3268
3402
|
case 0:
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3403
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3404
|
+
this.loggerService.info("agentPublicService commitToolOutput", {
|
|
3405
|
+
methodName: methodName,
|
|
3406
|
+
content: content,
|
|
3407
|
+
clientId: clientId,
|
|
3408
|
+
toolId: toolId,
|
|
3409
|
+
agentName: agentName,
|
|
3410
|
+
});
|
|
3276
3411
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3277
3412
|
return __generator(this, function (_a) {
|
|
3278
3413
|
switch (_a.label) {
|
|
@@ -3304,12 +3439,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3304
3439
|
return __generator(this, function (_a) {
|
|
3305
3440
|
switch (_a.label) {
|
|
3306
3441
|
case 0:
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3442
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3443
|
+
this.loggerService.info("agentPublicService commitSystemMessage", {
|
|
3444
|
+
methodName: methodName,
|
|
3445
|
+
message: message,
|
|
3446
|
+
clientId: clientId,
|
|
3447
|
+
agentName: agentName,
|
|
3448
|
+
});
|
|
3313
3449
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3314
3450
|
return __generator(this, function (_a) {
|
|
3315
3451
|
switch (_a.label) {
|
|
@@ -3341,12 +3477,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3341
3477
|
return __generator(this, function (_a) {
|
|
3342
3478
|
switch (_a.label) {
|
|
3343
3479
|
case 0:
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3480
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3481
|
+
this.loggerService.info("agentPublicService commitUserMessage", {
|
|
3482
|
+
methodName: methodName,
|
|
3483
|
+
message: message,
|
|
3484
|
+
clientId: clientId,
|
|
3485
|
+
agentName: agentName,
|
|
3486
|
+
});
|
|
3350
3487
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3351
3488
|
return __generator(this, function (_a) {
|
|
3352
3489
|
switch (_a.label) {
|
|
@@ -3377,11 +3514,12 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3377
3514
|
return __generator(this, function (_a) {
|
|
3378
3515
|
switch (_a.label) {
|
|
3379
3516
|
case 0:
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3517
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3518
|
+
this.loggerService.info("agentPublicService commitFlush", {
|
|
3519
|
+
methodName: methodName,
|
|
3520
|
+
clientId: clientId,
|
|
3521
|
+
agentName: agentName,
|
|
3522
|
+
});
|
|
3385
3523
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3386
3524
|
return __generator(this, function (_a) {
|
|
3387
3525
|
switch (_a.label) {
|
|
@@ -3412,11 +3550,12 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3412
3550
|
return __generator(this, function (_a) {
|
|
3413
3551
|
switch (_a.label) {
|
|
3414
3552
|
case 0:
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3553
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3554
|
+
this.loggerService.info("agentPublicService commitAgentChange", {
|
|
3555
|
+
methodName: methodName,
|
|
3556
|
+
clientId: clientId,
|
|
3557
|
+
agentName: agentName,
|
|
3558
|
+
});
|
|
3420
3559
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3421
3560
|
return __generator(this, function (_a) {
|
|
3422
3561
|
switch (_a.label) {
|
|
@@ -3447,11 +3586,12 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3447
3586
|
return __generator(this, function (_a) {
|
|
3448
3587
|
switch (_a.label) {
|
|
3449
3588
|
case 0:
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3589
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3590
|
+
this.loggerService.info("agentPublicService dispose", {
|
|
3591
|
+
methodName: methodName,
|
|
3592
|
+
clientId: clientId,
|
|
3593
|
+
agentName: agentName,
|
|
3594
|
+
});
|
|
3455
3595
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3456
3596
|
return __generator(this, function (_a) {
|
|
3457
3597
|
switch (_a.label) {
|
|
@@ -3495,12 +3635,13 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3495
3635
|
return __generator(this, function (_a) {
|
|
3496
3636
|
switch (_a.label) {
|
|
3497
3637
|
case 0:
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3638
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3639
|
+
this.loggerService.info("historyPublicService push", {
|
|
3640
|
+
methodName: methodName,
|
|
3641
|
+
message: message,
|
|
3642
|
+
clientId: clientId,
|
|
3643
|
+
agentName: agentName,
|
|
3644
|
+
});
|
|
3504
3645
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3505
3646
|
return __generator(this, function (_a) {
|
|
3506
3647
|
switch (_a.label) {
|
|
@@ -3532,11 +3673,12 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3532
3673
|
return __generator(this, function (_a) {
|
|
3533
3674
|
switch (_a.label) {
|
|
3534
3675
|
case 0:
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3676
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3677
|
+
this.loggerService.info("historyPublicService toArrayForAgent", {
|
|
3678
|
+
prompt: prompt,
|
|
3679
|
+
clientId: clientId,
|
|
3680
|
+
agentName: agentName,
|
|
3681
|
+
});
|
|
3540
3682
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3541
3683
|
return __generator(this, function (_a) {
|
|
3542
3684
|
switch (_a.label) {
|
|
@@ -3567,11 +3709,12 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3567
3709
|
return __generator(this, function (_a) {
|
|
3568
3710
|
switch (_a.label) {
|
|
3569
3711
|
case 0:
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3712
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3713
|
+
this.loggerService.info("historyPublicService toArrayForRaw", {
|
|
3714
|
+
methodName: methodName,
|
|
3715
|
+
clientId: clientId,
|
|
3716
|
+
agentName: agentName,
|
|
3717
|
+
});
|
|
3575
3718
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3576
3719
|
return __generator(this, function (_a) {
|
|
3577
3720
|
switch (_a.label) {
|
|
@@ -3602,10 +3745,11 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3602
3745
|
return __generator(this, function (_a) {
|
|
3603
3746
|
switch (_a.label) {
|
|
3604
3747
|
case 0:
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3748
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3749
|
+
this.loggerService.info("historyPublicService dispose", {
|
|
3750
|
+
clientId: clientId,
|
|
3751
|
+
agentName: agentName,
|
|
3752
|
+
});
|
|
3609
3753
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3610
3754
|
return __generator(this, function (_a) {
|
|
3611
3755
|
switch (_a.label) {
|
|
@@ -3649,12 +3793,13 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3649
3793
|
return __generator(this, function (_a) {
|
|
3650
3794
|
switch (_a.label) {
|
|
3651
3795
|
case 0:
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3796
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3797
|
+
this.loggerService.info("sessionPublicService emit", {
|
|
3798
|
+
content: content,
|
|
3799
|
+
clientId: clientId,
|
|
3800
|
+
methodName: methodName,
|
|
3801
|
+
swarmName: swarmName,
|
|
3802
|
+
});
|
|
3658
3803
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3659
3804
|
return __generator(this, function (_a) {
|
|
3660
3805
|
switch (_a.label) {
|
|
@@ -3686,12 +3831,13 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3686
3831
|
return __generator(this, function (_a) {
|
|
3687
3832
|
switch (_a.label) {
|
|
3688
3833
|
case 0:
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3834
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3835
|
+
this.loggerService.info("sessionPublicService execute", {
|
|
3836
|
+
content: content,
|
|
3837
|
+
mode: mode,
|
|
3838
|
+
clientId: clientId,
|
|
3839
|
+
swarmName: swarmName,
|
|
3840
|
+
});
|
|
3695
3841
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3696
3842
|
return __generator(this, function (_a) {
|
|
3697
3843
|
switch (_a.label) {
|
|
@@ -3719,11 +3865,12 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3719
3865
|
* @returns {ReceiveMessageFn}
|
|
3720
3866
|
*/
|
|
3721
3867
|
this.connect = function (connector, methodName, clientId, swarmName) {
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3868
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3869
|
+
_this.loggerService.info("sessionPublicService connect", {
|
|
3870
|
+
methodName: methodName,
|
|
3871
|
+
clientId: clientId,
|
|
3872
|
+
swarmName: swarmName,
|
|
3873
|
+
});
|
|
3727
3874
|
var send = _this.sessionConnectionService.connect(connector, clientId, swarmName);
|
|
3728
3875
|
return function (incoming) { return __awaiter(_this, void 0, void 0, function () {
|
|
3729
3876
|
var executionId;
|
|
@@ -3734,12 +3881,13 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3734
3881
|
return __generator(this, function (_a) {
|
|
3735
3882
|
switch (_a.label) {
|
|
3736
3883
|
case 0:
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3884
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
3885
|
+
this.loggerService.log("sessionPublicService connect execute", {
|
|
3886
|
+
content: incoming,
|
|
3887
|
+
methodName: methodName,
|
|
3888
|
+
clientId: clientId,
|
|
3889
|
+
executionId: executionId,
|
|
3890
|
+
});
|
|
3743
3891
|
return [4 /*yield*/, send(incoming)];
|
|
3744
3892
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3745
3893
|
}
|
|
@@ -3764,13 +3912,14 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3764
3912
|
return __generator(this, function (_a) {
|
|
3765
3913
|
switch (_a.label) {
|
|
3766
3914
|
case 0:
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3915
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3916
|
+
this.loggerService.info("sessionPublicService commitToolOutput", {
|
|
3917
|
+
methodName: methodName,
|
|
3918
|
+
toolId: toolId,
|
|
3919
|
+
content: content,
|
|
3920
|
+
clientId: clientId,
|
|
3921
|
+
swarmName: swarmName,
|
|
3922
|
+
});
|
|
3774
3923
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3775
3924
|
return __generator(this, function (_a) {
|
|
3776
3925
|
switch (_a.label) {
|
|
@@ -3802,12 +3951,13 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3802
3951
|
return __generator(this, function (_a) {
|
|
3803
3952
|
switch (_a.label) {
|
|
3804
3953
|
case 0:
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3954
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3955
|
+
this.loggerService.info("sessionPublicService commitSystemMessage", {
|
|
3956
|
+
methodName: methodName,
|
|
3957
|
+
message: message,
|
|
3958
|
+
clientId: clientId,
|
|
3959
|
+
swarmName: swarmName,
|
|
3960
|
+
});
|
|
3811
3961
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3812
3962
|
return __generator(this, function (_a) {
|
|
3813
3963
|
switch (_a.label) {
|
|
@@ -3839,12 +3989,13 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3839
3989
|
return __generator(this, function (_a) {
|
|
3840
3990
|
switch (_a.label) {
|
|
3841
3991
|
case 0:
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3992
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3993
|
+
this.loggerService.info("sessionPublicService commitUserMessage", {
|
|
3994
|
+
methodName: methodName,
|
|
3995
|
+
message: message,
|
|
3996
|
+
clientId: clientId,
|
|
3997
|
+
swarmName: swarmName,
|
|
3998
|
+
});
|
|
3848
3999
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3849
4000
|
return __generator(this, function (_a) {
|
|
3850
4001
|
switch (_a.label) {
|
|
@@ -3875,10 +4026,11 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3875
4026
|
return __generator(this, function (_a) {
|
|
3876
4027
|
switch (_a.label) {
|
|
3877
4028
|
case 0:
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
4029
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4030
|
+
this.loggerService.info("sessionPublicService commitFlush", {
|
|
4031
|
+
clientId: clientId,
|
|
4032
|
+
swarmName: swarmName,
|
|
4033
|
+
});
|
|
3882
4034
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3883
4035
|
return __generator(this, function (_a) {
|
|
3884
4036
|
switch (_a.label) {
|
|
@@ -3909,11 +4061,12 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3909
4061
|
return __generator(this, function (_a) {
|
|
3910
4062
|
switch (_a.label) {
|
|
3911
4063
|
case 0:
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
4064
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4065
|
+
this.loggerService.info("sessionPublicService dispose", {
|
|
4066
|
+
methodName: methodName,
|
|
4067
|
+
clientId: clientId,
|
|
4068
|
+
swarmName: swarmName,
|
|
4069
|
+
});
|
|
3917
4070
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3918
4071
|
return __generator(this, function (_a) {
|
|
3919
4072
|
switch (_a.label) {
|
|
@@ -3956,10 +4109,11 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3956
4109
|
return __generator(this, function (_a) {
|
|
3957
4110
|
switch (_a.label) {
|
|
3958
4111
|
case 0:
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
4112
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4113
|
+
this.loggerService.info("swarmPublicService cancelOutput", {
|
|
4114
|
+
clientId: clientId,
|
|
4115
|
+
swarmName: swarmName,
|
|
4116
|
+
});
|
|
3963
4117
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3964
4118
|
return __generator(this, function (_a) {
|
|
3965
4119
|
switch (_a.label) {
|
|
@@ -3990,11 +4144,12 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3990
4144
|
return __generator(this, function (_a) {
|
|
3991
4145
|
switch (_a.label) {
|
|
3992
4146
|
case 0:
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
4147
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4148
|
+
this.loggerService.info("swarmPublicService waitForOutput", {
|
|
4149
|
+
clientId: clientId,
|
|
4150
|
+
methodName: methodName,
|
|
4151
|
+
swarmName: swarmName,
|
|
4152
|
+
});
|
|
3998
4153
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3999
4154
|
return __generator(this, function (_a) {
|
|
4000
4155
|
switch (_a.label) {
|
|
@@ -4025,11 +4180,12 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4025
4180
|
return __generator(this, function (_a) {
|
|
4026
4181
|
switch (_a.label) {
|
|
4027
4182
|
case 0:
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4183
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4184
|
+
this.loggerService.info("swarmPublicService getAgentName", {
|
|
4185
|
+
clientId: clientId,
|
|
4186
|
+
swarmName: swarmName,
|
|
4187
|
+
methodName: methodName,
|
|
4188
|
+
});
|
|
4033
4189
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
4034
4190
|
return __generator(this, function (_a) {
|
|
4035
4191
|
switch (_a.label) {
|
|
@@ -4060,10 +4216,11 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4060
4216
|
return __generator(this, function (_a) {
|
|
4061
4217
|
switch (_a.label) {
|
|
4062
4218
|
case 0:
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4219
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4220
|
+
this.loggerService.info("swarmPublicService getAgent", {
|
|
4221
|
+
clientId: clientId,
|
|
4222
|
+
swarmName: swarmName,
|
|
4223
|
+
});
|
|
4067
4224
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
4068
4225
|
return __generator(this, function (_a) {
|
|
4069
4226
|
switch (_a.label) {
|
|
@@ -4096,13 +4253,14 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4096
4253
|
return __generator(this, function (_a) {
|
|
4097
4254
|
switch (_a.label) {
|
|
4098
4255
|
case 0:
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4256
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4257
|
+
this.loggerService.info("swarmPublicService setAgentRef", {
|
|
4258
|
+
methodName: methodName,
|
|
4259
|
+
agentName: agentName,
|
|
4260
|
+
agent: agent,
|
|
4261
|
+
clientId: clientId,
|
|
4262
|
+
swarmName: swarmName,
|
|
4263
|
+
});
|
|
4106
4264
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
4107
4265
|
return __generator(this, function (_a) {
|
|
4108
4266
|
switch (_a.label) {
|
|
@@ -4134,12 +4292,13 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4134
4292
|
return __generator(this, function (_a) {
|
|
4135
4293
|
switch (_a.label) {
|
|
4136
4294
|
case 0:
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4295
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4296
|
+
this.loggerService.info("swarmPublicService setAgentName", {
|
|
4297
|
+
methodName: methodName,
|
|
4298
|
+
agentName: agentName,
|
|
4299
|
+
clientId: clientId,
|
|
4300
|
+
swarmName: swarmName,
|
|
4301
|
+
});
|
|
4143
4302
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
4144
4303
|
return __generator(this, function (_a) {
|
|
4145
4304
|
switch (_a.label) {
|
|
@@ -4170,11 +4329,12 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4170
4329
|
return __generator(this, function (_a) {
|
|
4171
4330
|
switch (_a.label) {
|
|
4172
4331
|
case 0:
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4332
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4333
|
+
this.loggerService.info("swarmPublicService dispose", {
|
|
4334
|
+
methodName: methodName,
|
|
4335
|
+
clientId: clientId,
|
|
4336
|
+
swarmName: swarmName,
|
|
4337
|
+
});
|
|
4178
4338
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
4179
4339
|
return __generator(this, function (_a) {
|
|
4180
4340
|
switch (_a.label) {
|
|
@@ -4240,10 +4400,11 @@ var AgentValidationService = /** @class */ (function () {
|
|
|
4240
4400
|
* @throws {Error} If the agent already exists.
|
|
4241
4401
|
*/
|
|
4242
4402
|
this.addAgent = function (agentName, agentSchema) {
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4403
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4404
|
+
_this.loggerService.info("agentValidationService addAgent", {
|
|
4405
|
+
agentName: agentName,
|
|
4406
|
+
agentSchema: agentSchema,
|
|
4407
|
+
});
|
|
4247
4408
|
if (_this._agentMap.has(agentName)) {
|
|
4248
4409
|
throw new Error("agent-swarm agent ".concat(agentName, " already exist"));
|
|
4249
4410
|
}
|
|
@@ -4256,10 +4417,11 @@ var AgentValidationService = /** @class */ (function () {
|
|
|
4256
4417
|
var _b = __read(_a, 2), agentName = _b[0], storageName = _b[1];
|
|
4257
4418
|
return "".concat(agentName, "-").concat(storageName);
|
|
4258
4419
|
}, function (agentName, storageName) {
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4420
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4421
|
+
_this.loggerService.info("agentValidationService hasStorage", {
|
|
4422
|
+
agentName: agentName,
|
|
4423
|
+
storageName: storageName,
|
|
4424
|
+
});
|
|
4263
4425
|
if (!_this._agentMap.has(agentName)) {
|
|
4264
4426
|
throw new Error("agent-swarm agent ".concat(agentName, " not exist (hasStorage)"));
|
|
4265
4427
|
}
|
|
@@ -4273,10 +4435,11 @@ var AgentValidationService = /** @class */ (function () {
|
|
|
4273
4435
|
var _b = __read(_a, 2), agentName = _b[0], stateName = _b[1];
|
|
4274
4436
|
return "".concat(agentName, "-").concat(stateName);
|
|
4275
4437
|
}, function (agentName, stateName) {
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4438
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4439
|
+
_this.loggerService.info("agentValidationService hasState", {
|
|
4440
|
+
agentName: agentName,
|
|
4441
|
+
stateName: stateName,
|
|
4442
|
+
});
|
|
4280
4443
|
if (!_this._agentMap.has(agentName)) {
|
|
4281
4444
|
throw new Error("agent-swarm agent ".concat(agentName, " not exist (hasState)"));
|
|
4282
4445
|
}
|
|
@@ -4294,10 +4457,11 @@ var AgentValidationService = /** @class */ (function () {
|
|
|
4294
4457
|
return agentName;
|
|
4295
4458
|
}, function (agentName, source) {
|
|
4296
4459
|
var _a, _b;
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4460
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4461
|
+
_this.loggerService.info("agentValidationService validate", {
|
|
4462
|
+
agentName: agentName,
|
|
4463
|
+
source: source,
|
|
4464
|
+
});
|
|
4301
4465
|
var agent = _this._agentMap.get(agentName);
|
|
4302
4466
|
if (!agent) {
|
|
4303
4467
|
throw new Error("agent-swarm agent ".concat(agentName, " not found source=").concat(source));
|
|
@@ -4335,9 +4499,10 @@ var CompletionValidationService = /** @class */ (function () {
|
|
|
4335
4499
|
* @throws Will throw an error if the completion name already exists.
|
|
4336
4500
|
*/
|
|
4337
4501
|
this.addCompletion = function (completionName) {
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4502
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4503
|
+
_this.loggerService.info("completionValidationService addCompletion", {
|
|
4504
|
+
completionName: completionName,
|
|
4505
|
+
});
|
|
4341
4506
|
if (_this._completionSet.has(completionName)) {
|
|
4342
4507
|
throw new Error("agent-swarm completion ".concat(completionName, " already exist"));
|
|
4343
4508
|
}
|
|
@@ -4353,10 +4518,11 @@ var CompletionValidationService = /** @class */ (function () {
|
|
|
4353
4518
|
var _b = __read(_a, 1), completionName = _b[0];
|
|
4354
4519
|
return completionName;
|
|
4355
4520
|
}, function (completionName, source) {
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4521
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4522
|
+
_this.loggerService.info("completionValidationService validate", {
|
|
4523
|
+
completionName: completionName,
|
|
4524
|
+
source: source,
|
|
4525
|
+
});
|
|
4360
4526
|
if (!_this._completionSet.has(completionName)) {
|
|
4361
4527
|
throw new Error("agent-swarm completion ".concat(completionName, " not found source=").concat(source));
|
|
4362
4528
|
}
|
|
@@ -4387,9 +4553,10 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
4387
4553
|
* @throws Will throw an error if the session already exists.
|
|
4388
4554
|
*/
|
|
4389
4555
|
this.addSession = function (clientId, swarmName, sessionMode) {
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4556
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4557
|
+
_this.loggerService.info("sessionValidationService addSession", {
|
|
4558
|
+
clientId: clientId,
|
|
4559
|
+
});
|
|
4393
4560
|
if (_this._sessionSwarmMap.has(clientId)) {
|
|
4394
4561
|
throw new Error("agent-swarm session clientId=".concat(clientId, " already exist"));
|
|
4395
4562
|
}
|
|
@@ -4402,10 +4569,11 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
4402
4569
|
* @param {AgentName} agentName - The name of the agent.
|
|
4403
4570
|
*/
|
|
4404
4571
|
this.addAgentUsage = function (sessionId, agentName) {
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4572
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4573
|
+
_this.loggerService.info("sessionValidationService addAgentUsage", {
|
|
4574
|
+
sessionId: sessionId,
|
|
4575
|
+
agentName: agentName,
|
|
4576
|
+
});
|
|
4409
4577
|
if (_this._agentSwarmMap.has(sessionId)) {
|
|
4410
4578
|
var agents = _this._agentSwarmMap.get(sessionId);
|
|
4411
4579
|
if (!agents.includes(agentName)) {
|
|
@@ -4422,10 +4590,11 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
4422
4590
|
* @param {AgentName} agentName - The name of the agent.
|
|
4423
4591
|
*/
|
|
4424
4592
|
this.addHistoryUsage = function (sessionId, agentName) {
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4593
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4594
|
+
_this.loggerService.info("sessionValidationService addHistoryUsage", {
|
|
4595
|
+
sessionId: sessionId,
|
|
4596
|
+
agentName: agentName,
|
|
4597
|
+
});
|
|
4429
4598
|
if (_this._historySwarmMap.has(sessionId)) {
|
|
4430
4599
|
var agents = _this._historySwarmMap.get(sessionId);
|
|
4431
4600
|
if (!agents.includes(agentName)) {
|
|
@@ -4442,10 +4611,11 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
4442
4611
|
* @param {StorageName} storageName - The name of the storage.
|
|
4443
4612
|
*/
|
|
4444
4613
|
this.addStorageUsage = function (sessionId, storageName) {
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4614
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4615
|
+
_this.loggerService.info("sessionValidationService addStorageUsage", {
|
|
4616
|
+
sessionId: sessionId,
|
|
4617
|
+
storageName: storageName,
|
|
4618
|
+
});
|
|
4449
4619
|
if (_this._storageSwarmMap.has(sessionId)) {
|
|
4450
4620
|
var storages = _this._storageSwarmMap.get(sessionId);
|
|
4451
4621
|
if (!storages.includes(storageName)) {
|
|
@@ -4462,10 +4632,11 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
4462
4632
|
* @param {StateName} stateName - The name of the state.
|
|
4463
4633
|
*/
|
|
4464
4634
|
this.addStateUsage = function (sessionId, stateName) {
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4635
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4636
|
+
_this.loggerService.info("sessionValidationService addStateUsage", {
|
|
4637
|
+
sessionId: sessionId,
|
|
4638
|
+
stateName: stateName,
|
|
4639
|
+
});
|
|
4469
4640
|
if (_this._stateSwarmMap.has(sessionId)) {
|
|
4470
4641
|
var states = _this._stateSwarmMap.get(sessionId);
|
|
4471
4642
|
if (!states.includes(stateName)) {
|
|
@@ -4483,10 +4654,11 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
4483
4654
|
* @throws Will throw an error if no agents are found for the session.
|
|
4484
4655
|
*/
|
|
4485
4656
|
this.removeAgentUsage = function (sessionId, agentName) {
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4657
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4658
|
+
_this.loggerService.info("sessionValidationService removeAgentUsage", {
|
|
4659
|
+
sessionId: sessionId,
|
|
4660
|
+
agentName: agentName,
|
|
4661
|
+
});
|
|
4490
4662
|
if (_this._agentSwarmMap.has(sessionId)) {
|
|
4491
4663
|
var agents = _this._agentSwarmMap.get(sessionId);
|
|
4492
4664
|
var agentIndex = agents.indexOf(agentName);
|
|
@@ -4508,10 +4680,11 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
4508
4680
|
* @throws Will throw an error if no agents are found for the session.
|
|
4509
4681
|
*/
|
|
4510
4682
|
this.removeHistoryUsage = function (sessionId, agentName) {
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4683
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4684
|
+
_this.loggerService.info("sessionValidationService removeHistoryUsage", {
|
|
4685
|
+
sessionId: sessionId,
|
|
4686
|
+
agentName: agentName,
|
|
4687
|
+
});
|
|
4515
4688
|
if (_this._historySwarmMap.has(sessionId)) {
|
|
4516
4689
|
var agents = _this._historySwarmMap.get(sessionId);
|
|
4517
4690
|
var agentIndex = agents.indexOf(agentName);
|
|
@@ -4533,10 +4706,11 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
4533
4706
|
* @throws Will throw an error if no storages are found for the session.
|
|
4534
4707
|
*/
|
|
4535
4708
|
this.removeStorageUsage = function (sessionId, storageName) {
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4709
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4710
|
+
_this.loggerService.info("sessionValidationService removeStorageUsage", {
|
|
4711
|
+
sessionId: sessionId,
|
|
4712
|
+
storageName: storageName,
|
|
4713
|
+
});
|
|
4540
4714
|
if (_this._storageSwarmMap.has(sessionId)) {
|
|
4541
4715
|
var agents = _this._storageSwarmMap.get(sessionId);
|
|
4542
4716
|
var agentIndex = agents.indexOf(storageName);
|
|
@@ -4558,10 +4732,11 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
4558
4732
|
* @throws Will throw an error if no states are found for the session.
|
|
4559
4733
|
*/
|
|
4560
4734
|
this.removeStateUsage = function (sessionId, stateName) {
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4735
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4736
|
+
_this.loggerService.info("sessionValidationService removeStateUsage", {
|
|
4737
|
+
sessionId: sessionId,
|
|
4738
|
+
stateName: stateName,
|
|
4739
|
+
});
|
|
4565
4740
|
if (_this._stateSwarmMap.has(sessionId)) {
|
|
4566
4741
|
var agents = _this._stateSwarmMap.get(sessionId);
|
|
4567
4742
|
var agentIndex = agents.indexOf(stateName);
|
|
@@ -4583,9 +4758,10 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
4583
4758
|
* @throws Will throw an error if the session does not exist.
|
|
4584
4759
|
*/
|
|
4585
4760
|
this.getSessionMode = function (clientId) {
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4761
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4762
|
+
_this.loggerService.info("sessionValidationService getSessionMode", {
|
|
4763
|
+
clientId: clientId,
|
|
4764
|
+
});
|
|
4589
4765
|
if (!_this._sessionModeMap.has(clientId)) {
|
|
4590
4766
|
throw new Error("agent-swarm session getSessionMode clientId=".concat(clientId, " session not exist"));
|
|
4591
4767
|
}
|
|
@@ -4596,7 +4772,8 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
4596
4772
|
* @returns {boolean}
|
|
4597
4773
|
*/
|
|
4598
4774
|
this.hasSession = function (clientId) {
|
|
4599
|
-
|
|
4775
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4776
|
+
_this.loggerService.info("sessionValidationService hasSession");
|
|
4600
4777
|
return _this._sessionSwarmMap.has(clientId);
|
|
4601
4778
|
};
|
|
4602
4779
|
/**
|
|
@@ -4604,7 +4781,8 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
4604
4781
|
* @returns {SessionId[]} The list of session IDs.
|
|
4605
4782
|
*/
|
|
4606
4783
|
this.getSessionList = function () {
|
|
4607
|
-
|
|
4784
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4785
|
+
_this.loggerService.info("sessionValidationService getSessionList");
|
|
4608
4786
|
return __spreadArray([], __read(_this._sessionSwarmMap.keys()), false);
|
|
4609
4787
|
};
|
|
4610
4788
|
/**
|
|
@@ -4614,9 +4792,10 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
4614
4792
|
*/
|
|
4615
4793
|
this.getSessionAgentList = function (clientId) {
|
|
4616
4794
|
var _a;
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4795
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4796
|
+
_this.loggerService.info("sessionValidationService getSessionAgentList", {
|
|
4797
|
+
clientId: clientId,
|
|
4798
|
+
});
|
|
4620
4799
|
return (_a = _this._agentSwarmMap.get(clientId)) !== null && _a !== void 0 ? _a : [];
|
|
4621
4800
|
};
|
|
4622
4801
|
/**
|
|
@@ -4626,9 +4805,10 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
4626
4805
|
*/
|
|
4627
4806
|
this.getSessionHistoryList = function (clientId) {
|
|
4628
4807
|
var _a;
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4808
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4809
|
+
_this.loggerService.info("sessionValidationService getSessionHistoryList", {
|
|
4810
|
+
clientId: clientId,
|
|
4811
|
+
});
|
|
4632
4812
|
return (_a = _this._agentSwarmMap.get(clientId)) !== null && _a !== void 0 ? _a : [];
|
|
4633
4813
|
};
|
|
4634
4814
|
/**
|
|
@@ -4638,9 +4818,10 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
4638
4818
|
* @throws Will throw an error if the session does not exist.
|
|
4639
4819
|
*/
|
|
4640
4820
|
this.getSwarm = function (clientId) {
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4821
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4822
|
+
_this.loggerService.info("sessionValidationService getSwarm", {
|
|
4823
|
+
clientId: clientId,
|
|
4824
|
+
});
|
|
4644
4825
|
var session = _this._sessionSwarmMap.get(clientId);
|
|
4645
4826
|
if (session === undefined) {
|
|
4646
4827
|
throw new Error("agent-swarm session clientId=".concat(clientId, " not found"));
|
|
@@ -4654,7 +4835,10 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
4654
4835
|
* @throws Will throw an error if the session does not exist.
|
|
4655
4836
|
*/
|
|
4656
4837
|
this.validate = function (clientId, source) {
|
|
4657
|
-
|
|
4838
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4839
|
+
_this.loggerService.info("sessionValidationService validate", {
|
|
4840
|
+
clientId: clientId,
|
|
4841
|
+
});
|
|
4658
4842
|
if (!_this._sessionSwarmMap.has(clientId)) {
|
|
4659
4843
|
throw new Error("agent-swarm session clientId=".concat(clientId, " not exist source=").concat(source));
|
|
4660
4844
|
}
|
|
@@ -4665,9 +4849,10 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
4665
4849
|
* @param {SessionId} clientId - The ID of the client.
|
|
4666
4850
|
*/
|
|
4667
4851
|
this.removeSession = function (clientId) {
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4852
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4853
|
+
_this.loggerService.info("sessionValidationService addSession", {
|
|
4854
|
+
clientId: clientId,
|
|
4855
|
+
});
|
|
4671
4856
|
_this._sessionSwarmMap.delete(clientId);
|
|
4672
4857
|
_this._sessionModeMap.delete(clientId);
|
|
4673
4858
|
};
|
|
@@ -4691,10 +4876,11 @@ var SwarmValidationService = /** @class */ (function () {
|
|
|
4691
4876
|
* @throws Will throw an error if the swarm already exists.
|
|
4692
4877
|
*/
|
|
4693
4878
|
this.addSwarm = function (swarmName, swarmSchema) {
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4879
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4880
|
+
_this.loggerService.info("swarmValidationService addSwarm", {
|
|
4881
|
+
swarmName: swarmName,
|
|
4882
|
+
swarmSchema: swarmSchema,
|
|
4883
|
+
});
|
|
4698
4884
|
if (_this._swarmMap.has(swarmName)) {
|
|
4699
4885
|
throw new Error("swarm-swarm swarm ".concat(swarmName, " already exist"));
|
|
4700
4886
|
}
|
|
@@ -4707,9 +4893,10 @@ var SwarmValidationService = /** @class */ (function () {
|
|
|
4707
4893
|
* @throws Will throw an error if the swarm is not found.
|
|
4708
4894
|
*/
|
|
4709
4895
|
this.getAgentList = function (swarmName) {
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4896
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4897
|
+
_this.loggerService.info("swarmValidationService getAgentList", {
|
|
4898
|
+
swarmName: swarmName,
|
|
4899
|
+
});
|
|
4713
4900
|
var swarm = _this._swarmMap.get(swarmName);
|
|
4714
4901
|
if (!swarm) {
|
|
4715
4902
|
throw new Error("agent-swarm swarm ".concat(swarmName, " not found"));
|
|
@@ -4726,10 +4913,11 @@ var SwarmValidationService = /** @class */ (function () {
|
|
|
4726
4913
|
var _b = __read(_a, 1), swarmName = _b[0];
|
|
4727
4914
|
return swarmName;
|
|
4728
4915
|
}, function (swarmName, source) {
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4916
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4917
|
+
_this.loggerService.info("swarmValidationService validate", {
|
|
4918
|
+
swarmName: swarmName,
|
|
4919
|
+
source: source,
|
|
4920
|
+
});
|
|
4733
4921
|
var swarm = _this._swarmMap.get(swarmName);
|
|
4734
4922
|
if (!swarm) {
|
|
4735
4923
|
throw new Error("agent-swarm swarm ".concat(swarmName, " not found"));
|
|
@@ -4761,10 +4949,11 @@ var ToolValidationService = /** @class */ (function () {
|
|
|
4761
4949
|
* @throws Will throw an error if the tool already exists.
|
|
4762
4950
|
*/
|
|
4763
4951
|
this.addTool = function (toolName, toolSchema) {
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4952
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4953
|
+
_this.loggerService.info("toolValidationService addTool", {
|
|
4954
|
+
toolName: toolName,
|
|
4955
|
+
toolSchema: toolSchema,
|
|
4956
|
+
});
|
|
4768
4957
|
if (_this._toolMap.has(toolName)) {
|
|
4769
4958
|
throw new Error("agent-swarm tool ".concat(toolName, " already exist"));
|
|
4770
4959
|
}
|
|
@@ -4780,10 +4969,11 @@ var ToolValidationService = /** @class */ (function () {
|
|
|
4780
4969
|
var _b = __read(_a, 1), toolName = _b[0];
|
|
4781
4970
|
return toolName;
|
|
4782
4971
|
}, function (toolName, source) {
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4972
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4973
|
+
_this.loggerService.info("toolValidationService validate", {
|
|
4974
|
+
toolName: toolName,
|
|
4975
|
+
source: source,
|
|
4976
|
+
});
|
|
4787
4977
|
if (!_this._toolMap.has(toolName)) {
|
|
4788
4978
|
throw new Error("agent-swarm tool ".concat(toolName, " not found source=").concat(source));
|
|
4789
4979
|
}
|
|
@@ -4807,7 +4997,8 @@ var EmbeddingSchemaService = /** @class */ (function () {
|
|
|
4807
4997
|
* @param {IAgentTool} value - The embedding to register.
|
|
4808
4998
|
*/
|
|
4809
4999
|
this.register = function (key, value) {
|
|
4810
|
-
|
|
5000
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5001
|
+
_this.loggerService.info("embeddingSchemaService register");
|
|
4811
5002
|
_this.registry = _this.registry.register(key, value);
|
|
4812
5003
|
};
|
|
4813
5004
|
/**
|
|
@@ -4816,7 +5007,8 @@ var EmbeddingSchemaService = /** @class */ (function () {
|
|
|
4816
5007
|
* @returns {IAgentTool} The embedding associated with the given key.
|
|
4817
5008
|
*/
|
|
4818
5009
|
this.get = function (key) {
|
|
4819
|
-
|
|
5010
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5011
|
+
_this.loggerService.info("embeddingSchemaService get", { key: key });
|
|
4820
5012
|
return _this.registry.get(key);
|
|
4821
5013
|
};
|
|
4822
5014
|
}
|
|
@@ -4837,7 +5029,8 @@ var StorageSchemaService = /** @class */ (function () {
|
|
|
4837
5029
|
* @param {IStorageSchema} value - The schema to register.
|
|
4838
5030
|
*/
|
|
4839
5031
|
this.register = function (key, value) {
|
|
4840
|
-
|
|
5032
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5033
|
+
_this.loggerService.info("storageSchemaService register", { key: key });
|
|
4841
5034
|
_this.registry = _this.registry.register(key, value);
|
|
4842
5035
|
};
|
|
4843
5036
|
/**
|
|
@@ -4846,7 +5039,8 @@ var StorageSchemaService = /** @class */ (function () {
|
|
|
4846
5039
|
* @returns {IStorageSchema} The retrieved schema.
|
|
4847
5040
|
*/
|
|
4848
5041
|
this.get = function (key) {
|
|
4849
|
-
|
|
5042
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5043
|
+
_this.loggerService.info("storageSchemaService get", { key: key });
|
|
4850
5044
|
return _this.registry.get(key);
|
|
4851
5045
|
};
|
|
4852
5046
|
}
|
|
@@ -4880,9 +5074,10 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4880
5074
|
return __generator(this, function (_a) {
|
|
4881
5075
|
switch (_a.label) {
|
|
4882
5076
|
case 0:
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
5077
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
5078
|
+
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " _createEmbedding"), {
|
|
5079
|
+
id: item.id,
|
|
5080
|
+
});
|
|
4886
5081
|
return [4 /*yield*/, this.params.createIndex(item)];
|
|
4887
5082
|
case 1:
|
|
4888
5083
|
index = _a.sent();
|
|
@@ -4905,7 +5100,8 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4905
5100
|
return __generator(this, function (_a) {
|
|
4906
5101
|
switch (_a.label) {
|
|
4907
5102
|
case 0:
|
|
4908
|
-
|
|
5103
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
5104
|
+
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " waitForInit"));
|
|
4909
5105
|
if (!this.params.getData) {
|
|
4910
5106
|
return [2 /*return*/];
|
|
4911
5107
|
}
|
|
@@ -4943,10 +5139,11 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4943
5139
|
return __generator(this, function (_c) {
|
|
4944
5140
|
switch (_c.label) {
|
|
4945
5141
|
case 0:
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
5142
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
5143
|
+
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " take"), {
|
|
5144
|
+
search: search,
|
|
5145
|
+
total: total,
|
|
5146
|
+
});
|
|
4950
5147
|
indexed = new functoolsKit.SortedArray();
|
|
4951
5148
|
return [4 /*yield*/, this.params.createEmbedding(search)];
|
|
4952
5149
|
case 1:
|
|
@@ -4977,9 +5174,10 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4977
5174
|
})))];
|
|
4978
5175
|
case 2:
|
|
4979
5176
|
_c.sent();
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
5177
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
5178
|
+
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " take indexed"), {
|
|
5179
|
+
indexed: indexed.getEntries(),
|
|
5180
|
+
});
|
|
4983
5181
|
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onSearch) {
|
|
4984
5182
|
(_b = this.params.callbacks) === null || _b === void 0 ? void 0 : _b.onSearch(search, indexed, this.params.clientId, this.params.storageName);
|
|
4985
5183
|
}
|
|
@@ -5016,9 +5214,10 @@ var ClientStorage = /** @class */ (function () {
|
|
|
5016
5214
|
return __generator(this, function (_c) {
|
|
5017
5215
|
switch (_c.label) {
|
|
5018
5216
|
case 0:
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5217
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
5218
|
+
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " upsert"), {
|
|
5219
|
+
item: item,
|
|
5220
|
+
});
|
|
5022
5221
|
this._itemMap.set(item.id, item);
|
|
5023
5222
|
this._createEmbedding.clear(item.id);
|
|
5024
5223
|
return [4 /*yield*/, this._createEmbedding(item)];
|
|
@@ -5055,9 +5254,10 @@ var ClientStorage = /** @class */ (function () {
|
|
|
5055
5254
|
return __generator(this, function (_c) {
|
|
5056
5255
|
switch (_c.label) {
|
|
5057
5256
|
case 0:
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5257
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
5258
|
+
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " remove"), {
|
|
5259
|
+
id: itemId,
|
|
5260
|
+
});
|
|
5061
5261
|
this._itemMap.delete(itemId);
|
|
5062
5262
|
this._createEmbedding.clear(itemId);
|
|
5063
5263
|
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onUpdate) {
|
|
@@ -5089,7 +5289,8 @@ var ClientStorage = /** @class */ (function () {
|
|
|
5089
5289
|
return __generator(this, function (_a) {
|
|
5090
5290
|
switch (_a.label) {
|
|
5091
5291
|
case 0:
|
|
5092
|
-
|
|
5292
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
5293
|
+
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " clear"));
|
|
5093
5294
|
this._itemMap.clear();
|
|
5094
5295
|
this._createEmbedding.clear();
|
|
5095
5296
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
@@ -5119,9 +5320,10 @@ var ClientStorage = /** @class */ (function () {
|
|
|
5119
5320
|
return __generator(this, function (_b) {
|
|
5120
5321
|
switch (_b.label) {
|
|
5121
5322
|
case 0:
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5323
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
5324
|
+
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " get"), {
|
|
5325
|
+
id: itemId,
|
|
5326
|
+
});
|
|
5125
5327
|
result = (_a = this._itemMap.get(itemId)) !== null && _a !== void 0 ? _a : null;
|
|
5126
5328
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
5127
5329
|
type: "get",
|
|
@@ -5154,7 +5356,8 @@ var ClientStorage = /** @class */ (function () {
|
|
|
5154
5356
|
return __generator(this, function (_d) {
|
|
5155
5357
|
switch (_d.label) {
|
|
5156
5358
|
case 0:
|
|
5157
|
-
|
|
5359
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
5360
|
+
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " list"));
|
|
5158
5361
|
if (!filter) {
|
|
5159
5362
|
return [2 /*return*/, __spreadArray([], __read(this._itemMap.values()), false)];
|
|
5160
5363
|
}
|
|
@@ -5199,16 +5402,18 @@ var ClientStorage = /** @class */ (function () {
|
|
|
5199
5402
|
this.dispose = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5200
5403
|
var _a;
|
|
5201
5404
|
return __generator(this, function (_b) {
|
|
5202
|
-
|
|
5405
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
5406
|
+
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " dispose"));
|
|
5203
5407
|
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onDispose) {
|
|
5204
5408
|
this.params.callbacks.onDispose(this.params.clientId, this.params.storageName);
|
|
5205
5409
|
}
|
|
5206
5410
|
return [2 /*return*/];
|
|
5207
5411
|
});
|
|
5208
5412
|
}); };
|
|
5209
|
-
|
|
5210
|
-
params
|
|
5211
|
-
|
|
5413
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
5414
|
+
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " CTOR"), {
|
|
5415
|
+
params: params,
|
|
5416
|
+
});
|
|
5212
5417
|
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onInit) {
|
|
5213
5418
|
this.params.callbacks.onInit(this.params.clientId, this.params.storageName);
|
|
5214
5419
|
}
|
|
@@ -5275,11 +5480,12 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5275
5480
|
return __generator(this, function (_a) {
|
|
5276
5481
|
switch (_a.label) {
|
|
5277
5482
|
case 0:
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5483
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5484
|
+
this.loggerService.info("storageConnectionService take", {
|
|
5485
|
+
search: search,
|
|
5486
|
+
total: total,
|
|
5487
|
+
score: score,
|
|
5488
|
+
});
|
|
5283
5489
|
storage = this.getStorage(this.methodContextService.context.clientId, this.methodContextService.context.storageName);
|
|
5284
5490
|
return [4 /*yield*/, storage.waitForInit()];
|
|
5285
5491
|
case 1:
|
|
@@ -5299,9 +5505,10 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5299
5505
|
return __generator(this, function (_a) {
|
|
5300
5506
|
switch (_a.label) {
|
|
5301
5507
|
case 0:
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5508
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5509
|
+
this.loggerService.info("storageConnectionService upsert", {
|
|
5510
|
+
item: item,
|
|
5511
|
+
});
|
|
5305
5512
|
storage = this.getStorage(this.methodContextService.context.clientId, this.methodContextService.context.storageName);
|
|
5306
5513
|
return [4 /*yield*/, storage.waitForInit()];
|
|
5307
5514
|
case 1:
|
|
@@ -5321,9 +5528,10 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5321
5528
|
return __generator(this, function (_a) {
|
|
5322
5529
|
switch (_a.label) {
|
|
5323
5530
|
case 0:
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5531
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5532
|
+
this.loggerService.info("storageConnectionService remove", {
|
|
5533
|
+
itemId: itemId,
|
|
5534
|
+
});
|
|
5327
5535
|
storage = this.getStorage(this.methodContextService.context.clientId, this.methodContextService.context.storageName);
|
|
5328
5536
|
return [4 /*yield*/, storage.waitForInit()];
|
|
5329
5537
|
case 1:
|
|
@@ -5343,9 +5551,10 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5343
5551
|
return __generator(this, function (_a) {
|
|
5344
5552
|
switch (_a.label) {
|
|
5345
5553
|
case 0:
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5554
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5555
|
+
this.loggerService.info("storageConnectionService get", {
|
|
5556
|
+
itemId: itemId,
|
|
5557
|
+
});
|
|
5349
5558
|
storage = this.getStorage(this.methodContextService.context.clientId, this.methodContextService.context.storageName);
|
|
5350
5559
|
return [4 /*yield*/, storage.waitForInit()];
|
|
5351
5560
|
case 1:
|
|
@@ -5365,7 +5574,8 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5365
5574
|
return __generator(this, function (_a) {
|
|
5366
5575
|
switch (_a.label) {
|
|
5367
5576
|
case 0:
|
|
5368
|
-
|
|
5577
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5578
|
+
this.loggerService.info("storageConnectionService list");
|
|
5369
5579
|
storage = this.getStorage(this.methodContextService.context.clientId, this.methodContextService.context.storageName);
|
|
5370
5580
|
return [4 /*yield*/, storage.waitForInit()];
|
|
5371
5581
|
case 1:
|
|
@@ -5384,7 +5594,8 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5384
5594
|
return __generator(this, function (_a) {
|
|
5385
5595
|
switch (_a.label) {
|
|
5386
5596
|
case 0:
|
|
5387
|
-
|
|
5597
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5598
|
+
this.loggerService.info("storageConnectionService clear");
|
|
5388
5599
|
storage = this.getStorage(this.methodContextService.context.clientId, this.methodContextService.context.storageName);
|
|
5389
5600
|
return [4 /*yield*/, storage.waitForInit()];
|
|
5390
5601
|
case 1:
|
|
@@ -5403,7 +5614,8 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5403
5614
|
return __generator(this, function (_a) {
|
|
5404
5615
|
switch (_a.label) {
|
|
5405
5616
|
case 0:
|
|
5406
|
-
|
|
5617
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5618
|
+
this.loggerService.info("storageConnectionService dispose");
|
|
5407
5619
|
key = "".concat(this.methodContextService.context.clientId, "-").concat(this.methodContextService.context.storageName);
|
|
5408
5620
|
if (!this.getStorage.has(key)) {
|
|
5409
5621
|
return [2 /*return*/];
|
|
@@ -5447,14 +5659,15 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5447
5659
|
return __generator(this, function (_a) {
|
|
5448
5660
|
switch (_a.label) {
|
|
5449
5661
|
case 0:
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5662
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5663
|
+
this.loggerService.info("storagePublicService take", {
|
|
5664
|
+
methodName: methodName,
|
|
5665
|
+
search: search,
|
|
5666
|
+
total: total,
|
|
5667
|
+
clientId: clientId,
|
|
5668
|
+
storageName: storageName,
|
|
5669
|
+
score: score,
|
|
5670
|
+
});
|
|
5458
5671
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5459
5672
|
return __generator(this, function (_a) {
|
|
5460
5673
|
switch (_a.label) {
|
|
@@ -5484,11 +5697,12 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5484
5697
|
return __generator(this, function (_a) {
|
|
5485
5698
|
switch (_a.label) {
|
|
5486
5699
|
case 0:
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5700
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5701
|
+
this.loggerService.info("storagePublicService upsert", {
|
|
5702
|
+
item: item,
|
|
5703
|
+
clientId: clientId,
|
|
5704
|
+
storageName: storageName,
|
|
5705
|
+
});
|
|
5492
5706
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5493
5707
|
return __generator(this, function (_a) {
|
|
5494
5708
|
switch (_a.label) {
|
|
@@ -5518,11 +5732,12 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5518
5732
|
return __generator(this, function (_a) {
|
|
5519
5733
|
switch (_a.label) {
|
|
5520
5734
|
case 0:
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5735
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5736
|
+
this.loggerService.info("storagePublicService remove", {
|
|
5737
|
+
itemId: itemId,
|
|
5738
|
+
clientId: clientId,
|
|
5739
|
+
storageName: storageName,
|
|
5740
|
+
});
|
|
5526
5741
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5527
5742
|
return __generator(this, function (_a) {
|
|
5528
5743
|
switch (_a.label) {
|
|
@@ -5552,14 +5767,15 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5552
5767
|
return __generator(this, function (_a) {
|
|
5553
5768
|
switch (_a.label) {
|
|
5554
5769
|
case 0:
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5770
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5771
|
+
this.loggerService.info("storagePublicService get", {
|
|
5772
|
+
methodName: methodName,
|
|
5773
|
+
itemId: itemId,
|
|
5774
|
+
clientId: clientId,
|
|
5775
|
+
storageName: storageName,
|
|
5776
|
+
});
|
|
5777
|
+
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5778
|
+
return __generator(this, function (_a) {
|
|
5563
5779
|
switch (_a.label) {
|
|
5564
5780
|
case 0: return [4 /*yield*/, this.storageConnectionService.get(itemId)];
|
|
5565
5781
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -5587,11 +5803,12 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5587
5803
|
return __generator(this, function (_a) {
|
|
5588
5804
|
switch (_a.label) {
|
|
5589
5805
|
case 0:
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5806
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5807
|
+
this.loggerService.info("storagePublicService list", {
|
|
5808
|
+
methodName: methodName,
|
|
5809
|
+
clientId: clientId,
|
|
5810
|
+
storageName: storageName,
|
|
5811
|
+
});
|
|
5595
5812
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5596
5813
|
return __generator(this, function (_a) {
|
|
5597
5814
|
switch (_a.label) {
|
|
@@ -5620,11 +5837,12 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5620
5837
|
return __generator(this, function (_a) {
|
|
5621
5838
|
switch (_a.label) {
|
|
5622
5839
|
case 0:
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5840
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5841
|
+
this.loggerService.info("storagePublicService clear", {
|
|
5842
|
+
methodName: methodName,
|
|
5843
|
+
clientId: clientId,
|
|
5844
|
+
storageName: storageName,
|
|
5845
|
+
});
|
|
5628
5846
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5629
5847
|
return __generator(this, function (_a) {
|
|
5630
5848
|
switch (_a.label) {
|
|
@@ -5655,10 +5873,11 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5655
5873
|
return __generator(this, function (_a) {
|
|
5656
5874
|
switch (_a.label) {
|
|
5657
5875
|
case 0:
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5876
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5877
|
+
this.loggerService.info("storagePublicService dispose", {
|
|
5878
|
+
clientId: clientId,
|
|
5879
|
+
storageName: storageName,
|
|
5880
|
+
});
|
|
5662
5881
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5663
5882
|
return __generator(this, function (_a) {
|
|
5664
5883
|
switch (_a.label) {
|
|
@@ -5698,10 +5917,11 @@ var StorageValidationService = /** @class */ (function () {
|
|
|
5698
5917
|
* @throws {Error} If the storage already exists.
|
|
5699
5918
|
*/
|
|
5700
5919
|
this.addStorage = function (storageName, storageSchema) {
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5920
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5921
|
+
_this.loggerService.info("storageValidationService addStorage", {
|
|
5922
|
+
storageName: storageName,
|
|
5923
|
+
storageSchema: storageSchema,
|
|
5924
|
+
});
|
|
5705
5925
|
if (_this._storageMap.has(storageName)) {
|
|
5706
5926
|
throw new Error("storage-swarm storage ".concat(storageName, " already exist"));
|
|
5707
5927
|
}
|
|
@@ -5717,10 +5937,11 @@ var StorageValidationService = /** @class */ (function () {
|
|
|
5717
5937
|
var _b = __read(_a, 1), storageName = _b[0];
|
|
5718
5938
|
return storageName;
|
|
5719
5939
|
}, function (storageName, source) {
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5940
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5941
|
+
_this.loggerService.info("storageValidationService validate", {
|
|
5942
|
+
storageName: storageName,
|
|
5943
|
+
source: source,
|
|
5944
|
+
});
|
|
5724
5945
|
var storage = _this._storageMap.get(storageName);
|
|
5725
5946
|
if (!storage) {
|
|
5726
5947
|
throw new Error("storage-swarm storage ".concat(storageName, " not found source=").concat(source));
|
|
@@ -5747,10 +5968,11 @@ var EmbeddingValidationService = /** @class */ (function () {
|
|
|
5747
5968
|
* @throws Will throw an error if the embedding already exists.
|
|
5748
5969
|
*/
|
|
5749
5970
|
this.addEmbedding = function (embeddingName, embeddingSchema) {
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5971
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5972
|
+
_this.loggerService.info("embeddingValidationService addEmbedding", {
|
|
5973
|
+
embeddingName: embeddingName,
|
|
5974
|
+
embeddingSchema: embeddingSchema,
|
|
5975
|
+
});
|
|
5754
5976
|
if (_this._embeddingMap.has(embeddingName)) {
|
|
5755
5977
|
throw new Error("agent-swarm embedding ".concat(embeddingName, " already exist"));
|
|
5756
5978
|
}
|
|
@@ -5766,10 +5988,11 @@ var EmbeddingValidationService = /** @class */ (function () {
|
|
|
5766
5988
|
var _b = __read(_a, 1), embeddingName = _b[0];
|
|
5767
5989
|
return embeddingName;
|
|
5768
5990
|
}, function (embeddingName, source) {
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5991
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5992
|
+
_this.loggerService.info("embeddingValidationService validate", {
|
|
5993
|
+
embeddingName: embeddingName,
|
|
5994
|
+
source: source,
|
|
5995
|
+
});
|
|
5773
5996
|
if (!_this._embeddingMap.has(embeddingName)) {
|
|
5774
5997
|
throw new Error("agent-swarm embedding ".concat(embeddingName, " not found source=").concat(source));
|
|
5775
5998
|
}
|
|
@@ -5793,7 +6016,8 @@ var StateSchemaService = /** @class */ (function () {
|
|
|
5793
6016
|
* @param {IStateSchema} value - The schema to register.
|
|
5794
6017
|
*/
|
|
5795
6018
|
this.register = function (key, value) {
|
|
5796
|
-
|
|
6019
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
6020
|
+
_this.loggerService.info("stateSchemaService register", { key: key });
|
|
5797
6021
|
_this.registry = _this.registry.register(key, value);
|
|
5798
6022
|
};
|
|
5799
6023
|
/**
|
|
@@ -5802,7 +6026,8 @@ var StateSchemaService = /** @class */ (function () {
|
|
|
5802
6026
|
* @returns {IStateSchema} The retrieved schema.
|
|
5803
6027
|
*/
|
|
5804
6028
|
this.get = function (key) {
|
|
5805
|
-
|
|
6029
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
6030
|
+
_this.loggerService.info("stateSchemaService get", { key: key });
|
|
5806
6031
|
return _this.registry.get(key);
|
|
5807
6032
|
};
|
|
5808
6033
|
}
|
|
@@ -5836,7 +6061,7 @@ var ClientState = /** @class */ (function () {
|
|
|
5836
6061
|
console.assert(payload, "agent-swarm ClientState write action undefined payload");
|
|
5837
6062
|
_a = this;
|
|
5838
6063
|
return [4 /*yield*/, payload(this._state)];
|
|
5839
|
-
case 1: return [2 /*return*/, _a._state = _b.sent()];
|
|
6064
|
+
case 1: return [2 /*return*/, (_a._state = _b.sent())];
|
|
5840
6065
|
case 2: throw new Error("agent-swarm ClientState unknown action");
|
|
5841
6066
|
}
|
|
5842
6067
|
});
|
|
@@ -5851,12 +6076,14 @@ var ClientState = /** @class */ (function () {
|
|
|
5851
6076
|
return __generator(this, function (_c) {
|
|
5852
6077
|
switch (_c.label) {
|
|
5853
6078
|
case 0:
|
|
5854
|
-
|
|
6079
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
6080
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " waitForInit"));
|
|
5855
6081
|
_a = this;
|
|
5856
6082
|
return [4 /*yield*/, this.params.getState(this.params.clientId, this.params.stateName)];
|
|
5857
6083
|
case 1:
|
|
5858
6084
|
_a._state = _c.sent();
|
|
5859
|
-
|
|
6085
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
6086
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " waitForInit output"), { initialState: this._state });
|
|
5860
6087
|
if ((_b = this.params.callbacks) === null || _b === void 0 ? void 0 : _b.onLoad) {
|
|
5861
6088
|
this.params.callbacks.onLoad(this._state, this.params.clientId, this.params.stateName);
|
|
5862
6089
|
}
|
|
@@ -5875,7 +6102,8 @@ var ClientState = /** @class */ (function () {
|
|
|
5875
6102
|
return __generator(this, function (_b) {
|
|
5876
6103
|
switch (_b.label) {
|
|
5877
6104
|
case 0:
|
|
5878
|
-
|
|
6105
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
6106
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " setState"));
|
|
5879
6107
|
return [4 /*yield*/, this.dispatch("write", function (currentState) { return __awaiter(_this, void 0, void 0, function () {
|
|
5880
6108
|
var _a, _b, middleware, e_1_1;
|
|
5881
6109
|
var e_1, _c;
|
|
@@ -5913,7 +6141,8 @@ var ClientState = /** @class */ (function () {
|
|
|
5913
6141
|
}); })];
|
|
5914
6142
|
case 1:
|
|
5915
6143
|
_b.sent();
|
|
5916
|
-
|
|
6144
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
6145
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " setState output"), { pendingState: this._state });
|
|
5917
6146
|
this.params.setState &&
|
|
5918
6147
|
this.params.setState(this._state, this.params.clientId, this.params.stateName);
|
|
5919
6148
|
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onWrite) {
|
|
@@ -5946,7 +6175,8 @@ var ClientState = /** @class */ (function () {
|
|
|
5946
6175
|
return __generator(this, function (_b) {
|
|
5947
6176
|
switch (_b.label) {
|
|
5948
6177
|
case 0:
|
|
5949
|
-
|
|
6178
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
6179
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " getState"));
|
|
5950
6180
|
return [4 /*yield*/, this.dispatch("read")];
|
|
5951
6181
|
case 1:
|
|
5952
6182
|
_b.sent();
|
|
@@ -5978,16 +6208,18 @@ var ClientState = /** @class */ (function () {
|
|
|
5978
6208
|
this.dispose = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5979
6209
|
var _a;
|
|
5980
6210
|
return __generator(this, function (_b) {
|
|
5981
|
-
|
|
6211
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
6212
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " dispose"));
|
|
5982
6213
|
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onDispose) {
|
|
5983
6214
|
this.params.callbacks.onDispose(this.params.clientId, this.params.stateName);
|
|
5984
6215
|
}
|
|
5985
6216
|
return [2 /*return*/];
|
|
5986
6217
|
});
|
|
5987
6218
|
}); };
|
|
5988
|
-
|
|
5989
|
-
params
|
|
5990
|
-
|
|
6219
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
6220
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " CTOR"), {
|
|
6221
|
+
params: params,
|
|
6222
|
+
});
|
|
5991
6223
|
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onInit) {
|
|
5992
6224
|
this.params.callbacks.onInit(this.params.clientId, this.params.stateName);
|
|
5993
6225
|
}
|
|
@@ -6096,7 +6328,8 @@ var StateConnectionService = /** @class */ (function () {
|
|
|
6096
6328
|
return __generator(this, function (_a) {
|
|
6097
6329
|
switch (_a.label) {
|
|
6098
6330
|
case 0:
|
|
6099
|
-
|
|
6331
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
6332
|
+
this.loggerService.info("stateConnectionService setState");
|
|
6100
6333
|
state = this.getStateRef(this.methodContextService.context.clientId, this.methodContextService.context.stateName);
|
|
6101
6334
|
return [4 /*yield*/, state.waitForInit()];
|
|
6102
6335
|
case 1:
|
|
@@ -6115,7 +6348,8 @@ var StateConnectionService = /** @class */ (function () {
|
|
|
6115
6348
|
return __generator(this, function (_a) {
|
|
6116
6349
|
switch (_a.label) {
|
|
6117
6350
|
case 0:
|
|
6118
|
-
|
|
6351
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
6352
|
+
this.loggerService.info("stateConnectionService getState");
|
|
6119
6353
|
state = this.getStateRef(this.methodContextService.context.clientId, this.methodContextService.context.stateName);
|
|
6120
6354
|
return [4 /*yield*/, state.waitForInit()];
|
|
6121
6355
|
case 1:
|
|
@@ -6134,7 +6368,8 @@ var StateConnectionService = /** @class */ (function () {
|
|
|
6134
6368
|
return __generator(this, function (_a) {
|
|
6135
6369
|
switch (_a.label) {
|
|
6136
6370
|
case 0:
|
|
6137
|
-
|
|
6371
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
6372
|
+
this.loggerService.info("stateConnectionService dispose");
|
|
6138
6373
|
key = "".concat(this.methodContextService.context.clientId, "-").concat(this.methodContextService.context.stateName);
|
|
6139
6374
|
if (!this.getStateRef.has(key)) {
|
|
6140
6375
|
return [2 /*return*/];
|
|
@@ -6176,11 +6411,12 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6176
6411
|
return __generator(this, function (_a) {
|
|
6177
6412
|
switch (_a.label) {
|
|
6178
6413
|
case 0:
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6414
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
6415
|
+
this.loggerService.info("statePublicService setState", {
|
|
6416
|
+
methodName: methodName,
|
|
6417
|
+
clientId: clientId,
|
|
6418
|
+
stateName: stateName,
|
|
6419
|
+
});
|
|
6184
6420
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
6185
6421
|
return __generator(this, function (_a) {
|
|
6186
6422
|
switch (_a.label) {
|
|
@@ -6211,10 +6447,11 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6211
6447
|
return __generator(this, function (_a) {
|
|
6212
6448
|
switch (_a.label) {
|
|
6213
6449
|
case 0:
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6450
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
6451
|
+
this.loggerService.info("statePublicService getState", {
|
|
6452
|
+
clientId: clientId,
|
|
6453
|
+
stateName: stateName,
|
|
6454
|
+
});
|
|
6218
6455
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
6219
6456
|
return __generator(this, function (_a) {
|
|
6220
6457
|
switch (_a.label) {
|
|
@@ -6245,11 +6482,12 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6245
6482
|
return __generator(this, function (_a) {
|
|
6246
6483
|
switch (_a.label) {
|
|
6247
6484
|
case 0:
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6485
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
6486
|
+
this.loggerService.info("statePublicService dispose", {
|
|
6487
|
+
methodName: methodName,
|
|
6488
|
+
clientId: clientId,
|
|
6489
|
+
stateName: stateName,
|
|
6490
|
+
});
|
|
6253
6491
|
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
6254
6492
|
return __generator(this, function (_a) {
|
|
6255
6493
|
switch (_a.label) {
|
|
@@ -6291,10 +6529,11 @@ var BusService = /** @class */ (function () {
|
|
|
6291
6529
|
* @param {(event: T) => void} fn - The callback function to handle the event.
|
|
6292
6530
|
*/
|
|
6293
6531
|
this.subscribe = function (clientId, source, fn) {
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6532
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
6533
|
+
_this.loggerService.info("busService subscribe", {
|
|
6534
|
+
clientId: clientId,
|
|
6535
|
+
source: source,
|
|
6536
|
+
});
|
|
6298
6537
|
if (clientId === "*") {
|
|
6299
6538
|
_this._eventWildcardMap.set(source, true);
|
|
6300
6539
|
}
|
|
@@ -6310,10 +6549,11 @@ var BusService = /** @class */ (function () {
|
|
|
6310
6549
|
* @returns {Subscription} The subscription object.
|
|
6311
6550
|
*/
|
|
6312
6551
|
this.once = function (clientId, source, filterFn, fn) {
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6552
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
6553
|
+
_this.loggerService.info("busService once", {
|
|
6554
|
+
clientId: clientId,
|
|
6555
|
+
source: source,
|
|
6556
|
+
});
|
|
6317
6557
|
if (clientId === "*") {
|
|
6318
6558
|
_this._eventWildcardMap.set(source, true);
|
|
6319
6559
|
}
|
|
@@ -6330,10 +6570,11 @@ var BusService = /** @class */ (function () {
|
|
|
6330
6570
|
return __generator(this, function (_a) {
|
|
6331
6571
|
switch (_a.label) {
|
|
6332
6572
|
case 0:
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6573
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
6574
|
+
this.loggerService.info("busService emit", {
|
|
6575
|
+
clientId: clientId,
|
|
6576
|
+
event: event,
|
|
6577
|
+
});
|
|
6337
6578
|
if (!this.sessionValidationService.hasSession(clientId)) {
|
|
6338
6579
|
return [2 /*return*/];
|
|
6339
6580
|
}
|
|
@@ -6358,9 +6599,10 @@ var BusService = /** @class */ (function () {
|
|
|
6358
6599
|
*/
|
|
6359
6600
|
this.dispose = function (clientId) {
|
|
6360
6601
|
var e_1, _a;
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6602
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
6603
|
+
_this.loggerService.info("busService dispose", {
|
|
6604
|
+
clientId: clientId,
|
|
6605
|
+
});
|
|
6364
6606
|
try {
|
|
6365
6607
|
for (var _b = __values(_this._eventSourceSet), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
6366
6608
|
var source = _c.value;
|
|
@@ -6477,6 +6719,7 @@ var validationServices = {
|
|
|
6477
6719
|
var swarm = __assign(__assign(__assign(__assign(__assign(__assign({}, baseServices), contextServices), connectionServices), schemaServices), publicServices), validationServices);
|
|
6478
6720
|
init();
|
|
6479
6721
|
|
|
6722
|
+
var METHOD_NAME$C = "function.addAgent";
|
|
6480
6723
|
/**
|
|
6481
6724
|
* Adds a new agent to the agent registry. The swarm takes only those agents which was registered
|
|
6482
6725
|
*
|
|
@@ -6484,14 +6727,16 @@ init();
|
|
|
6484
6727
|
* @returns {string} The name of the added agent.
|
|
6485
6728
|
*/
|
|
6486
6729
|
var addAgent = function (agentSchema) {
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6730
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6731
|
+
swarm.loggerService.log(METHOD_NAME$C, {
|
|
6732
|
+
agentSchema: agentSchema,
|
|
6733
|
+
});
|
|
6490
6734
|
swarm.agentValidationService.addAgent(agentSchema.agentName, agentSchema);
|
|
6491
6735
|
swarm.agentSchemaService.register(agentSchema.agentName, agentSchema);
|
|
6492
6736
|
return agentSchema.agentName;
|
|
6493
6737
|
};
|
|
6494
6738
|
|
|
6739
|
+
var METHOD_NAME$B = "function.addCompletion";
|
|
6495
6740
|
/**
|
|
6496
6741
|
* Adds a completion engine for agents. Agents could use different models and
|
|
6497
6742
|
* framewords for completion like: mock, gpt4all, ollama, openai
|
|
@@ -6500,14 +6745,16 @@ var addAgent = function (agentSchema) {
|
|
|
6500
6745
|
* @returns {string} The name of the completion that was added.
|
|
6501
6746
|
*/
|
|
6502
6747
|
var addCompletion = function (completionSchema) {
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6748
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6749
|
+
swarm.loggerService.log(METHOD_NAME$B, {
|
|
6750
|
+
completionSchema: completionSchema,
|
|
6751
|
+
});
|
|
6506
6752
|
swarm.completionValidationService.addCompletion(completionSchema.completionName);
|
|
6507
6753
|
swarm.completionSchemaService.register(completionSchema.completionName, completionSchema);
|
|
6508
6754
|
return completionSchema.completionName;
|
|
6509
6755
|
};
|
|
6510
6756
|
|
|
6757
|
+
var METHOD_NAME$A = "function.addSwarm";
|
|
6511
6758
|
/**
|
|
6512
6759
|
* Adds a new swarm to the system. The swarm is a root for starting client session
|
|
6513
6760
|
*
|
|
@@ -6515,14 +6762,16 @@ var addCompletion = function (completionSchema) {
|
|
|
6515
6762
|
* @returns {string} The name of the added swarm.
|
|
6516
6763
|
*/
|
|
6517
6764
|
var addSwarm = function (swarmSchema) {
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6765
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6766
|
+
swarm.loggerService.log(METHOD_NAME$A, {
|
|
6767
|
+
swarmSchema: swarmSchema,
|
|
6768
|
+
});
|
|
6521
6769
|
swarm.swarmValidationService.addSwarm(swarmSchema.swarmName, swarmSchema);
|
|
6522
6770
|
swarm.swarmSchemaService.register(swarmSchema.swarmName, swarmSchema);
|
|
6523
6771
|
return swarmSchema.swarmName;
|
|
6524
6772
|
};
|
|
6525
6773
|
|
|
6774
|
+
var METHOD_NAME$z = "function.addTool";
|
|
6526
6775
|
/**
|
|
6527
6776
|
* Adds a new tool for agents in a swarm. Tool should be registered in `addAgent`
|
|
6528
6777
|
* declaration
|
|
@@ -6531,14 +6780,16 @@ var addSwarm = function (swarmSchema) {
|
|
|
6531
6780
|
* @returns {string} The name of the tool that was added.
|
|
6532
6781
|
*/
|
|
6533
6782
|
var addTool = function (toolSchema) {
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6783
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6784
|
+
swarm.loggerService.log(METHOD_NAME$z, {
|
|
6785
|
+
toolSchema: toolSchema,
|
|
6786
|
+
});
|
|
6537
6787
|
swarm.toolValidationService.addTool(toolSchema.toolName, toolSchema);
|
|
6538
6788
|
swarm.toolSchemaService.register(toolSchema.toolName, toolSchema);
|
|
6539
6789
|
return toolSchema.toolName;
|
|
6540
6790
|
};
|
|
6541
6791
|
|
|
6792
|
+
var METHOD_NAME$y = "function.addState";
|
|
6542
6793
|
/**
|
|
6543
6794
|
* Adds a new state to the state registry. The swarm takes only those states which was registered
|
|
6544
6795
|
*
|
|
@@ -6546,9 +6797,10 @@ var addTool = function (toolSchema) {
|
|
|
6546
6797
|
* @returns {string} The name of the added state.
|
|
6547
6798
|
*/
|
|
6548
6799
|
var addState = function (stateSchema) {
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
6800
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6801
|
+
swarm.loggerService.log(METHOD_NAME$y, {
|
|
6802
|
+
stateSchema: stateSchema,
|
|
6803
|
+
});
|
|
6552
6804
|
swarm.stateSchemaService.register(stateSchema.stateName, stateSchema);
|
|
6553
6805
|
if (stateSchema.shared) {
|
|
6554
6806
|
swarm.stateConnectionService
|
|
@@ -6558,6 +6810,7 @@ var addState = function (stateSchema) {
|
|
|
6558
6810
|
return stateSchema.stateName;
|
|
6559
6811
|
};
|
|
6560
6812
|
|
|
6813
|
+
var METHOD_NAME$x = "function.addEmbedding";
|
|
6561
6814
|
/**
|
|
6562
6815
|
* Adds a new embedding to the embedding registry. The swarm takes only those embeddings which was registered
|
|
6563
6816
|
*
|
|
@@ -6565,14 +6818,16 @@ var addState = function (stateSchema) {
|
|
|
6565
6818
|
* @returns {string} The name of the added embedding.
|
|
6566
6819
|
*/
|
|
6567
6820
|
var addEmbedding = function (embeddingSchema) {
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6821
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6822
|
+
swarm.loggerService.log(METHOD_NAME$x, {
|
|
6823
|
+
embeddingSchema: embeddingSchema,
|
|
6824
|
+
});
|
|
6571
6825
|
swarm.embeddingValidationService.addEmbedding(embeddingSchema.embeddingName, embeddingSchema);
|
|
6572
6826
|
swarm.embeddingSchemaService.register(embeddingSchema.embeddingName, embeddingSchema);
|
|
6573
6827
|
return embeddingSchema.embeddingName;
|
|
6574
6828
|
};
|
|
6575
6829
|
|
|
6830
|
+
var METHOD_NAME$w = "function.addStorage";
|
|
6576
6831
|
/**
|
|
6577
6832
|
* Adds a new storage to the storage registry. The swarm takes only those storages which was registered
|
|
6578
6833
|
*
|
|
@@ -6580,9 +6835,10 @@ var addEmbedding = function (embeddingSchema) {
|
|
|
6580
6835
|
* @returns {string} The name of the added storage.
|
|
6581
6836
|
*/
|
|
6582
6837
|
var addStorage = function (storageSchema) {
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6838
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6839
|
+
swarm.loggerService.log(METHOD_NAME$w, {
|
|
6840
|
+
storageSchema: storageSchema,
|
|
6841
|
+
});
|
|
6586
6842
|
swarm.storageValidationService.addStorage(storageSchema.storageName, storageSchema);
|
|
6587
6843
|
swarm.storageSchemaService.register(storageSchema.storageName, storageSchema);
|
|
6588
6844
|
if (storageSchema.shared) {
|
|
@@ -6593,6 +6849,7 @@ var addStorage = function (storageSchema) {
|
|
|
6593
6849
|
return storageSchema.storageName;
|
|
6594
6850
|
};
|
|
6595
6851
|
|
|
6852
|
+
var METHOD_NAME$v = "function.commitSystemMessage";
|
|
6596
6853
|
/**
|
|
6597
6854
|
* Commits a user message to the active agent history in as swarm without answer.
|
|
6598
6855
|
*
|
|
@@ -6602,32 +6859,33 @@ var addStorage = function (storageSchema) {
|
|
|
6602
6859
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
6603
6860
|
*/
|
|
6604
6861
|
var commitUserMessage = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6605
|
-
var
|
|
6862
|
+
var swarmName, currentAgentName;
|
|
6606
6863
|
return __generator(this, function (_a) {
|
|
6607
6864
|
switch (_a.label) {
|
|
6608
6865
|
case 0:
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
swarm.agentValidationService.validate(agentName,
|
|
6616
|
-
swarm.sessionValidationService.validate(clientId,
|
|
6866
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6867
|
+
swarm.loggerService.log(METHOD_NAME$v, {
|
|
6868
|
+
content: content,
|
|
6869
|
+
clientId: clientId,
|
|
6870
|
+
agentName: agentName,
|
|
6871
|
+
});
|
|
6872
|
+
swarm.agentValidationService.validate(agentName, METHOD_NAME$v);
|
|
6873
|
+
swarm.sessionValidationService.validate(clientId, METHOD_NAME$v);
|
|
6617
6874
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
6618
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
6619
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(
|
|
6875
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$v);
|
|
6876
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(METHOD_NAME$v, clientId, swarmName)];
|
|
6620
6877
|
case 1:
|
|
6621
6878
|
currentAgentName = _a.sent();
|
|
6622
6879
|
if (currentAgentName !== agentName) {
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6880
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6881
|
+
swarm.loggerService.log('function "commitUserMessage" skipped due to the agent change', {
|
|
6882
|
+
currentAgentName: currentAgentName,
|
|
6883
|
+
agentName: agentName,
|
|
6884
|
+
clientId: clientId,
|
|
6885
|
+
});
|
|
6628
6886
|
return [2 /*return*/];
|
|
6629
6887
|
}
|
|
6630
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content,
|
|
6888
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, METHOD_NAME$v, clientId, swarmName)];
|
|
6631
6889
|
case 2:
|
|
6632
6890
|
_a.sent();
|
|
6633
6891
|
return [2 /*return*/];
|
|
@@ -6635,6 +6893,7 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
|
|
|
6635
6893
|
});
|
|
6636
6894
|
}); };
|
|
6637
6895
|
|
|
6896
|
+
var METHOD_NAME$u = "function.getAgentName";
|
|
6638
6897
|
/**
|
|
6639
6898
|
* Retrieves the agent name for a given client ID.
|
|
6640
6899
|
*
|
|
@@ -6643,24 +6902,25 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
|
|
|
6643
6902
|
* @throws Will throw an error if the client ID is invalid or if the swarm validation fails.
|
|
6644
6903
|
*/
|
|
6645
6904
|
var getAgentName = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6646
|
-
var
|
|
6905
|
+
var swarmName;
|
|
6647
6906
|
return __generator(this, function (_a) {
|
|
6648
6907
|
switch (_a.label) {
|
|
6649
6908
|
case 0:
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
swarm.sessionValidationService.validate(clientId,
|
|
6909
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6910
|
+
swarm.loggerService.log(METHOD_NAME$u, {
|
|
6911
|
+
clientId: clientId,
|
|
6912
|
+
});
|
|
6913
|
+
swarm.sessionValidationService.validate(clientId, METHOD_NAME$u);
|
|
6655
6914
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
6656
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
6657
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(
|
|
6915
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$u);
|
|
6916
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(METHOD_NAME$u, clientId, swarmName)];
|
|
6658
6917
|
case 1: return [2 /*return*/, _a.sent()];
|
|
6659
6918
|
}
|
|
6660
6919
|
});
|
|
6661
6920
|
}); };
|
|
6662
6921
|
|
|
6663
6922
|
var SCHEDULED_DELAY$1 = 1000;
|
|
6923
|
+
var METHOD_NAME$t = "function.makeConnection";
|
|
6664
6924
|
/**
|
|
6665
6925
|
* A connection factory for a client to a swarm and returns a function to send messages.
|
|
6666
6926
|
*
|
|
@@ -6670,26 +6930,26 @@ var SCHEDULED_DELAY$1 = 1000;
|
|
|
6670
6930
|
* @returns {SendMessageFn} - A function to send messages to the swarm.
|
|
6671
6931
|
*/
|
|
6672
6932
|
var makeConnection = function (connector, clientId, swarmName) {
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
6933
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6934
|
+
swarm.loggerService.log(METHOD_NAME$t, {
|
|
6935
|
+
clientId: clientId,
|
|
6936
|
+
swarmName: swarmName,
|
|
6937
|
+
});
|
|
6938
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$t);
|
|
6679
6939
|
swarm.sessionValidationService.addSession(clientId, swarmName, "makeConnection");
|
|
6680
|
-
var send = swarm.sessionPublicService.connect(connector,
|
|
6940
|
+
var send = swarm.sessionPublicService.connect(connector, METHOD_NAME$t, clientId, swarmName);
|
|
6681
6941
|
return functoolsKit.queued(function (outgoing) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6682
6942
|
var _a;
|
|
6683
6943
|
var _b;
|
|
6684
6944
|
return __generator(this, function (_c) {
|
|
6685
6945
|
switch (_c.label) {
|
|
6686
6946
|
case 0:
|
|
6687
|
-
swarm.sessionValidationService.validate(clientId,
|
|
6947
|
+
swarm.sessionValidationService.validate(clientId, METHOD_NAME$t);
|
|
6688
6948
|
_a = send;
|
|
6689
6949
|
_b = {
|
|
6690
6950
|
data: outgoing
|
|
6691
6951
|
};
|
|
6692
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(
|
|
6952
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(METHOD_NAME$t, clientId, swarmName)];
|
|
6693
6953
|
case 1: return [4 /*yield*/, _a.apply(void 0, [(_b.agentName = _c.sent(),
|
|
6694
6954
|
_b.clientId = clientId,
|
|
6695
6955
|
_b)])];
|
|
@@ -6775,6 +7035,7 @@ makeConnection.scheduled = function (connector, clientId, swarmName, _a) {
|
|
|
6775
7035
|
}); };
|
|
6776
7036
|
};
|
|
6777
7037
|
|
|
7038
|
+
var METHOD_NAME$s = "function.changeAgent";
|
|
6778
7039
|
/**
|
|
6779
7040
|
* Time-to-live for the change agent function in milliseconds.
|
|
6780
7041
|
* @constant {number}
|
|
@@ -6797,8 +7058,8 @@ var createChangeAgent = functoolsKit.ttl(function (clientId) {
|
|
|
6797
7058
|
return __generator(this, function (_d) {
|
|
6798
7059
|
switch (_d.label) {
|
|
6799
7060
|
case 0:
|
|
6800
|
-
swarm.sessionValidationService.validate(clientId,
|
|
6801
|
-
swarm.agentValidationService.validate(agentName,
|
|
7061
|
+
swarm.sessionValidationService.validate(clientId, METHOD_NAME$s);
|
|
7062
|
+
swarm.agentValidationService.validate(agentName, METHOD_NAME$s);
|
|
6802
7063
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
6803
7064
|
return [4 /*yield*/, Promise.all(swarm.swarmValidationService
|
|
6804
7065
|
.getAgentList(swarmName)
|
|
@@ -6863,25 +7124,26 @@ var createGc$1 = functoolsKit.singleshot(function () { return __awaiter(void 0,
|
|
|
6863
7124
|
* @returns {Promise<void>} - A promise that resolves when the agent is changed.
|
|
6864
7125
|
*/
|
|
6865
7126
|
var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6866
|
-
var
|
|
7127
|
+
var run;
|
|
6867
7128
|
return __generator(this, function (_a) {
|
|
6868
7129
|
switch (_a.label) {
|
|
6869
7130
|
case 0:
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
7131
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7132
|
+
swarm.loggerService.log(METHOD_NAME$s, {
|
|
7133
|
+
agentName: agentName,
|
|
7134
|
+
clientId: clientId,
|
|
7135
|
+
});
|
|
6875
7136
|
return [4 /*yield*/, createChangeAgent(clientId)];
|
|
6876
7137
|
case 1:
|
|
6877
7138
|
run = _a.sent();
|
|
6878
7139
|
createGc$1();
|
|
6879
|
-
return [4 /*yield*/, run(
|
|
7140
|
+
return [4 /*yield*/, run(METHOD_NAME$s, agentName)];
|
|
6880
7141
|
case 2: return [2 /*return*/, _a.sent()];
|
|
6881
7142
|
}
|
|
6882
7143
|
});
|
|
6883
7144
|
}); };
|
|
6884
7145
|
|
|
7146
|
+
var METHOD_NAME$r = "function.disposeConnection";
|
|
6885
7147
|
/**
|
|
6886
7148
|
* Disposes the session for a given client with all related swarms and agents.
|
|
6887
7149
|
*
|
|
@@ -6895,15 +7157,16 @@ var disposeConnection = function (clientId_1, swarmName_1) {
|
|
|
6895
7157
|
args_1[_i - 2] = arguments[_i];
|
|
6896
7158
|
}
|
|
6897
7159
|
return __awaiter(void 0, __spreadArray([clientId_1, swarmName_1], __read(args_1), false), void 0, function (clientId, swarmName, methodName) {
|
|
6898
|
-
if (methodName === void 0) { methodName =
|
|
7160
|
+
if (methodName === void 0) { methodName = METHOD_NAME$r; }
|
|
6899
7161
|
return __generator(this, function (_a) {
|
|
6900
7162
|
switch (_a.label) {
|
|
6901
7163
|
case 0:
|
|
6902
|
-
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
|
|
7164
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7165
|
+
swarm.loggerService.log(METHOD_NAME$r, {
|
|
7166
|
+
clientId: clientId,
|
|
7167
|
+
swarmName: swarmName,
|
|
7168
|
+
});
|
|
7169
|
+
swarm.swarmValidationService.validate(swarmName, methodName);
|
|
6907
7170
|
swarm.sessionValidationService.removeSession(clientId);
|
|
6908
7171
|
swarm.busService.dispose(clientId);
|
|
6909
7172
|
return [4 /*yield*/, swarm.sessionPublicService.dispose(methodName, clientId, swarmName)];
|
|
@@ -6974,6 +7237,7 @@ var disposeConnection = function (clientId_1, swarmName_1) {
|
|
|
6974
7237
|
});
|
|
6975
7238
|
};
|
|
6976
7239
|
|
|
7240
|
+
var METHOD_NAME$q = "function.complete";
|
|
6977
7241
|
var COMPLETE_TTL = 15 * 60 * 1000;
|
|
6978
7242
|
var COMPLETE_GC = 60 * 1000;
|
|
6979
7243
|
/**
|
|
@@ -6983,17 +7247,17 @@ var COMPLETE_GC = 60 * 1000;
|
|
|
6983
7247
|
* @returns {TCompleteRun} The complete run function.
|
|
6984
7248
|
*/
|
|
6985
7249
|
var createComplete = functoolsKit.ttl(function (clientId, swarmName) {
|
|
6986
|
-
return functoolsKit.queued(function (
|
|
7250
|
+
return functoolsKit.queued(function (METHOD_NAME, content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6987
7251
|
var result;
|
|
6988
7252
|
return __generator(this, function (_a) {
|
|
6989
7253
|
switch (_a.label) {
|
|
6990
7254
|
case 0:
|
|
6991
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
7255
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME);
|
|
6992
7256
|
swarm.sessionValidationService.addSession(clientId, swarmName, "complete");
|
|
6993
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user",
|
|
7257
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", METHOD_NAME, clientId, swarmName)];
|
|
6994
7258
|
case 1:
|
|
6995
7259
|
result = _a.sent();
|
|
6996
|
-
return [4 /*yield*/, disposeConnection(clientId, swarmName,
|
|
7260
|
+
return [4 /*yield*/, disposeConnection(clientId, swarmName, METHOD_NAME)];
|
|
6997
7261
|
case 2:
|
|
6998
7262
|
_a.sent();
|
|
6999
7263
|
return [2 /*return*/, result];
|
|
@@ -7027,18 +7291,18 @@ var createGc = functoolsKit.singleshot(function () { return __awaiter(void 0, vo
|
|
|
7027
7291
|
* @returns {Promise<string>} The result of the complete function.
|
|
7028
7292
|
*/
|
|
7029
7293
|
var complete = function (content, clientId, swarmName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7030
|
-
var
|
|
7294
|
+
var executionId, run;
|
|
7031
7295
|
return __generator(this, function (_a) {
|
|
7032
7296
|
switch (_a.label) {
|
|
7033
7297
|
case 0:
|
|
7034
|
-
methodName = "function complete";
|
|
7035
7298
|
executionId = functoolsKit.randomString();
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
-
|
|
7040
|
-
|
|
7041
|
-
|
|
7299
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7300
|
+
swarm.loggerService.log(METHOD_NAME$q, {
|
|
7301
|
+
content: content,
|
|
7302
|
+
clientId: clientId,
|
|
7303
|
+
executionId: executionId,
|
|
7304
|
+
swarmName: swarmName,
|
|
7305
|
+
});
|
|
7042
7306
|
return [4 /*yield*/, createComplete(clientId, swarmName)];
|
|
7043
7307
|
case 1:
|
|
7044
7308
|
run = _a.sent();
|
|
@@ -7046,7 +7310,7 @@ var complete = function (content, clientId, swarmName) { return __awaiter(void 0
|
|
|
7046
7310
|
return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
7047
7311
|
return __generator(this, function (_a) {
|
|
7048
7312
|
switch (_a.label) {
|
|
7049
|
-
case 0: return [4 /*yield*/, run(
|
|
7313
|
+
case 0: return [4 /*yield*/, run(METHOD_NAME$q, content)];
|
|
7050
7314
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7051
7315
|
}
|
|
7052
7316
|
});
|
|
@@ -7059,6 +7323,7 @@ var complete = function (content, clientId, swarmName) { return __awaiter(void 0
|
|
|
7059
7323
|
}); };
|
|
7060
7324
|
|
|
7061
7325
|
var SCHEDULED_DELAY = 1000;
|
|
7326
|
+
var METHOD_NAME$p = "function.session";
|
|
7062
7327
|
/**
|
|
7063
7328
|
* Creates a session for the given client and swarm.
|
|
7064
7329
|
*
|
|
@@ -7069,14 +7334,14 @@ var SCHEDULED_DELAY = 1000;
|
|
|
7069
7334
|
* @returns {Function} dispose - A function to dispose of the session.
|
|
7070
7335
|
*/
|
|
7071
7336
|
var session = function (clientId, swarmName) {
|
|
7072
|
-
var methodName = "function session";
|
|
7073
7337
|
var executionId = functoolsKit.randomString();
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7338
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7339
|
+
swarm.loggerService.log(METHOD_NAME$p, {
|
|
7340
|
+
clientId: clientId,
|
|
7341
|
+
swarmName: swarmName,
|
|
7342
|
+
executionId: executionId,
|
|
7343
|
+
});
|
|
7344
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$p);
|
|
7080
7345
|
swarm.sessionValidationService.addSession(clientId, swarmName, "session");
|
|
7081
7346
|
return {
|
|
7082
7347
|
/**
|
|
@@ -7087,11 +7352,11 @@ var session = function (clientId, swarmName) {
|
|
|
7087
7352
|
*/
|
|
7088
7353
|
complete: functoolsKit.queued(function (content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7089
7354
|
return __generator(this, function (_a) {
|
|
7090
|
-
swarm.sessionValidationService.validate(clientId,
|
|
7355
|
+
swarm.sessionValidationService.validate(clientId, METHOD_NAME$p);
|
|
7091
7356
|
return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
7092
7357
|
return __generator(this, function (_a) {
|
|
7093
7358
|
switch (_a.label) {
|
|
7094
|
-
case 0: return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user",
|
|
7359
|
+
case 0: return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", METHOD_NAME$p, clientId, swarmName)];
|
|
7095
7360
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7096
7361
|
}
|
|
7097
7362
|
});
|
|
@@ -7109,7 +7374,7 @@ var session = function (clientId, swarmName) {
|
|
|
7109
7374
|
dispose: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
7110
7375
|
return __generator(this, function (_a) {
|
|
7111
7376
|
switch (_a.label) {
|
|
7112
|
-
case 0: return [4 /*yield*/, disposeConnection(clientId, swarmName,
|
|
7377
|
+
case 0: return [4 /*yield*/, disposeConnection(clientId, swarmName, METHOD_NAME$p)];
|
|
7113
7378
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7114
7379
|
}
|
|
7115
7380
|
});
|
|
@@ -7208,6 +7473,7 @@ session.scheduled = function (clientId, swarmName, _a) {
|
|
|
7208
7473
|
};
|
|
7209
7474
|
};
|
|
7210
7475
|
|
|
7476
|
+
var METHOD_NAME$o = "function.getRawHistory";
|
|
7211
7477
|
/**
|
|
7212
7478
|
* Retrieves the raw history as it is for a given client ID without any modifications.
|
|
7213
7479
|
*
|
|
@@ -7221,16 +7487,17 @@ var getRawHistory = function (clientId_1) {
|
|
|
7221
7487
|
}
|
|
7222
7488
|
return __awaiter(void 0, __spreadArray([clientId_1], __read(args_1), false), void 0, function (clientId, methodName) {
|
|
7223
7489
|
var swarmName, agentName, history;
|
|
7224
|
-
if (methodName === void 0) { methodName =
|
|
7490
|
+
if (methodName === void 0) { methodName = METHOD_NAME$o; }
|
|
7225
7491
|
return __generator(this, function (_a) {
|
|
7226
7492
|
switch (_a.label) {
|
|
7227
7493
|
case 0:
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7494
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7495
|
+
swarm.loggerService.log(METHOD_NAME$o, {
|
|
7496
|
+
clientId: clientId,
|
|
7497
|
+
});
|
|
7498
|
+
swarm.sessionValidationService.validate(clientId, methodName);
|
|
7232
7499
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7233
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
7500
|
+
swarm.swarmValidationService.validate(swarmName, methodName);
|
|
7234
7501
|
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(methodName, clientId, swarmName)];
|
|
7235
7502
|
case 1:
|
|
7236
7503
|
agentName = _a.sent();
|
|
@@ -7243,6 +7510,7 @@ var getRawHistory = function (clientId_1) {
|
|
|
7243
7510
|
});
|
|
7244
7511
|
};
|
|
7245
7512
|
|
|
7513
|
+
var METHOD_NAME$n = "function.getAgentHistory";
|
|
7246
7514
|
/**
|
|
7247
7515
|
* Retrieves the history prepared for a specific agent with resque algorithm tweaks
|
|
7248
7516
|
*
|
|
@@ -7251,18 +7519,18 @@ var getRawHistory = function (clientId_1) {
|
|
|
7251
7519
|
* @returns {Promise<Array>} - A promise that resolves to an array containing the agent's history.
|
|
7252
7520
|
*/
|
|
7253
7521
|
var getAgentHistory = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7254
|
-
var
|
|
7522
|
+
var prompt, history;
|
|
7255
7523
|
return __generator(this, function (_a) {
|
|
7256
7524
|
switch (_a.label) {
|
|
7257
7525
|
case 0:
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
swarm.agentValidationService.validate(agentName,
|
|
7526
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7527
|
+
swarm.loggerService.log(METHOD_NAME$n, {
|
|
7528
|
+
clientId: clientId,
|
|
7529
|
+
agentName: agentName,
|
|
7530
|
+
});
|
|
7531
|
+
swarm.agentValidationService.validate(agentName, METHOD_NAME$n);
|
|
7264
7532
|
prompt = swarm.agentSchemaService.get(agentName).prompt;
|
|
7265
|
-
return [4 /*yield*/, swarm.historyPublicService.toArrayForAgent(prompt,
|
|
7533
|
+
return [4 /*yield*/, swarm.historyPublicService.toArrayForAgent(prompt, METHOD_NAME$n, clientId, agentName)];
|
|
7266
7534
|
case 1:
|
|
7267
7535
|
history = _a.sent();
|
|
7268
7536
|
return [2 /*return*/, __spreadArray([], __read(history), false)];
|
|
@@ -7270,6 +7538,7 @@ var getAgentHistory = function (clientId, agentName) { return __awaiter(void 0,
|
|
|
7270
7538
|
});
|
|
7271
7539
|
}); };
|
|
7272
7540
|
|
|
7541
|
+
var METHOD_NAME$m = "function.getSessionMode";
|
|
7273
7542
|
/**
|
|
7274
7543
|
* Return the session mode (`"session" | "makeConnection" | "complete"`) for clientId
|
|
7275
7544
|
*
|
|
@@ -7278,15 +7547,17 @@ var getAgentHistory = function (clientId, agentName) { return __awaiter(void 0,
|
|
|
7278
7547
|
var getSessionMode = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7279
7548
|
var swarmName;
|
|
7280
7549
|
return __generator(this, function (_a) {
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
|
|
7550
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7551
|
+
swarm.loggerService.log(METHOD_NAME$m, {
|
|
7552
|
+
clientId: clientId,
|
|
7553
|
+
});
|
|
7284
7554
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7285
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
7555
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$m);
|
|
7286
7556
|
return [2 /*return*/, swarm.sessionValidationService.getSessionMode(clientId)];
|
|
7287
7557
|
});
|
|
7288
7558
|
}); };
|
|
7289
7559
|
|
|
7560
|
+
var METHOD_NAME$l = "function.commitToolOutput";
|
|
7290
7561
|
/**
|
|
7291
7562
|
* Commits the tool output to the active agent in a swarm session
|
|
7292
7563
|
*
|
|
@@ -7296,35 +7567,35 @@ var getSessionMode = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
7296
7567
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
7297
7568
|
*/
|
|
7298
7569
|
var commitToolOutput = function (toolId, content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7299
|
-
var
|
|
7570
|
+
var swarmName, currentAgentName;
|
|
7300
7571
|
return __generator(this, function (_a) {
|
|
7301
7572
|
switch (_a.label) {
|
|
7302
7573
|
case 0:
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
swarm.
|
|
7312
|
-
swarm.sessionValidationService.validate(clientId, "commitToolOutput");
|
|
7574
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7575
|
+
swarm.loggerService.log(METHOD_NAME$l, {
|
|
7576
|
+
toolId: toolId,
|
|
7577
|
+
content: content,
|
|
7578
|
+
clientId: clientId,
|
|
7579
|
+
agentName: agentName,
|
|
7580
|
+
});
|
|
7581
|
+
swarm.agentValidationService.validate(agentName, METHOD_NAME$l);
|
|
7582
|
+
swarm.sessionValidationService.validate(clientId, METHOD_NAME$l);
|
|
7313
7583
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7314
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
7315
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(
|
|
7584
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$l);
|
|
7585
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(METHOD_NAME$l, clientId, swarmName)];
|
|
7316
7586
|
case 1:
|
|
7317
7587
|
currentAgentName = _a.sent();
|
|
7318
7588
|
if (currentAgentName !== agentName) {
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7589
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7590
|
+
swarm.loggerService.log('function "commitToolOutput" skipped due to the agent change', {
|
|
7591
|
+
toolId: toolId,
|
|
7592
|
+
currentAgentName: currentAgentName,
|
|
7593
|
+
agentName: agentName,
|
|
7594
|
+
clientId: clientId,
|
|
7595
|
+
});
|
|
7325
7596
|
return [2 /*return*/];
|
|
7326
7597
|
}
|
|
7327
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content,
|
|
7598
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$l, clientId, swarmName)];
|
|
7328
7599
|
case 2:
|
|
7329
7600
|
_a.sent();
|
|
7330
7601
|
return [2 /*return*/];
|
|
@@ -7332,8 +7603,9 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
|
|
|
7332
7603
|
});
|
|
7333
7604
|
}); };
|
|
7334
7605
|
|
|
7606
|
+
var METHOD_NAME$k = "function.commitSystemMessage";
|
|
7335
7607
|
/**
|
|
7336
|
-
* Commits a system message to the active agent in
|
|
7608
|
+
* Commits a system message to the active agent in the swarm.
|
|
7337
7609
|
*
|
|
7338
7610
|
* @param {string} content - The content of the system message.
|
|
7339
7611
|
* @param {string} clientId - The ID of the client.
|
|
@@ -7341,32 +7613,33 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
|
|
|
7341
7613
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7342
7614
|
*/
|
|
7343
7615
|
var commitSystemMessage = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7344
|
-
var
|
|
7616
|
+
var swarmName, currentAgentName;
|
|
7345
7617
|
return __generator(this, function (_a) {
|
|
7346
7618
|
switch (_a.label) {
|
|
7347
7619
|
case 0:
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
swarm.agentValidationService.validate(agentName,
|
|
7355
|
-
swarm.sessionValidationService.validate(clientId,
|
|
7620
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7621
|
+
swarm.loggerService.log(METHOD_NAME$k, {
|
|
7622
|
+
content: content,
|
|
7623
|
+
clientId: clientId,
|
|
7624
|
+
agentName: agentName,
|
|
7625
|
+
});
|
|
7626
|
+
swarm.agentValidationService.validate(agentName, METHOD_NAME$k);
|
|
7627
|
+
swarm.sessionValidationService.validate(clientId, METHOD_NAME$k);
|
|
7356
7628
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7357
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
7358
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(
|
|
7629
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$k);
|
|
7630
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(METHOD_NAME$k, clientId, swarmName)];
|
|
7359
7631
|
case 1:
|
|
7360
7632
|
currentAgentName = _a.sent();
|
|
7361
7633
|
if (currentAgentName !== agentName) {
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7634
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7635
|
+
swarm.loggerService.log('function "commitSystemMessage" skipped due to the agent change', {
|
|
7636
|
+
currentAgentName: currentAgentName,
|
|
7637
|
+
agentName: agentName,
|
|
7638
|
+
clientId: clientId,
|
|
7639
|
+
});
|
|
7367
7640
|
return [2 /*return*/];
|
|
7368
7641
|
}
|
|
7369
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content,
|
|
7642
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, METHOD_NAME$k, clientId, swarmName)];
|
|
7370
7643
|
case 2:
|
|
7371
7644
|
_a.sent();
|
|
7372
7645
|
return [2 /*return*/];
|
|
@@ -7374,6 +7647,7 @@ var commitSystemMessage = function (content, clientId, agentName) { return __awa
|
|
|
7374
7647
|
});
|
|
7375
7648
|
}); };
|
|
7376
7649
|
|
|
7650
|
+
var METHOD_NAME$j = "function.commitFlush";
|
|
7377
7651
|
/**
|
|
7378
7652
|
* Commits flush of agent history
|
|
7379
7653
|
*
|
|
@@ -7382,31 +7656,32 @@ var commitSystemMessage = function (content, clientId, agentName) { return __awa
|
|
|
7382
7656
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7383
7657
|
*/
|
|
7384
7658
|
var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7385
|
-
var
|
|
7659
|
+
var swarmName, currentAgentName;
|
|
7386
7660
|
return __generator(this, function (_a) {
|
|
7387
7661
|
switch (_a.label) {
|
|
7388
7662
|
case 0:
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
swarm.agentValidationService.validate(agentName,
|
|
7395
|
-
swarm.sessionValidationService.validate(clientId,
|
|
7663
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7664
|
+
swarm.loggerService.log(METHOD_NAME$j, {
|
|
7665
|
+
clientId: clientId,
|
|
7666
|
+
agentName: agentName,
|
|
7667
|
+
});
|
|
7668
|
+
swarm.agentValidationService.validate(agentName, METHOD_NAME$j);
|
|
7669
|
+
swarm.sessionValidationService.validate(clientId, METHOD_NAME$j);
|
|
7396
7670
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7397
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
7398
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(
|
|
7671
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$j);
|
|
7672
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(METHOD_NAME$j, clientId, swarmName)];
|
|
7399
7673
|
case 1:
|
|
7400
7674
|
currentAgentName = _a.sent();
|
|
7401
7675
|
if (currentAgentName !== agentName) {
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7676
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7677
|
+
swarm.loggerService.log('function "commitFlush" skipped due to the agent change', {
|
|
7678
|
+
currentAgentName: currentAgentName,
|
|
7679
|
+
agentName: agentName,
|
|
7680
|
+
clientId: clientId,
|
|
7681
|
+
});
|
|
7407
7682
|
return [2 /*return*/];
|
|
7408
7683
|
}
|
|
7409
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitFlush(
|
|
7684
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitFlush(METHOD_NAME$j, clientId, swarmName)];
|
|
7410
7685
|
case 2:
|
|
7411
7686
|
_a.sent();
|
|
7412
7687
|
return [2 /*return*/];
|
|
@@ -7414,6 +7689,7 @@ var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void
|
|
|
7414
7689
|
});
|
|
7415
7690
|
}); };
|
|
7416
7691
|
|
|
7692
|
+
var METHOD_NAME$i = "function.execute";
|
|
7417
7693
|
/**
|
|
7418
7694
|
* Send the message to the active agent in the swarm content like it income from client side
|
|
7419
7695
|
* Should be used to review tool output and initiate conversation from the model side to client
|
|
@@ -7424,38 +7700,38 @@ var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void
|
|
|
7424
7700
|
* @returns {Promise<void>} - A promise that resolves when the execution is complete.
|
|
7425
7701
|
*/
|
|
7426
7702
|
var execute = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7427
|
-
var
|
|
7703
|
+
var executionId, swarmName, currentAgentName;
|
|
7428
7704
|
return __generator(this, function (_a) {
|
|
7429
7705
|
switch (_a.label) {
|
|
7430
7706
|
case 0:
|
|
7431
|
-
methodName = "function execute";
|
|
7432
7707
|
executionId = functoolsKit.randomString();
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
swarm.agentValidationService.validate(agentName,
|
|
7441
|
-
swarm.sessionValidationService.validate(clientId,
|
|
7708
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7709
|
+
swarm.loggerService.log(METHOD_NAME$i, {
|
|
7710
|
+
content: content,
|
|
7711
|
+
clientId: clientId,
|
|
7712
|
+
agentName: agentName,
|
|
7713
|
+
executionId: executionId,
|
|
7714
|
+
});
|
|
7715
|
+
swarm.agentValidationService.validate(agentName, METHOD_NAME$i);
|
|
7716
|
+
swarm.sessionValidationService.validate(clientId, METHOD_NAME$i);
|
|
7442
7717
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7443
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
7444
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(
|
|
7718
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$i);
|
|
7719
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(METHOD_NAME$i, clientId, swarmName)];
|
|
7445
7720
|
case 1:
|
|
7446
7721
|
currentAgentName = _a.sent();
|
|
7447
7722
|
if (currentAgentName !== agentName) {
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7723
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7724
|
+
swarm.loggerService.log('function "execute" skipped due to the agent change', {
|
|
7725
|
+
currentAgentName: currentAgentName,
|
|
7726
|
+
agentName: agentName,
|
|
7727
|
+
clientId: clientId,
|
|
7728
|
+
});
|
|
7453
7729
|
return [2 /*return*/];
|
|
7454
7730
|
}
|
|
7455
7731
|
return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
7456
7732
|
return __generator(this, function (_a) {
|
|
7457
7733
|
switch (_a.label) {
|
|
7458
|
-
case 0: return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool",
|
|
7734
|
+
case 0: return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", METHOD_NAME$i, clientId, swarmName)];
|
|
7459
7735
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7460
7736
|
}
|
|
7461
7737
|
});
|
|
@@ -7467,6 +7743,7 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
|
|
|
7467
7743
|
});
|
|
7468
7744
|
}); };
|
|
7469
7745
|
|
|
7746
|
+
var METHOD_NAME$h = "function.emit";
|
|
7470
7747
|
/**
|
|
7471
7748
|
* Emits a string constant as the model output without executing incoming message
|
|
7472
7749
|
* Works only for `makeConnection`
|
|
@@ -7478,40 +7755,42 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
|
|
|
7478
7755
|
* @returns {Promise<void>} A promise that resolves when the content is emitted.
|
|
7479
7756
|
*/
|
|
7480
7757
|
var emit = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7481
|
-
var
|
|
7758
|
+
var swarmName, currentAgentName;
|
|
7482
7759
|
return __generator(this, function (_a) {
|
|
7483
7760
|
switch (_a.label) {
|
|
7484
7761
|
case 0:
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7762
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7763
|
+
swarm.loggerService.log(METHOD_NAME$h, {
|
|
7764
|
+
content: content,
|
|
7765
|
+
clientId: clientId,
|
|
7766
|
+
agentName: agentName,
|
|
7767
|
+
});
|
|
7491
7768
|
if (swarm.sessionValidationService.getSessionMode(clientId) !== "makeConnection") {
|
|
7492
7769
|
throw new Error("agent-swarm-kit emit session is not makeConnection clientId=".concat(clientId));
|
|
7493
7770
|
}
|
|
7494
|
-
swarm.agentValidationService.validate(agentName,
|
|
7495
|
-
swarm.sessionValidationService.validate(clientId,
|
|
7771
|
+
swarm.agentValidationService.validate(agentName, METHOD_NAME$h);
|
|
7772
|
+
swarm.sessionValidationService.validate(clientId, METHOD_NAME$h);
|
|
7496
7773
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7497
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
7498
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(
|
|
7774
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$h);
|
|
7775
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(METHOD_NAME$h, clientId, swarmName)];
|
|
7499
7776
|
case 1:
|
|
7500
7777
|
currentAgentName = _a.sent();
|
|
7501
7778
|
if (currentAgentName !== agentName) {
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7779
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7780
|
+
swarm.loggerService.log('function "emit" skipped due to the agent change', {
|
|
7781
|
+
currentAgentName: currentAgentName,
|
|
7782
|
+
agentName: agentName,
|
|
7783
|
+
clientId: clientId,
|
|
7784
|
+
});
|
|
7507
7785
|
return [2 /*return*/];
|
|
7508
7786
|
}
|
|
7509
|
-
return [4 /*yield*/, swarm.sessionPublicService.emit(content,
|
|
7787
|
+
return [4 /*yield*/, swarm.sessionPublicService.emit(content, METHOD_NAME$h, clientId, swarmName)];
|
|
7510
7788
|
case 2: return [2 /*return*/, _a.sent()];
|
|
7511
7789
|
}
|
|
7512
7790
|
});
|
|
7513
7791
|
}); };
|
|
7514
7792
|
|
|
7793
|
+
var METHOD_NAME$g = "function.commitToolOutputForce";
|
|
7515
7794
|
/**
|
|
7516
7795
|
* Commits the tool output to the active agent in a swarm session without checking active agent
|
|
7517
7796
|
*
|
|
@@ -7520,20 +7799,20 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
|
|
|
7520
7799
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
7521
7800
|
*/
|
|
7522
7801
|
var commitToolOutputForce = function (toolId, content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7523
|
-
var
|
|
7802
|
+
var swarmName;
|
|
7524
7803
|
return __generator(this, function (_a) {
|
|
7525
7804
|
switch (_a.label) {
|
|
7526
7805
|
case 0:
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
swarm.sessionValidationService.validate(clientId,
|
|
7806
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7807
|
+
swarm.loggerService.log(METHOD_NAME$g, {
|
|
7808
|
+
toolId: toolId,
|
|
7809
|
+
content: content,
|
|
7810
|
+
clientId: clientId,
|
|
7811
|
+
});
|
|
7812
|
+
swarm.sessionValidationService.validate(clientId, METHOD_NAME$g);
|
|
7534
7813
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7535
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
7536
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content,
|
|
7814
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$g);
|
|
7815
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$g, clientId, swarmName)];
|
|
7537
7816
|
case 1:
|
|
7538
7817
|
_a.sent();
|
|
7539
7818
|
return [2 /*return*/];
|
|
@@ -7541,6 +7820,7 @@ var commitToolOutputForce = function (toolId, content, clientId) { return __awai
|
|
|
7541
7820
|
});
|
|
7542
7821
|
}); };
|
|
7543
7822
|
|
|
7823
|
+
var METHOD_NAME$f = "function.commitSystemMessageForce";
|
|
7544
7824
|
/**
|
|
7545
7825
|
* Commits a system message to the active agent in as swarm without checking active agent.
|
|
7546
7826
|
*
|
|
@@ -7549,19 +7829,19 @@ var commitToolOutputForce = function (toolId, content, clientId) { return __awai
|
|
|
7549
7829
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7550
7830
|
*/
|
|
7551
7831
|
var commitSystemMessageForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7552
|
-
var
|
|
7832
|
+
var swarmName;
|
|
7553
7833
|
return __generator(this, function (_a) {
|
|
7554
7834
|
switch (_a.label) {
|
|
7555
7835
|
case 0:
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
swarm.sessionValidationService.validate(clientId,
|
|
7836
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7837
|
+
swarm.loggerService.log(METHOD_NAME$f, {
|
|
7838
|
+
content: content,
|
|
7839
|
+
clientId: clientId,
|
|
7840
|
+
});
|
|
7841
|
+
swarm.sessionValidationService.validate(clientId, METHOD_NAME$f);
|
|
7562
7842
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7563
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
7564
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content,
|
|
7843
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$f);
|
|
7844
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, METHOD_NAME$f, clientId, swarmName)];
|
|
7565
7845
|
case 1:
|
|
7566
7846
|
_a.sent();
|
|
7567
7847
|
return [2 /*return*/];
|
|
@@ -7569,6 +7849,7 @@ var commitSystemMessageForce = function (content, clientId) { return __awaiter(v
|
|
|
7569
7849
|
});
|
|
7570
7850
|
}); };
|
|
7571
7851
|
|
|
7852
|
+
var METHOD_NAME$e = "function.commitFlushForce";
|
|
7572
7853
|
/**
|
|
7573
7854
|
* Commits flush of agent history without active agent check
|
|
7574
7855
|
*
|
|
@@ -7576,19 +7857,19 @@ var commitSystemMessageForce = function (content, clientId) { return __awaiter(v
|
|
|
7576
7857
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7577
7858
|
*/
|
|
7578
7859
|
var commitFlushForce = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7579
|
-
var
|
|
7860
|
+
var swarmName;
|
|
7580
7861
|
return __generator(this, function (_a) {
|
|
7581
7862
|
switch (_a.label) {
|
|
7582
7863
|
case 0:
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
swarm.sessionValidationService.validate(clientId,
|
|
7864
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7865
|
+
swarm.loggerService.log(METHOD_NAME$e, {
|
|
7866
|
+
clientId: clientId,
|
|
7867
|
+
METHOD_NAME: METHOD_NAME$e,
|
|
7868
|
+
});
|
|
7869
|
+
swarm.sessionValidationService.validate(clientId, METHOD_NAME$e);
|
|
7589
7870
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7590
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
7591
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitFlush(
|
|
7871
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$e);
|
|
7872
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitFlush(METHOD_NAME$e, clientId, swarmName)];
|
|
7592
7873
|
case 1:
|
|
7593
7874
|
_a.sent();
|
|
7594
7875
|
return [2 /*return*/];
|
|
@@ -7596,6 +7877,7 @@ var commitFlushForce = function (clientId) { return __awaiter(void 0, void 0, vo
|
|
|
7596
7877
|
});
|
|
7597
7878
|
}); };
|
|
7598
7879
|
|
|
7880
|
+
var METHOD_NAME$d = "function.commitSystemMessage";
|
|
7599
7881
|
/**
|
|
7600
7882
|
* Commits a user message to the active agent history in as swarm without answer and checking active agent
|
|
7601
7883
|
*
|
|
@@ -7604,19 +7886,19 @@ var commitFlushForce = function (clientId) { return __awaiter(void 0, void 0, vo
|
|
|
7604
7886
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7605
7887
|
*/
|
|
7606
7888
|
var commitUserMessageForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7607
|
-
var
|
|
7889
|
+
var swarmName;
|
|
7608
7890
|
return __generator(this, function (_a) {
|
|
7609
7891
|
switch (_a.label) {
|
|
7610
7892
|
case 0:
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
swarm.sessionValidationService.validate(clientId,
|
|
7893
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7894
|
+
swarm.loggerService.log(METHOD_NAME$d, {
|
|
7895
|
+
content: content,
|
|
7896
|
+
clientId: clientId,
|
|
7897
|
+
});
|
|
7898
|
+
swarm.sessionValidationService.validate(clientId, METHOD_NAME$d);
|
|
7617
7899
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7618
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
7619
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content,
|
|
7900
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$d);
|
|
7901
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, METHOD_NAME$d, clientId, swarmName)];
|
|
7620
7902
|
case 1:
|
|
7621
7903
|
_a.sent();
|
|
7622
7904
|
return [2 /*return*/];
|
|
@@ -7624,6 +7906,7 @@ var commitUserMessageForce = function (content, clientId) { return __awaiter(voi
|
|
|
7624
7906
|
});
|
|
7625
7907
|
}); };
|
|
7626
7908
|
|
|
7909
|
+
var METHOD_NAME$c = "function.emitForce";
|
|
7627
7910
|
/**
|
|
7628
7911
|
* Emits a string constant as the model output without executing incoming message and checking active agent
|
|
7629
7912
|
* Works only for `makeConnection`
|
|
@@ -7635,27 +7918,28 @@ var commitUserMessageForce = function (content, clientId) { return __awaiter(voi
|
|
|
7635
7918
|
* @returns {Promise<void>} A promise that resolves when the content is emitted.
|
|
7636
7919
|
*/
|
|
7637
7920
|
var emitForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7638
|
-
var
|
|
7921
|
+
var swarmName;
|
|
7639
7922
|
return __generator(this, function (_a) {
|
|
7640
7923
|
switch (_a.label) {
|
|
7641
7924
|
case 0:
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7925
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7926
|
+
swarm.loggerService.log(METHOD_NAME$c, {
|
|
7927
|
+
content: content,
|
|
7928
|
+
clientId: clientId,
|
|
7929
|
+
});
|
|
7647
7930
|
if (swarm.sessionValidationService.getSessionMode(clientId) !== "makeConnection") {
|
|
7648
7931
|
throw new Error("agent-swarm-kit emitForce session is not makeConnection clientId=".concat(clientId));
|
|
7649
7932
|
}
|
|
7650
|
-
swarm.sessionValidationService.validate(clientId,
|
|
7933
|
+
swarm.sessionValidationService.validate(clientId, METHOD_NAME$c);
|
|
7651
7934
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7652
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
7653
|
-
return [4 /*yield*/, swarm.sessionPublicService.emit(content,
|
|
7935
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$c);
|
|
7936
|
+
return [4 /*yield*/, swarm.sessionPublicService.emit(content, METHOD_NAME$c, clientId, swarmName)];
|
|
7654
7937
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7655
7938
|
}
|
|
7656
7939
|
});
|
|
7657
7940
|
}); };
|
|
7658
7941
|
|
|
7942
|
+
var METHOD_NAME$b = "function.executeForce";
|
|
7659
7943
|
/**
|
|
7660
7944
|
* Send the message to the active agent in the swarm content like it income from client side
|
|
7661
7945
|
* Should be used to review tool output and initiate conversation from the model side to client
|
|
@@ -7667,22 +7951,22 @@ var emitForce = function (content, clientId) { return __awaiter(void 0, void 0,
|
|
|
7667
7951
|
* @returns {Promise<void>} - A promise that resolves when the execution is complete.
|
|
7668
7952
|
*/
|
|
7669
7953
|
var executeForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7670
|
-
var
|
|
7954
|
+
var executionId, swarmName;
|
|
7671
7955
|
return __generator(this, function (_a) {
|
|
7672
|
-
methodName = "function executeForce";
|
|
7673
7956
|
executionId = functoolsKit.randomString();
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7957
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7958
|
+
swarm.loggerService.log(METHOD_NAME$b, {
|
|
7959
|
+
content: content,
|
|
7960
|
+
clientId: clientId,
|
|
7961
|
+
executionId: executionId,
|
|
7962
|
+
});
|
|
7963
|
+
swarm.sessionValidationService.validate(clientId, METHOD_NAME$b);
|
|
7680
7964
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7681
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
7965
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$b);
|
|
7682
7966
|
return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
7683
7967
|
return __generator(this, function (_a) {
|
|
7684
7968
|
switch (_a.label) {
|
|
7685
|
-
case 0: return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool",
|
|
7969
|
+
case 0: return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", METHOD_NAME$b, clientId, swarmName)];
|
|
7686
7970
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7687
7971
|
}
|
|
7688
7972
|
});
|
|
@@ -7693,6 +7977,7 @@ var executeForce = function (content, clientId) { return __awaiter(void 0, void
|
|
|
7693
7977
|
});
|
|
7694
7978
|
}); };
|
|
7695
7979
|
|
|
7980
|
+
var METHOD_NAME$a = "function.listenEvent";
|
|
7696
7981
|
var DISALLOWED_EVENT_SOURCE_LIST$2 = new Set([
|
|
7697
7982
|
"agent-bus",
|
|
7698
7983
|
"history-bus",
|
|
@@ -7717,9 +8002,10 @@ var validateClientId$d = function (clientId) {
|
|
|
7717
8002
|
* @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.
|
|
7718
8003
|
*/
|
|
7719
8004
|
var listenEvent = function (clientId, topicName, fn) {
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
8005
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8006
|
+
swarm.loggerService.log(METHOD_NAME$a, {
|
|
8007
|
+
clientId: clientId,
|
|
8008
|
+
});
|
|
7723
8009
|
if (DISALLOWED_EVENT_SOURCE_LIST$2.has(topicName)) {
|
|
7724
8010
|
throw new Error("agent-swarm listenEvent topic is reserved topicName=".concat(topicName));
|
|
7725
8011
|
}
|
|
@@ -7730,6 +8016,7 @@ var listenEvent = function (clientId, topicName, fn) {
|
|
|
7730
8016
|
});
|
|
7731
8017
|
};
|
|
7732
8018
|
|
|
8019
|
+
var METHOD_NAME$9 = "function.listenEventOnce";
|
|
7733
8020
|
var DISALLOWED_EVENT_SOURCE_LIST$1 = new Set([
|
|
7734
8021
|
"agent-bus",
|
|
7735
8022
|
"history-bus",
|
|
@@ -7754,9 +8041,10 @@ var validateClientId$c = function (clientId) {
|
|
|
7754
8041
|
* @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.
|
|
7755
8042
|
*/
|
|
7756
8043
|
var listenEventOnce = function (clientId, topicName, filterFn, fn) {
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
8044
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8045
|
+
swarm.loggerService.log(METHOD_NAME$9, {
|
|
8046
|
+
clientId: clientId,
|
|
8047
|
+
});
|
|
7760
8048
|
if (DISALLOWED_EVENT_SOURCE_LIST$1.has(topicName)) {
|
|
7761
8049
|
throw new Error("agent-swarm listenEventOnce topic is reserved topicName=".concat(topicName));
|
|
7762
8050
|
}
|
|
@@ -7770,6 +8058,7 @@ var listenEventOnce = function (clientId, topicName, filterFn, fn) {
|
|
|
7770
8058
|
});
|
|
7771
8059
|
};
|
|
7772
8060
|
|
|
8061
|
+
var METHOD_NAME$8 = "function.getLastUserMessage";
|
|
7773
8062
|
/**
|
|
7774
8063
|
* Retrieves the last message sent by the user from the client's message history.
|
|
7775
8064
|
*
|
|
@@ -7777,15 +8066,15 @@ var listenEventOnce = function (clientId, topicName, filterFn, fn) {
|
|
|
7777
8066
|
* @returns {Promise<string | null>} - The content of the last user message, or null if no user message is found.
|
|
7778
8067
|
*/
|
|
7779
8068
|
var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7780
|
-
var
|
|
8069
|
+
var history, last;
|
|
7781
8070
|
return __generator(this, function (_a) {
|
|
7782
8071
|
switch (_a.label) {
|
|
7783
8072
|
case 0:
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
return [4 /*yield*/, getRawHistory(clientId,
|
|
8073
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8074
|
+
swarm.loggerService.log(METHOD_NAME$8, {
|
|
8075
|
+
clientId: clientId,
|
|
8076
|
+
});
|
|
8077
|
+
return [4 /*yield*/, getRawHistory(clientId, METHOD_NAME$8)];
|
|
7789
8078
|
case 1:
|
|
7790
8079
|
history = _a.sent();
|
|
7791
8080
|
last = history.findLast(function (_a) {
|
|
@@ -7797,6 +8086,7 @@ var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0,
|
|
|
7797
8086
|
});
|
|
7798
8087
|
}); };
|
|
7799
8088
|
|
|
8089
|
+
var METHOD_NAME$7 = "function.getUserHistory";
|
|
7800
8090
|
/**
|
|
7801
8091
|
* Retrieves the user history for a given client ID.
|
|
7802
8092
|
*
|
|
@@ -7804,15 +8094,15 @@ var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0,
|
|
|
7804
8094
|
* @returns {Promise<Array>} A promise that resolves to an array of history objects filtered by user role.
|
|
7805
8095
|
*/
|
|
7806
8096
|
var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7807
|
-
var
|
|
8097
|
+
var history;
|
|
7808
8098
|
return __generator(this, function (_a) {
|
|
7809
8099
|
switch (_a.label) {
|
|
7810
8100
|
case 0:
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
return [4 /*yield*/, getRawHistory(clientId,
|
|
8101
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8102
|
+
swarm.loggerService.log(METHOD_NAME$7, {
|
|
8103
|
+
clientId: clientId,
|
|
8104
|
+
});
|
|
8105
|
+
return [4 /*yield*/, getRawHistory(clientId, METHOD_NAME$7)];
|
|
7816
8106
|
case 1:
|
|
7817
8107
|
history = _a.sent();
|
|
7818
8108
|
return [2 /*return*/, history.filter(function (_a) {
|
|
@@ -7823,6 +8113,7 @@ var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
7823
8113
|
});
|
|
7824
8114
|
}); };
|
|
7825
8115
|
|
|
8116
|
+
var METHOD_NAME$6 = "function.getAssistantHistory";
|
|
7826
8117
|
/**
|
|
7827
8118
|
* Retrieves the assistant's history for a given client.
|
|
7828
8119
|
*
|
|
@@ -7830,15 +8121,15 @@ var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
7830
8121
|
* @returns {Promise<Array>} - A promise that resolves to an array of history objects where the role is "assistant".
|
|
7831
8122
|
*/
|
|
7832
8123
|
var getAssistantHistory = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7833
|
-
var
|
|
8124
|
+
var history;
|
|
7834
8125
|
return __generator(this, function (_a) {
|
|
7835
8126
|
switch (_a.label) {
|
|
7836
8127
|
case 0:
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
return [4 /*yield*/, getRawHistory(clientId,
|
|
8128
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8129
|
+
swarm.loggerService.log(METHOD_NAME$6, {
|
|
8130
|
+
clientId: clientId,
|
|
8131
|
+
});
|
|
8132
|
+
return [4 /*yield*/, getRawHistory(clientId, METHOD_NAME$6)];
|
|
7842
8133
|
case 1:
|
|
7843
8134
|
history = _a.sent();
|
|
7844
8135
|
return [2 /*return*/, history.filter(function (_a) {
|
|
@@ -7849,6 +8140,7 @@ var getAssistantHistory = function (clientId) { return __awaiter(void 0, void 0,
|
|
|
7849
8140
|
});
|
|
7850
8141
|
}); };
|
|
7851
8142
|
|
|
8143
|
+
var METHOD_NAME$5 = "function.getLastAssistantMessage";
|
|
7852
8144
|
/**
|
|
7853
8145
|
* Retrieves the last message sent by the assistant from the client's message history.
|
|
7854
8146
|
*
|
|
@@ -7856,15 +8148,15 @@ var getAssistantHistory = function (clientId) { return __awaiter(void 0, void 0,
|
|
|
7856
8148
|
* @returns {Promise<string | null>} - The content of the last assistant message, or null if no user message is found.
|
|
7857
8149
|
*/
|
|
7858
8150
|
var getLastAssistantMessage = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7859
|
-
var
|
|
8151
|
+
var history, last;
|
|
7860
8152
|
return __generator(this, function (_a) {
|
|
7861
8153
|
switch (_a.label) {
|
|
7862
8154
|
case 0:
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
return [4 /*yield*/, getRawHistory(clientId,
|
|
8155
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8156
|
+
swarm.loggerService.log(METHOD_NAME$5, {
|
|
8157
|
+
clientId: clientId,
|
|
8158
|
+
});
|
|
8159
|
+
return [4 /*yield*/, getRawHistory(clientId, METHOD_NAME$5)];
|
|
7868
8160
|
case 1:
|
|
7869
8161
|
history = _a.sent();
|
|
7870
8162
|
last = history.findLast(function (_a) {
|
|
@@ -7876,6 +8168,7 @@ var getLastAssistantMessage = function (clientId) { return __awaiter(void 0, voi
|
|
|
7876
8168
|
});
|
|
7877
8169
|
}); };
|
|
7878
8170
|
|
|
8171
|
+
var METHOD_NAME$4 = "function.getLastSystemMessage";
|
|
7879
8172
|
/**
|
|
7880
8173
|
* Retrieves the last message sent by the system from the client's message history.
|
|
7881
8174
|
*
|
|
@@ -7883,15 +8176,15 @@ var getLastAssistantMessage = function (clientId) { return __awaiter(void 0, voi
|
|
|
7883
8176
|
* @returns {Promise<string | null>} - The content of the last system message, or null if no user message is found.
|
|
7884
8177
|
*/
|
|
7885
8178
|
var getLastSystemMessage = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7886
|
-
var
|
|
8179
|
+
var history, last;
|
|
7887
8180
|
return __generator(this, function (_a) {
|
|
7888
8181
|
switch (_a.label) {
|
|
7889
8182
|
case 0:
|
|
7890
|
-
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
return [4 /*yield*/, getRawHistory(clientId,
|
|
8183
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8184
|
+
swarm.loggerService.log(METHOD_NAME$4, {
|
|
8185
|
+
clientId: clientId,
|
|
8186
|
+
});
|
|
8187
|
+
return [4 /*yield*/, getRawHistory(clientId, METHOD_NAME$4)];
|
|
7895
8188
|
case 1:
|
|
7896
8189
|
history = _a.sent();
|
|
7897
8190
|
last = history.findLast(function (_a) {
|
|
@@ -7903,6 +8196,7 @@ var getLastSystemMessage = function (clientId) { return __awaiter(void 0, void 0
|
|
|
7903
8196
|
});
|
|
7904
8197
|
}); };
|
|
7905
8198
|
|
|
8199
|
+
var METHOD_NAME$3 = "function.makeAutoDispose";
|
|
7906
8200
|
var DEFAULT_TIMEOUT = 15 * 60;
|
|
7907
8201
|
/**
|
|
7908
8202
|
* Creates an auto-dispose mechanism for a client in a swarm.
|
|
@@ -7914,6 +8208,11 @@ var DEFAULT_TIMEOUT = 15 * 60;
|
|
|
7914
8208
|
*/
|
|
7915
8209
|
var makeAutoDispose = function (clientId, swarmName, _a) {
|
|
7916
8210
|
var _b = _a === void 0 ? {} : _a, _c = _b.timeoutSeconds, timeoutSeconds = _c === void 0 ? DEFAULT_TIMEOUT : _c, onDestroy = _b.onDestroy;
|
|
8211
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8212
|
+
swarm.loggerService.log(METHOD_NAME$3, {
|
|
8213
|
+
clientId: clientId,
|
|
8214
|
+
swarmName: swarmName,
|
|
8215
|
+
});
|
|
7917
8216
|
var isOk = true;
|
|
7918
8217
|
var unSource = functoolsKit.Source.fromInterval(1000)
|
|
7919
8218
|
.reduce(function (acm) {
|
|
@@ -7957,6 +8256,7 @@ var makeAutoDispose = function (clientId, swarmName, _a) {
|
|
|
7957
8256
|
};
|
|
7958
8257
|
};
|
|
7959
8258
|
|
|
8259
|
+
var METHOD_NAME$2 = "function.listenEvent";
|
|
7960
8260
|
var DISALLOWED_EVENT_SOURCE_LIST = new Set([
|
|
7961
8261
|
"agent-bus",
|
|
7962
8262
|
"history-bus",
|
|
@@ -7974,9 +8274,10 @@ var DISALLOWED_EVENT_SOURCE_LIST = new Set([
|
|
|
7974
8274
|
* @returns {boolean} - Returns true if the event was successfully emitted.
|
|
7975
8275
|
*/
|
|
7976
8276
|
var event = function (clientId, topicName, payload) {
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
8277
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8278
|
+
swarm.loggerService.log(METHOD_NAME$2, {
|
|
8279
|
+
clientId: clientId,
|
|
8280
|
+
});
|
|
7980
8281
|
if (DISALLOWED_EVENT_SOURCE_LIST.has(topicName)) {
|
|
7981
8282
|
throw new Error("agent-swarm event topic is reserved topicName=".concat(topicName));
|
|
7982
8283
|
}
|
|
@@ -7987,6 +8288,7 @@ var event = function (clientId, topicName, payload) {
|
|
|
7987
8288
|
});
|
|
7988
8289
|
};
|
|
7989
8290
|
|
|
8291
|
+
var METHOD_NAME$1 = "function.cancelOutput";
|
|
7990
8292
|
/**
|
|
7991
8293
|
* Cancel the await of output by emit of empty string
|
|
7992
8294
|
*
|
|
@@ -7995,31 +8297,32 @@ var event = function (clientId, topicName, payload) {
|
|
|
7995
8297
|
* @returns {Promise<void>} - A promise that resolves when the output is canceled
|
|
7996
8298
|
*/
|
|
7997
8299
|
var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7998
|
-
var
|
|
8300
|
+
var swarmName, currentAgentName;
|
|
7999
8301
|
return __generator(this, function (_a) {
|
|
8000
8302
|
switch (_a.label) {
|
|
8001
8303
|
case 0:
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8007
|
-
swarm.agentValidationService.validate(agentName,
|
|
8008
|
-
swarm.sessionValidationService.validate(clientId,
|
|
8304
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8305
|
+
swarm.loggerService.log(METHOD_NAME$1, {
|
|
8306
|
+
clientId: clientId,
|
|
8307
|
+
agentName: agentName,
|
|
8308
|
+
});
|
|
8309
|
+
swarm.agentValidationService.validate(agentName, METHOD_NAME$1);
|
|
8310
|
+
swarm.sessionValidationService.validate(clientId, METHOD_NAME$1);
|
|
8009
8311
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
8010
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
8011
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(
|
|
8312
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$1);
|
|
8313
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(METHOD_NAME$1, clientId, swarmName)];
|
|
8012
8314
|
case 1:
|
|
8013
8315
|
currentAgentName = _a.sent();
|
|
8014
8316
|
if (currentAgentName !== agentName) {
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
|
|
8317
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8318
|
+
swarm.loggerService.log('function "cancelOutput" skipped due to the agent change', {
|
|
8319
|
+
currentAgentName: currentAgentName,
|
|
8320
|
+
agentName: agentName,
|
|
8321
|
+
clientId: clientId,
|
|
8322
|
+
});
|
|
8020
8323
|
return [2 /*return*/];
|
|
8021
8324
|
}
|
|
8022
|
-
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(
|
|
8325
|
+
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(METHOD_NAME$1, clientId, swarmName)];
|
|
8023
8326
|
case 2:
|
|
8024
8327
|
_a.sent();
|
|
8025
8328
|
return [2 /*return*/];
|
|
@@ -8027,6 +8330,7 @@ var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, voi
|
|
|
8027
8330
|
});
|
|
8028
8331
|
}); };
|
|
8029
8332
|
|
|
8333
|
+
var METHOD_NAME = "function.cancelOutputForce";
|
|
8030
8334
|
/**
|
|
8031
8335
|
* Cancel the await of output by emit of empty string without checking active agent
|
|
8032
8336
|
*
|
|
@@ -8035,18 +8339,18 @@ var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, voi
|
|
|
8035
8339
|
* @returns {Promise<void>} - A promise that resolves when the output is canceled
|
|
8036
8340
|
*/
|
|
8037
8341
|
var cancelOutputForce = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
8038
|
-
var
|
|
8342
|
+
var swarmName;
|
|
8039
8343
|
return __generator(this, function (_a) {
|
|
8040
8344
|
switch (_a.label) {
|
|
8041
8345
|
case 0:
|
|
8042
|
-
|
|
8043
|
-
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
swarm.sessionValidationService.validate(clientId,
|
|
8346
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8347
|
+
swarm.loggerService.log(METHOD_NAME, {
|
|
8348
|
+
clientId: clientId,
|
|
8349
|
+
});
|
|
8350
|
+
swarm.sessionValidationService.validate(clientId, METHOD_NAME);
|
|
8047
8351
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
8048
|
-
swarm.swarmValidationService.validate(swarmName,
|
|
8049
|
-
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(
|
|
8352
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME);
|
|
8353
|
+
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(METHOD_NAME, clientId, swarmName)];
|
|
8050
8354
|
case 1:
|
|
8051
8355
|
_a.sent();
|
|
8052
8356
|
return [2 /*return*/];
|
|
@@ -8318,6 +8622,12 @@ var listenSwarmEventOnce = function (clientId, filterFn, fn) {
|
|
|
8318
8622
|
return swarm.busService.once(clientId, "swarm-bus", filterFn, fn);
|
|
8319
8623
|
};
|
|
8320
8624
|
|
|
8625
|
+
var METHOD_NAME_TAKE = "StorageUtils.take";
|
|
8626
|
+
var METHOD_NAME_UPSERT = "StorageUtils.upsert";
|
|
8627
|
+
var METHOD_NAME_REMOVE = "StorageUtils.remove";
|
|
8628
|
+
var METHOD_NAME_GET$1 = "StorageUtils.get";
|
|
8629
|
+
var METHOD_NAME_LIST = "StorageUtils.list";
|
|
8630
|
+
var METHOD_NAME_CLEAR = "StorageUtils.clear";
|
|
8321
8631
|
var StorageUtils = /** @class */ (function () {
|
|
8322
8632
|
function StorageUtils() {
|
|
8323
8633
|
var _this = this;
|
|
@@ -8332,23 +8642,22 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8332
8642
|
* @template T
|
|
8333
8643
|
*/
|
|
8334
8644
|
this.take = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8335
|
-
var methodName;
|
|
8336
8645
|
return __generator(this, function (_a) {
|
|
8337
8646
|
switch (_a.label) {
|
|
8338
8647
|
case 0:
|
|
8339
|
-
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
swarm.storageValidationService.validate(payload.storageName,
|
|
8648
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8649
|
+
swarm.loggerService.log(METHOD_NAME_TAKE, {
|
|
8650
|
+
search: payload.search,
|
|
8651
|
+
total: payload.total,
|
|
8652
|
+
clientId: payload.clientId,
|
|
8653
|
+
storageName: payload.storageName,
|
|
8654
|
+
score: payload.score,
|
|
8655
|
+
});
|
|
8656
|
+
swarm.storageValidationService.validate(payload.storageName, METHOD_NAME_TAKE);
|
|
8348
8657
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8349
8658
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (take)"));
|
|
8350
8659
|
}
|
|
8351
|
-
return [4 /*yield*/, swarm.storagePublicService.take(payload.search, payload.total,
|
|
8660
|
+
return [4 /*yield*/, swarm.storagePublicService.take(payload.search, payload.total, METHOD_NAME_TAKE, payload.clientId, payload.storageName, payload.score)];
|
|
8352
8661
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
8353
8662
|
}
|
|
8354
8663
|
});
|
|
@@ -8363,21 +8672,20 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8363
8672
|
* @template T
|
|
8364
8673
|
*/
|
|
8365
8674
|
this.upsert = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8366
|
-
var methodName;
|
|
8367
8675
|
return __generator(this, function (_a) {
|
|
8368
8676
|
switch (_a.label) {
|
|
8369
8677
|
case 0:
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
swarm.storageValidationService.validate(payload.storageName,
|
|
8678
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8679
|
+
swarm.loggerService.log(METHOD_NAME_UPSERT, {
|
|
8680
|
+
item: payload.item,
|
|
8681
|
+
clientId: payload.clientId,
|
|
8682
|
+
storageName: payload.storageName,
|
|
8683
|
+
});
|
|
8684
|
+
swarm.storageValidationService.validate(payload.storageName, METHOD_NAME_UPSERT);
|
|
8377
8685
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8378
8686
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (upsert)"));
|
|
8379
8687
|
}
|
|
8380
|
-
return [4 /*yield*/, swarm.storagePublicService.upsert(payload.item,
|
|
8688
|
+
return [4 /*yield*/, swarm.storagePublicService.upsert(payload.item, METHOD_NAME_UPSERT, payload.clientId, payload.storageName)];
|
|
8381
8689
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8382
8690
|
}
|
|
8383
8691
|
});
|
|
@@ -8391,21 +8699,20 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8391
8699
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
8392
8700
|
*/
|
|
8393
8701
|
this.remove = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8394
|
-
var methodName;
|
|
8395
8702
|
return __generator(this, function (_a) {
|
|
8396
8703
|
switch (_a.label) {
|
|
8397
8704
|
case 0:
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8404
|
-
swarm.storageValidationService.validate(payload.storageName,
|
|
8705
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8706
|
+
swarm.loggerService.log(METHOD_NAME_REMOVE, {
|
|
8707
|
+
itemId: payload.itemId,
|
|
8708
|
+
clientId: payload.clientId,
|
|
8709
|
+
storageName: payload.storageName,
|
|
8710
|
+
});
|
|
8711
|
+
swarm.storageValidationService.validate(payload.storageName, METHOD_NAME_REMOVE);
|
|
8405
8712
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8406
8713
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (remove)"));
|
|
8407
8714
|
}
|
|
8408
|
-
return [4 /*yield*/, swarm.storagePublicService.remove(payload.itemId,
|
|
8715
|
+
return [4 /*yield*/, swarm.storagePublicService.remove(payload.itemId, METHOD_NAME_REMOVE, payload.clientId, payload.storageName)];
|
|
8409
8716
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8410
8717
|
}
|
|
8411
8718
|
});
|
|
@@ -8420,21 +8727,20 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8420
8727
|
* @template T
|
|
8421
8728
|
*/
|
|
8422
8729
|
this.get = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8423
|
-
var methodName;
|
|
8424
8730
|
return __generator(this, function (_a) {
|
|
8425
8731
|
switch (_a.label) {
|
|
8426
8732
|
case 0:
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8430
|
-
|
|
8431
|
-
|
|
8432
|
-
|
|
8433
|
-
swarm.storageValidationService.validate(payload.storageName,
|
|
8733
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8734
|
+
swarm.loggerService.log(METHOD_NAME_GET$1, {
|
|
8735
|
+
itemId: payload.itemId,
|
|
8736
|
+
clientId: payload.clientId,
|
|
8737
|
+
storageName: payload.storageName,
|
|
8738
|
+
});
|
|
8739
|
+
swarm.storageValidationService.validate(payload.storageName, METHOD_NAME_GET$1);
|
|
8434
8740
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8435
8741
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (get)"));
|
|
8436
8742
|
}
|
|
8437
|
-
return [4 /*yield*/, swarm.storagePublicService.get(payload.itemId,
|
|
8743
|
+
return [4 /*yield*/, swarm.storagePublicService.get(payload.itemId, METHOD_NAME_GET$1, payload.clientId, payload.storageName)];
|
|
8438
8744
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
8439
8745
|
}
|
|
8440
8746
|
});
|
|
@@ -8449,20 +8755,19 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8449
8755
|
* @template T
|
|
8450
8756
|
*/
|
|
8451
8757
|
this.list = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8452
|
-
var methodName;
|
|
8453
8758
|
return __generator(this, function (_a) {
|
|
8454
8759
|
switch (_a.label) {
|
|
8455
8760
|
case 0:
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
|
|
8460
|
-
|
|
8461
|
-
swarm.storageValidationService.validate(payload.storageName,
|
|
8761
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8762
|
+
swarm.loggerService.log(METHOD_NAME_LIST, {
|
|
8763
|
+
clientId: payload.clientId,
|
|
8764
|
+
storageName: payload.storageName,
|
|
8765
|
+
});
|
|
8766
|
+
swarm.storageValidationService.validate(payload.storageName, METHOD_NAME_LIST);
|
|
8462
8767
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8463
8768
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (list)"));
|
|
8464
8769
|
}
|
|
8465
|
-
return [4 /*yield*/, swarm.storagePublicService.list(
|
|
8770
|
+
return [4 /*yield*/, swarm.storagePublicService.list(METHOD_NAME_LIST, payload.clientId, payload.storageName, payload.filter)];
|
|
8466
8771
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
8467
8772
|
}
|
|
8468
8773
|
});
|
|
@@ -8475,20 +8780,19 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8475
8780
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
8476
8781
|
*/
|
|
8477
8782
|
this.clear = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8478
|
-
var methodName;
|
|
8479
8783
|
return __generator(this, function (_a) {
|
|
8480
8784
|
switch (_a.label) {
|
|
8481
8785
|
case 0:
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
swarm.storageValidationService.validate(payload.storageName,
|
|
8786
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8787
|
+
swarm.loggerService.log(METHOD_NAME_CLEAR, {
|
|
8788
|
+
clientId: payload.clientId,
|
|
8789
|
+
storageName: payload.storageName,
|
|
8790
|
+
});
|
|
8791
|
+
swarm.storageValidationService.validate(payload.storageName, METHOD_NAME_CLEAR);
|
|
8488
8792
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8489
8793
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (clear)"));
|
|
8490
8794
|
}
|
|
8491
|
-
return [4 /*yield*/, swarm.storagePublicService.clear(
|
|
8795
|
+
return [4 /*yield*/, swarm.storagePublicService.clear(METHOD_NAME_CLEAR, payload.clientId, payload.storageName)];
|
|
8492
8796
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8493
8797
|
}
|
|
8494
8798
|
});
|
|
@@ -8498,6 +8802,8 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8498
8802
|
}());
|
|
8499
8803
|
var Storage = new StorageUtils();
|
|
8500
8804
|
|
|
8805
|
+
var METHOD_NAME_GET = "StateUtils.getState";
|
|
8806
|
+
var METHOD_NAME_SET = "StateUtils.setState";
|
|
8501
8807
|
/**
|
|
8502
8808
|
* Utility class for managing state in the agent swarm.
|
|
8503
8809
|
* @implements {TState}
|
|
@@ -8516,19 +8822,18 @@ var StateUtils = /** @class */ (function () {
|
|
|
8516
8822
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
8517
8823
|
*/
|
|
8518
8824
|
this.getState = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8519
|
-
var methodName;
|
|
8520
8825
|
return __generator(this, function (_a) {
|
|
8521
8826
|
switch (_a.label) {
|
|
8522
8827
|
case 0:
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8828
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8829
|
+
swarm.loggerService.log(METHOD_NAME_GET, {
|
|
8830
|
+
clientId: payload.clientId,
|
|
8831
|
+
stateName: payload.stateName,
|
|
8832
|
+
});
|
|
8528
8833
|
if (!swarm.agentValidationService.hasState(payload.agentName, payload.stateName)) {
|
|
8529
8834
|
throw new Error("agent-swarm StateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (getState)"));
|
|
8530
8835
|
}
|
|
8531
|
-
return [4 /*yield*/, swarm.statePublicService.getState(
|
|
8836
|
+
return [4 /*yield*/, swarm.statePublicService.getState(METHOD_NAME_GET, payload.clientId, payload.stateName)];
|
|
8532
8837
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8533
8838
|
}
|
|
8534
8839
|
});
|
|
@@ -8545,25 +8850,24 @@ var StateUtils = /** @class */ (function () {
|
|
|
8545
8850
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
8546
8851
|
*/
|
|
8547
8852
|
this.setState = function (dispatchFn, payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8548
|
-
var methodName;
|
|
8549
8853
|
var _this = this;
|
|
8550
8854
|
return __generator(this, function (_a) {
|
|
8551
8855
|
switch (_a.label) {
|
|
8552
8856
|
case 0:
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8857
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8858
|
+
swarm.loggerService.log(METHOD_NAME_SET, {
|
|
8859
|
+
clientId: payload.clientId,
|
|
8860
|
+
stateName: payload.stateName,
|
|
8861
|
+
});
|
|
8558
8862
|
if (!swarm.agentValidationService.hasState(payload.agentName, payload.stateName)) {
|
|
8559
8863
|
throw new Error("agent-swarm StateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (setState)"));
|
|
8560
8864
|
}
|
|
8561
8865
|
if (!(typeof dispatchFn === "function")) return [3 /*break*/, 2];
|
|
8562
|
-
return [4 /*yield*/, swarm.statePublicService.setState(dispatchFn,
|
|
8866
|
+
return [4 /*yield*/, swarm.statePublicService.setState(dispatchFn, METHOD_NAME_SET, payload.clientId, payload.stateName)];
|
|
8563
8867
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8564
8868
|
case 2: return [4 /*yield*/, swarm.statePublicService.setState(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
8565
8869
|
return [2 /*return*/, dispatchFn];
|
|
8566
|
-
}); }); },
|
|
8870
|
+
}); }); }, METHOD_NAME_SET, payload.clientId, payload.stateName)];
|
|
8567
8871
|
case 3: return [2 /*return*/, _a.sent()];
|
|
8568
8872
|
}
|
|
8569
8873
|
});
|
|
@@ -8577,6 +8881,7 @@ var StateUtils = /** @class */ (function () {
|
|
|
8577
8881
|
*/
|
|
8578
8882
|
var State = new StateUtils();
|
|
8579
8883
|
|
|
8884
|
+
var METHOD_NAME_USE_LOGGER = "HistoryInstance.useLogger";
|
|
8580
8885
|
var LoggerUtils = /** @class */ (function () {
|
|
8581
8886
|
function LoggerUtils() {
|
|
8582
8887
|
/**
|
|
@@ -8584,7 +8889,8 @@ var LoggerUtils = /** @class */ (function () {
|
|
|
8584
8889
|
* @param {ILogger} logger - The logger instance to be used.
|
|
8585
8890
|
*/
|
|
8586
8891
|
this.useLogger = function (logger) {
|
|
8587
|
-
|
|
8892
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8893
|
+
swarm.loggerService.log(METHOD_NAME_USE_LOGGER);
|
|
8588
8894
|
swarm.loggerService.setLogger(logger);
|
|
8589
8895
|
};
|
|
8590
8896
|
}
|
|
@@ -8596,12 +8902,100 @@ var LoggerUtils = /** @class */ (function () {
|
|
|
8596
8902
|
*/
|
|
8597
8903
|
var Logger = new LoggerUtils();
|
|
8598
8904
|
|
|
8905
|
+
/**
|
|
8906
|
+
* Function that recursively flattens a nested object to array of entries.
|
|
8907
|
+
*/
|
|
8908
|
+
var objectFlat = function (data) {
|
|
8909
|
+
var result = [];
|
|
8910
|
+
var process = function (entries) {
|
|
8911
|
+
if (entries === void 0) { entries = []; }
|
|
8912
|
+
return entries.forEach(function (_a) {
|
|
8913
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
8914
|
+
if (typeof value === "function") {
|
|
8915
|
+
return;
|
|
8916
|
+
}
|
|
8917
|
+
if (functoolsKit.isObject(value)) {
|
|
8918
|
+
result.push(["", ""]);
|
|
8919
|
+
result.push([key, ""]);
|
|
8920
|
+
process(Object.entries(value));
|
|
8921
|
+
result.push(["", ""]);
|
|
8922
|
+
return;
|
|
8923
|
+
}
|
|
8924
|
+
if (Array.isArray(value)) {
|
|
8925
|
+
result.push(["", ""]);
|
|
8926
|
+
result.push([key, ""]);
|
|
8927
|
+
process(value.map(function (value, idx) { return [String(idx + 1), value]; }));
|
|
8928
|
+
result.push(["", ""]);
|
|
8929
|
+
return;
|
|
8930
|
+
}
|
|
8931
|
+
result.push([key, String(value)]);
|
|
8932
|
+
});
|
|
8933
|
+
};
|
|
8934
|
+
process(Object.entries(data));
|
|
8935
|
+
return result;
|
|
8936
|
+
};
|
|
8937
|
+
|
|
8938
|
+
var LIST_SEPARATOR = Array.from({ length: 80 }, function () { return "-"; });
|
|
8939
|
+
var METHOD_NAME_SERIALIZE = "SchemaUtils.serialize";
|
|
8940
|
+
/**
|
|
8941
|
+
* Utility class for schema-related operations.
|
|
8942
|
+
*/
|
|
8943
|
+
var SchemaUtils = /** @class */ (function () {
|
|
8944
|
+
function SchemaUtils() {
|
|
8945
|
+
/**
|
|
8946
|
+
* Serializes an object or an array of objects into a formatted string.
|
|
8947
|
+
*
|
|
8948
|
+
* @template T - The type of the object.
|
|
8949
|
+
* @param {T[] | T} data - The data to serialize.
|
|
8950
|
+
* @returns {string} The serialized string.
|
|
8951
|
+
*/
|
|
8952
|
+
this.serialize = function (data) {
|
|
8953
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8954
|
+
swarm.loggerService.log(METHOD_NAME_SERIALIZE, {
|
|
8955
|
+
data: data,
|
|
8956
|
+
});
|
|
8957
|
+
if (Array.isArray(data)) {
|
|
8958
|
+
return data
|
|
8959
|
+
.map(function (item) {
|
|
8960
|
+
return objectFlat(item)
|
|
8961
|
+
.map(function (_a) {
|
|
8962
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
8963
|
+
return [GLOBAL_CONFIG.CC_NAME_TO_TITLE(key), value];
|
|
8964
|
+
})
|
|
8965
|
+
.map(function (_a) {
|
|
8966
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
8967
|
+
return "".concat(key, ": ").concat(value);
|
|
8968
|
+
})
|
|
8969
|
+
.join("\n");
|
|
8970
|
+
})
|
|
8971
|
+
.join("\n".concat(LIST_SEPARATOR, "\n"));
|
|
8972
|
+
}
|
|
8973
|
+
return objectFlat(data)
|
|
8974
|
+
.map(function (_a) {
|
|
8975
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
8976
|
+
return [GLOBAL_CONFIG.CC_NAME_TO_TITLE(key), value];
|
|
8977
|
+
})
|
|
8978
|
+
.map(function (_a) {
|
|
8979
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
8980
|
+
return "".concat(key, ": ").concat(value);
|
|
8981
|
+
})
|
|
8982
|
+
.join("\n");
|
|
8983
|
+
};
|
|
8984
|
+
}
|
|
8985
|
+
return SchemaUtils;
|
|
8986
|
+
}());
|
|
8987
|
+
/**
|
|
8988
|
+
* An instance of the SchemaUtils class.
|
|
8989
|
+
*/
|
|
8990
|
+
var Schema = new SchemaUtils();
|
|
8991
|
+
|
|
8599
8992
|
exports.ExecutionContextService = ExecutionContextService;
|
|
8600
8993
|
exports.History = History;
|
|
8601
8994
|
exports.HistoryAdapter = HistoryAdapter;
|
|
8602
8995
|
exports.HistoryInstance = HistoryInstance;
|
|
8603
8996
|
exports.Logger = Logger;
|
|
8604
8997
|
exports.MethodContextService = MethodContextService;
|
|
8998
|
+
exports.Schema = Schema;
|
|
8605
8999
|
exports.State = State;
|
|
8606
9000
|
exports.Storage = Storage;
|
|
8607
9001
|
exports.addAgent = addAgent;
|