agent-swarm-kit 1.0.111 → 1.0.113
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 +579 -127
- package/build/index.mjs +578 -128
- package/package.json +1 -1
- package/types.d.ts +131 -1
package/build/index.cjs
CHANGED
|
@@ -1671,6 +1671,7 @@ var AgentSchemaService = /** @class */ (function () {
|
|
|
1671
1671
|
|
|
1672
1672
|
var AGENT_CHANGE_SYMBOL = Symbol("agent-change");
|
|
1673
1673
|
var TOOL_ERROR_SYMBOL = Symbol("tool-error");
|
|
1674
|
+
var TOOL_STOP_SYMBOL = Symbol("tool-stop");
|
|
1674
1675
|
var getPlaceholder = function () {
|
|
1675
1676
|
return GLOBAL_CONFIG.CC_EMPTY_OUTPUT_PLACEHOLDERS[Math.floor(Math.random() * GLOBAL_CONFIG.CC_EMPTY_OUTPUT_PLACEHOLDERS.length)];
|
|
1676
1677
|
};
|
|
@@ -1688,6 +1689,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1688
1689
|
this.params = params;
|
|
1689
1690
|
this._agentChangeSubject = new functoolsKit.Subject();
|
|
1690
1691
|
this._toolErrorSubject = new functoolsKit.Subject();
|
|
1692
|
+
this._toolStopSubject = new functoolsKit.Subject();
|
|
1691
1693
|
this._toolCommitSubject = new functoolsKit.Subject();
|
|
1692
1694
|
this._outputSubject = new functoolsKit.Subject();
|
|
1693
1695
|
/**
|
|
@@ -1987,6 +1989,35 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1987
1989
|
}
|
|
1988
1990
|
});
|
|
1989
1991
|
}); };
|
|
1992
|
+
/**
|
|
1993
|
+
* Commits change of agent to prevent the next tool execution from being called.
|
|
1994
|
+
* @returns {Promise<void>}
|
|
1995
|
+
*/
|
|
1996
|
+
this.commitStopTools = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1997
|
+
return __generator(this, function (_a) {
|
|
1998
|
+
switch (_a.label) {
|
|
1999
|
+
case 0:
|
|
2000
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2001
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " commitStopTools"));
|
|
2002
|
+
return [4 /*yield*/, this._toolStopSubject.next(TOOL_STOP_SYMBOL)];
|
|
2003
|
+
case 1:
|
|
2004
|
+
_a.sent();
|
|
2005
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2006
|
+
type: "commit-stop-tools",
|
|
2007
|
+
source: "agent-bus",
|
|
2008
|
+
input: {},
|
|
2009
|
+
output: {},
|
|
2010
|
+
context: {
|
|
2011
|
+
agentName: this.params.agentName,
|
|
2012
|
+
},
|
|
2013
|
+
clientId: this.params.clientId,
|
|
2014
|
+
})];
|
|
2015
|
+
case 2:
|
|
2016
|
+
_a.sent();
|
|
2017
|
+
return [2 /*return*/];
|
|
2018
|
+
}
|
|
2019
|
+
});
|
|
2020
|
+
}); };
|
|
1990
2021
|
/**
|
|
1991
2022
|
* Commits a system message to the history.
|
|
1992
2023
|
* @param {string} message - The system message to commit.
|
|
@@ -2117,9 +2148,9 @@ var ClientAgent = /** @class */ (function () {
|
|
|
2117
2148
|
this.execute = functoolsKit.queued(function (incoming, mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
2118
2149
|
var rawMessage, message, toolCalls, _loop_1, this_1, idx, state_1, result, validation, result1;
|
|
2119
2150
|
var _this = this;
|
|
2120
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2121
|
-
return __generator(this, function (
|
|
2122
|
-
switch (
|
|
2151
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2152
|
+
return __generator(this, function (_j) {
|
|
2153
|
+
switch (_j.label) {
|
|
2123
2154
|
case 0:
|
|
2124
2155
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2125
2156
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute begin"), { incoming: incoming, mode: mode });
|
|
@@ -2132,13 +2163,13 @@ var ClientAgent = /** @class */ (function () {
|
|
|
2132
2163
|
content: incoming.trim(),
|
|
2133
2164
|
})];
|
|
2134
2165
|
case 1:
|
|
2135
|
-
|
|
2166
|
+
_j.sent();
|
|
2136
2167
|
return [4 /*yield*/, this.getCompletion(mode)];
|
|
2137
2168
|
case 2:
|
|
2138
|
-
rawMessage =
|
|
2169
|
+
rawMessage = _j.sent();
|
|
2139
2170
|
return [4 /*yield*/, this.params.map(rawMessage, this.params.clientId, this.params.agentName)];
|
|
2140
2171
|
case 3:
|
|
2141
|
-
message =
|
|
2172
|
+
message = _j.sent();
|
|
2142
2173
|
if (!message.tool_calls) return [3 /*break*/, 9];
|
|
2143
2174
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2144
2175
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " tool call begin"));
|
|
@@ -2152,11 +2183,11 @@ var ClientAgent = /** @class */ (function () {
|
|
|
2152
2183
|
});
|
|
2153
2184
|
return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
|
|
2154
2185
|
case 4:
|
|
2155
|
-
|
|
2186
|
+
_j.sent();
|
|
2156
2187
|
_loop_1 = function (idx) {
|
|
2157
2188
|
var tool, targetFn, result_2, result_3, status, result_4;
|
|
2158
|
-
return __generator(this, function (
|
|
2159
|
-
switch (
|
|
2189
|
+
return __generator(this, function (_k) {
|
|
2190
|
+
switch (_k.label) {
|
|
2160
2191
|
case 0:
|
|
2161
2192
|
tool = toolCalls[idx];
|
|
2162
2193
|
targetFn = (_a = this_1.params.tools) === null || _a === void 0 ? void 0 : _a.find(function (t) { return t.function.name === tool.function.name; });
|
|
@@ -2165,12 +2196,12 @@ var ClientAgent = /** @class */ (function () {
|
|
|
2165
2196
|
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);
|
|
2166
2197
|
return [4 /*yield*/, this_1._resurrectModel(mode, "No target function for ".concat(tool.function.name))];
|
|
2167
2198
|
case 1:
|
|
2168
|
-
result_2 =
|
|
2199
|
+
result_2 = _k.sent();
|
|
2169
2200
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2170
2201
|
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_2));
|
|
2171
2202
|
return [4 /*yield*/, this_1._emitOuput(mode, result_2)];
|
|
2172
2203
|
case 2:
|
|
2173
|
-
|
|
2204
|
+
_k.sent();
|
|
2174
2205
|
return [2 /*return*/, { value: void 0 }];
|
|
2175
2206
|
case 3:
|
|
2176
2207
|
((_b = targetFn.callbacks) === null || _b === void 0 ? void 0 : _b.onValidate) &&
|
|
@@ -2182,17 +2213,17 @@ var ClientAgent = /** @class */ (function () {
|
|
|
2182
2213
|
toolCalls: toolCalls,
|
|
2183
2214
|
}))];
|
|
2184
2215
|
case 4:
|
|
2185
|
-
if (!
|
|
2216
|
+
if (!_k.sent()) return [3 /*break*/, 7];
|
|
2186
2217
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2187
2218
|
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"));
|
|
2188
2219
|
return [4 /*yield*/, this_1._resurrectModel(mode, "Function validation failed: name=".concat(tool.function.name, " arguments=").concat(JSON.stringify(tool.function.arguments)))];
|
|
2189
2220
|
case 5:
|
|
2190
|
-
result_3 =
|
|
2221
|
+
result_3 = _k.sent();
|
|
2191
2222
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2192
2223
|
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_3));
|
|
2193
2224
|
return [4 /*yield*/, this_1._emitOuput(mode, result_3)];
|
|
2194
2225
|
case 6:
|
|
2195
|
-
|
|
2226
|
+
_k.sent();
|
|
2196
2227
|
return [2 /*return*/, { value: void 0 }];
|
|
2197
2228
|
case 7:
|
|
2198
2229
|
((_d = targetFn.callbacks) === null || _d === void 0 ? void 0 : _d.onBeforeCall) &&
|
|
@@ -2232,10 +2263,11 @@ var ClientAgent = /** @class */ (function () {
|
|
|
2232
2263
|
this_1._agentChangeSubject.toPromise(),
|
|
2233
2264
|
this_1._toolCommitSubject.toPromise(),
|
|
2234
2265
|
this_1._toolErrorSubject.toPromise(),
|
|
2266
|
+
this_1._toolStopSubject.toPromise(),
|
|
2235
2267
|
this_1._outputSubject.toPromise(),
|
|
2236
2268
|
])];
|
|
2237
2269
|
case 8:
|
|
2238
|
-
status =
|
|
2270
|
+
status = _k.sent();
|
|
2239
2271
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2240
2272
|
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"));
|
|
2241
2273
|
if (status === AGENT_CHANGE_SYMBOL) {
|
|
@@ -2245,17 +2277,24 @@ var ClientAgent = /** @class */ (function () {
|
|
|
2245
2277
|
this_1.params.callbacks.onAfterToolCalls(this_1.params.clientId, this_1.params.agentName, toolCalls);
|
|
2246
2278
|
return [2 /*return*/, { value: void 0 }];
|
|
2247
2279
|
}
|
|
2280
|
+
if (status === TOOL_STOP_SYMBOL) {
|
|
2281
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2282
|
+
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 commitStopTools call"));
|
|
2283
|
+
((_g = this_1.params.callbacks) === null || _g === void 0 ? void 0 : _g.onAfterToolCalls) &&
|
|
2284
|
+
this_1.params.callbacks.onAfterToolCalls(this_1.params.clientId, this_1.params.agentName, toolCalls);
|
|
2285
|
+
return [2 /*return*/, { value: void 0 }];
|
|
2286
|
+
}
|
|
2248
2287
|
if (!(status === TOOL_ERROR_SYMBOL)) return [3 /*break*/, 11];
|
|
2249
2288
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2250
2289
|
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 call error"));
|
|
2251
2290
|
return [4 /*yield*/, this_1._resurrectModel(mode, "Function call failed with error: name=".concat(tool.function.name, " arguments=").concat(JSON.stringify(tool.function.arguments)))];
|
|
2252
2291
|
case 9:
|
|
2253
|
-
result_4 =
|
|
2292
|
+
result_4 = _k.sent();
|
|
2254
2293
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2255
2294
|
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_4));
|
|
2256
2295
|
return [4 /*yield*/, this_1._emitOuput(mode, result_4)];
|
|
2257
2296
|
case 10:
|
|
2258
|
-
|
|
2297
|
+
_k.sent();
|
|
2259
2298
|
return [2 /*return*/, { value: void 0 }];
|
|
2260
2299
|
case 11: return [2 /*return*/];
|
|
2261
2300
|
}
|
|
@@ -2263,20 +2302,20 @@ var ClientAgent = /** @class */ (function () {
|
|
|
2263
2302
|
};
|
|
2264
2303
|
this_1 = this;
|
|
2265
2304
|
idx = 0;
|
|
2266
|
-
|
|
2305
|
+
_j.label = 5;
|
|
2267
2306
|
case 5:
|
|
2268
2307
|
if (!(idx !== toolCalls.length)) return [3 /*break*/, 8];
|
|
2269
2308
|
return [5 /*yield**/, _loop_1(idx)];
|
|
2270
2309
|
case 6:
|
|
2271
|
-
state_1 =
|
|
2310
|
+
state_1 = _j.sent();
|
|
2272
2311
|
if (typeof state_1 === "object")
|
|
2273
2312
|
return [2 /*return*/, state_1.value];
|
|
2274
|
-
|
|
2313
|
+
_j.label = 7;
|
|
2275
2314
|
case 7:
|
|
2276
2315
|
idx++;
|
|
2277
2316
|
return [3 /*break*/, 5];
|
|
2278
2317
|
case 8:
|
|
2279
|
-
((
|
|
2318
|
+
((_h = this.params.callbacks) === null || _h === void 0 ? void 0 : _h.onAfterToolCalls) &&
|
|
2280
2319
|
this.params.callbacks.onAfterToolCalls(this.params.clientId, this.params.agentName, toolCalls);
|
|
2281
2320
|
return [2 /*return*/];
|
|
2282
2321
|
case 9:
|
|
@@ -2286,29 +2325,29 @@ var ClientAgent = /** @class */ (function () {
|
|
|
2286
2325
|
}
|
|
2287
2326
|
return [4 /*yield*/, this.params.transform(message.content, this.params.clientId, this.params.agentName)];
|
|
2288
2327
|
case 10:
|
|
2289
|
-
result =
|
|
2328
|
+
result = _j.sent();
|
|
2290
2329
|
return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
|
|
2291
2330
|
case 11:
|
|
2292
|
-
|
|
2331
|
+
_j.sent();
|
|
2293
2332
|
validation = null;
|
|
2294
2333
|
return [4 /*yield*/, this.params.validate(result)];
|
|
2295
2334
|
case 12:
|
|
2296
|
-
if (!(validation =
|
|
2335
|
+
if (!(validation = _j.sent())) return [3 /*break*/, 15];
|
|
2297
2336
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2298
2337
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute invalid tool call detected: ").concat(validation), { result: result });
|
|
2299
2338
|
return [4 /*yield*/, this._resurrectModel(mode, "Invalid model output: ".concat(result))];
|
|
2300
2339
|
case 13:
|
|
2301
|
-
result1 =
|
|
2340
|
+
result1 = _j.sent();
|
|
2302
2341
|
return [4 /*yield*/, this._emitOuput(mode, result1)];
|
|
2303
2342
|
case 14:
|
|
2304
|
-
|
|
2343
|
+
_j.sent();
|
|
2305
2344
|
return [2 /*return*/];
|
|
2306
2345
|
case 15:
|
|
2307
2346
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2308
2347
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute end result=").concat(result));
|
|
2309
2348
|
return [4 /*yield*/, this._emitOuput(mode, result)];
|
|
2310
2349
|
case 16:
|
|
2311
|
-
|
|
2350
|
+
_j.sent();
|
|
2312
2351
|
return [2 /*return*/];
|
|
2313
2352
|
}
|
|
2314
2353
|
});
|
|
@@ -2499,6 +2538,21 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
2499
2538
|
}
|
|
2500
2539
|
});
|
|
2501
2540
|
}); };
|
|
2541
|
+
/**
|
|
2542
|
+
* Prevent the next tool from being executed
|
|
2543
|
+
* @returns {Promise<any>} The commit result.
|
|
2544
|
+
*/
|
|
2545
|
+
this.commitStopTools = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2546
|
+
return __generator(this, function (_a) {
|
|
2547
|
+
switch (_a.label) {
|
|
2548
|
+
case 0:
|
|
2549
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
2550
|
+
this.loggerService.info("agentConnectionService commitStopTools");
|
|
2551
|
+
return [4 /*yield*/, this.getAgent(this.methodContextService.context.clientId, this.methodContextService.context.agentName).commitStopTools()];
|
|
2552
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
2553
|
+
}
|
|
2554
|
+
});
|
|
2555
|
+
}); };
|
|
2502
2556
|
/**
|
|
2503
2557
|
* Commits flush of agent history
|
|
2504
2558
|
* @returns {Promise<any>} The commit result.
|
|
@@ -3792,6 +3846,39 @@ var ClientSession = /** @class */ (function () {
|
|
|
3792
3846
|
}
|
|
3793
3847
|
});
|
|
3794
3848
|
}); };
|
|
3849
|
+
/**
|
|
3850
|
+
* Commits stop of the nexttool execution
|
|
3851
|
+
* @returns {Promise<void>}
|
|
3852
|
+
*/
|
|
3853
|
+
this.commitStopTools = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3854
|
+
var agent, result;
|
|
3855
|
+
return __generator(this, function (_a) {
|
|
3856
|
+
switch (_a.label) {
|
|
3857
|
+
case 0:
|
|
3858
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
3859
|
+
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " commitStopTools"));
|
|
3860
|
+
return [4 /*yield*/, this.params.swarm.getAgent()];
|
|
3861
|
+
case 1:
|
|
3862
|
+
agent = _a.sent();
|
|
3863
|
+
return [4 /*yield*/, agent.commitStopTools()];
|
|
3864
|
+
case 2:
|
|
3865
|
+
result = _a.sent();
|
|
3866
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
3867
|
+
type: "commit-stop-tools",
|
|
3868
|
+
source: "session-bus",
|
|
3869
|
+
input: {},
|
|
3870
|
+
output: {},
|
|
3871
|
+
context: {
|
|
3872
|
+
swarmName: this.params.swarmName,
|
|
3873
|
+
},
|
|
3874
|
+
clientId: this.params.clientId,
|
|
3875
|
+
})];
|
|
3876
|
+
case 3:
|
|
3877
|
+
_a.sent();
|
|
3878
|
+
return [2 /*return*/, result];
|
|
3879
|
+
}
|
|
3880
|
+
});
|
|
3881
|
+
}); };
|
|
3795
3882
|
/**
|
|
3796
3883
|
* Commits a system message.
|
|
3797
3884
|
* @param {string} message - The system message to commit.
|
|
@@ -4119,6 +4206,22 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
4119
4206
|
}
|
|
4120
4207
|
});
|
|
4121
4208
|
}); };
|
|
4209
|
+
/**
|
|
4210
|
+
* Commits user message to the agent without answer.
|
|
4211
|
+
* @param {string} message - The message to commit.
|
|
4212
|
+
* @returns {Promise<void>} A promise that resolves when the message is committed.
|
|
4213
|
+
*/
|
|
4214
|
+
this.commitStopTools = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
4215
|
+
return __generator(this, function (_a) {
|
|
4216
|
+
switch (_a.label) {
|
|
4217
|
+
case 0:
|
|
4218
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4219
|
+
this.loggerService.info("sessionConnectionService commitStopTools");
|
|
4220
|
+
return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).commitStopTools()];
|
|
4221
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
4222
|
+
}
|
|
4223
|
+
});
|
|
4224
|
+
}); };
|
|
4122
4225
|
/**
|
|
4123
4226
|
* Disposes of the session connection service.
|
|
4124
4227
|
* @returns {Promise<void>} A promise that resolves when the service is disposed.
|
|
@@ -4491,6 +4594,42 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
4491
4594
|
}
|
|
4492
4595
|
});
|
|
4493
4596
|
}); };
|
|
4597
|
+
/**
|
|
4598
|
+
* Prevent the next tool from being executed
|
|
4599
|
+
* @param {string} clientId - The client ID.
|
|
4600
|
+
* @param {AgentName} agentName - The name of the agent.
|
|
4601
|
+
* @returns {Promise<unknown>} The commit result.
|
|
4602
|
+
*/
|
|
4603
|
+
this.commitStopTools = function (methodName, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4604
|
+
var _this = this;
|
|
4605
|
+
return __generator(this, function (_a) {
|
|
4606
|
+
switch (_a.label) {
|
|
4607
|
+
case 0:
|
|
4608
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
4609
|
+
this.loggerService.info("agentPublicService commitStopTools", {
|
|
4610
|
+
methodName: methodName,
|
|
4611
|
+
clientId: clientId,
|
|
4612
|
+
agentName: agentName,
|
|
4613
|
+
});
|
|
4614
|
+
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
4615
|
+
return __generator(this, function (_a) {
|
|
4616
|
+
switch (_a.label) {
|
|
4617
|
+
case 0: return [4 /*yield*/, this.agentConnectionService.commitStopTools()];
|
|
4618
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
4619
|
+
}
|
|
4620
|
+
});
|
|
4621
|
+
}); }, {
|
|
4622
|
+
methodName: methodName,
|
|
4623
|
+
clientId: clientId,
|
|
4624
|
+
agentName: agentName,
|
|
4625
|
+
swarmName: "",
|
|
4626
|
+
storageName: "",
|
|
4627
|
+
stateName: "",
|
|
4628
|
+
})];
|
|
4629
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
4630
|
+
}
|
|
4631
|
+
});
|
|
4632
|
+
}); };
|
|
4494
4633
|
/**
|
|
4495
4634
|
* Disposes of the agent.
|
|
4496
4635
|
* @param {string} clientId - The client ID.
|
|
@@ -5004,6 +5143,41 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
5004
5143
|
}
|
|
5005
5144
|
});
|
|
5006
5145
|
}); };
|
|
5146
|
+
/**
|
|
5147
|
+
* Prevent the next tool from being executed
|
|
5148
|
+
* @param {string} clientId - The client ID.
|
|
5149
|
+
* @param {SwarmName} swarmName - The swarm name.
|
|
5150
|
+
* @returns {Promise<void>}
|
|
5151
|
+
*/
|
|
5152
|
+
this.commitStopTools = function (methodName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5153
|
+
var _this = this;
|
|
5154
|
+
return __generator(this, function (_a) {
|
|
5155
|
+
switch (_a.label) {
|
|
5156
|
+
case 0:
|
|
5157
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5158
|
+
this.loggerService.info("sessionPublicService commitStopTools", {
|
|
5159
|
+
clientId: clientId,
|
|
5160
|
+
swarmName: swarmName,
|
|
5161
|
+
});
|
|
5162
|
+
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5163
|
+
return __generator(this, function (_a) {
|
|
5164
|
+
switch (_a.label) {
|
|
5165
|
+
case 0: return [4 /*yield*/, this.sessionConnectionService.commitStopTools()];
|
|
5166
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5167
|
+
}
|
|
5168
|
+
});
|
|
5169
|
+
}); }, {
|
|
5170
|
+
methodName: methodName,
|
|
5171
|
+
clientId: clientId,
|
|
5172
|
+
swarmName: swarmName,
|
|
5173
|
+
agentName: "",
|
|
5174
|
+
storageName: "",
|
|
5175
|
+
stateName: "",
|
|
5176
|
+
})];
|
|
5177
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5178
|
+
}
|
|
5179
|
+
});
|
|
5180
|
+
}); };
|
|
5007
5181
|
/**
|
|
5008
5182
|
* Disposes of the session.
|
|
5009
5183
|
* @param {string} clientId - The client ID.
|
|
@@ -7256,6 +7430,53 @@ var ClientState = /** @class */ (function () {
|
|
|
7256
7430
|
}
|
|
7257
7431
|
});
|
|
7258
7432
|
}); };
|
|
7433
|
+
/**
|
|
7434
|
+
* Sets the to initial value
|
|
7435
|
+
* @returns {Promise<State>}
|
|
7436
|
+
*/
|
|
7437
|
+
this.clearState = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
7438
|
+
var _this = this;
|
|
7439
|
+
var _a;
|
|
7440
|
+
return __generator(this, function (_b) {
|
|
7441
|
+
switch (_b.label) {
|
|
7442
|
+
case 0:
|
|
7443
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
7444
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " clearState"));
|
|
7445
|
+
return [4 /*yield*/, this.dispatch("write", function () { return __awaiter(_this, void 0, void 0, function () {
|
|
7446
|
+
return __generator(this, function (_a) {
|
|
7447
|
+
switch (_a.label) {
|
|
7448
|
+
case 0: return [4 /*yield*/, this.params.getState(this.params.clientId, this.params.stateName)];
|
|
7449
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
7450
|
+
}
|
|
7451
|
+
});
|
|
7452
|
+
}); })];
|
|
7453
|
+
case 1:
|
|
7454
|
+
_b.sent();
|
|
7455
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
7456
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " clearState output"), { pendingState: this._state });
|
|
7457
|
+
this.params.setState &&
|
|
7458
|
+
this.params.setState(this._state, this.params.clientId, this.params.stateName);
|
|
7459
|
+
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onWrite) {
|
|
7460
|
+
this.params.callbacks.onWrite(this._state, this.params.clientId, this.params.stateName);
|
|
7461
|
+
}
|
|
7462
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
7463
|
+
type: "clear-state",
|
|
7464
|
+
source: "state-bus",
|
|
7465
|
+
input: {},
|
|
7466
|
+
output: {
|
|
7467
|
+
state: this._state,
|
|
7468
|
+
},
|
|
7469
|
+
context: {
|
|
7470
|
+
stateName: this.params.stateName,
|
|
7471
|
+
},
|
|
7472
|
+
clientId: this.params.clientId,
|
|
7473
|
+
})];
|
|
7474
|
+
case 2:
|
|
7475
|
+
_b.sent();
|
|
7476
|
+
return [2 /*return*/, this._state];
|
|
7477
|
+
}
|
|
7478
|
+
});
|
|
7479
|
+
}); };
|
|
7259
7480
|
/**
|
|
7260
7481
|
* Gets the current state.
|
|
7261
7482
|
* @returns {Promise<State>}
|
|
@@ -7393,6 +7614,26 @@ var StateConnectionService = /** @class */ (function () {
|
|
|
7393
7614
|
}
|
|
7394
7615
|
});
|
|
7395
7616
|
}); };
|
|
7617
|
+
/**
|
|
7618
|
+
* Set the state to initial value
|
|
7619
|
+
* @returns {Promise<T>} The initial state.
|
|
7620
|
+
*/
|
|
7621
|
+
this.clearState = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
7622
|
+
var state;
|
|
7623
|
+
return __generator(this, function (_a) {
|
|
7624
|
+
switch (_a.label) {
|
|
7625
|
+
case 0:
|
|
7626
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
7627
|
+
this.loggerService.info("stateConnectionService clearState");
|
|
7628
|
+
state = this.getStateRef(this.methodContextService.context.clientId, this.methodContextService.context.stateName);
|
|
7629
|
+
return [4 /*yield*/, state.waitForInit()];
|
|
7630
|
+
case 1:
|
|
7631
|
+
_a.sent();
|
|
7632
|
+
return [4 /*yield*/, state.clearState()];
|
|
7633
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
7634
|
+
}
|
|
7635
|
+
});
|
|
7636
|
+
}); };
|
|
7396
7637
|
/**
|
|
7397
7638
|
* Gets the state.
|
|
7398
7639
|
* @returns {Promise<T>} The current state.
|
|
@@ -7490,6 +7731,42 @@ var StatePublicService = /** @class */ (function () {
|
|
|
7490
7731
|
}
|
|
7491
7732
|
});
|
|
7492
7733
|
}); };
|
|
7734
|
+
/**
|
|
7735
|
+
* Set the state to initial value
|
|
7736
|
+
* @param {string} clientId - The client ID.
|
|
7737
|
+
* @param {StateName} stateName - The name of the state.
|
|
7738
|
+
* @returns {Promise<T>} - The initial state.
|
|
7739
|
+
*/
|
|
7740
|
+
this.clearState = function (methodName, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
7741
|
+
var _this = this;
|
|
7742
|
+
return __generator(this, function (_a) {
|
|
7743
|
+
switch (_a.label) {
|
|
7744
|
+
case 0:
|
|
7745
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
7746
|
+
this.loggerService.info("statePublicService clearState", {
|
|
7747
|
+
methodName: methodName,
|
|
7748
|
+
clientId: clientId,
|
|
7749
|
+
stateName: stateName,
|
|
7750
|
+
});
|
|
7751
|
+
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
7752
|
+
return __generator(this, function (_a) {
|
|
7753
|
+
switch (_a.label) {
|
|
7754
|
+
case 0: return [4 /*yield*/, this.stateConnectionService.clearState()];
|
|
7755
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
7756
|
+
}
|
|
7757
|
+
});
|
|
7758
|
+
}); }, {
|
|
7759
|
+
methodName: methodName,
|
|
7760
|
+
clientId: clientId,
|
|
7761
|
+
stateName: stateName,
|
|
7762
|
+
agentName: "",
|
|
7763
|
+
swarmName: "",
|
|
7764
|
+
storageName: "",
|
|
7765
|
+
})];
|
|
7766
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
7767
|
+
}
|
|
7768
|
+
});
|
|
7769
|
+
}); };
|
|
7493
7770
|
/**
|
|
7494
7771
|
* Gets the current state.
|
|
7495
7772
|
* @param {string} clientId - The client ID.
|
|
@@ -8359,6 +8636,26 @@ var SharedStateConnectionService = /** @class */ (function () {
|
|
|
8359
8636
|
}
|
|
8360
8637
|
});
|
|
8361
8638
|
}); };
|
|
8639
|
+
/**
|
|
8640
|
+
* Set the state to initial value
|
|
8641
|
+
* @returns {Promise<T>} The new state.
|
|
8642
|
+
*/
|
|
8643
|
+
this.clearState = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
8644
|
+
var state;
|
|
8645
|
+
return __generator(this, function (_a) {
|
|
8646
|
+
switch (_a.label) {
|
|
8647
|
+
case 0:
|
|
8648
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
8649
|
+
this.loggerService.info("sharedStateConnectionService clearState");
|
|
8650
|
+
state = this.getStateRef(this.methodContextService.context.stateName);
|
|
8651
|
+
return [4 /*yield*/, state.waitForInit()];
|
|
8652
|
+
case 1:
|
|
8653
|
+
_a.sent();
|
|
8654
|
+
return [4 /*yield*/, state.clearState()];
|
|
8655
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
8656
|
+
}
|
|
8657
|
+
});
|
|
8658
|
+
}); };
|
|
8362
8659
|
/**
|
|
8363
8660
|
* Gets the state.
|
|
8364
8661
|
* @returns {Promise<T>} The current state.
|
|
@@ -8592,6 +8889,40 @@ var SharedStatePublicService = /** @class */ (function () {
|
|
|
8592
8889
|
}
|
|
8593
8890
|
});
|
|
8594
8891
|
}); };
|
|
8892
|
+
/**
|
|
8893
|
+
* Set the state to initial value
|
|
8894
|
+
* @param {StateName} stateName - The name of the state.
|
|
8895
|
+
* @returns {Promise<T>} - The initial state.
|
|
8896
|
+
*/
|
|
8897
|
+
this.clearState = function (methodName, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
8898
|
+
var _this = this;
|
|
8899
|
+
return __generator(this, function (_a) {
|
|
8900
|
+
switch (_a.label) {
|
|
8901
|
+
case 0:
|
|
8902
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
8903
|
+
this.loggerService.info("sharedStatePublicService clearState", {
|
|
8904
|
+
methodName: methodName,
|
|
8905
|
+
stateName: stateName,
|
|
8906
|
+
});
|
|
8907
|
+
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
8908
|
+
return __generator(this, function (_a) {
|
|
8909
|
+
switch (_a.label) {
|
|
8910
|
+
case 0: return [4 /*yield*/, this.sharedStateConnectionService.clearState()];
|
|
8911
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
8912
|
+
}
|
|
8913
|
+
});
|
|
8914
|
+
}); }, {
|
|
8915
|
+
methodName: methodName,
|
|
8916
|
+
clientId: "",
|
|
8917
|
+
stateName: stateName,
|
|
8918
|
+
agentName: "",
|
|
8919
|
+
swarmName: "",
|
|
8920
|
+
storageName: "",
|
|
8921
|
+
})];
|
|
8922
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
8923
|
+
}
|
|
8924
|
+
});
|
|
8925
|
+
}); };
|
|
8595
8926
|
/**
|
|
8596
8927
|
* Gets the current state.
|
|
8597
8928
|
* @param {StateName} stateName - The name of the state.
|
|
@@ -8891,12 +9222,6 @@ var SharedStoragePublicService = /** @class */ (function () {
|
|
|
8891
9222
|
provide(TYPES.swarmMetaService, function () { return new SwarmMetaService(); });
|
|
8892
9223
|
provide(TYPES.agentMetaService, function () { return new AgentMetaService(); });
|
|
8893
9224
|
}
|
|
8894
|
-
{
|
|
8895
|
-
provide(TYPES.agentPublicService, function () { return new AgentPublicService(); });
|
|
8896
|
-
provide(TYPES.historyPublicService, function () { return new HistoryPublicService(); });
|
|
8897
|
-
provide(TYPES.sessionPublicService, function () { return new SessionPublicService(); });
|
|
8898
|
-
provide(TYPES.swarmPublicService, function () { return new SwarmPublicService(); });
|
|
8899
|
-
}
|
|
8900
9225
|
{
|
|
8901
9226
|
provide(TYPES.agentValidationService, function () { return new AgentValidationService(); });
|
|
8902
9227
|
provide(TYPES.completionValidationService, function () { return new CompletionValidationService(); });
|
|
@@ -8962,7 +9287,7 @@ var swarm = __assign(__assign(__assign(__assign(__assign(__assign(__assign({}, b
|
|
|
8962
9287
|
init();
|
|
8963
9288
|
var swarm$1 = swarm;
|
|
8964
9289
|
|
|
8965
|
-
var METHOD_NAME$
|
|
9290
|
+
var METHOD_NAME$L = "cli.dumpDocs";
|
|
8966
9291
|
/**
|
|
8967
9292
|
* Dumps the documentation for the agents and swarms.
|
|
8968
9293
|
*
|
|
@@ -8973,7 +9298,7 @@ var METHOD_NAME$J = "cli.dumpDocs";
|
|
|
8973
9298
|
var dumpDocs = function (dirName, PlantUML) {
|
|
8974
9299
|
if (dirName === void 0) { dirName = "./docs/chat"; }
|
|
8975
9300
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8976
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9301
|
+
swarm$1.loggerService.log(METHOD_NAME$L, {
|
|
8977
9302
|
dirName: dirName,
|
|
8978
9303
|
});
|
|
8979
9304
|
if (PlantUML) {
|
|
@@ -8984,12 +9309,12 @@ var dumpDocs = function (dirName, PlantUML) {
|
|
|
8984
9309
|
swarm$1.agentValidationService
|
|
8985
9310
|
.getAgentList()
|
|
8986
9311
|
.forEach(function (agentName) {
|
|
8987
|
-
return swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
9312
|
+
return swarm$1.agentValidationService.validate(agentName, METHOD_NAME$L);
|
|
8988
9313
|
});
|
|
8989
9314
|
swarm$1.swarmValidationService
|
|
8990
9315
|
.getSwarmList()
|
|
8991
9316
|
.forEach(function (swarmName) {
|
|
8992
|
-
return swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
9317
|
+
return swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$L);
|
|
8993
9318
|
});
|
|
8994
9319
|
swarm$1.agentValidationService.getAgentList().forEach(function (agentName) {
|
|
8995
9320
|
var dependsOn = swarm$1.agentSchemaService.get(agentName).dependsOn;
|
|
@@ -9000,7 +9325,7 @@ var dumpDocs = function (dirName, PlantUML) {
|
|
|
9000
9325
|
return swarm$1.docService.dumpDocs(dirName);
|
|
9001
9326
|
};
|
|
9002
9327
|
|
|
9003
|
-
var METHOD_NAME$
|
|
9328
|
+
var METHOD_NAME$K = "cli.dumpAgent";
|
|
9004
9329
|
/**
|
|
9005
9330
|
* Dumps the agent information into PlantUML format.
|
|
9006
9331
|
*
|
|
@@ -9010,14 +9335,14 @@ var METHOD_NAME$I = "cli.dumpAgent";
|
|
|
9010
9335
|
var dumpAgent = function (agentName, _a) {
|
|
9011
9336
|
var _b = _a === void 0 ? {} : _a, _c = _b.withSubtree, withSubtree = _c === void 0 ? false : _c;
|
|
9012
9337
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9013
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9338
|
+
swarm$1.loggerService.log(METHOD_NAME$K, {
|
|
9014
9339
|
agentName: agentName,
|
|
9015
9340
|
});
|
|
9016
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
9341
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$K);
|
|
9017
9342
|
return swarm$1.agentMetaService.toUML(agentName, withSubtree);
|
|
9018
9343
|
};
|
|
9019
9344
|
|
|
9020
|
-
var METHOD_NAME$
|
|
9345
|
+
var METHOD_NAME$J = "cli.dumpSwarm";
|
|
9021
9346
|
/**
|
|
9022
9347
|
* Dumps the swarm information into PlantUML format.
|
|
9023
9348
|
*
|
|
@@ -9026,14 +9351,14 @@ var METHOD_NAME$H = "cli.dumpSwarm";
|
|
|
9026
9351
|
*/
|
|
9027
9352
|
var dumpSwarm = function (swarmName) {
|
|
9028
9353
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9029
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9354
|
+
swarm$1.loggerService.log(METHOD_NAME$J, {
|
|
9030
9355
|
swarmName: swarmName,
|
|
9031
9356
|
});
|
|
9032
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
9357
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$J);
|
|
9033
9358
|
return swarm$1.swarmMetaService.toUML(swarmName);
|
|
9034
9359
|
};
|
|
9035
9360
|
|
|
9036
|
-
var METHOD_NAME$
|
|
9361
|
+
var METHOD_NAME$I = "function.addAgent";
|
|
9037
9362
|
/**
|
|
9038
9363
|
* Adds a new agent to the agent registry. The swarm takes only those agents which was registered
|
|
9039
9364
|
*
|
|
@@ -9042,7 +9367,7 @@ var METHOD_NAME$G = "function.addAgent";
|
|
|
9042
9367
|
*/
|
|
9043
9368
|
var addAgent = function (agentSchema) {
|
|
9044
9369
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9045
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9370
|
+
swarm$1.loggerService.log(METHOD_NAME$I, {
|
|
9046
9371
|
agentSchema: agentSchema,
|
|
9047
9372
|
});
|
|
9048
9373
|
swarm$1.agentValidationService.addAgent(agentSchema.agentName, agentSchema);
|
|
@@ -9050,7 +9375,7 @@ var addAgent = function (agentSchema) {
|
|
|
9050
9375
|
return agentSchema.agentName;
|
|
9051
9376
|
};
|
|
9052
9377
|
|
|
9053
|
-
var METHOD_NAME$
|
|
9378
|
+
var METHOD_NAME$H = "function.addCompletion";
|
|
9054
9379
|
/**
|
|
9055
9380
|
* Adds a completion engine for agents. Agents could use different models and
|
|
9056
9381
|
* framewords for completion like: mock, gpt4all, ollama, openai
|
|
@@ -9060,7 +9385,7 @@ var METHOD_NAME$F = "function.addCompletion";
|
|
|
9060
9385
|
*/
|
|
9061
9386
|
var addCompletion = function (completionSchema) {
|
|
9062
9387
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9063
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9388
|
+
swarm$1.loggerService.log(METHOD_NAME$H, {
|
|
9064
9389
|
completionSchema: completionSchema,
|
|
9065
9390
|
});
|
|
9066
9391
|
swarm$1.completionValidationService.addCompletion(completionSchema.completionName);
|
|
@@ -9068,7 +9393,7 @@ var addCompletion = function (completionSchema) {
|
|
|
9068
9393
|
return completionSchema.completionName;
|
|
9069
9394
|
};
|
|
9070
9395
|
|
|
9071
|
-
var METHOD_NAME$
|
|
9396
|
+
var METHOD_NAME$G = "function.addSwarm";
|
|
9072
9397
|
/**
|
|
9073
9398
|
* Adds a new swarm to the system. The swarm is a root for starting client session
|
|
9074
9399
|
*
|
|
@@ -9077,7 +9402,7 @@ var METHOD_NAME$E = "function.addSwarm";
|
|
|
9077
9402
|
*/
|
|
9078
9403
|
var addSwarm = function (swarmSchema) {
|
|
9079
9404
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9080
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9405
|
+
swarm$1.loggerService.log(METHOD_NAME$G, {
|
|
9081
9406
|
swarmSchema: swarmSchema,
|
|
9082
9407
|
});
|
|
9083
9408
|
swarm$1.swarmValidationService.addSwarm(swarmSchema.swarmName, swarmSchema);
|
|
@@ -9085,7 +9410,7 @@ var addSwarm = function (swarmSchema) {
|
|
|
9085
9410
|
return swarmSchema.swarmName;
|
|
9086
9411
|
};
|
|
9087
9412
|
|
|
9088
|
-
var METHOD_NAME$
|
|
9413
|
+
var METHOD_NAME$F = "function.addTool";
|
|
9089
9414
|
/**
|
|
9090
9415
|
* Adds a new tool for agents in a swarm. Tool should be registered in `addAgent`
|
|
9091
9416
|
* declaration
|
|
@@ -9095,7 +9420,7 @@ var METHOD_NAME$D = "function.addTool";
|
|
|
9095
9420
|
*/
|
|
9096
9421
|
var addTool = function (toolSchema) {
|
|
9097
9422
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9098
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9423
|
+
swarm$1.loggerService.log(METHOD_NAME$F, {
|
|
9099
9424
|
toolSchema: toolSchema,
|
|
9100
9425
|
});
|
|
9101
9426
|
swarm$1.toolValidationService.addTool(toolSchema.toolName, toolSchema);
|
|
@@ -9103,7 +9428,7 @@ var addTool = function (toolSchema) {
|
|
|
9103
9428
|
return toolSchema.toolName;
|
|
9104
9429
|
};
|
|
9105
9430
|
|
|
9106
|
-
var METHOD_NAME$
|
|
9431
|
+
var METHOD_NAME$E = "function.addState";
|
|
9107
9432
|
/**
|
|
9108
9433
|
* Adds a new state to the state registry. The swarm takes only those states which was registered
|
|
9109
9434
|
*
|
|
@@ -9112,7 +9437,7 @@ var METHOD_NAME$C = "function.addState";
|
|
|
9112
9437
|
*/
|
|
9113
9438
|
var addState = function (stateSchema) {
|
|
9114
9439
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9115
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9440
|
+
swarm$1.loggerService.log(METHOD_NAME$E, {
|
|
9116
9441
|
stateSchema: stateSchema,
|
|
9117
9442
|
});
|
|
9118
9443
|
swarm$1.stateSchemaService.register(stateSchema.stateName, stateSchema);
|
|
@@ -9124,7 +9449,7 @@ var addState = function (stateSchema) {
|
|
|
9124
9449
|
return stateSchema.stateName;
|
|
9125
9450
|
};
|
|
9126
9451
|
|
|
9127
|
-
var METHOD_NAME$
|
|
9452
|
+
var METHOD_NAME$D = "function.addEmbedding";
|
|
9128
9453
|
/**
|
|
9129
9454
|
* Adds a new embedding to the embedding registry. The swarm takes only those embeddings which was registered
|
|
9130
9455
|
*
|
|
@@ -9133,7 +9458,7 @@ var METHOD_NAME$B = "function.addEmbedding";
|
|
|
9133
9458
|
*/
|
|
9134
9459
|
var addEmbedding = function (embeddingSchema) {
|
|
9135
9460
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9136
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9461
|
+
swarm$1.loggerService.log(METHOD_NAME$D, {
|
|
9137
9462
|
embeddingSchema: embeddingSchema,
|
|
9138
9463
|
});
|
|
9139
9464
|
swarm$1.embeddingValidationService.addEmbedding(embeddingSchema.embeddingName, embeddingSchema);
|
|
@@ -9141,7 +9466,7 @@ var addEmbedding = function (embeddingSchema) {
|
|
|
9141
9466
|
return embeddingSchema.embeddingName;
|
|
9142
9467
|
};
|
|
9143
9468
|
|
|
9144
|
-
var METHOD_NAME$
|
|
9469
|
+
var METHOD_NAME$C = "function.addStorage";
|
|
9145
9470
|
/**
|
|
9146
9471
|
* Adds a new storage to the storage registry. The swarm takes only those storages which was registered
|
|
9147
9472
|
*
|
|
@@ -9150,7 +9475,7 @@ var METHOD_NAME$A = "function.addStorage";
|
|
|
9150
9475
|
*/
|
|
9151
9476
|
var addStorage = function (storageSchema) {
|
|
9152
9477
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9153
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9478
|
+
swarm$1.loggerService.log(METHOD_NAME$C, {
|
|
9154
9479
|
storageSchema: storageSchema,
|
|
9155
9480
|
});
|
|
9156
9481
|
swarm$1.storageValidationService.addStorage(storageSchema.storageName, storageSchema);
|
|
@@ -9163,7 +9488,7 @@ var addStorage = function (storageSchema) {
|
|
|
9163
9488
|
return storageSchema.storageName;
|
|
9164
9489
|
};
|
|
9165
9490
|
|
|
9166
|
-
var METHOD_NAME$
|
|
9491
|
+
var METHOD_NAME$B = "function.commitToolOutput";
|
|
9167
9492
|
/**
|
|
9168
9493
|
* Commits the tool output to the active agent in a swarm session
|
|
9169
9494
|
*
|
|
@@ -9178,17 +9503,17 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
|
|
|
9178
9503
|
switch (_a.label) {
|
|
9179
9504
|
case 0:
|
|
9180
9505
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9181
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9506
|
+
swarm$1.loggerService.log(METHOD_NAME$B, {
|
|
9182
9507
|
toolId: toolId,
|
|
9183
9508
|
content: content,
|
|
9184
9509
|
clientId: clientId,
|
|
9185
9510
|
agentName: agentName,
|
|
9186
9511
|
});
|
|
9187
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
9188
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
9512
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$B);
|
|
9513
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$B);
|
|
9189
9514
|
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
9190
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
9191
|
-
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
9515
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$B);
|
|
9516
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$B, clientId, swarmName)];
|
|
9192
9517
|
case 1:
|
|
9193
9518
|
currentAgentName = _a.sent();
|
|
9194
9519
|
if (currentAgentName !== agentName) {
|
|
@@ -9201,7 +9526,7 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
|
|
|
9201
9526
|
});
|
|
9202
9527
|
return [2 /*return*/];
|
|
9203
9528
|
}
|
|
9204
|
-
return [4 /*yield*/, swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$
|
|
9529
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$B, clientId, swarmName)];
|
|
9205
9530
|
case 2:
|
|
9206
9531
|
_a.sent();
|
|
9207
9532
|
return [2 /*return*/];
|
|
@@ -9209,7 +9534,7 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
|
|
|
9209
9534
|
});
|
|
9210
9535
|
}); };
|
|
9211
9536
|
|
|
9212
|
-
var METHOD_NAME$
|
|
9537
|
+
var METHOD_NAME$A = "function.commitSystemMessage";
|
|
9213
9538
|
/**
|
|
9214
9539
|
* Commits a system message to the active agent in the swarm.
|
|
9215
9540
|
*
|
|
@@ -9224,16 +9549,16 @@ var commitSystemMessage = function (content, clientId, agentName) { return __awa
|
|
|
9224
9549
|
switch (_a.label) {
|
|
9225
9550
|
case 0:
|
|
9226
9551
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9227
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9552
|
+
swarm$1.loggerService.log(METHOD_NAME$A, {
|
|
9228
9553
|
content: content,
|
|
9229
9554
|
clientId: clientId,
|
|
9230
9555
|
agentName: agentName,
|
|
9231
9556
|
});
|
|
9232
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
9233
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
9557
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$A);
|
|
9558
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$A);
|
|
9234
9559
|
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
9235
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
9236
|
-
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
9560
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$A);
|
|
9561
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$A, clientId, swarmName)];
|
|
9237
9562
|
case 1:
|
|
9238
9563
|
currentAgentName = _a.sent();
|
|
9239
9564
|
if (currentAgentName !== agentName) {
|
|
@@ -9245,7 +9570,7 @@ var commitSystemMessage = function (content, clientId, agentName) { return __awa
|
|
|
9245
9570
|
});
|
|
9246
9571
|
return [2 /*return*/];
|
|
9247
9572
|
}
|
|
9248
|
-
return [4 /*yield*/, swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$
|
|
9573
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$A, clientId, swarmName)];
|
|
9249
9574
|
case 2:
|
|
9250
9575
|
_a.sent();
|
|
9251
9576
|
return [2 /*return*/];
|
|
@@ -9253,7 +9578,7 @@ var commitSystemMessage = function (content, clientId, agentName) { return __awa
|
|
|
9253
9578
|
});
|
|
9254
9579
|
}); };
|
|
9255
9580
|
|
|
9256
|
-
var METHOD_NAME$
|
|
9581
|
+
var METHOD_NAME$z = "function.commitFlush";
|
|
9257
9582
|
/**
|
|
9258
9583
|
* Commits flush of agent history
|
|
9259
9584
|
*
|
|
@@ -9267,15 +9592,15 @@ var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void
|
|
|
9267
9592
|
switch (_a.label) {
|
|
9268
9593
|
case 0:
|
|
9269
9594
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9270
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9595
|
+
swarm$1.loggerService.log(METHOD_NAME$z, {
|
|
9271
9596
|
clientId: clientId,
|
|
9272
9597
|
agentName: agentName,
|
|
9273
9598
|
});
|
|
9274
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
9275
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
9599
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$z);
|
|
9600
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$z);
|
|
9276
9601
|
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
9277
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
9278
|
-
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
9602
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$z);
|
|
9603
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$z, clientId, swarmName)];
|
|
9279
9604
|
case 1:
|
|
9280
9605
|
currentAgentName = _a.sent();
|
|
9281
9606
|
if (currentAgentName !== agentName) {
|
|
@@ -9287,7 +9612,7 @@ var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void
|
|
|
9287
9612
|
});
|
|
9288
9613
|
return [2 /*return*/];
|
|
9289
9614
|
}
|
|
9290
|
-
return [4 /*yield*/, swarm$1.sessionPublicService.commitFlush(METHOD_NAME$
|
|
9615
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitFlush(METHOD_NAME$z, clientId, swarmName)];
|
|
9291
9616
|
case 2:
|
|
9292
9617
|
_a.sent();
|
|
9293
9618
|
return [2 /*return*/];
|
|
@@ -9295,7 +9620,7 @@ var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void
|
|
|
9295
9620
|
});
|
|
9296
9621
|
}); };
|
|
9297
9622
|
|
|
9298
|
-
var METHOD_NAME$
|
|
9623
|
+
var METHOD_NAME$y = "function.commitSystemMessage";
|
|
9299
9624
|
/**
|
|
9300
9625
|
* Commits a user message to the active agent history in as swarm without answer.
|
|
9301
9626
|
*
|
|
@@ -9310,16 +9635,16 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
|
|
|
9310
9635
|
switch (_a.label) {
|
|
9311
9636
|
case 0:
|
|
9312
9637
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9313
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9638
|
+
swarm$1.loggerService.log(METHOD_NAME$y, {
|
|
9314
9639
|
content: content,
|
|
9315
9640
|
clientId: clientId,
|
|
9316
9641
|
agentName: agentName,
|
|
9317
9642
|
});
|
|
9318
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
9319
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
9643
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$y);
|
|
9644
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$y);
|
|
9320
9645
|
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
9321
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
9322
|
-
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
9646
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$y);
|
|
9647
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$y, clientId, swarmName)];
|
|
9323
9648
|
case 1:
|
|
9324
9649
|
currentAgentName = _a.sent();
|
|
9325
9650
|
if (currentAgentName !== agentName) {
|
|
@@ -9331,7 +9656,7 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
|
|
|
9331
9656
|
});
|
|
9332
9657
|
return [2 /*return*/];
|
|
9333
9658
|
}
|
|
9334
|
-
return [4 /*yield*/, swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$
|
|
9659
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$y, clientId, swarmName)];
|
|
9335
9660
|
case 2:
|
|
9336
9661
|
_a.sent();
|
|
9337
9662
|
return [2 /*return*/];
|
|
@@ -9339,7 +9664,7 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
|
|
|
9339
9664
|
});
|
|
9340
9665
|
}); };
|
|
9341
9666
|
|
|
9342
|
-
var METHOD_NAME$
|
|
9667
|
+
var METHOD_NAME$x = "function.commitToolOutputForce";
|
|
9343
9668
|
/**
|
|
9344
9669
|
* Commits the tool output to the active agent in a swarm session without checking active agent
|
|
9345
9670
|
*
|
|
@@ -9353,15 +9678,15 @@ var commitToolOutputForce = function (toolId, content, clientId) { return __awai
|
|
|
9353
9678
|
switch (_a.label) {
|
|
9354
9679
|
case 0:
|
|
9355
9680
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9356
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9681
|
+
swarm$1.loggerService.log(METHOD_NAME$x, {
|
|
9357
9682
|
toolId: toolId,
|
|
9358
9683
|
content: content,
|
|
9359
9684
|
clientId: clientId,
|
|
9360
9685
|
});
|
|
9361
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
9686
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$x);
|
|
9362
9687
|
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
9363
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
9364
|
-
return [4 /*yield*/, swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$
|
|
9688
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$x);
|
|
9689
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$x, clientId, swarmName)];
|
|
9365
9690
|
case 1:
|
|
9366
9691
|
_a.sent();
|
|
9367
9692
|
return [2 /*return*/];
|
|
@@ -9369,7 +9694,7 @@ var commitToolOutputForce = function (toolId, content, clientId) { return __awai
|
|
|
9369
9694
|
});
|
|
9370
9695
|
}); };
|
|
9371
9696
|
|
|
9372
|
-
var METHOD_NAME$
|
|
9697
|
+
var METHOD_NAME$w = "function.commitSystemMessageForce";
|
|
9373
9698
|
/**
|
|
9374
9699
|
* Commits a system message to the active agent in as swarm without checking active agent.
|
|
9375
9700
|
*
|
|
@@ -9383,14 +9708,14 @@ var commitSystemMessageForce = function (content, clientId) { return __awaiter(v
|
|
|
9383
9708
|
switch (_a.label) {
|
|
9384
9709
|
case 0:
|
|
9385
9710
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9386
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9711
|
+
swarm$1.loggerService.log(METHOD_NAME$w, {
|
|
9387
9712
|
content: content,
|
|
9388
9713
|
clientId: clientId,
|
|
9389
9714
|
});
|
|
9390
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
9715
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$w);
|
|
9391
9716
|
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
9392
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
9393
|
-
return [4 /*yield*/, swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$
|
|
9717
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$w);
|
|
9718
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$w, clientId, swarmName)];
|
|
9394
9719
|
case 1:
|
|
9395
9720
|
_a.sent();
|
|
9396
9721
|
return [2 /*return*/];
|
|
@@ -9398,7 +9723,7 @@ var commitSystemMessageForce = function (content, clientId) { return __awaiter(v
|
|
|
9398
9723
|
});
|
|
9399
9724
|
}); };
|
|
9400
9725
|
|
|
9401
|
-
var METHOD_NAME$
|
|
9726
|
+
var METHOD_NAME$v = "function.commitFlushForce";
|
|
9402
9727
|
/**
|
|
9403
9728
|
* Commits flush of agent history without active agent check
|
|
9404
9729
|
*
|
|
@@ -9411,14 +9736,14 @@ var commitFlushForce = function (clientId) { return __awaiter(void 0, void 0, vo
|
|
|
9411
9736
|
switch (_a.label) {
|
|
9412
9737
|
case 0:
|
|
9413
9738
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9414
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9739
|
+
swarm$1.loggerService.log(METHOD_NAME$v, {
|
|
9415
9740
|
clientId: clientId,
|
|
9416
|
-
METHOD_NAME: METHOD_NAME$
|
|
9741
|
+
METHOD_NAME: METHOD_NAME$v,
|
|
9417
9742
|
});
|
|
9418
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
9743
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$v);
|
|
9419
9744
|
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
9420
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
9421
|
-
return [4 /*yield*/, swarm$1.sessionPublicService.commitFlush(METHOD_NAME$
|
|
9745
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$v);
|
|
9746
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitFlush(METHOD_NAME$v, clientId, swarmName)];
|
|
9422
9747
|
case 1:
|
|
9423
9748
|
_a.sent();
|
|
9424
9749
|
return [2 /*return*/];
|
|
@@ -9426,7 +9751,7 @@ var commitFlushForce = function (clientId) { return __awaiter(void 0, void 0, vo
|
|
|
9426
9751
|
});
|
|
9427
9752
|
}); };
|
|
9428
9753
|
|
|
9429
|
-
var METHOD_NAME$
|
|
9754
|
+
var METHOD_NAME$u = "function.commitSystemMessage";
|
|
9430
9755
|
/**
|
|
9431
9756
|
* Commits a user message to the active agent history in as swarm without answer and checking active agent
|
|
9432
9757
|
*
|
|
@@ -9440,14 +9765,14 @@ var commitUserMessageForce = function (content, clientId) { return __awaiter(voi
|
|
|
9440
9765
|
switch (_a.label) {
|
|
9441
9766
|
case 0:
|
|
9442
9767
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9443
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9768
|
+
swarm$1.loggerService.log(METHOD_NAME$u, {
|
|
9444
9769
|
content: content,
|
|
9445
9770
|
clientId: clientId,
|
|
9446
9771
|
});
|
|
9447
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
9772
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$u);
|
|
9448
9773
|
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
9449
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
9450
|
-
return [4 /*yield*/, swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$
|
|
9774
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$u);
|
|
9775
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$u, clientId, swarmName)];
|
|
9451
9776
|
case 1:
|
|
9452
9777
|
_a.sent();
|
|
9453
9778
|
return [2 /*return*/];
|
|
@@ -9455,7 +9780,7 @@ var commitUserMessageForce = function (content, clientId) { return __awaiter(voi
|
|
|
9455
9780
|
});
|
|
9456
9781
|
}); };
|
|
9457
9782
|
|
|
9458
|
-
var METHOD_NAME$
|
|
9783
|
+
var METHOD_NAME$t = "function.commitAssistantMessage";
|
|
9459
9784
|
/**
|
|
9460
9785
|
* Commits an assistant message to the active agent in the swarm.
|
|
9461
9786
|
*
|
|
@@ -9470,16 +9795,16 @@ var commitAssistantMessage = function (content, clientId, agentName) { return __
|
|
|
9470
9795
|
switch (_a.label) {
|
|
9471
9796
|
case 0:
|
|
9472
9797
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9473
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9798
|
+
swarm$1.loggerService.log(METHOD_NAME$t, {
|
|
9474
9799
|
content: content,
|
|
9475
9800
|
clientId: clientId,
|
|
9476
9801
|
agentName: agentName,
|
|
9477
9802
|
});
|
|
9478
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
9479
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
9803
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$t);
|
|
9804
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$t);
|
|
9480
9805
|
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
9481
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
9482
|
-
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
9806
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$t);
|
|
9807
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$t, clientId, swarmName)];
|
|
9483
9808
|
case 1:
|
|
9484
9809
|
currentAgentName = _a.sent();
|
|
9485
9810
|
if (currentAgentName !== agentName) {
|
|
@@ -9491,7 +9816,7 @@ var commitAssistantMessage = function (content, clientId, agentName) { return __
|
|
|
9491
9816
|
});
|
|
9492
9817
|
return [2 /*return*/];
|
|
9493
9818
|
}
|
|
9494
|
-
return [4 /*yield*/, swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$
|
|
9819
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$t, clientId, swarmName)];
|
|
9495
9820
|
case 2:
|
|
9496
9821
|
_a.sent();
|
|
9497
9822
|
return [2 /*return*/];
|
|
@@ -9499,7 +9824,7 @@ var commitAssistantMessage = function (content, clientId, agentName) { return __
|
|
|
9499
9824
|
});
|
|
9500
9825
|
}); };
|
|
9501
9826
|
|
|
9502
|
-
var METHOD_NAME$
|
|
9827
|
+
var METHOD_NAME$s = "function.commitAssistantMessageForce";
|
|
9503
9828
|
/**
|
|
9504
9829
|
* Commits an assistant message to the active agent in as swarm without checking active agent.
|
|
9505
9830
|
*
|
|
@@ -9513,14 +9838,14 @@ var commitAssistantMessageForce = function (content, clientId) { return __awaite
|
|
|
9513
9838
|
switch (_a.label) {
|
|
9514
9839
|
case 0:
|
|
9515
9840
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9516
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9841
|
+
swarm$1.loggerService.log(METHOD_NAME$s, {
|
|
9517
9842
|
content: content,
|
|
9518
9843
|
clientId: clientId,
|
|
9519
9844
|
});
|
|
9520
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
9845
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$s);
|
|
9521
9846
|
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
9522
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
9523
|
-
return [4 /*yield*/, swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$
|
|
9847
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$s);
|
|
9848
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$s, clientId, swarmName)];
|
|
9524
9849
|
case 1:
|
|
9525
9850
|
_a.sent();
|
|
9526
9851
|
return [2 /*return*/];
|
|
@@ -9528,7 +9853,7 @@ var commitAssistantMessageForce = function (content, clientId) { return __awaite
|
|
|
9528
9853
|
});
|
|
9529
9854
|
}); };
|
|
9530
9855
|
|
|
9531
|
-
var METHOD_NAME$
|
|
9856
|
+
var METHOD_NAME$r = "function.cancelOutput";
|
|
9532
9857
|
/**
|
|
9533
9858
|
* Cancel the await of output by emit of empty string
|
|
9534
9859
|
*
|
|
@@ -9542,15 +9867,15 @@ var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, voi
|
|
|
9542
9867
|
switch (_a.label) {
|
|
9543
9868
|
case 0:
|
|
9544
9869
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9545
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
9870
|
+
swarm$1.loggerService.log(METHOD_NAME$r, {
|
|
9546
9871
|
clientId: clientId,
|
|
9547
9872
|
agentName: agentName,
|
|
9548
9873
|
});
|
|
9549
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
9550
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
9874
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$r);
|
|
9875
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$r);
|
|
9551
9876
|
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
9552
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
9553
|
-
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
9877
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$r);
|
|
9878
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$r, clientId, swarmName)];
|
|
9554
9879
|
case 1:
|
|
9555
9880
|
currentAgentName = _a.sent();
|
|
9556
9881
|
if (currentAgentName !== agentName) {
|
|
@@ -9562,7 +9887,7 @@ var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, voi
|
|
|
9562
9887
|
});
|
|
9563
9888
|
return [2 /*return*/];
|
|
9564
9889
|
}
|
|
9565
|
-
return [4 /*yield*/, swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$
|
|
9890
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$r, clientId, swarmName)];
|
|
9566
9891
|
case 2:
|
|
9567
9892
|
_a.sent();
|
|
9568
9893
|
return [2 /*return*/];
|
|
@@ -9570,7 +9895,7 @@ var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, voi
|
|
|
9570
9895
|
});
|
|
9571
9896
|
}); };
|
|
9572
9897
|
|
|
9573
|
-
var METHOD_NAME$
|
|
9898
|
+
var METHOD_NAME$q = "function.cancelOutputForce";
|
|
9574
9899
|
/**
|
|
9575
9900
|
* Cancel the await of output by emit of empty string without checking active agent
|
|
9576
9901
|
*
|
|
@@ -9579,6 +9904,75 @@ var METHOD_NAME$o = "function.cancelOutputForce";
|
|
|
9579
9904
|
* @returns {Promise<void>} - A promise that resolves when the output is canceled
|
|
9580
9905
|
*/
|
|
9581
9906
|
var cancelOutputForce = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
9907
|
+
var swarmName;
|
|
9908
|
+
return __generator(this, function (_a) {
|
|
9909
|
+
switch (_a.label) {
|
|
9910
|
+
case 0:
|
|
9911
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9912
|
+
swarm$1.loggerService.log(METHOD_NAME$q, {
|
|
9913
|
+
clientId: clientId,
|
|
9914
|
+
});
|
|
9915
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$q);
|
|
9916
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
9917
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$q);
|
|
9918
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$q, clientId, swarmName)];
|
|
9919
|
+
case 1:
|
|
9920
|
+
_a.sent();
|
|
9921
|
+
return [2 /*return*/];
|
|
9922
|
+
}
|
|
9923
|
+
});
|
|
9924
|
+
}); };
|
|
9925
|
+
|
|
9926
|
+
var METHOD_NAME$p = "function.commitStopTools";
|
|
9927
|
+
/**
|
|
9928
|
+
* Prevent the next tool from being executed
|
|
9929
|
+
*
|
|
9930
|
+
* @param {string} clientId - The ID of the client.
|
|
9931
|
+
* @param {string} agentName - The name of the agent.
|
|
9932
|
+
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
9933
|
+
*/
|
|
9934
|
+
var commitStopTools = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
9935
|
+
var swarmName, currentAgentName;
|
|
9936
|
+
return __generator(this, function (_a) {
|
|
9937
|
+
switch (_a.label) {
|
|
9938
|
+
case 0:
|
|
9939
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9940
|
+
swarm$1.loggerService.log(METHOD_NAME$p, {
|
|
9941
|
+
clientId: clientId,
|
|
9942
|
+
agentName: agentName,
|
|
9943
|
+
});
|
|
9944
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$p);
|
|
9945
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$p);
|
|
9946
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
9947
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$p);
|
|
9948
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$p, clientId, swarmName)];
|
|
9949
|
+
case 1:
|
|
9950
|
+
currentAgentName = _a.sent();
|
|
9951
|
+
if (currentAgentName !== agentName) {
|
|
9952
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9953
|
+
swarm$1.loggerService.log('function "commitStopTools" skipped due to the agent change', {
|
|
9954
|
+
currentAgentName: currentAgentName,
|
|
9955
|
+
agentName: agentName,
|
|
9956
|
+
clientId: clientId,
|
|
9957
|
+
});
|
|
9958
|
+
return [2 /*return*/];
|
|
9959
|
+
}
|
|
9960
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$p, clientId, swarmName)];
|
|
9961
|
+
case 2:
|
|
9962
|
+
_a.sent();
|
|
9963
|
+
return [2 /*return*/];
|
|
9964
|
+
}
|
|
9965
|
+
});
|
|
9966
|
+
}); };
|
|
9967
|
+
|
|
9968
|
+
var METHOD_NAME$o = "function.commitStopToolsForce";
|
|
9969
|
+
/**
|
|
9970
|
+
* Prevent the next tool from being executed without active agent check
|
|
9971
|
+
*
|
|
9972
|
+
* @param {string} clientId - The ID of the client.
|
|
9973
|
+
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
9974
|
+
*/
|
|
9975
|
+
var commitStopToolsForce = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
9582
9976
|
var swarmName;
|
|
9583
9977
|
return __generator(this, function (_a) {
|
|
9584
9978
|
switch (_a.label) {
|
|
@@ -9586,11 +9980,12 @@ var cancelOutputForce = function (clientId) { return __awaiter(void 0, void 0, v
|
|
|
9586
9980
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
9587
9981
|
swarm$1.loggerService.log(METHOD_NAME$o, {
|
|
9588
9982
|
clientId: clientId,
|
|
9983
|
+
METHOD_NAME: METHOD_NAME$o,
|
|
9589
9984
|
});
|
|
9590
9985
|
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$o);
|
|
9591
9986
|
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
9592
9987
|
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$o);
|
|
9593
|
-
return [4 /*yield*/, swarm$1.
|
|
9988
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$o, clientId, swarmName)];
|
|
9594
9989
|
case 1:
|
|
9595
9990
|
_a.sent();
|
|
9596
9991
|
return [2 /*return*/];
|
|
@@ -11248,6 +11643,7 @@ var listenSwarmEventOnce = function (clientId, filterFn, fn) {
|
|
|
11248
11643
|
|
|
11249
11644
|
var METHOD_NAME_GET$3 = "StateUtils.getState";
|
|
11250
11645
|
var METHOD_NAME_SET$1 = "StateUtils.setState";
|
|
11646
|
+
var METHOD_NAME_CLEAR$3 = "StateUtils.clearState";
|
|
11251
11647
|
/**
|
|
11252
11648
|
* Utility class for managing state in the agent swarm.
|
|
11253
11649
|
* @implements {TState}
|
|
@@ -11318,6 +11714,34 @@ var StateUtils = /** @class */ (function () {
|
|
|
11318
11714
|
}
|
|
11319
11715
|
});
|
|
11320
11716
|
}); };
|
|
11717
|
+
/**
|
|
11718
|
+
* Set the state to initial value
|
|
11719
|
+
* @template T
|
|
11720
|
+
* @param {Object} payload - The payload containing client and state information.
|
|
11721
|
+
* @param {string} payload.clientId - The client ID.
|
|
11722
|
+
* @param {AgentName} payload.agentName - The agent name.
|
|
11723
|
+
* @param {StateName} payload.stateName - The state name.
|
|
11724
|
+
* @returns {Promise<void>}
|
|
11725
|
+
* @throws Will throw an error if the state is not registered in the agent.
|
|
11726
|
+
*/
|
|
11727
|
+
this.clearState = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
11728
|
+
return __generator(this, function (_a) {
|
|
11729
|
+
switch (_a.label) {
|
|
11730
|
+
case 0:
|
|
11731
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
11732
|
+
swarm$1.loggerService.log(METHOD_NAME_SET$1, {
|
|
11733
|
+
clientId: payload.clientId,
|
|
11734
|
+
stateName: payload.stateName,
|
|
11735
|
+
});
|
|
11736
|
+
swarm$1.sessionValidationService.validate(payload.clientId, METHOD_NAME_SET$1);
|
|
11737
|
+
if (!swarm$1.agentValidationService.hasState(payload.agentName, payload.stateName)) {
|
|
11738
|
+
throw new Error("agent-swarm StateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (clearState)"));
|
|
11739
|
+
}
|
|
11740
|
+
return [4 /*yield*/, swarm$1.statePublicService.clearState(METHOD_NAME_CLEAR$3, payload.clientId, payload.stateName)];
|
|
11741
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
11742
|
+
}
|
|
11743
|
+
});
|
|
11744
|
+
}); };
|
|
11321
11745
|
}
|
|
11322
11746
|
return StateUtils;
|
|
11323
11747
|
}());
|
|
@@ -11329,6 +11753,7 @@ var State = new StateUtils();
|
|
|
11329
11753
|
|
|
11330
11754
|
var METHOD_NAME_GET$2 = "SharedStateUtils.getSharedState";
|
|
11331
11755
|
var METHOD_NAME_SET = "SharedStateUtils.setSharedState";
|
|
11756
|
+
var METHOD_NAME_CLEAR$2 = "SharedStateUtils.clearSharedState";
|
|
11332
11757
|
/**
|
|
11333
11758
|
* Utility class for managing state in the agent swarm.
|
|
11334
11759
|
* @implements {TSharedState}
|
|
@@ -11393,6 +11818,31 @@ var SharedStateUtils = /** @class */ (function () {
|
|
|
11393
11818
|
}
|
|
11394
11819
|
});
|
|
11395
11820
|
}); };
|
|
11821
|
+
/**
|
|
11822
|
+
* Set the state to initial value
|
|
11823
|
+
* @template T
|
|
11824
|
+
* @param {Object} payload - The payload containing client and state information.
|
|
11825
|
+
* @param {AgentName} payload.agentName - The agent name.
|
|
11826
|
+
* @param {StateName} payload.stateName - The state name.
|
|
11827
|
+
* @returns {Promise<void>}
|
|
11828
|
+
* @throws Will throw an error if the state is not registered in the agent.
|
|
11829
|
+
*/
|
|
11830
|
+
this.clearState = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
11831
|
+
return __generator(this, function (_a) {
|
|
11832
|
+
switch (_a.label) {
|
|
11833
|
+
case 0:
|
|
11834
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
11835
|
+
swarm$1.loggerService.log(METHOD_NAME_SET, {
|
|
11836
|
+
stateName: payload.stateName,
|
|
11837
|
+
});
|
|
11838
|
+
if (!swarm$1.agentValidationService.hasState(payload.agentName, payload.stateName)) {
|
|
11839
|
+
throw new Error("agent-swarm SharedStateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (clearState)"));
|
|
11840
|
+
}
|
|
11841
|
+
return [4 /*yield*/, swarm$1.sharedStatePublicService.clearState(METHOD_NAME_CLEAR$2, payload.stateName)];
|
|
11842
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
11843
|
+
}
|
|
11844
|
+
});
|
|
11845
|
+
}); };
|
|
11396
11846
|
}
|
|
11397
11847
|
return SharedStateUtils;
|
|
11398
11848
|
}());
|
|
@@ -11869,6 +12319,8 @@ exports.commitAssistantMessage = commitAssistantMessage;
|
|
|
11869
12319
|
exports.commitAssistantMessageForce = commitAssistantMessageForce;
|
|
11870
12320
|
exports.commitFlush = commitFlush;
|
|
11871
12321
|
exports.commitFlushForce = commitFlushForce;
|
|
12322
|
+
exports.commitStopTools = commitStopTools;
|
|
12323
|
+
exports.commitStopToolsForce = commitStopToolsForce;
|
|
11872
12324
|
exports.commitSystemMessage = commitSystemMessage;
|
|
11873
12325
|
exports.commitSystemMessageForce = commitSystemMessageForce;
|
|
11874
12326
|
exports.commitToolOutput = commitToolOutput;
|