agent-swarm-kit 1.0.149 → 1.0.151
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 +39 -34
- package/build/index.mjs +39 -34
- package/package.json +1 -1
- package/types.d.ts +6 -1
package/build/index.cjs
CHANGED
|
@@ -1546,7 +1546,8 @@ var CC_AGENT_HISTORY_FILTER = function (agentName) {
|
|
|
1546
1546
|
};
|
|
1547
1547
|
var CC_AGENT_OUTPUT_TRANSFORM = removeXmlTags;
|
|
1548
1548
|
var CC_KEEP_MESSAGES = 15;
|
|
1549
|
-
var
|
|
1549
|
+
var CC_MAX_TOOL_CALLS = 1;
|
|
1550
|
+
var CC_AGENT_MAP_TOOLS = function (tools) { return tools; };
|
|
1550
1551
|
var CC_GET_AGENT_HISTORY_ADAPTER = function () { return HistoryAdapter; };
|
|
1551
1552
|
var CC_GET_CLIENT_LOGGER_ADAPTER = function () { return LoggerAdapter; };
|
|
1552
1553
|
var CC_AGENT_OUTPUT_MAP = function (message) { return message; };
|
|
@@ -1559,7 +1560,9 @@ var CC_LOGGER_ENABLE_LOG = true;
|
|
|
1559
1560
|
var CC_LOGGER_ENABLE_CONSOLE = false;
|
|
1560
1561
|
var CC_RESQUE_STRATEGY;
|
|
1561
1562
|
var CC_NAME_TO_TITLE = nameToTitle;
|
|
1562
|
-
var CC_FN_PLANTUML = function () {
|
|
1563
|
+
var CC_FN_PLANTUML = function () {
|
|
1564
|
+
return Promise.resolve("");
|
|
1565
|
+
};
|
|
1563
1566
|
var CC_PROCESS_UUID = functoolsKit.randomString();
|
|
1564
1567
|
var CC_BANHAMMER_PLACEHOLDER = "You have been banned! To continue conversation, please contact the administrator.";
|
|
1565
1568
|
var GLOBAL_CONFIG = {
|
|
@@ -1567,7 +1570,8 @@ var GLOBAL_CONFIG = {
|
|
|
1567
1570
|
CC_TOOL_CALL_EXCEPTION_RECOMPLETE_PROMPT: CC_TOOL_CALL_EXCEPTION_RECOMPLETE_PROMPT,
|
|
1568
1571
|
CC_EMPTY_OUTPUT_PLACEHOLDERS: CC_EMPTY_OUTPUT_PLACEHOLDERS,
|
|
1569
1572
|
CC_KEEP_MESSAGES: CC_KEEP_MESSAGES,
|
|
1570
|
-
|
|
1573
|
+
CC_MAX_TOOL_CALLS: CC_MAX_TOOL_CALLS,
|
|
1574
|
+
CC_AGENT_MAP_TOOLS: CC_AGENT_MAP_TOOLS,
|
|
1571
1575
|
CC_GET_AGENT_HISTORY_ADAPTER: CC_GET_AGENT_HISTORY_ADAPTER,
|
|
1572
1576
|
CC_GET_CLIENT_LOGGER_ADAPTER: CC_GET_CLIENT_LOGGER_ADAPTER,
|
|
1573
1577
|
CC_SWARM_AGENT_CHANGED: CC_SWARM_AGENT_CHANGED,
|
|
@@ -1957,21 +1961,22 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
1957
1961
|
return [4 /*yield*/, self.params.map(rawMessage, self.params.clientId, self.params.agentName)];
|
|
1958
1962
|
case 3:
|
|
1959
1963
|
message = _g.sent();
|
|
1960
|
-
if (!message.tool_calls) return [3 /*break*/,
|
|
1964
|
+
if (!message.tool_calls) return [3 /*break*/, 10];
|
|
1961
1965
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1962
1966
|
self.params.logger.debug("ClientAgent agentName=".concat(self.params.agentName, " clientId=").concat(self.params.clientId, " tool call begin"));
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
});
|
|
1971
|
-
})
|
|
1972
|
-
.slice(0, GLOBAL_CONFIG.CC_MAX_TOOLS);
|
|
1973
|
-
return [4 /*yield*/, self.params.history.push(__assign(__assign({}, message), { agentName: self.params.agentName }))];
|
|
1967
|
+
return [4 /*yield*/, self.params.mapToolCalls(message.tool_calls.map(function (call) {
|
|
1968
|
+
var _a, _b;
|
|
1969
|
+
return ({
|
|
1970
|
+
function: call.function,
|
|
1971
|
+
id: (_a = call.id) !== null && _a !== void 0 ? _a : functoolsKit.randomString(),
|
|
1972
|
+
type: (_b = call.type) !== null && _b !== void 0 ? _b : "function",
|
|
1973
|
+
});
|
|
1974
|
+
}), self.params.clientId, self.params.agentName)];
|
|
1974
1975
|
case 4:
|
|
1976
|
+
toolCalls_1 = _g.sent();
|
|
1977
|
+
toolCalls_1 = toolCalls_1.slice(0, self.params.maxToolCalls);
|
|
1978
|
+
return [4 /*yield*/, self.params.history.push(__assign(__assign({}, message), { agentName: self.params.agentName }))];
|
|
1979
|
+
case 5:
|
|
1975
1980
|
_g.sent();
|
|
1976
1981
|
lastToolStatusRef = Promise.resolve(null);
|
|
1977
1982
|
_a = __read(functoolsKit.createAwaiter(), 2), runAwaiter_1 = _a[0], run = _a[1].resolve;
|
|
@@ -2108,19 +2113,19 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
2108
2113
|
});
|
|
2109
2114
|
};
|
|
2110
2115
|
idx = 0;
|
|
2111
|
-
_g.label =
|
|
2112
|
-
case 5:
|
|
2113
|
-
if (!(idx !== toolCalls_1.length)) return [3 /*break*/, 8];
|
|
2114
|
-
return [5 /*yield**/, _loop_1(idx)];
|
|
2116
|
+
_g.label = 6;
|
|
2115
2117
|
case 6:
|
|
2118
|
+
if (!(idx !== toolCalls_1.length)) return [3 /*break*/, 9];
|
|
2119
|
+
return [5 /*yield**/, _loop_1(idx)];
|
|
2120
|
+
case 7:
|
|
2116
2121
|
state_1 = _g.sent();
|
|
2117
2122
|
if (typeof state_1 === "object")
|
|
2118
2123
|
return [2 /*return*/, state_1.value];
|
|
2119
|
-
_g.label =
|
|
2120
|
-
case 7:
|
|
2121
|
-
idx++;
|
|
2122
|
-
return [3 /*break*/, 5];
|
|
2124
|
+
_g.label = 8;
|
|
2123
2125
|
case 8:
|
|
2126
|
+
idx++;
|
|
2127
|
+
return [3 /*break*/, 6];
|
|
2128
|
+
case 9:
|
|
2124
2129
|
lastToolStatusRef.finally(function () {
|
|
2125
2130
|
var _a;
|
|
2126
2131
|
((_a = self.params.callbacks) === null || _a === void 0 ? void 0 : _a.onAfterToolCalls) &&
|
|
@@ -2128,35 +2133,35 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
2128
2133
|
});
|
|
2129
2134
|
run(true);
|
|
2130
2135
|
return [2 /*return*/];
|
|
2131
|
-
case
|
|
2136
|
+
case 10:
|
|
2132
2137
|
if (!message.tool_calls) {
|
|
2133
2138
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2134
2139
|
self.params.logger.debug("ClientAgent agentName=".concat(self.params.agentName, " clientId=").concat(self.params.clientId, " execute no tool calls detected"));
|
|
2135
2140
|
}
|
|
2136
2141
|
return [4 /*yield*/, self.params.transform(message.content, self.params.clientId, self.params.agentName)];
|
|
2137
|
-
case
|
|
2142
|
+
case 11:
|
|
2138
2143
|
result = _g.sent();
|
|
2139
2144
|
return [4 /*yield*/, self.params.history.push(__assign(__assign({}, message), { agentName: self.params.agentName }))];
|
|
2140
|
-
case
|
|
2145
|
+
case 12:
|
|
2141
2146
|
_g.sent();
|
|
2142
2147
|
validation = null;
|
|
2143
2148
|
return [4 /*yield*/, self.params.validate(result)];
|
|
2144
|
-
case
|
|
2145
|
-
if (!(validation = _g.sent())) return [3 /*break*/,
|
|
2149
|
+
case 13:
|
|
2150
|
+
if (!(validation = _g.sent())) return [3 /*break*/, 16];
|
|
2146
2151
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2147
2152
|
self.params.logger.debug("ClientAgent agentName=".concat(self.params.agentName, " clientId=").concat(self.params.clientId, " execute invalid tool call detected: ").concat(validation), { result: result });
|
|
2148
2153
|
return [4 /*yield*/, self._resurrectModel(mode, "Invalid model output: ".concat(result))];
|
|
2149
|
-
case
|
|
2154
|
+
case 14:
|
|
2150
2155
|
result1 = _g.sent();
|
|
2151
2156
|
return [4 /*yield*/, self._emitOutput(mode, result1)];
|
|
2152
|
-
case
|
|
2157
|
+
case 15:
|
|
2153
2158
|
_g.sent();
|
|
2154
2159
|
return [2 /*return*/];
|
|
2155
|
-
case
|
|
2160
|
+
case 16:
|
|
2156
2161
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2157
2162
|
self.params.logger.debug("ClientAgent agentName=".concat(self.params.agentName, " clientId=").concat(self.params.clientId, " execute end result=").concat(result));
|
|
2158
2163
|
return [4 /*yield*/, self._emitOutput(mode, result)];
|
|
2159
|
-
case
|
|
2164
|
+
case 17:
|
|
2160
2165
|
_g.sent();
|
|
2161
2166
|
return [2 /*return*/];
|
|
2162
2167
|
}
|
|
@@ -2786,7 +2791,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
2786
2791
|
var _b = __read(_a, 2), clientId = _b[0], agentName = _b[1];
|
|
2787
2792
|
return "".concat(clientId, "-").concat(agentName);
|
|
2788
2793
|
}, function (clientId, agentName) {
|
|
2789
|
-
var _a = _this.agentSchemaService.get(agentName), prompt = _a.prompt, system = _a.system, tools = _a.tools, _b = _a.transform, transform = _b === void 0 ? GLOBAL_CONFIG.CC_AGENT_OUTPUT_TRANSFORM : _b, _c = _a.map, map = _c === void 0 ? GLOBAL_CONFIG.CC_AGENT_OUTPUT_MAP : _c, callbacks = _a.callbacks, storages = _a.storages, states = _a.states, completionName = _a.completion,
|
|
2794
|
+
var _a = _this.agentSchemaService.get(agentName), prompt = _a.prompt, system = _a.system, tools = _a.tools, _b = _a.transform, transform = _b === void 0 ? GLOBAL_CONFIG.CC_AGENT_OUTPUT_TRANSFORM : _b, _c = _a.map, map = _c === void 0 ? GLOBAL_CONFIG.CC_AGENT_OUTPUT_MAP : _c, _d = _a.maxToolCalls, maxToolCalls = _d === void 0 ? GLOBAL_CONFIG.CC_MAX_TOOL_CALLS : _d, _e = _a.mapToolCalls, mapToolCalls = _e === void 0 ? GLOBAL_CONFIG.CC_AGENT_MAP_TOOLS : _e, callbacks = _a.callbacks, storages = _a.storages, states = _a.states, completionName = _a.completion, _f = _a.validate, validate = _f === void 0 ? validateDefault : _f;
|
|
2790
2795
|
var completion = _this.completionSchemaService.get(completionName);
|
|
2791
2796
|
_this.sessionValidationService.addAgentUsage(clientId, agentName);
|
|
2792
2797
|
storages === null || storages === void 0 ? void 0 : storages.forEach(function (storageName) {
|
|
@@ -2799,7 +2804,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
2799
2804
|
.getStateRef(clientId, stateName)
|
|
2800
2805
|
.waitForInit();
|
|
2801
2806
|
});
|
|
2802
|
-
return new ClientAgent(__assign({ clientId: clientId, agentName: agentName, validate: validate, logger: _this.loggerService, bus: _this.busService, history: _this.historyConnectionService.getHistory(clientId, agentName), prompt: prompt, system: system, transform: transform, map: map, tools: tools === null || tools === void 0 ? void 0 : tools.map(_this.toolSchemaService.get), completion: completion }, callbacks));
|
|
2807
|
+
return new ClientAgent(__assign({ clientId: clientId, agentName: agentName, validate: validate, maxToolCalls: maxToolCalls, mapToolCalls: mapToolCalls, logger: _this.loggerService, bus: _this.busService, history: _this.historyConnectionService.getHistory(clientId, agentName), prompt: prompt, system: system, transform: transform, map: map, tools: tools === null || tools === void 0 ? void 0 : tools.map(_this.toolSchemaService.get), completion: completion }, callbacks));
|
|
2803
2808
|
});
|
|
2804
2809
|
/**
|
|
2805
2810
|
* Executes an input command.
|
package/build/index.mjs
CHANGED
|
@@ -1544,7 +1544,8 @@ var CC_AGENT_HISTORY_FILTER = function (agentName) {
|
|
|
1544
1544
|
};
|
|
1545
1545
|
var CC_AGENT_OUTPUT_TRANSFORM = removeXmlTags;
|
|
1546
1546
|
var CC_KEEP_MESSAGES = 15;
|
|
1547
|
-
var
|
|
1547
|
+
var CC_MAX_TOOL_CALLS = 1;
|
|
1548
|
+
var CC_AGENT_MAP_TOOLS = function (tools) { return tools; };
|
|
1548
1549
|
var CC_GET_AGENT_HISTORY_ADAPTER = function () { return HistoryAdapter; };
|
|
1549
1550
|
var CC_GET_CLIENT_LOGGER_ADAPTER = function () { return LoggerAdapter; };
|
|
1550
1551
|
var CC_AGENT_OUTPUT_MAP = function (message) { return message; };
|
|
@@ -1557,7 +1558,9 @@ var CC_LOGGER_ENABLE_LOG = true;
|
|
|
1557
1558
|
var CC_LOGGER_ENABLE_CONSOLE = false;
|
|
1558
1559
|
var CC_RESQUE_STRATEGY;
|
|
1559
1560
|
var CC_NAME_TO_TITLE = nameToTitle;
|
|
1560
|
-
var CC_FN_PLANTUML = function () {
|
|
1561
|
+
var CC_FN_PLANTUML = function () {
|
|
1562
|
+
return Promise.resolve("");
|
|
1563
|
+
};
|
|
1561
1564
|
var CC_PROCESS_UUID = randomString();
|
|
1562
1565
|
var CC_BANHAMMER_PLACEHOLDER = "You have been banned! To continue conversation, please contact the administrator.";
|
|
1563
1566
|
var GLOBAL_CONFIG = {
|
|
@@ -1565,7 +1568,8 @@ var GLOBAL_CONFIG = {
|
|
|
1565
1568
|
CC_TOOL_CALL_EXCEPTION_RECOMPLETE_PROMPT: CC_TOOL_CALL_EXCEPTION_RECOMPLETE_PROMPT,
|
|
1566
1569
|
CC_EMPTY_OUTPUT_PLACEHOLDERS: CC_EMPTY_OUTPUT_PLACEHOLDERS,
|
|
1567
1570
|
CC_KEEP_MESSAGES: CC_KEEP_MESSAGES,
|
|
1568
|
-
|
|
1571
|
+
CC_MAX_TOOL_CALLS: CC_MAX_TOOL_CALLS,
|
|
1572
|
+
CC_AGENT_MAP_TOOLS: CC_AGENT_MAP_TOOLS,
|
|
1569
1573
|
CC_GET_AGENT_HISTORY_ADAPTER: CC_GET_AGENT_HISTORY_ADAPTER,
|
|
1570
1574
|
CC_GET_CLIENT_LOGGER_ADAPTER: CC_GET_CLIENT_LOGGER_ADAPTER,
|
|
1571
1575
|
CC_SWARM_AGENT_CHANGED: CC_SWARM_AGENT_CHANGED,
|
|
@@ -1955,21 +1959,22 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
1955
1959
|
return [4 /*yield*/, self.params.map(rawMessage, self.params.clientId, self.params.agentName)];
|
|
1956
1960
|
case 3:
|
|
1957
1961
|
message = _g.sent();
|
|
1958
|
-
if (!message.tool_calls) return [3 /*break*/,
|
|
1962
|
+
if (!message.tool_calls) return [3 /*break*/, 10];
|
|
1959
1963
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
1960
1964
|
self.params.logger.debug("ClientAgent agentName=".concat(self.params.agentName, " clientId=").concat(self.params.clientId, " tool call begin"));
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
});
|
|
1969
|
-
})
|
|
1970
|
-
.slice(0, GLOBAL_CONFIG.CC_MAX_TOOLS);
|
|
1971
|
-
return [4 /*yield*/, self.params.history.push(__assign(__assign({}, message), { agentName: self.params.agentName }))];
|
|
1965
|
+
return [4 /*yield*/, self.params.mapToolCalls(message.tool_calls.map(function (call) {
|
|
1966
|
+
var _a, _b;
|
|
1967
|
+
return ({
|
|
1968
|
+
function: call.function,
|
|
1969
|
+
id: (_a = call.id) !== null && _a !== void 0 ? _a : randomString(),
|
|
1970
|
+
type: (_b = call.type) !== null && _b !== void 0 ? _b : "function",
|
|
1971
|
+
});
|
|
1972
|
+
}), self.params.clientId, self.params.agentName)];
|
|
1972
1973
|
case 4:
|
|
1974
|
+
toolCalls_1 = _g.sent();
|
|
1975
|
+
toolCalls_1 = toolCalls_1.slice(0, self.params.maxToolCalls);
|
|
1976
|
+
return [4 /*yield*/, self.params.history.push(__assign(__assign({}, message), { agentName: self.params.agentName }))];
|
|
1977
|
+
case 5:
|
|
1973
1978
|
_g.sent();
|
|
1974
1979
|
lastToolStatusRef = Promise.resolve(null);
|
|
1975
1980
|
_a = __read(createAwaiter(), 2), runAwaiter_1 = _a[0], run = _a[1].resolve;
|
|
@@ -2106,19 +2111,19 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
2106
2111
|
});
|
|
2107
2112
|
};
|
|
2108
2113
|
idx = 0;
|
|
2109
|
-
_g.label =
|
|
2110
|
-
case 5:
|
|
2111
|
-
if (!(idx !== toolCalls_1.length)) return [3 /*break*/, 8];
|
|
2112
|
-
return [5 /*yield**/, _loop_1(idx)];
|
|
2114
|
+
_g.label = 6;
|
|
2113
2115
|
case 6:
|
|
2116
|
+
if (!(idx !== toolCalls_1.length)) return [3 /*break*/, 9];
|
|
2117
|
+
return [5 /*yield**/, _loop_1(idx)];
|
|
2118
|
+
case 7:
|
|
2114
2119
|
state_1 = _g.sent();
|
|
2115
2120
|
if (typeof state_1 === "object")
|
|
2116
2121
|
return [2 /*return*/, state_1.value];
|
|
2117
|
-
_g.label =
|
|
2118
|
-
case 7:
|
|
2119
|
-
idx++;
|
|
2120
|
-
return [3 /*break*/, 5];
|
|
2122
|
+
_g.label = 8;
|
|
2121
2123
|
case 8:
|
|
2124
|
+
idx++;
|
|
2125
|
+
return [3 /*break*/, 6];
|
|
2126
|
+
case 9:
|
|
2122
2127
|
lastToolStatusRef.finally(function () {
|
|
2123
2128
|
var _a;
|
|
2124
2129
|
((_a = self.params.callbacks) === null || _a === void 0 ? void 0 : _a.onAfterToolCalls) &&
|
|
@@ -2126,35 +2131,35 @@ var EXECUTE_FN = function (incoming, mode, self) { return __awaiter(void 0, void
|
|
|
2126
2131
|
});
|
|
2127
2132
|
run(true);
|
|
2128
2133
|
return [2 /*return*/];
|
|
2129
|
-
case
|
|
2134
|
+
case 10:
|
|
2130
2135
|
if (!message.tool_calls) {
|
|
2131
2136
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2132
2137
|
self.params.logger.debug("ClientAgent agentName=".concat(self.params.agentName, " clientId=").concat(self.params.clientId, " execute no tool calls detected"));
|
|
2133
2138
|
}
|
|
2134
2139
|
return [4 /*yield*/, self.params.transform(message.content, self.params.clientId, self.params.agentName)];
|
|
2135
|
-
case
|
|
2140
|
+
case 11:
|
|
2136
2141
|
result = _g.sent();
|
|
2137
2142
|
return [4 /*yield*/, self.params.history.push(__assign(__assign({}, message), { agentName: self.params.agentName }))];
|
|
2138
|
-
case
|
|
2143
|
+
case 12:
|
|
2139
2144
|
_g.sent();
|
|
2140
2145
|
validation = null;
|
|
2141
2146
|
return [4 /*yield*/, self.params.validate(result)];
|
|
2142
|
-
case
|
|
2143
|
-
if (!(validation = _g.sent())) return [3 /*break*/,
|
|
2147
|
+
case 13:
|
|
2148
|
+
if (!(validation = _g.sent())) return [3 /*break*/, 16];
|
|
2144
2149
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2145
2150
|
self.params.logger.debug("ClientAgent agentName=".concat(self.params.agentName, " clientId=").concat(self.params.clientId, " execute invalid tool call detected: ").concat(validation), { result: result });
|
|
2146
2151
|
return [4 /*yield*/, self._resurrectModel(mode, "Invalid model output: ".concat(result))];
|
|
2147
|
-
case
|
|
2152
|
+
case 14:
|
|
2148
2153
|
result1 = _g.sent();
|
|
2149
2154
|
return [4 /*yield*/, self._emitOutput(mode, result1)];
|
|
2150
|
-
case
|
|
2155
|
+
case 15:
|
|
2151
2156
|
_g.sent();
|
|
2152
2157
|
return [2 /*return*/];
|
|
2153
|
-
case
|
|
2158
|
+
case 16:
|
|
2154
2159
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2155
2160
|
self.params.logger.debug("ClientAgent agentName=".concat(self.params.agentName, " clientId=").concat(self.params.clientId, " execute end result=").concat(result));
|
|
2156
2161
|
return [4 /*yield*/, self._emitOutput(mode, result)];
|
|
2157
|
-
case
|
|
2162
|
+
case 17:
|
|
2158
2163
|
_g.sent();
|
|
2159
2164
|
return [2 /*return*/];
|
|
2160
2165
|
}
|
|
@@ -2784,7 +2789,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
2784
2789
|
var _b = __read(_a, 2), clientId = _b[0], agentName = _b[1];
|
|
2785
2790
|
return "".concat(clientId, "-").concat(agentName);
|
|
2786
2791
|
}, function (clientId, agentName) {
|
|
2787
|
-
var _a = _this.agentSchemaService.get(agentName), prompt = _a.prompt, system = _a.system, tools = _a.tools, _b = _a.transform, transform = _b === void 0 ? GLOBAL_CONFIG.CC_AGENT_OUTPUT_TRANSFORM : _b, _c = _a.map, map = _c === void 0 ? GLOBAL_CONFIG.CC_AGENT_OUTPUT_MAP : _c, callbacks = _a.callbacks, storages = _a.storages, states = _a.states, completionName = _a.completion,
|
|
2792
|
+
var _a = _this.agentSchemaService.get(agentName), prompt = _a.prompt, system = _a.system, tools = _a.tools, _b = _a.transform, transform = _b === void 0 ? GLOBAL_CONFIG.CC_AGENT_OUTPUT_TRANSFORM : _b, _c = _a.map, map = _c === void 0 ? GLOBAL_CONFIG.CC_AGENT_OUTPUT_MAP : _c, _d = _a.maxToolCalls, maxToolCalls = _d === void 0 ? GLOBAL_CONFIG.CC_MAX_TOOL_CALLS : _d, _e = _a.mapToolCalls, mapToolCalls = _e === void 0 ? GLOBAL_CONFIG.CC_AGENT_MAP_TOOLS : _e, callbacks = _a.callbacks, storages = _a.storages, states = _a.states, completionName = _a.completion, _f = _a.validate, validate = _f === void 0 ? validateDefault : _f;
|
|
2788
2793
|
var completion = _this.completionSchemaService.get(completionName);
|
|
2789
2794
|
_this.sessionValidationService.addAgentUsage(clientId, agentName);
|
|
2790
2795
|
storages === null || storages === void 0 ? void 0 : storages.forEach(function (storageName) {
|
|
@@ -2797,7 +2802,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
2797
2802
|
.getStateRef(clientId, stateName)
|
|
2798
2803
|
.waitForInit();
|
|
2799
2804
|
});
|
|
2800
|
-
return new ClientAgent(__assign({ clientId: clientId, agentName: agentName, validate: validate, logger: _this.loggerService, bus: _this.busService, history: _this.historyConnectionService.getHistory(clientId, agentName), prompt: prompt, system: system, transform: transform, map: map, tools: tools === null || tools === void 0 ? void 0 : tools.map(_this.toolSchemaService.get), completion: completion }, callbacks));
|
|
2805
|
+
return new ClientAgent(__assign({ clientId: clientId, agentName: agentName, validate: validate, maxToolCalls: maxToolCalls, mapToolCalls: mapToolCalls, logger: _this.loggerService, bus: _this.busService, history: _this.historyConnectionService.getHistory(clientId, agentName), prompt: prompt, system: system, transform: transform, map: map, tools: tools === null || tools === void 0 ? void 0 : tools.map(_this.toolSchemaService.get), completion: completion }, callbacks));
|
|
2801
2806
|
});
|
|
2802
2807
|
/**
|
|
2803
2808
|
* Executes an input command.
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1645,6 +1645,10 @@ interface IAgentSchemaCallbacks {
|
|
|
1645
1645
|
* Interface representing the schema for an agent.
|
|
1646
1646
|
*/
|
|
1647
1647
|
interface IAgentSchema {
|
|
1648
|
+
/** The map function to filter unwanted tool calls */
|
|
1649
|
+
mapToolCalls?: (tool: IToolCall[], clientId: string, agentName: AgentName) => IToolCall[] | Promise<IToolCall[]>;
|
|
1650
|
+
/** The maximum quantity of tool calls per complete */
|
|
1651
|
+
maxToolCalls?: number;
|
|
1648
1652
|
/** The description for documentation */
|
|
1649
1653
|
docDescription?: string;
|
|
1650
1654
|
/** The name of the agent. */
|
|
@@ -5342,7 +5346,8 @@ declare const GLOBAL_CONFIG: {
|
|
|
5342
5346
|
CC_TOOL_CALL_EXCEPTION_RECOMPLETE_PROMPT: string;
|
|
5343
5347
|
CC_EMPTY_OUTPUT_PLACEHOLDERS: string[];
|
|
5344
5348
|
CC_KEEP_MESSAGES: number;
|
|
5345
|
-
|
|
5349
|
+
CC_MAX_TOOL_CALLS: number;
|
|
5350
|
+
CC_AGENT_MAP_TOOLS: (tool: IToolCall[], clientId: string, agentName: AgentName) => IToolCall[] | Promise<IToolCall[]>;
|
|
5346
5351
|
CC_GET_AGENT_HISTORY_ADAPTER: (clientId: string, agentName: AgentName) => IHistoryAdapter;
|
|
5347
5352
|
CC_GET_CLIENT_LOGGER_ADAPTER: () => ILoggerAdapter;
|
|
5348
5353
|
CC_SWARM_AGENT_CHANGED: (clientId: string, agentName: AgentName, swarmName: SwarmName) => Promise<void>;
|