agent-swarm-kit 1.0.144 → 1.0.145
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 +26 -46
- package/build/index.mjs +26 -46
- package/package.json +1 -1
- package/types.d.ts +2 -2
package/build/index.cjs
CHANGED
|
@@ -1821,18 +1821,13 @@ var TOOL_NO_OUTPUT_WARNING = 15000;
|
|
|
1821
1821
|
var createPlaceholder = function () {
|
|
1822
1822
|
return GLOBAL_CONFIG.CC_EMPTY_OUTPUT_PLACEHOLDERS[Math.floor(Math.random() * GLOBAL_CONFIG.CC_EMPTY_OUTPUT_PLACEHOLDERS.length)];
|
|
1823
1823
|
};
|
|
1824
|
-
var createToolCall = function (idx, tool, toolCalls, targetFn, self
|
|
1824
|
+
var createToolCall = function (idx, tool, toolCalls, targetFn, self) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1825
1825
|
var error_1;
|
|
1826
1826
|
var _a, _b, _c, _d;
|
|
1827
1827
|
return __generator(this, function (_e) {
|
|
1828
1828
|
switch (_e.label) {
|
|
1829
1829
|
case 0:
|
|
1830
|
-
|
|
1831
|
-
return [2 /*return*/];
|
|
1832
|
-
}
|
|
1833
|
-
_e.label = 1;
|
|
1834
|
-
case 1:
|
|
1835
|
-
_e.trys.push([1, 3, , 4]);
|
|
1830
|
+
_e.trys.push([0, 2, , 3]);
|
|
1836
1831
|
return [4 /*yield*/, targetFn.call({
|
|
1837
1832
|
toolId: tool.id,
|
|
1838
1833
|
clientId: self.params.clientId,
|
|
@@ -1841,12 +1836,12 @@ var createToolCall = function (idx, tool, toolCalls, targetFn, self, isResqued)
|
|
|
1841
1836
|
isLast: idx === toolCalls.length - 1,
|
|
1842
1837
|
toolCalls: toolCalls,
|
|
1843
1838
|
})];
|
|
1844
|
-
case
|
|
1839
|
+
case 1:
|
|
1845
1840
|
_e.sent();
|
|
1846
1841
|
((_a = targetFn.callbacks) === null || _a === void 0 ? void 0 : _a.onAfterCall) &&
|
|
1847
1842
|
((_b = targetFn.callbacks) === null || _b === void 0 ? void 0 : _b.onAfterCall(tool.id, self.params.clientId, self.params.agentName, tool.function.arguments));
|
|
1848
|
-
return [3 /*break*/,
|
|
1849
|
-
case
|
|
1843
|
+
return [3 /*break*/, 3];
|
|
1844
|
+
case 2:
|
|
1850
1845
|
error_1 = _e.sent();
|
|
1851
1846
|
console.error("agent-swarm tool call error functionName=".concat(tool.function.name, " error=").concat(functoolsKit.getErrorMessage(error_1)), {
|
|
1852
1847
|
clientId: self.params.clientId,
|
|
@@ -1858,8 +1853,8 @@ var createToolCall = function (idx, tool, toolCalls, targetFn, self, isResqued)
|
|
|
1858
1853
|
((_c = targetFn.callbacks) === null || _c === void 0 ? void 0 : _c.onCallError) &&
|
|
1859
1854
|
((_d = targetFn.callbacks) === null || _d === void 0 ? void 0 : _d.onCallError(tool.id, self.params.clientId, self.params.agentName, tool.function.arguments, error_1));
|
|
1860
1855
|
self._toolErrorSubject.next(TOOL_ERROR_SYMBOL);
|
|
1861
|
-
return [3 /*break*/,
|
|
1862
|
-
case
|
|
1856
|
+
return [3 /*break*/, 3];
|
|
1857
|
+
case 3: return [2 /*return*/];
|
|
1863
1858
|
}
|
|
1864
1859
|
});
|
|
1865
1860
|
}); };
|
|
@@ -1938,7 +1933,7 @@ var RUN_FN = function (incoming, self) { return __awaiter(void 0, void 0, void 0
|
|
|
1938
1933
|
});
|
|
1939
1934
|
}); };
|
|
1940
1935
|
var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1941
|
-
var rawMessage, message, toolCalls_1, lastToolCallRef, isResqued_1,
|
|
1936
|
+
var rawMessage, message, toolCalls_1, lastToolCallRef, isResqued_1, _loop_1, idx, state_1, result, validation, result1;
|
|
1942
1937
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1943
1938
|
return __generator(this, function (_k) {
|
|
1944
1939
|
switch (_k.label) {
|
|
@@ -1979,27 +1974,6 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
1979
1974
|
_k.sent();
|
|
1980
1975
|
lastToolCallRef = Promise.resolve(null);
|
|
1981
1976
|
isResqued_1 = false;
|
|
1982
|
-
{
|
|
1983
|
-
unResque = self._modelResqueSubject.once(function () {
|
|
1984
|
-
isResqued_1 = false;
|
|
1985
|
-
});
|
|
1986
|
-
/**
|
|
1987
|
-
* Effective way of garbage collection cause the agent
|
|
1988
|
-
* will defenitely say something or will be recreated on change
|
|
1989
|
-
*
|
|
1990
|
-
* On navigation:
|
|
1991
|
-
*
|
|
1992
|
-
* 1. Agent.dispose
|
|
1993
|
-
* 2. Agent.createAgentRef
|
|
1994
|
-
* 3. Swarm.setAgentRef
|
|
1995
|
-
*
|
|
1996
|
-
* That means the _outputSubject being marked for GC so this
|
|
1997
|
-
* does not matter are we listening it or not
|
|
1998
|
-
*
|
|
1999
|
-
* @see /src/function/navigate/changeToAgent
|
|
2000
|
-
*/
|
|
2001
|
-
self._outputSubject.once(unResque);
|
|
2002
|
-
}
|
|
2003
1977
|
_loop_1 = function (idx) {
|
|
2004
1978
|
var tool, targetFn, result_1, result_2, statusAwaiter, isResolved, status, result_3;
|
|
2005
1979
|
return __generator(this, function (_l) {
|
|
@@ -2020,7 +1994,7 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
2020
1994
|
result_1 = _l.sent();
|
|
2021
1995
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2022
1996
|
self.params.logger.debug("ClientAgent agentName=".concat(self.params.agentName, " clientId=").concat(self.params.clientId, " execute end result=").concat(result_1));
|
|
2023
|
-
return [4 /*yield*/, self.
|
|
1997
|
+
return [4 /*yield*/, self._emitOutput(mode, result_1)];
|
|
2024
1998
|
case 2:
|
|
2025
1999
|
_l.sent();
|
|
2026
2000
|
return [2 /*return*/, { value: void 0 }];
|
|
@@ -2042,7 +2016,7 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
2042
2016
|
result_2 = _l.sent();
|
|
2043
2017
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2044
2018
|
self.params.logger.debug("ClientAgent agentName=".concat(self.params.agentName, " clientId=").concat(self.params.clientId, " execute end result=").concat(result_2));
|
|
2045
|
-
return [4 /*yield*/, self.
|
|
2019
|
+
return [4 /*yield*/, self._emitOutput(mode, result_2)];
|
|
2046
2020
|
case 6:
|
|
2047
2021
|
_l.sent();
|
|
2048
2022
|
return [2 /*return*/, { value: void 0 }];
|
|
@@ -2055,13 +2029,18 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
2055
2029
|
self._toolErrorSubject.toPromise(),
|
|
2056
2030
|
self._toolStopSubject.toPromise(),
|
|
2057
2031
|
self._outputSubject.toPromise(),
|
|
2058
|
-
self.
|
|
2032
|
+
self._resqueSubject.toPromise(),
|
|
2059
2033
|
]);
|
|
2060
2034
|
/**
|
|
2061
2035
|
* Do not await to avoid deadlock! The tool can send the message to other agents by emulating user messages
|
|
2062
2036
|
*/
|
|
2063
2037
|
{
|
|
2064
|
-
lastToolCallRef.then(function () {
|
|
2038
|
+
lastToolCallRef.then(function () {
|
|
2039
|
+
if (isResqued_1) {
|
|
2040
|
+
return;
|
|
2041
|
+
}
|
|
2042
|
+
return createToolCall(idx, tool, toolCalls_1, targetFn, self);
|
|
2043
|
+
});
|
|
2065
2044
|
lastToolCallRef = lastToolCallRef.then(function () { return statusAwaiter; });
|
|
2066
2045
|
}
|
|
2067
2046
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
@@ -2081,6 +2060,7 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
2081
2060
|
if (status === MODEL_RESQUE_SYMBOL) {
|
|
2082
2061
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2083
2062
|
self.params.logger.debug("ClientAgent agentName=".concat(self.params.agentName, " clientId=").concat(self.params.clientId, " functionName=").concat(tool.function.name, " the next tool execution stopped due to the model resque"));
|
|
2063
|
+
isResqued_1 = true;
|
|
2084
2064
|
((_f = self.params.callbacks) === null || _f === void 0 ? void 0 : _f.onAfterToolCalls) &&
|
|
2085
2065
|
self.params.callbacks.onAfterToolCalls(self.params.clientId, self.params.agentName, toolCalls_1);
|
|
2086
2066
|
return [2 /*return*/, { value: void 0 }];
|
|
@@ -2107,7 +2087,7 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
2107
2087
|
result_3 = _l.sent();
|
|
2108
2088
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2109
2089
|
self.params.logger.debug("ClientAgent agentName=".concat(self.params.agentName, " clientId=").concat(self.params.clientId, " execute end result=").concat(result_3));
|
|
2110
|
-
return [4 /*yield*/, self.
|
|
2090
|
+
return [4 /*yield*/, self._emitOutput(mode, result_3)];
|
|
2111
2091
|
case 10:
|
|
2112
2092
|
_l.sent();
|
|
2113
2093
|
return [2 /*return*/, { value: void 0 }];
|
|
@@ -2152,14 +2132,14 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
2152
2132
|
return [4 /*yield*/, self._resurrectModel(mode, "Invalid model output: ".concat(result))];
|
|
2153
2133
|
case 13:
|
|
2154
2134
|
result1 = _k.sent();
|
|
2155
|
-
return [4 /*yield*/, self.
|
|
2135
|
+
return [4 /*yield*/, self._emitOutput(mode, result1)];
|
|
2156
2136
|
case 14:
|
|
2157
2137
|
_k.sent();
|
|
2158
2138
|
return [2 /*return*/];
|
|
2159
2139
|
case 15:
|
|
2160
2140
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2161
2141
|
self.params.logger.debug("ClientAgent agentName=".concat(self.params.agentName, " clientId=").concat(self.params.clientId, " execute end result=").concat(result));
|
|
2162
|
-
return [4 /*yield*/, self.
|
|
2142
|
+
return [4 /*yield*/, self._emitOutput(mode, result)];
|
|
2163
2143
|
case 16:
|
|
2164
2144
|
_k.sent();
|
|
2165
2145
|
return [2 /*return*/];
|
|
@@ -2179,7 +2159,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
2179
2159
|
var _this = this;
|
|
2180
2160
|
this.params = params;
|
|
2181
2161
|
this._agentChangeSubject = new functoolsKit.Subject();
|
|
2182
|
-
this.
|
|
2162
|
+
this._resqueSubject = new functoolsKit.Subject();
|
|
2183
2163
|
this._toolErrorSubject = new functoolsKit.Subject();
|
|
2184
2164
|
this._toolStopSubject = new functoolsKit.Subject();
|
|
2185
2165
|
this._toolCommitSubject = new functoolsKit.Subject();
|
|
@@ -2218,7 +2198,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
2218
2198
|
* @returns {Promise<void>}
|
|
2219
2199
|
* @private
|
|
2220
2200
|
*/
|
|
2221
|
-
ClientAgent.prototype.
|
|
2201
|
+
ClientAgent.prototype._emitOutput = function (mode, rawResult) {
|
|
2222
2202
|
return __awaiter(this, void 0, void 0, function () {
|
|
2223
2203
|
var result, validation, rawResult_1, result_4;
|
|
2224
2204
|
return __generator(this, function (_a) {
|
|
@@ -2227,7 +2207,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
2227
2207
|
case 1:
|
|
2228
2208
|
result = _a.sent();
|
|
2229
2209
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2230
|
-
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, "
|
|
2210
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " _emitOutput"), { mode: mode, result: result, rawResult: rawResult });
|
|
2231
2211
|
validation = null;
|
|
2232
2212
|
return [4 /*yield*/, this.params.validate(result)];
|
|
2233
2213
|
case 2:
|
|
@@ -2375,14 +2355,14 @@ var ClientAgent = /** @class */ (function () {
|
|
|
2375
2355
|
})];
|
|
2376
2356
|
case 13:
|
|
2377
2357
|
_a.sent();
|
|
2378
|
-
return [4 /*yield*/, this.
|
|
2358
|
+
return [4 /*yield*/, this._resqueSubject.next(MODEL_RESQUE_SYMBOL)];
|
|
2379
2359
|
case 14:
|
|
2380
2360
|
_a.sent();
|
|
2381
2361
|
return [2 /*return*/, content];
|
|
2382
2362
|
case 15: return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
|
|
2383
2363
|
case 16:
|
|
2384
2364
|
_a.sent();
|
|
2385
|
-
return [4 /*yield*/, this.
|
|
2365
|
+
return [4 /*yield*/, this._resqueSubject.next(MODEL_RESQUE_SYMBOL)];
|
|
2386
2366
|
case 17:
|
|
2387
2367
|
_a.sent();
|
|
2388
2368
|
return [2 /*return*/, result];
|
package/build/index.mjs
CHANGED
|
@@ -1819,18 +1819,13 @@ var TOOL_NO_OUTPUT_WARNING = 15000;
|
|
|
1819
1819
|
var createPlaceholder = function () {
|
|
1820
1820
|
return GLOBAL_CONFIG.CC_EMPTY_OUTPUT_PLACEHOLDERS[Math.floor(Math.random() * GLOBAL_CONFIG.CC_EMPTY_OUTPUT_PLACEHOLDERS.length)];
|
|
1821
1821
|
};
|
|
1822
|
-
var createToolCall = function (idx, tool, toolCalls, targetFn, self
|
|
1822
|
+
var createToolCall = function (idx, tool, toolCalls, targetFn, self) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1823
1823
|
var error_1;
|
|
1824
1824
|
var _a, _b, _c, _d;
|
|
1825
1825
|
return __generator(this, function (_e) {
|
|
1826
1826
|
switch (_e.label) {
|
|
1827
1827
|
case 0:
|
|
1828
|
-
|
|
1829
|
-
return [2 /*return*/];
|
|
1830
|
-
}
|
|
1831
|
-
_e.label = 1;
|
|
1832
|
-
case 1:
|
|
1833
|
-
_e.trys.push([1, 3, , 4]);
|
|
1828
|
+
_e.trys.push([0, 2, , 3]);
|
|
1834
1829
|
return [4 /*yield*/, targetFn.call({
|
|
1835
1830
|
toolId: tool.id,
|
|
1836
1831
|
clientId: self.params.clientId,
|
|
@@ -1839,12 +1834,12 @@ var createToolCall = function (idx, tool, toolCalls, targetFn, self, isResqued)
|
|
|
1839
1834
|
isLast: idx === toolCalls.length - 1,
|
|
1840
1835
|
toolCalls: toolCalls,
|
|
1841
1836
|
})];
|
|
1842
|
-
case
|
|
1837
|
+
case 1:
|
|
1843
1838
|
_e.sent();
|
|
1844
1839
|
((_a = targetFn.callbacks) === null || _a === void 0 ? void 0 : _a.onAfterCall) &&
|
|
1845
1840
|
((_b = targetFn.callbacks) === null || _b === void 0 ? void 0 : _b.onAfterCall(tool.id, self.params.clientId, self.params.agentName, tool.function.arguments));
|
|
1846
|
-
return [3 /*break*/,
|
|
1847
|
-
case
|
|
1841
|
+
return [3 /*break*/, 3];
|
|
1842
|
+
case 2:
|
|
1848
1843
|
error_1 = _e.sent();
|
|
1849
1844
|
console.error("agent-swarm tool call error functionName=".concat(tool.function.name, " error=").concat(getErrorMessage(error_1)), {
|
|
1850
1845
|
clientId: self.params.clientId,
|
|
@@ -1856,8 +1851,8 @@ var createToolCall = function (idx, tool, toolCalls, targetFn, self, isResqued)
|
|
|
1856
1851
|
((_c = targetFn.callbacks) === null || _c === void 0 ? void 0 : _c.onCallError) &&
|
|
1857
1852
|
((_d = targetFn.callbacks) === null || _d === void 0 ? void 0 : _d.onCallError(tool.id, self.params.clientId, self.params.agentName, tool.function.arguments, error_1));
|
|
1858
1853
|
self._toolErrorSubject.next(TOOL_ERROR_SYMBOL);
|
|
1859
|
-
return [3 /*break*/,
|
|
1860
|
-
case
|
|
1854
|
+
return [3 /*break*/, 3];
|
|
1855
|
+
case 3: return [2 /*return*/];
|
|
1861
1856
|
}
|
|
1862
1857
|
});
|
|
1863
1858
|
}); };
|
|
@@ -1936,7 +1931,7 @@ var RUN_FN = function (incoming, self) { return __awaiter(void 0, void 0, void 0
|
|
|
1936
1931
|
});
|
|
1937
1932
|
}); };
|
|
1938
1933
|
var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1939
|
-
var rawMessage, message, toolCalls_1, lastToolCallRef, isResqued_1,
|
|
1934
|
+
var rawMessage, message, toolCalls_1, lastToolCallRef, isResqued_1, _loop_1, idx, state_1, result, validation, result1;
|
|
1940
1935
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1941
1936
|
return __generator(this, function (_k) {
|
|
1942
1937
|
switch (_k.label) {
|
|
@@ -1977,27 +1972,6 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
1977
1972
|
_k.sent();
|
|
1978
1973
|
lastToolCallRef = Promise.resolve(null);
|
|
1979
1974
|
isResqued_1 = false;
|
|
1980
|
-
{
|
|
1981
|
-
unResque = self._modelResqueSubject.once(function () {
|
|
1982
|
-
isResqued_1 = false;
|
|
1983
|
-
});
|
|
1984
|
-
/**
|
|
1985
|
-
* Effective way of garbage collection cause the agent
|
|
1986
|
-
* will defenitely say something or will be recreated on change
|
|
1987
|
-
*
|
|
1988
|
-
* On navigation:
|
|
1989
|
-
*
|
|
1990
|
-
* 1. Agent.dispose
|
|
1991
|
-
* 2. Agent.createAgentRef
|
|
1992
|
-
* 3. Swarm.setAgentRef
|
|
1993
|
-
*
|
|
1994
|
-
* That means the _outputSubject being marked for GC so this
|
|
1995
|
-
* does not matter are we listening it or not
|
|
1996
|
-
*
|
|
1997
|
-
* @see /src/function/navigate/changeToAgent
|
|
1998
|
-
*/
|
|
1999
|
-
self._outputSubject.once(unResque);
|
|
2000
|
-
}
|
|
2001
1975
|
_loop_1 = function (idx) {
|
|
2002
1976
|
var tool, targetFn, result_1, result_2, statusAwaiter, isResolved, status, result_3;
|
|
2003
1977
|
return __generator(this, function (_l) {
|
|
@@ -2018,7 +1992,7 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
2018
1992
|
result_1 = _l.sent();
|
|
2019
1993
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2020
1994
|
self.params.logger.debug("ClientAgent agentName=".concat(self.params.agentName, " clientId=").concat(self.params.clientId, " execute end result=").concat(result_1));
|
|
2021
|
-
return [4 /*yield*/, self.
|
|
1995
|
+
return [4 /*yield*/, self._emitOutput(mode, result_1)];
|
|
2022
1996
|
case 2:
|
|
2023
1997
|
_l.sent();
|
|
2024
1998
|
return [2 /*return*/, { value: void 0 }];
|
|
@@ -2040,7 +2014,7 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
2040
2014
|
result_2 = _l.sent();
|
|
2041
2015
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2042
2016
|
self.params.logger.debug("ClientAgent agentName=".concat(self.params.agentName, " clientId=").concat(self.params.clientId, " execute end result=").concat(result_2));
|
|
2043
|
-
return [4 /*yield*/, self.
|
|
2017
|
+
return [4 /*yield*/, self._emitOutput(mode, result_2)];
|
|
2044
2018
|
case 6:
|
|
2045
2019
|
_l.sent();
|
|
2046
2020
|
return [2 /*return*/, { value: void 0 }];
|
|
@@ -2053,13 +2027,18 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
2053
2027
|
self._toolErrorSubject.toPromise(),
|
|
2054
2028
|
self._toolStopSubject.toPromise(),
|
|
2055
2029
|
self._outputSubject.toPromise(),
|
|
2056
|
-
self.
|
|
2030
|
+
self._resqueSubject.toPromise(),
|
|
2057
2031
|
]);
|
|
2058
2032
|
/**
|
|
2059
2033
|
* Do not await to avoid deadlock! The tool can send the message to other agents by emulating user messages
|
|
2060
2034
|
*/
|
|
2061
2035
|
{
|
|
2062
|
-
lastToolCallRef.then(function () {
|
|
2036
|
+
lastToolCallRef.then(function () {
|
|
2037
|
+
if (isResqued_1) {
|
|
2038
|
+
return;
|
|
2039
|
+
}
|
|
2040
|
+
return createToolCall(idx, tool, toolCalls_1, targetFn, self);
|
|
2041
|
+
});
|
|
2063
2042
|
lastToolCallRef = lastToolCallRef.then(function () { return statusAwaiter; });
|
|
2064
2043
|
}
|
|
2065
2044
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
@@ -2079,6 +2058,7 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
2079
2058
|
if (status === MODEL_RESQUE_SYMBOL) {
|
|
2080
2059
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2081
2060
|
self.params.logger.debug("ClientAgent agentName=".concat(self.params.agentName, " clientId=").concat(self.params.clientId, " functionName=").concat(tool.function.name, " the next tool execution stopped due to the model resque"));
|
|
2061
|
+
isResqued_1 = true;
|
|
2082
2062
|
((_f = self.params.callbacks) === null || _f === void 0 ? void 0 : _f.onAfterToolCalls) &&
|
|
2083
2063
|
self.params.callbacks.onAfterToolCalls(self.params.clientId, self.params.agentName, toolCalls_1);
|
|
2084
2064
|
return [2 /*return*/, { value: void 0 }];
|
|
@@ -2105,7 +2085,7 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
2105
2085
|
result_3 = _l.sent();
|
|
2106
2086
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2107
2087
|
self.params.logger.debug("ClientAgent agentName=".concat(self.params.agentName, " clientId=").concat(self.params.clientId, " execute end result=").concat(result_3));
|
|
2108
|
-
return [4 /*yield*/, self.
|
|
2088
|
+
return [4 /*yield*/, self._emitOutput(mode, result_3)];
|
|
2109
2089
|
case 10:
|
|
2110
2090
|
_l.sent();
|
|
2111
2091
|
return [2 /*return*/, { value: void 0 }];
|
|
@@ -2150,14 +2130,14 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
2150
2130
|
return [4 /*yield*/, self._resurrectModel(mode, "Invalid model output: ".concat(result))];
|
|
2151
2131
|
case 13:
|
|
2152
2132
|
result1 = _k.sent();
|
|
2153
|
-
return [4 /*yield*/, self.
|
|
2133
|
+
return [4 /*yield*/, self._emitOutput(mode, result1)];
|
|
2154
2134
|
case 14:
|
|
2155
2135
|
_k.sent();
|
|
2156
2136
|
return [2 /*return*/];
|
|
2157
2137
|
case 15:
|
|
2158
2138
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2159
2139
|
self.params.logger.debug("ClientAgent agentName=".concat(self.params.agentName, " clientId=").concat(self.params.clientId, " execute end result=").concat(result));
|
|
2160
|
-
return [4 /*yield*/, self.
|
|
2140
|
+
return [4 /*yield*/, self._emitOutput(mode, result)];
|
|
2161
2141
|
case 16:
|
|
2162
2142
|
_k.sent();
|
|
2163
2143
|
return [2 /*return*/];
|
|
@@ -2177,7 +2157,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
2177
2157
|
var _this = this;
|
|
2178
2158
|
this.params = params;
|
|
2179
2159
|
this._agentChangeSubject = new Subject();
|
|
2180
|
-
this.
|
|
2160
|
+
this._resqueSubject = new Subject();
|
|
2181
2161
|
this._toolErrorSubject = new Subject();
|
|
2182
2162
|
this._toolStopSubject = new Subject();
|
|
2183
2163
|
this._toolCommitSubject = new Subject();
|
|
@@ -2216,7 +2196,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
2216
2196
|
* @returns {Promise<void>}
|
|
2217
2197
|
* @private
|
|
2218
2198
|
*/
|
|
2219
|
-
ClientAgent.prototype.
|
|
2199
|
+
ClientAgent.prototype._emitOutput = function (mode, rawResult) {
|
|
2220
2200
|
return __awaiter(this, void 0, void 0, function () {
|
|
2221
2201
|
var result, validation, rawResult_1, result_4;
|
|
2222
2202
|
return __generator(this, function (_a) {
|
|
@@ -2225,7 +2205,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
2225
2205
|
case 1:
|
|
2226
2206
|
result = _a.sent();
|
|
2227
2207
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2228
|
-
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, "
|
|
2208
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " _emitOutput"), { mode: mode, result: result, rawResult: rawResult });
|
|
2229
2209
|
validation = null;
|
|
2230
2210
|
return [4 /*yield*/, this.params.validate(result)];
|
|
2231
2211
|
case 2:
|
|
@@ -2373,14 +2353,14 @@ var ClientAgent = /** @class */ (function () {
|
|
|
2373
2353
|
})];
|
|
2374
2354
|
case 13:
|
|
2375
2355
|
_a.sent();
|
|
2376
|
-
return [4 /*yield*/, this.
|
|
2356
|
+
return [4 /*yield*/, this._resqueSubject.next(MODEL_RESQUE_SYMBOL)];
|
|
2377
2357
|
case 14:
|
|
2378
2358
|
_a.sent();
|
|
2379
2359
|
return [2 /*return*/, content];
|
|
2380
2360
|
case 15: return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
|
|
2381
2361
|
case 16:
|
|
2382
2362
|
_a.sent();
|
|
2383
|
-
return [4 /*yield*/, this.
|
|
2363
|
+
return [4 /*yield*/, this._resqueSubject.next(MODEL_RESQUE_SYMBOL)];
|
|
2384
2364
|
case 17:
|
|
2385
2365
|
_a.sent();
|
|
2386
2366
|
return [2 /*return*/, result];
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1817,7 +1817,7 @@ declare const TOOL_STOP_SYMBOL: unique symbol;
|
|
|
1817
1817
|
declare class ClientAgent implements IAgent {
|
|
1818
1818
|
readonly params: IAgentParams;
|
|
1819
1819
|
readonly _agentChangeSubject: Subject<typeof AGENT_CHANGE_SYMBOL>;
|
|
1820
|
-
readonly
|
|
1820
|
+
readonly _resqueSubject: Subject<typeof MODEL_RESQUE_SYMBOL>;
|
|
1821
1821
|
readonly _toolErrorSubject: Subject<typeof TOOL_ERROR_SYMBOL>;
|
|
1822
1822
|
readonly _toolStopSubject: Subject<typeof TOOL_STOP_SYMBOL>;
|
|
1823
1823
|
readonly _toolCommitSubject: Subject<void>;
|
|
@@ -1833,7 +1833,7 @@ declare class ClientAgent implements IAgent {
|
|
|
1833
1833
|
* @returns {Promise<void>}
|
|
1834
1834
|
* @private
|
|
1835
1835
|
*/
|
|
1836
|
-
|
|
1836
|
+
_emitOutput(mode: ExecutionMode, rawResult: string): Promise<void>;
|
|
1837
1837
|
/**
|
|
1838
1838
|
* Resurrects the model based on the given reason.
|
|
1839
1839
|
* @param {string} [reason] - The reason for resurrecting the model.
|