agent-swarm-kit 1.0.105 → 1.0.106
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 +403 -78
- package/build/index.mjs +401 -78
- package/package.json +1 -1
- package/types.d.ts +48 -3
package/build/index.cjs
CHANGED
|
@@ -343,7 +343,7 @@ var _a$1;
|
|
|
343
343
|
var HISTORY_INSTANCE_WAIT_FOR_INIT = Symbol("wait-for-init");
|
|
344
344
|
var INSTANCE_METHOD_NAME_WAIT_FOR_INIT = "HistoryInstance.waitForInit";
|
|
345
345
|
var INSTANCE_METHOD_NAME_CTOR = "HistoryInstance.CTOR";
|
|
346
|
-
var INSTANCE_METHOD_NAME_ITERATE_CONDITION = "HistoryInstance.
|
|
346
|
+
var INSTANCE_METHOD_NAME_ITERATE_CONDITION = "HistoryInstance.iterate_condition";
|
|
347
347
|
var INSTANCE_METHOD_NAME_ITERATE = "HistoryInstance.iterate";
|
|
348
348
|
var INSTANCE_METHOD_NAME_PUSH = "HistoryInstance.push";
|
|
349
349
|
var INSTANCE_METHOD_NAME_DISPOSE = "HistoryInstance.dispose";
|
|
@@ -1395,14 +1395,18 @@ var CC_EMPTY_OUTPUT_PLACEHOLDERS = [
|
|
|
1395
1395
|
"I didn’t hear you properly. Can you say that again?",
|
|
1396
1396
|
"Could you please repeat that? I didn’t catch it.",
|
|
1397
1397
|
];
|
|
1398
|
-
var CC_SWARM_AGENT_CHANGED = function () { return
|
|
1399
|
-
return [2 /*return*/, Promise.resolve()];
|
|
1400
|
-
}); }); };
|
|
1398
|
+
var CC_SWARM_AGENT_CHANGED = function () { return Promise.resolve(); };
|
|
1401
1399
|
var CC_SWARM_DEFAULT_AGENT = function (_a, _b, defaultAgent_1) { return __awaiter(void 0, [_a, _b, defaultAgent_1], void 0, function (_c, _d, defaultAgent) {
|
|
1402
1400
|
return __generator(this, function (_e) {
|
|
1403
1401
|
return [2 /*return*/, defaultAgent];
|
|
1404
1402
|
});
|
|
1405
1403
|
}); };
|
|
1404
|
+
var CC_SWARM_STACK_CHANGED = function () { return Promise.resolve(); };
|
|
1405
|
+
var CC_SWARM_DEFAULT_STACK = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1406
|
+
return __generator(this, function (_a) {
|
|
1407
|
+
return [2 /*return*/, []];
|
|
1408
|
+
});
|
|
1409
|
+
}); };
|
|
1406
1410
|
var CC_AGENT_DEFAULT_VALIDATION = validateDefault;
|
|
1407
1411
|
var CC_AGENT_DISALLOWED_TAGS = ["tool_call", "toolcall", "tool"];
|
|
1408
1412
|
var CC_AGENT_DISALLOWED_SYMBOLS = ["{", "}"];
|
|
@@ -1440,6 +1444,8 @@ var GLOBAL_CONFIG = {
|
|
|
1440
1444
|
CC_GET_CLIENT_LOGGER_ADAPTER: CC_GET_CLIENT_LOGGER_ADAPTER,
|
|
1441
1445
|
CC_SWARM_AGENT_CHANGED: CC_SWARM_AGENT_CHANGED,
|
|
1442
1446
|
CC_SWARM_DEFAULT_AGENT: CC_SWARM_DEFAULT_AGENT,
|
|
1447
|
+
CC_SWARM_DEFAULT_STACK: CC_SWARM_DEFAULT_STACK,
|
|
1448
|
+
CC_SWARM_STACK_CHANGED: CC_SWARM_STACK_CHANGED,
|
|
1443
1449
|
CC_AGENT_DEFAULT_VALIDATION: CC_AGENT_DEFAULT_VALIDATION,
|
|
1444
1450
|
CC_AGENT_HISTORY_FILTER: CC_AGENT_HISTORY_FILTER,
|
|
1445
1451
|
CC_AGENT_OUTPUT_TRANSFORM: CC_AGENT_OUTPUT_TRANSFORM,
|
|
@@ -2833,6 +2839,7 @@ var ToolSchemaService = /** @class */ (function () {
|
|
|
2833
2839
|
}());
|
|
2834
2840
|
|
|
2835
2841
|
var AGENT_NEED_FETCH = Symbol("agent-need-fetch");
|
|
2842
|
+
var STACK_NEED_FETCH = Symbol("stack-need-fetch");
|
|
2836
2843
|
/**
|
|
2837
2844
|
* ClientSwarm class implements the ISwarm interface and manages agents within a swarm.
|
|
2838
2845
|
*/
|
|
@@ -2846,7 +2853,34 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2846
2853
|
this.params = params;
|
|
2847
2854
|
this._agentChangedSubject = new functoolsKit.Subject();
|
|
2848
2855
|
this._activeAgent = AGENT_NEED_FETCH;
|
|
2856
|
+
this._navigationStack = STACK_NEED_FETCH;
|
|
2849
2857
|
this._cancelOutputSubject = new functoolsKit.Subject();
|
|
2858
|
+
/**
|
|
2859
|
+
* Pop the navigation stack or return default agent
|
|
2860
|
+
* @returns {Promise<string>} - The pending agent for navigation
|
|
2861
|
+
*/
|
|
2862
|
+
this.navigationPop = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2863
|
+
var _a, prevAgent;
|
|
2864
|
+
return __generator(this, function (_b) {
|
|
2865
|
+
switch (_b.label) {
|
|
2866
|
+
case 0:
|
|
2867
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2868
|
+
this.params.logger.debug("ClientSwarm swarmName=".concat(this.params.swarmName, " clientId=").concat(this.params.clientId, " navigationPop"));
|
|
2869
|
+
if (!(this._navigationStack === STACK_NEED_FETCH)) return [3 /*break*/, 2];
|
|
2870
|
+
_a = this;
|
|
2871
|
+
return [4 /*yield*/, this.params.getNavigationStack(this.params.clientId, this.params.swarmName)];
|
|
2872
|
+
case 1:
|
|
2873
|
+
_a._navigationStack = _b.sent();
|
|
2874
|
+
_b.label = 2;
|
|
2875
|
+
case 2:
|
|
2876
|
+
prevAgent = this._navigationStack.pop();
|
|
2877
|
+
return [4 /*yield*/, this.params.setNavigationStack(this.params.clientId, this._navigationStack, this.params.swarmName)];
|
|
2878
|
+
case 3:
|
|
2879
|
+
_b.sent();
|
|
2880
|
+
return [2 /*return*/, prevAgent ? prevAgent : this.params.defaultAgent];
|
|
2881
|
+
}
|
|
2882
|
+
});
|
|
2883
|
+
}); };
|
|
2850
2884
|
/**
|
|
2851
2885
|
* Cancel the await of output by emit of empty string
|
|
2852
2886
|
* @returns {Promise<string>} - The output from the active agent.
|
|
@@ -3072,18 +3106,30 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
3072
3106
|
*/
|
|
3073
3107
|
this.setAgentName = function (agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3074
3108
|
var _a;
|
|
3075
|
-
|
|
3076
|
-
|
|
3109
|
+
var _b;
|
|
3110
|
+
return __generator(this, function (_c) {
|
|
3111
|
+
switch (_c.label) {
|
|
3077
3112
|
case 0:
|
|
3078
3113
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
3079
3114
|
this.params.logger.debug("ClientSwarm swarmName=".concat(this.params.swarmName, " clientId=").concat(this.params.clientId, " setAgentName agentName=").concat(agentName));
|
|
3080
3115
|
this._activeAgent = agentName;
|
|
3081
3116
|
return [4 /*yield*/, this.params.setActiveAgent(this.params.clientId, agentName, this.params.swarmName)];
|
|
3082
3117
|
case 1:
|
|
3083
|
-
|
|
3084
|
-
if ((
|
|
3118
|
+
_c.sent();
|
|
3119
|
+
if ((_b = this.params.callbacks) === null || _b === void 0 ? void 0 : _b.onAgentChanged) {
|
|
3085
3120
|
this.params.callbacks.onAgentChanged(this.params.clientId, agentName, this.params.swarmName);
|
|
3086
3121
|
}
|
|
3122
|
+
if (!(this._navigationStack === STACK_NEED_FETCH)) return [3 /*break*/, 3];
|
|
3123
|
+
_a = this;
|
|
3124
|
+
return [4 /*yield*/, this.params.getNavigationStack(this.params.clientId, this.params.swarmName)];
|
|
3125
|
+
case 2:
|
|
3126
|
+
_a._navigationStack = _c.sent();
|
|
3127
|
+
_c.label = 3;
|
|
3128
|
+
case 3:
|
|
3129
|
+
this._navigationStack.push(agentName);
|
|
3130
|
+
return [4 /*yield*/, this.params.setNavigationStack(this.params.clientId, this._navigationStack, this.params.swarmName)];
|
|
3131
|
+
case 4:
|
|
3132
|
+
_c.sent();
|
|
3087
3133
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
3088
3134
|
type: "set-agent-name",
|
|
3089
3135
|
source: "swarm-bus",
|
|
@@ -3096,8 +3142,8 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
3096
3142
|
},
|
|
3097
3143
|
clientId: this.params.clientId,
|
|
3098
3144
|
})];
|
|
3099
|
-
case
|
|
3100
|
-
|
|
3145
|
+
case 5:
|
|
3146
|
+
_c.sent();
|
|
3101
3147
|
return [2 /*return*/];
|
|
3102
3148
|
}
|
|
3103
3149
|
});
|
|
@@ -3140,7 +3186,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
3140
3186
|
return "".concat(clientId, "-").concat(swarmName);
|
|
3141
3187
|
}, function (clientId, swarmName) {
|
|
3142
3188
|
var e_1, _a;
|
|
3143
|
-
var _b = _this.swarmSchemaService.get(swarmName), agentList = _b.agentList, defaultAgent = _b.defaultAgent, callbacks = _b.callbacks, _c = _b.getActiveAgent, getActiveAgent = _c === void 0 ? GLOBAL_CONFIG.CC_SWARM_DEFAULT_AGENT : _c, _d = _b.setActiveAgent, setActiveAgent = _d === void 0 ? GLOBAL_CONFIG.CC_SWARM_AGENT_CHANGED : _d;
|
|
3189
|
+
var _b = _this.swarmSchemaService.get(swarmName), agentList = _b.agentList, defaultAgent = _b.defaultAgent, callbacks = _b.callbacks, _c = _b.getActiveAgent, getActiveAgent = _c === void 0 ? GLOBAL_CONFIG.CC_SWARM_DEFAULT_AGENT : _c, _d = _b.setActiveAgent, setActiveAgent = _d === void 0 ? GLOBAL_CONFIG.CC_SWARM_AGENT_CHANGED : _d, _e = _b.getNavigationStack, getNavigationStack = _e === void 0 ? GLOBAL_CONFIG.CC_SWARM_DEFAULT_STACK : _e, _f = _b.setNavigationStack, setNavigationStack = _f === void 0 ? GLOBAL_CONFIG.CC_SWARM_STACK_CHANGED : _f;
|
|
3144
3190
|
var agentMap = {};
|
|
3145
3191
|
try {
|
|
3146
3192
|
for (var agentList_1 = __values(agentList), agentList_1_1 = agentList_1.next(); !agentList_1_1.done; agentList_1_1 = agentList_1.next()) {
|
|
@@ -3164,9 +3210,26 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
3164
3210
|
bus: _this.busService,
|
|
3165
3211
|
getActiveAgent: getActiveAgent,
|
|
3166
3212
|
setActiveAgent: setActiveAgent,
|
|
3213
|
+
getNavigationStack: getNavigationStack,
|
|
3214
|
+
setNavigationStack: setNavigationStack,
|
|
3167
3215
|
callbacks: callbacks,
|
|
3168
3216
|
});
|
|
3169
3217
|
});
|
|
3218
|
+
/**
|
|
3219
|
+
* Pop the navigation stack or return default agent
|
|
3220
|
+
* @returns {Promise<string>} - The pending agent for navigation
|
|
3221
|
+
*/
|
|
3222
|
+
this.navigationPop = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3223
|
+
return __generator(this, function (_a) {
|
|
3224
|
+
switch (_a.label) {
|
|
3225
|
+
case 0:
|
|
3226
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
3227
|
+
this.loggerService.info("swarmConnectionService navigationPop");
|
|
3228
|
+
return [4 /*yield*/, this.getSwarm(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).navigationPop()];
|
|
3229
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
3230
|
+
}
|
|
3231
|
+
});
|
|
3232
|
+
}); };
|
|
3170
3233
|
/**
|
|
3171
3234
|
* Cancel the await of output by emit of empty string
|
|
3172
3235
|
* @returns {Promise<void>}
|
|
@@ -4684,6 +4747,39 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4684
4747
|
var _this = this;
|
|
4685
4748
|
this.loggerService = inject(TYPES.loggerService);
|
|
4686
4749
|
this.swarmConnectionService = inject(TYPES.swarmConnectionService);
|
|
4750
|
+
/**
|
|
4751
|
+
* Pop the navigation stack or return default agent
|
|
4752
|
+
* @returns {Promise<string>} - The pending agent for navigation
|
|
4753
|
+
*/
|
|
4754
|
+
this.navigationPop = function (methodName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4755
|
+
var _this = this;
|
|
4756
|
+
return __generator(this, function (_a) {
|
|
4757
|
+
switch (_a.label) {
|
|
4758
|
+
case 0:
|
|
4759
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4760
|
+
this.loggerService.info("swarmPublicService navigationPop", {
|
|
4761
|
+
clientId: clientId,
|
|
4762
|
+
swarmName: swarmName,
|
|
4763
|
+
});
|
|
4764
|
+
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
4765
|
+
return __generator(this, function (_a) {
|
|
4766
|
+
switch (_a.label) {
|
|
4767
|
+
case 0: return [4 /*yield*/, this.swarmConnectionService.navigationPop()];
|
|
4768
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
4769
|
+
}
|
|
4770
|
+
});
|
|
4771
|
+
}); }, {
|
|
4772
|
+
methodName: methodName,
|
|
4773
|
+
clientId: clientId,
|
|
4774
|
+
swarmName: swarmName,
|
|
4775
|
+
agentName: "",
|
|
4776
|
+
storageName: "",
|
|
4777
|
+
stateName: "",
|
|
4778
|
+
})];
|
|
4779
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
4780
|
+
}
|
|
4781
|
+
});
|
|
4782
|
+
}); };
|
|
4687
4783
|
/**
|
|
4688
4784
|
* Cancel the await of output by emit of empty string
|
|
4689
4785
|
* @param {string} clientId - The client ID.
|
|
@@ -7968,7 +8064,7 @@ var swarm = __assign(__assign(__assign(__assign(__assign(__assign(__assign({}, b
|
|
|
7968
8064
|
init();
|
|
7969
8065
|
var swarm$1 = swarm;
|
|
7970
8066
|
|
|
7971
|
-
var METHOD_NAME$
|
|
8067
|
+
var METHOD_NAME$H = "cli.dumpDocs";
|
|
7972
8068
|
/**
|
|
7973
8069
|
* Dumps the documentation for the agents and swarms.
|
|
7974
8070
|
*
|
|
@@ -7979,7 +8075,7 @@ var METHOD_NAME$F = "cli.dumpDocs";
|
|
|
7979
8075
|
var dumpDocs = function (dirName, PlantUML) {
|
|
7980
8076
|
if (dirName === void 0) { dirName = "./docs/chat"; }
|
|
7981
8077
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7982
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
8078
|
+
swarm$1.loggerService.log(METHOD_NAME$H, {
|
|
7983
8079
|
dirName: dirName,
|
|
7984
8080
|
});
|
|
7985
8081
|
if (PlantUML) {
|
|
@@ -7990,12 +8086,12 @@ var dumpDocs = function (dirName, PlantUML) {
|
|
|
7990
8086
|
swarm$1.agentValidationService
|
|
7991
8087
|
.getAgentList()
|
|
7992
8088
|
.forEach(function (agentName) {
|
|
7993
|
-
return swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
8089
|
+
return swarm$1.agentValidationService.validate(agentName, METHOD_NAME$H);
|
|
7994
8090
|
});
|
|
7995
8091
|
swarm$1.swarmValidationService
|
|
7996
8092
|
.getSwarmList()
|
|
7997
8093
|
.forEach(function (swarmName) {
|
|
7998
|
-
return swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
8094
|
+
return swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$H);
|
|
7999
8095
|
});
|
|
8000
8096
|
swarm$1.agentValidationService.getAgentList().forEach(function (agentName) {
|
|
8001
8097
|
var dependsOn = swarm$1.agentSchemaService.get(agentName).dependsOn;
|
|
@@ -8006,7 +8102,7 @@ var dumpDocs = function (dirName, PlantUML) {
|
|
|
8006
8102
|
return swarm$1.docService.dumpDocs(dirName);
|
|
8007
8103
|
};
|
|
8008
8104
|
|
|
8009
|
-
var METHOD_NAME$
|
|
8105
|
+
var METHOD_NAME$G = "cli.dumpAgent";
|
|
8010
8106
|
/**
|
|
8011
8107
|
* Dumps the agent information into PlantUML format.
|
|
8012
8108
|
*
|
|
@@ -8016,14 +8112,14 @@ var METHOD_NAME$E = "cli.dumpAgent";
|
|
|
8016
8112
|
var dumpAgent = function (agentName, _a) {
|
|
8017
8113
|
var _b = _a === void 0 ? {} : _a, _c = _b.withSubtree, withSubtree = _c === void 0 ? false : _c;
|
|
8018
8114
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8019
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
8115
|
+
swarm$1.loggerService.log(METHOD_NAME$G, {
|
|
8020
8116
|
agentName: agentName,
|
|
8021
8117
|
});
|
|
8022
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
8118
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$G);
|
|
8023
8119
|
return swarm$1.agentMetaService.toUML(agentName, withSubtree);
|
|
8024
8120
|
};
|
|
8025
8121
|
|
|
8026
|
-
var METHOD_NAME$
|
|
8122
|
+
var METHOD_NAME$F = "cli.dumpSwarm";
|
|
8027
8123
|
/**
|
|
8028
8124
|
* Dumps the swarm information into PlantUML format.
|
|
8029
8125
|
*
|
|
@@ -8032,14 +8128,14 @@ var METHOD_NAME$D = "cli.dumpSwarm";
|
|
|
8032
8128
|
*/
|
|
8033
8129
|
var dumpSwarm = function (swarmName) {
|
|
8034
8130
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8035
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
8131
|
+
swarm$1.loggerService.log(METHOD_NAME$F, {
|
|
8036
8132
|
swarmName: swarmName,
|
|
8037
8133
|
});
|
|
8038
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
8134
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$F);
|
|
8039
8135
|
return swarm$1.swarmMetaService.toUML(swarmName);
|
|
8040
8136
|
};
|
|
8041
8137
|
|
|
8042
|
-
var METHOD_NAME$
|
|
8138
|
+
var METHOD_NAME$E = "function.addAgent";
|
|
8043
8139
|
/**
|
|
8044
8140
|
* Adds a new agent to the agent registry. The swarm takes only those agents which was registered
|
|
8045
8141
|
*
|
|
@@ -8048,7 +8144,7 @@ var METHOD_NAME$C = "function.addAgent";
|
|
|
8048
8144
|
*/
|
|
8049
8145
|
var addAgent = function (agentSchema) {
|
|
8050
8146
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8051
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
8147
|
+
swarm$1.loggerService.log(METHOD_NAME$E, {
|
|
8052
8148
|
agentSchema: agentSchema,
|
|
8053
8149
|
});
|
|
8054
8150
|
swarm$1.agentValidationService.addAgent(agentSchema.agentName, agentSchema);
|
|
@@ -8056,7 +8152,7 @@ var addAgent = function (agentSchema) {
|
|
|
8056
8152
|
return agentSchema.agentName;
|
|
8057
8153
|
};
|
|
8058
8154
|
|
|
8059
|
-
var METHOD_NAME$
|
|
8155
|
+
var METHOD_NAME$D = "function.addCompletion";
|
|
8060
8156
|
/**
|
|
8061
8157
|
* Adds a completion engine for agents. Agents could use different models and
|
|
8062
8158
|
* framewords for completion like: mock, gpt4all, ollama, openai
|
|
@@ -8066,7 +8162,7 @@ var METHOD_NAME$B = "function.addCompletion";
|
|
|
8066
8162
|
*/
|
|
8067
8163
|
var addCompletion = function (completionSchema) {
|
|
8068
8164
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8069
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
8165
|
+
swarm$1.loggerService.log(METHOD_NAME$D, {
|
|
8070
8166
|
completionSchema: completionSchema,
|
|
8071
8167
|
});
|
|
8072
8168
|
swarm$1.completionValidationService.addCompletion(completionSchema.completionName);
|
|
@@ -8074,7 +8170,7 @@ var addCompletion = function (completionSchema) {
|
|
|
8074
8170
|
return completionSchema.completionName;
|
|
8075
8171
|
};
|
|
8076
8172
|
|
|
8077
|
-
var METHOD_NAME$
|
|
8173
|
+
var METHOD_NAME$C = "function.addSwarm";
|
|
8078
8174
|
/**
|
|
8079
8175
|
* Adds a new swarm to the system. The swarm is a root for starting client session
|
|
8080
8176
|
*
|
|
@@ -8083,7 +8179,7 @@ var METHOD_NAME$A = "function.addSwarm";
|
|
|
8083
8179
|
*/
|
|
8084
8180
|
var addSwarm = function (swarmSchema) {
|
|
8085
8181
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8086
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
8182
|
+
swarm$1.loggerService.log(METHOD_NAME$C, {
|
|
8087
8183
|
swarmSchema: swarmSchema,
|
|
8088
8184
|
});
|
|
8089
8185
|
swarm$1.swarmValidationService.addSwarm(swarmSchema.swarmName, swarmSchema);
|
|
@@ -8091,7 +8187,7 @@ var addSwarm = function (swarmSchema) {
|
|
|
8091
8187
|
return swarmSchema.swarmName;
|
|
8092
8188
|
};
|
|
8093
8189
|
|
|
8094
|
-
var METHOD_NAME$
|
|
8190
|
+
var METHOD_NAME$B = "function.addTool";
|
|
8095
8191
|
/**
|
|
8096
8192
|
* Adds a new tool for agents in a swarm. Tool should be registered in `addAgent`
|
|
8097
8193
|
* declaration
|
|
@@ -8101,7 +8197,7 @@ var METHOD_NAME$z = "function.addTool";
|
|
|
8101
8197
|
*/
|
|
8102
8198
|
var addTool = function (toolSchema) {
|
|
8103
8199
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8104
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
8200
|
+
swarm$1.loggerService.log(METHOD_NAME$B, {
|
|
8105
8201
|
toolSchema: toolSchema,
|
|
8106
8202
|
});
|
|
8107
8203
|
swarm$1.toolValidationService.addTool(toolSchema.toolName, toolSchema);
|
|
@@ -8109,7 +8205,7 @@ var addTool = function (toolSchema) {
|
|
|
8109
8205
|
return toolSchema.toolName;
|
|
8110
8206
|
};
|
|
8111
8207
|
|
|
8112
|
-
var METHOD_NAME$
|
|
8208
|
+
var METHOD_NAME$A = "function.addState";
|
|
8113
8209
|
/**
|
|
8114
8210
|
* Adds a new state to the state registry. The swarm takes only those states which was registered
|
|
8115
8211
|
*
|
|
@@ -8118,7 +8214,7 @@ var METHOD_NAME$y = "function.addState";
|
|
|
8118
8214
|
*/
|
|
8119
8215
|
var addState = function (stateSchema) {
|
|
8120
8216
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8121
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
8217
|
+
swarm$1.loggerService.log(METHOD_NAME$A, {
|
|
8122
8218
|
stateSchema: stateSchema,
|
|
8123
8219
|
});
|
|
8124
8220
|
swarm$1.stateSchemaService.register(stateSchema.stateName, stateSchema);
|
|
@@ -8130,7 +8226,7 @@ var addState = function (stateSchema) {
|
|
|
8130
8226
|
return stateSchema.stateName;
|
|
8131
8227
|
};
|
|
8132
8228
|
|
|
8133
|
-
var METHOD_NAME$
|
|
8229
|
+
var METHOD_NAME$z = "function.addEmbedding";
|
|
8134
8230
|
/**
|
|
8135
8231
|
* Adds a new embedding to the embedding registry. The swarm takes only those embeddings which was registered
|
|
8136
8232
|
*
|
|
@@ -8139,7 +8235,7 @@ var METHOD_NAME$x = "function.addEmbedding";
|
|
|
8139
8235
|
*/
|
|
8140
8236
|
var addEmbedding = function (embeddingSchema) {
|
|
8141
8237
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8142
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
8238
|
+
swarm$1.loggerService.log(METHOD_NAME$z, {
|
|
8143
8239
|
embeddingSchema: embeddingSchema,
|
|
8144
8240
|
});
|
|
8145
8241
|
swarm$1.embeddingValidationService.addEmbedding(embeddingSchema.embeddingName, embeddingSchema);
|
|
@@ -8147,7 +8243,7 @@ var addEmbedding = function (embeddingSchema) {
|
|
|
8147
8243
|
return embeddingSchema.embeddingName;
|
|
8148
8244
|
};
|
|
8149
8245
|
|
|
8150
|
-
var METHOD_NAME$
|
|
8246
|
+
var METHOD_NAME$y = "function.addStorage";
|
|
8151
8247
|
/**
|
|
8152
8248
|
* Adds a new storage to the storage registry. The swarm takes only those storages which was registered
|
|
8153
8249
|
*
|
|
@@ -8156,7 +8252,7 @@ var METHOD_NAME$w = "function.addStorage";
|
|
|
8156
8252
|
*/
|
|
8157
8253
|
var addStorage = function (storageSchema) {
|
|
8158
8254
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8159
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
8255
|
+
swarm$1.loggerService.log(METHOD_NAME$y, {
|
|
8160
8256
|
storageSchema: storageSchema,
|
|
8161
8257
|
});
|
|
8162
8258
|
swarm$1.storageValidationService.addStorage(storageSchema.storageName, storageSchema);
|
|
@@ -8169,7 +8265,7 @@ var addStorage = function (storageSchema) {
|
|
|
8169
8265
|
return storageSchema.storageName;
|
|
8170
8266
|
};
|
|
8171
8267
|
|
|
8172
|
-
var METHOD_NAME$
|
|
8268
|
+
var METHOD_NAME$x = "function.commitSystemMessage";
|
|
8173
8269
|
/**
|
|
8174
8270
|
* Commits a user message to the active agent history in as swarm without answer.
|
|
8175
8271
|
*
|
|
@@ -8184,16 +8280,16 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
|
|
|
8184
8280
|
switch (_a.label) {
|
|
8185
8281
|
case 0:
|
|
8186
8282
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8187
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
8283
|
+
swarm$1.loggerService.log(METHOD_NAME$x, {
|
|
8188
8284
|
content: content,
|
|
8189
8285
|
clientId: clientId,
|
|
8190
8286
|
agentName: agentName,
|
|
8191
8287
|
});
|
|
8192
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
8193
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
8288
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$x);
|
|
8289
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$x);
|
|
8194
8290
|
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8195
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
8196
|
-
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
8291
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$x);
|
|
8292
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$x, clientId, swarmName)];
|
|
8197
8293
|
case 1:
|
|
8198
8294
|
currentAgentName = _a.sent();
|
|
8199
8295
|
if (currentAgentName !== agentName) {
|
|
@@ -8205,7 +8301,7 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
|
|
|
8205
8301
|
});
|
|
8206
8302
|
return [2 /*return*/];
|
|
8207
8303
|
}
|
|
8208
|
-
return [4 /*yield*/, swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$
|
|
8304
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$x, clientId, swarmName)];
|
|
8209
8305
|
case 2:
|
|
8210
8306
|
_a.sent();
|
|
8211
8307
|
return [2 /*return*/];
|
|
@@ -8213,7 +8309,7 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
|
|
|
8213
8309
|
});
|
|
8214
8310
|
}); };
|
|
8215
8311
|
|
|
8216
|
-
var METHOD_NAME$
|
|
8312
|
+
var METHOD_NAME$w = "function.getAgentName";
|
|
8217
8313
|
/**
|
|
8218
8314
|
* Retrieves the agent name for a given client ID.
|
|
8219
8315
|
*
|
|
@@ -8227,20 +8323,20 @@ var getAgentName = function (clientId) { return __awaiter(void 0, void 0, void 0
|
|
|
8227
8323
|
switch (_a.label) {
|
|
8228
8324
|
case 0:
|
|
8229
8325
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8230
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
8326
|
+
swarm$1.loggerService.log(METHOD_NAME$w, {
|
|
8231
8327
|
clientId: clientId,
|
|
8232
8328
|
});
|
|
8233
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
8329
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$w);
|
|
8234
8330
|
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8235
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
8236
|
-
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
8331
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$w);
|
|
8332
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$w, clientId, swarmName)];
|
|
8237
8333
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8238
8334
|
}
|
|
8239
8335
|
});
|
|
8240
8336
|
}); };
|
|
8241
8337
|
|
|
8242
8338
|
var SCHEDULED_DELAY$1 = 1000;
|
|
8243
|
-
var METHOD_NAME$
|
|
8339
|
+
var METHOD_NAME$v = "function.makeConnection";
|
|
8244
8340
|
/**
|
|
8245
8341
|
* A connection factory for a client to a swarm and returns a function to send messages.
|
|
8246
8342
|
*
|
|
@@ -8251,25 +8347,25 @@ var METHOD_NAME$t = "function.makeConnection";
|
|
|
8251
8347
|
*/
|
|
8252
8348
|
var makeConnection = function (connector, clientId, swarmName) {
|
|
8253
8349
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8254
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
8350
|
+
swarm$1.loggerService.log(METHOD_NAME$v, {
|
|
8255
8351
|
clientId: clientId,
|
|
8256
8352
|
swarmName: swarmName,
|
|
8257
8353
|
});
|
|
8258
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
8354
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$v);
|
|
8259
8355
|
swarm$1.sessionValidationService.addSession(clientId, swarmName, "makeConnection");
|
|
8260
|
-
var send = swarm$1.sessionPublicService.connect(connector, METHOD_NAME$
|
|
8356
|
+
var send = swarm$1.sessionPublicService.connect(connector, METHOD_NAME$v, clientId, swarmName);
|
|
8261
8357
|
return functoolsKit.queued(function (outgoing) { return __awaiter(void 0, void 0, void 0, function () {
|
|
8262
8358
|
var _a;
|
|
8263
8359
|
var _b;
|
|
8264
8360
|
return __generator(this, function (_c) {
|
|
8265
8361
|
switch (_c.label) {
|
|
8266
8362
|
case 0:
|
|
8267
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
8363
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$v);
|
|
8268
8364
|
_a = send;
|
|
8269
8365
|
_b = {
|
|
8270
8366
|
data: outgoing
|
|
8271
8367
|
};
|
|
8272
|
-
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
8368
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$v, clientId, swarmName)];
|
|
8273
8369
|
case 1: return [4 /*yield*/, _a.apply(void 0, [(_b.agentName = _c.sent(),
|
|
8274
8370
|
_b.clientId = clientId,
|
|
8275
8371
|
_b)])];
|
|
@@ -8355,26 +8451,26 @@ makeConnection.scheduled = function (connector, clientId, swarmName, _a) {
|
|
|
8355
8451
|
}); };
|
|
8356
8452
|
};
|
|
8357
8453
|
|
|
8358
|
-
var METHOD_NAME$
|
|
8454
|
+
var METHOD_NAME$u = "function.changeToAgent";
|
|
8359
8455
|
/**
|
|
8360
8456
|
* Time-to-live for the change agent function in milliseconds.
|
|
8361
8457
|
* @constant {number}
|
|
8362
8458
|
*/
|
|
8363
|
-
var CHANGE_AGENT_TTL = 15 * 60 * 1000;
|
|
8459
|
+
var CHANGE_AGENT_TTL$2 = 15 * 60 * 1000;
|
|
8364
8460
|
/**
|
|
8365
8461
|
* Garbage collection interval for the change agent function in milliseconds.
|
|
8366
8462
|
* @constant {number}
|
|
8367
8463
|
*/
|
|
8368
|
-
var CHANGE_AGENT_GC = 60 * 1000;
|
|
8464
|
+
var CHANGE_AGENT_GC$2 = 60 * 1000;
|
|
8369
8465
|
/**
|
|
8370
8466
|
* Creates a change agent function with TTL and queuing.
|
|
8371
8467
|
* @function
|
|
8372
8468
|
* @param {string} clientId - The client ID.
|
|
8373
|
-
* @returns {
|
|
8469
|
+
* @returns {TChangeToAgentRun} - The change agent function.
|
|
8374
8470
|
*/
|
|
8375
|
-
var
|
|
8471
|
+
var createChangeToAgent = functoolsKit.ttl(function (clientId) {
|
|
8376
8472
|
return functoolsKit.queued(function (methodName, agentName, swarmName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
8377
|
-
var _a, _b, _c;
|
|
8473
|
+
var agentName_1, _a, _b, _c;
|
|
8378
8474
|
return __generator(this, function (_d) {
|
|
8379
8475
|
switch (_d.label) {
|
|
8380
8476
|
case 0: return [4 /*yield*/, Promise.all(swarm$1.swarmValidationService
|
|
@@ -8391,23 +8487,26 @@ var createChangeAgent = functoolsKit.ttl(function (clientId) {
|
|
|
8391
8487
|
}); }))];
|
|
8392
8488
|
case 1:
|
|
8393
8489
|
_d.sent();
|
|
8394
|
-
return [4 /*yield*/, swarm$1.
|
|
8490
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$u, clientId, swarmName)];
|
|
8395
8491
|
case 2:
|
|
8396
|
-
_d.sent();
|
|
8397
|
-
return [4 /*yield*/, swarm$1.
|
|
8492
|
+
agentName_1 = _d.sent();
|
|
8493
|
+
return [4 /*yield*/, swarm$1.agentPublicService.dispose(methodName, clientId, agentName_1)];
|
|
8398
8494
|
case 3:
|
|
8495
|
+
_d.sent();
|
|
8496
|
+
return [4 /*yield*/, swarm$1.historyPublicService.dispose(methodName, clientId, agentName_1)];
|
|
8497
|
+
case 4:
|
|
8399
8498
|
_d.sent();
|
|
8400
8499
|
_b = (_a = swarm$1.swarmPublicService).setAgentRef;
|
|
8401
8500
|
_c = [methodName,
|
|
8402
8501
|
clientId,
|
|
8403
8502
|
swarmName,
|
|
8404
|
-
|
|
8405
|
-
return [4 /*yield*/, swarm$1.agentPublicService.createAgentRef(methodName, clientId,
|
|
8406
|
-
case
|
|
8407
|
-
case
|
|
8503
|
+
agentName_1];
|
|
8504
|
+
return [4 /*yield*/, swarm$1.agentPublicService.createAgentRef(methodName, clientId, agentName_1)];
|
|
8505
|
+
case 5: return [4 /*yield*/, _b.apply(_a, _c.concat([_d.sent()]))];
|
|
8506
|
+
case 6:
|
|
8408
8507
|
_d.sent();
|
|
8409
8508
|
return [4 /*yield*/, swarm$1.swarmPublicService.setAgentName(agentName, methodName, clientId, swarmName)];
|
|
8410
|
-
case
|
|
8509
|
+
case 7:
|
|
8411
8510
|
_d.sent();
|
|
8412
8511
|
return [2 /*return*/];
|
|
8413
8512
|
}
|
|
@@ -8418,16 +8517,16 @@ var createChangeAgent = functoolsKit.ttl(function (clientId) {
|
|
|
8418
8517
|
var _b = __read(_a, 1), clientId = _b[0];
|
|
8419
8518
|
return "".concat(clientId);
|
|
8420
8519
|
},
|
|
8421
|
-
timeout: CHANGE_AGENT_TTL,
|
|
8520
|
+
timeout: CHANGE_AGENT_TTL$2,
|
|
8422
8521
|
});
|
|
8423
8522
|
/**
|
|
8424
8523
|
* Creates a garbage collector for the change agent function.
|
|
8425
8524
|
* @function
|
|
8426
8525
|
* @returns {Promise<void>} - A promise that resolves when the garbage collector is created.
|
|
8427
8526
|
*/
|
|
8428
|
-
var createGc$
|
|
8527
|
+
var createGc$3 = functoolsKit.singleshot(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
8429
8528
|
return __generator(this, function (_a) {
|
|
8430
|
-
setInterval(
|
|
8529
|
+
setInterval(createChangeToAgent.gc, CHANGE_AGENT_GC$2);
|
|
8431
8530
|
return [2 /*return*/];
|
|
8432
8531
|
});
|
|
8433
8532
|
}); });
|
|
@@ -8439,31 +8538,255 @@ var createGc$1 = functoolsKit.singleshot(function () { return __awaiter(void 0,
|
|
|
8439
8538
|
* @param {string} clientId - The client ID.
|
|
8440
8539
|
* @returns {Promise<void>} - A promise that resolves when the agent is changed.
|
|
8441
8540
|
*/
|
|
8442
|
-
var
|
|
8541
|
+
var changeToAgent = function (agentName, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
8443
8542
|
var swarmName, activeAgent, run;
|
|
8444
8543
|
return __generator(this, function (_a) {
|
|
8445
8544
|
switch (_a.label) {
|
|
8446
8545
|
case 0:
|
|
8447
8546
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8448
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
8547
|
+
swarm$1.loggerService.log(METHOD_NAME$u, {
|
|
8449
8548
|
agentName: agentName,
|
|
8450
8549
|
clientId: clientId,
|
|
8451
8550
|
});
|
|
8452
8551
|
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8453
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
8454
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
8455
|
-
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
8552
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$u);
|
|
8553
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$u);
|
|
8554
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$u, clientId, swarmName)];
|
|
8456
8555
|
case 1:
|
|
8457
8556
|
activeAgent = _a.sent();
|
|
8458
8557
|
if (!swarm$1.agentValidationService.hasDependency(activeAgent, agentName)) {
|
|
8459
8558
|
console.error("agent-swarm missing dependency detected for activeAgent=".concat(activeAgent, " dependencyAgent=").concat(agentName));
|
|
8460
8559
|
}
|
|
8461
|
-
return [4 /*yield*/,
|
|
8560
|
+
return [4 /*yield*/, createChangeToAgent(clientId)];
|
|
8561
|
+
case 2:
|
|
8562
|
+
run = _a.sent();
|
|
8563
|
+
createGc$3();
|
|
8564
|
+
return [4 /*yield*/, run(METHOD_NAME$u, agentName, swarmName)];
|
|
8565
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
8566
|
+
}
|
|
8567
|
+
});
|
|
8568
|
+
}); };
|
|
8569
|
+
|
|
8570
|
+
var METHOD_NAME$t = "function.changeToPrevAgent";
|
|
8571
|
+
/**
|
|
8572
|
+
* Time-to-live for the change agent function in milliseconds.
|
|
8573
|
+
* @constant {number}
|
|
8574
|
+
*/
|
|
8575
|
+
var CHANGE_AGENT_TTL$1 = 15 * 60 * 1000;
|
|
8576
|
+
/**
|
|
8577
|
+
* Garbage collection interval for the change agent function in milliseconds.
|
|
8578
|
+
* @constant {number}
|
|
8579
|
+
*/
|
|
8580
|
+
var CHANGE_AGENT_GC$1 = 60 * 1000;
|
|
8581
|
+
/**
|
|
8582
|
+
* Creates a change agent function with TTL and queuing.
|
|
8583
|
+
* @function
|
|
8584
|
+
* @param {string} clientId - The client ID.
|
|
8585
|
+
* @returns {TChangeToPrevAgentRun} - The change agent function.
|
|
8586
|
+
*/
|
|
8587
|
+
var createChangeToPrevAgent = functoolsKit.ttl(function (clientId) {
|
|
8588
|
+
return functoolsKit.queued(function (methodName, agentName, swarmName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
8589
|
+
var agentName_1, _a, _b, _c;
|
|
8590
|
+
return __generator(this, function (_d) {
|
|
8591
|
+
switch (_d.label) {
|
|
8592
|
+
case 0: return [4 /*yield*/, Promise.all(swarm$1.swarmValidationService
|
|
8593
|
+
.getAgentList(swarmName)
|
|
8594
|
+
.map(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
8595
|
+
return __generator(this, function (_a) {
|
|
8596
|
+
switch (_a.label) {
|
|
8597
|
+
case 0: return [4 /*yield*/, swarm$1.agentPublicService.commitAgentChange(methodName, clientId, agentName)];
|
|
8598
|
+
case 1:
|
|
8599
|
+
_a.sent();
|
|
8600
|
+
return [2 /*return*/];
|
|
8601
|
+
}
|
|
8602
|
+
});
|
|
8603
|
+
}); }))];
|
|
8604
|
+
case 1:
|
|
8605
|
+
_d.sent();
|
|
8606
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$t, clientId, swarmName)];
|
|
8607
|
+
case 2:
|
|
8608
|
+
agentName_1 = _d.sent();
|
|
8609
|
+
return [4 /*yield*/, swarm$1.agentPublicService.dispose(methodName, clientId, agentName_1)];
|
|
8610
|
+
case 3:
|
|
8611
|
+
_d.sent();
|
|
8612
|
+
return [4 /*yield*/, swarm$1.historyPublicService.dispose(methodName, clientId, agentName_1)];
|
|
8613
|
+
case 4:
|
|
8614
|
+
_d.sent();
|
|
8615
|
+
_b = (_a = swarm$1.swarmPublicService).setAgentRef;
|
|
8616
|
+
_c = [methodName,
|
|
8617
|
+
clientId,
|
|
8618
|
+
swarmName,
|
|
8619
|
+
agentName_1];
|
|
8620
|
+
return [4 /*yield*/, swarm$1.agentPublicService.createAgentRef(methodName, clientId, agentName_1)];
|
|
8621
|
+
case 5: return [4 /*yield*/, _b.apply(_a, _c.concat([_d.sent()]))];
|
|
8622
|
+
case 6:
|
|
8623
|
+
_d.sent();
|
|
8624
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.setAgentName(agentName, methodName, clientId, swarmName)];
|
|
8625
|
+
case 7:
|
|
8626
|
+
_d.sent();
|
|
8627
|
+
return [2 /*return*/];
|
|
8628
|
+
}
|
|
8629
|
+
});
|
|
8630
|
+
}); });
|
|
8631
|
+
}, {
|
|
8632
|
+
key: function (_a) {
|
|
8633
|
+
var _b = __read(_a, 1), clientId = _b[0];
|
|
8634
|
+
return "".concat(clientId);
|
|
8635
|
+
},
|
|
8636
|
+
timeout: CHANGE_AGENT_TTL$1,
|
|
8637
|
+
});
|
|
8638
|
+
/**
|
|
8639
|
+
* Creates a garbage collector for the change agent function.
|
|
8640
|
+
* @function
|
|
8641
|
+
* @returns {Promise<void>} - A promise that resolves when the garbage collector is created.
|
|
8642
|
+
*/
|
|
8643
|
+
var createGc$2 = functoolsKit.singleshot(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
8644
|
+
return __generator(this, function (_a) {
|
|
8645
|
+
setInterval(createChangeToPrevAgent.gc, CHANGE_AGENT_GC$1);
|
|
8646
|
+
return [2 /*return*/];
|
|
8647
|
+
});
|
|
8648
|
+
}); });
|
|
8649
|
+
/**
|
|
8650
|
+
* Navigates back to the previous or default agent
|
|
8651
|
+
* @async
|
|
8652
|
+
* @function
|
|
8653
|
+
* @param {string} clientId - The client ID.
|
|
8654
|
+
* @returns {Promise<void>} - A promise that resolves when the agent is changed.
|
|
8655
|
+
*/
|
|
8656
|
+
var changeToPrevAgent = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
8657
|
+
var swarmName, agentName, run;
|
|
8658
|
+
return __generator(this, function (_a) {
|
|
8659
|
+
switch (_a.label) {
|
|
8660
|
+
case 0:
|
|
8661
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8662
|
+
swarm$1.loggerService.log(METHOD_NAME$t, {
|
|
8663
|
+
clientId: clientId,
|
|
8664
|
+
});
|
|
8665
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8666
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.navigationPop(METHOD_NAME$t, clientId, swarmName)];
|
|
8667
|
+
case 1:
|
|
8668
|
+
agentName = _a.sent();
|
|
8669
|
+
{
|
|
8670
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$t);
|
|
8671
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$t);
|
|
8672
|
+
}
|
|
8673
|
+
return [4 /*yield*/, createChangeToPrevAgent(clientId)];
|
|
8462
8674
|
case 2:
|
|
8675
|
+
run = _a.sent();
|
|
8676
|
+
createGc$2();
|
|
8677
|
+
return [4 /*yield*/, run(METHOD_NAME$t, agentName, swarmName)];
|
|
8678
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
8679
|
+
}
|
|
8680
|
+
});
|
|
8681
|
+
}); };
|
|
8682
|
+
|
|
8683
|
+
var METHOD_NAME$s = "function.changeToDefaultAgent";
|
|
8684
|
+
/**
|
|
8685
|
+
* Time-to-live for the change agent function in milliseconds.
|
|
8686
|
+
* @constant {number}
|
|
8687
|
+
*/
|
|
8688
|
+
var CHANGE_AGENT_TTL = 15 * 60 * 1000;
|
|
8689
|
+
/**
|
|
8690
|
+
* Garbage collection interval for the change agent function in milliseconds.
|
|
8691
|
+
* @constant {number}
|
|
8692
|
+
*/
|
|
8693
|
+
var CHANGE_AGENT_GC = 60 * 1000;
|
|
8694
|
+
/**
|
|
8695
|
+
* Creates a change agent function with TTL and queuing.
|
|
8696
|
+
* @function
|
|
8697
|
+
* @param {string} clientId - The client ID.
|
|
8698
|
+
* @returns {TChangeToDefaultAgentRun} - The change agent function.
|
|
8699
|
+
*/
|
|
8700
|
+
var createChangeToDefaultAgent = functoolsKit.ttl(function (clientId) {
|
|
8701
|
+
return functoolsKit.queued(function (methodName, agentName, swarmName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
8702
|
+
var agentName_1, _a, _b, _c;
|
|
8703
|
+
return __generator(this, function (_d) {
|
|
8704
|
+
switch (_d.label) {
|
|
8705
|
+
case 0: return [4 /*yield*/, Promise.all(swarm$1.swarmValidationService
|
|
8706
|
+
.getAgentList(swarmName)
|
|
8707
|
+
.map(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
8708
|
+
return __generator(this, function (_a) {
|
|
8709
|
+
switch (_a.label) {
|
|
8710
|
+
case 0: return [4 /*yield*/, swarm$1.agentPublicService.commitAgentChange(methodName, clientId, agentName)];
|
|
8711
|
+
case 1:
|
|
8712
|
+
_a.sent();
|
|
8713
|
+
return [2 /*return*/];
|
|
8714
|
+
}
|
|
8715
|
+
});
|
|
8716
|
+
}); }))];
|
|
8717
|
+
case 1:
|
|
8718
|
+
_d.sent();
|
|
8719
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$s, clientId, swarmName)];
|
|
8720
|
+
case 2:
|
|
8721
|
+
agentName_1 = _d.sent();
|
|
8722
|
+
return [4 /*yield*/, swarm$1.agentPublicService.dispose(methodName, clientId, agentName_1)];
|
|
8723
|
+
case 3:
|
|
8724
|
+
_d.sent();
|
|
8725
|
+
return [4 /*yield*/, swarm$1.historyPublicService.dispose(methodName, clientId, agentName_1)];
|
|
8726
|
+
case 4:
|
|
8727
|
+
_d.sent();
|
|
8728
|
+
_b = (_a = swarm$1.swarmPublicService).setAgentRef;
|
|
8729
|
+
_c = [methodName,
|
|
8730
|
+
clientId,
|
|
8731
|
+
swarmName,
|
|
8732
|
+
agentName_1];
|
|
8733
|
+
return [4 /*yield*/, swarm$1.agentPublicService.createAgentRef(methodName, clientId, agentName_1)];
|
|
8734
|
+
case 5: return [4 /*yield*/, _b.apply(_a, _c.concat([_d.sent()]))];
|
|
8735
|
+
case 6:
|
|
8736
|
+
_d.sent();
|
|
8737
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.setAgentName(agentName, methodName, clientId, swarmName)];
|
|
8738
|
+
case 7:
|
|
8739
|
+
_d.sent();
|
|
8740
|
+
return [2 /*return*/];
|
|
8741
|
+
}
|
|
8742
|
+
});
|
|
8743
|
+
}); });
|
|
8744
|
+
}, {
|
|
8745
|
+
key: function (_a) {
|
|
8746
|
+
var _b = __read(_a, 1), clientId = _b[0];
|
|
8747
|
+
return "".concat(clientId);
|
|
8748
|
+
},
|
|
8749
|
+
timeout: CHANGE_AGENT_TTL,
|
|
8750
|
+
});
|
|
8751
|
+
/**
|
|
8752
|
+
* Creates a garbage collector for the change agent function.
|
|
8753
|
+
* @function
|
|
8754
|
+
* @returns {Promise<void>} - A promise that resolves when the garbage collector is created.
|
|
8755
|
+
*/
|
|
8756
|
+
var createGc$1 = functoolsKit.singleshot(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
8757
|
+
return __generator(this, function (_a) {
|
|
8758
|
+
setInterval(createChangeToDefaultAgent.gc, CHANGE_AGENT_GC);
|
|
8759
|
+
return [2 /*return*/];
|
|
8760
|
+
});
|
|
8761
|
+
}); });
|
|
8762
|
+
/**
|
|
8763
|
+
* Navigates back to the default agent
|
|
8764
|
+
* @async
|
|
8765
|
+
* @function
|
|
8766
|
+
* @param {string} clientId - The client ID.
|
|
8767
|
+
* @returns {Promise<void>} - A promise that resolves when the agent is changed.
|
|
8768
|
+
*/
|
|
8769
|
+
var changeToDefaultAgent = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
8770
|
+
var swarmName, agentName, run;
|
|
8771
|
+
return __generator(this, function (_a) {
|
|
8772
|
+
switch (_a.label) {
|
|
8773
|
+
case 0:
|
|
8774
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8775
|
+
swarm$1.loggerService.log(METHOD_NAME$s, {
|
|
8776
|
+
clientId: clientId,
|
|
8777
|
+
});
|
|
8778
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8779
|
+
agentName = swarm$1.swarmSchemaService.get(swarmName).defaultAgent;
|
|
8780
|
+
{
|
|
8781
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$s);
|
|
8782
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$s);
|
|
8783
|
+
}
|
|
8784
|
+
return [4 /*yield*/, createChangeToDefaultAgent(clientId)];
|
|
8785
|
+
case 1:
|
|
8463
8786
|
run = _a.sent();
|
|
8464
8787
|
createGc$1();
|
|
8465
8788
|
return [4 /*yield*/, run(METHOD_NAME$s, agentName, swarmName)];
|
|
8466
|
-
case
|
|
8789
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
8467
8790
|
}
|
|
8468
8791
|
});
|
|
8469
8792
|
}); };
|
|
@@ -10316,7 +10639,9 @@ exports.addSwarm = addSwarm;
|
|
|
10316
10639
|
exports.addTool = addTool;
|
|
10317
10640
|
exports.cancelOutput = cancelOutput;
|
|
10318
10641
|
exports.cancelOutputForce = cancelOutputForce;
|
|
10319
|
-
exports.
|
|
10642
|
+
exports.changeToAgent = changeToAgent;
|
|
10643
|
+
exports.changeToDefaultAgent = changeToDefaultAgent;
|
|
10644
|
+
exports.changeToPrevAgent = changeToPrevAgent;
|
|
10320
10645
|
exports.commitFlush = commitFlush;
|
|
10321
10646
|
exports.commitFlushForce = commitFlushForce;
|
|
10322
10647
|
exports.commitSystemMessage = commitSystemMessage;
|