agent-swarm-kit 1.0.40 → 1.0.42
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 +101 -78
- package/build/index.mjs +101 -78
- package/package.json +1 -1
- package/types.d.ts +5 -1
package/build/index.cjs
CHANGED
|
@@ -356,7 +356,10 @@ var validateDefault = function (output) { return __awaiter(void 0, void 0, void
|
|
|
356
356
|
}); };
|
|
357
357
|
|
|
358
358
|
var removeXmlTags = function (input) {
|
|
359
|
-
return input
|
|
359
|
+
return input
|
|
360
|
+
.replace(/<[^>]+>[\s\S]*?<\/[^>]+>/g, '')
|
|
361
|
+
.replace(/\n\s*\n/g, '\n')
|
|
362
|
+
.trim();
|
|
360
363
|
};
|
|
361
364
|
|
|
362
365
|
/**
|
|
@@ -396,24 +399,25 @@ var CC_SWARM_DEFAULT_AGENT = function (_a, _b, defaultAgent_1) { return __awaite
|
|
|
396
399
|
}); };
|
|
397
400
|
var CC_AGENT_DEFAULT_VALIDATION = validateDefault;
|
|
398
401
|
var CC_AGENT_DISALLOWED_TAGS = ["tool_call", "toolcall", "tool"];
|
|
399
|
-
var CC_AGENT_DISALLOWED_SYMBOLS = [
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
}; };
|
|
402
|
+
var CC_AGENT_DISALLOWED_SYMBOLS = ["{", "}"];
|
|
403
|
+
var CC_AGENT_HISTORY_FILTER = function (agentName) {
|
|
404
|
+
return function (message) {
|
|
405
|
+
var isOk = true;
|
|
406
|
+
if (message.role === "tool") {
|
|
407
|
+
isOk = isOk && message.agentName === agentName;
|
|
408
|
+
}
|
|
409
|
+
if (message.tool_calls) {
|
|
410
|
+
isOk = isOk && message.agentName === agentName;
|
|
411
|
+
}
|
|
412
|
+
return isOk;
|
|
413
|
+
};
|
|
414
|
+
};
|
|
413
415
|
var CC_AGENT_OUTPUT_TRANSFORM = removeXmlTags;
|
|
414
416
|
var CC_KEEP_MESSAGES = 5;
|
|
415
417
|
var CC_GET_AGENT_HISTORY = function () { return new functoolsKit.PubsubArrayAdapter(); };
|
|
418
|
+
var CC_AGENT_OUTPUT_MAP = function (message) { return message; };
|
|
416
419
|
var CC_AGENT_SEPARATE_HISTORY = false;
|
|
420
|
+
var CC_AGENT_SYSTEM_PROMPT = undefined;
|
|
417
421
|
var GLOBAL_CONFIG = {
|
|
418
422
|
CC_TOOL_CALL_EXCEPTION_PROMPT: CC_TOOL_CALL_EXCEPTION_PROMPT,
|
|
419
423
|
CC_EMPTY_OUTPUT_PLACEHOLDERS: CC_EMPTY_OUTPUT_PLACEHOLDERS,
|
|
@@ -424,6 +428,8 @@ var GLOBAL_CONFIG = {
|
|
|
424
428
|
CC_AGENT_DEFAULT_VALIDATION: CC_AGENT_DEFAULT_VALIDATION,
|
|
425
429
|
CC_AGENT_HISTORY_FILTER: CC_AGENT_HISTORY_FILTER,
|
|
426
430
|
CC_AGENT_OUTPUT_TRANSFORM: CC_AGENT_OUTPUT_TRANSFORM,
|
|
431
|
+
CC_AGENT_OUTPUT_MAP: CC_AGENT_OUTPUT_MAP,
|
|
432
|
+
CC_AGENT_SYSTEM_PROMPT: CC_AGENT_SYSTEM_PROMPT,
|
|
427
433
|
CC_AGENT_SEPARATE_HISTORY: CC_AGENT_SEPARATE_HISTORY,
|
|
428
434
|
CC_AGENT_DISALLOWED_TAGS: CC_AGENT_DISALLOWED_TAGS,
|
|
429
435
|
CC_AGENT_DISALLOWED_SYMBOLS: CC_AGENT_DISALLOWED_SYMBOLS,
|
|
@@ -459,33 +465,36 @@ var ClientAgent = /** @class */ (function () {
|
|
|
459
465
|
var result, validation, rawResult_1, result_1;
|
|
460
466
|
return __generator(this, function (_a) {
|
|
461
467
|
switch (_a.label) {
|
|
462
|
-
case 0:
|
|
463
|
-
|
|
468
|
+
case 0: return [4 /*yield*/, this.params.transform(rawResult, this.params.clientId, this.params.agentName)];
|
|
469
|
+
case 1:
|
|
470
|
+
result = _a.sent();
|
|
464
471
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " _emitOuput"), { mode: mode, result: result, rawResult: rawResult });
|
|
465
472
|
validation = null;
|
|
466
473
|
return [4 /*yield*/, this.params.validate(result)];
|
|
467
|
-
case 1:
|
|
468
|
-
if (!(validation = _a.sent())) return [3 /*break*/, 5];
|
|
469
|
-
return [4 /*yield*/, this._resurrectModel(mode, validation)];
|
|
470
474
|
case 2:
|
|
475
|
+
if (!(validation = _a.sent())) return [3 /*break*/, 7];
|
|
476
|
+
return [4 /*yield*/, this._resurrectModel(mode, validation)];
|
|
477
|
+
case 3:
|
|
471
478
|
rawResult_1 = _a.sent();
|
|
472
|
-
|
|
479
|
+
return [4 /*yield*/, this.params.transform(rawResult_1, this.params.clientId, this.params.agentName)];
|
|
480
|
+
case 4:
|
|
481
|
+
result_1 = _a.sent();
|
|
473
482
|
return [4 /*yield*/, this.params.validate(result_1)];
|
|
474
|
-
case
|
|
483
|
+
case 5:
|
|
475
484
|
if ((validation = _a.sent())) {
|
|
476
485
|
throw new Error("agent-swarm-kit ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " model ressurect failed: ").concat(validation));
|
|
477
486
|
}
|
|
478
487
|
this.params.onOutput &&
|
|
479
488
|
this.params.onOutput(this.params.clientId, this.params.agentName, result_1);
|
|
480
489
|
return [4 /*yield*/, this._outputSubject.next(result_1)];
|
|
481
|
-
case
|
|
490
|
+
case 6:
|
|
482
491
|
_a.sent();
|
|
483
492
|
return [2 /*return*/];
|
|
484
|
-
case
|
|
493
|
+
case 7:
|
|
485
494
|
this.params.onOutput &&
|
|
486
495
|
this.params.onOutput(this.params.clientId, this.params.agentName, result);
|
|
487
496
|
return [4 /*yield*/, this._outputSubject.next(result)];
|
|
488
|
-
case
|
|
497
|
+
case 8:
|
|
489
498
|
_a.sent();
|
|
490
499
|
return [2 /*return*/];
|
|
491
500
|
}
|
|
@@ -498,7 +507,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
498
507
|
* @private
|
|
499
508
|
*/
|
|
500
509
|
this._resurrectModel = function (mode, reason) { return __awaiter(_this, void 0, void 0, function () {
|
|
501
|
-
var message, result, validation, content;
|
|
510
|
+
var rawMessage, message, result, validation, content;
|
|
502
511
|
return __generator(this, function (_a) {
|
|
503
512
|
switch (_a.label) {
|
|
504
513
|
case 0:
|
|
@@ -523,12 +532,15 @@ var ClientAgent = /** @class */ (function () {
|
|
|
523
532
|
_a.sent();
|
|
524
533
|
return [4 /*yield*/, this.getCompletion(mode)];
|
|
525
534
|
case 3:
|
|
535
|
+
rawMessage = _a.sent();
|
|
536
|
+
return [4 /*yield*/, this.params.map(rawMessage, this.params.clientId, this.params.agentName)];
|
|
537
|
+
case 4:
|
|
526
538
|
message = _a.sent();
|
|
527
539
|
result = message.content;
|
|
528
540
|
validation = null;
|
|
529
541
|
return [4 /*yield*/, this.params.validate(result)];
|
|
530
|
-
case
|
|
531
|
-
if (!(validation = _a.sent())) return [3 /*break*/,
|
|
542
|
+
case 5:
|
|
543
|
+
if (!(validation = _a.sent())) return [3 /*break*/, 7];
|
|
532
544
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " _resurrectModel validation error: ").concat(validation));
|
|
533
545
|
content = getPlaceholder();
|
|
534
546
|
return [4 /*yield*/, this.params.history.push({
|
|
@@ -537,11 +549,11 @@ var ClientAgent = /** @class */ (function () {
|
|
|
537
549
|
mode: "tool",
|
|
538
550
|
content: content,
|
|
539
551
|
})];
|
|
540
|
-
case
|
|
552
|
+
case 6:
|
|
541
553
|
_a.sent();
|
|
542
554
|
return [2 /*return*/, content];
|
|
543
|
-
case
|
|
544
|
-
case
|
|
555
|
+
case 7: return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
|
|
556
|
+
case 8:
|
|
545
557
|
_a.sent();
|
|
546
558
|
return [2 /*return*/, result];
|
|
547
559
|
}
|
|
@@ -698,7 +710,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
698
710
|
* @returns {Promise<void>}
|
|
699
711
|
*/
|
|
700
712
|
this.execute = functoolsKit.queued(function (incoming, mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
701
|
-
var message, toolCalls, _loop_1, this_1, toolCalls_1, toolCalls_1_1, tool, state_1, e_1_1, result, validation, result1;
|
|
713
|
+
var rawMessage, message, toolCalls, _loop_1, this_1, toolCalls_1, toolCalls_1_1, tool, state_1, e_1_1, result, validation, result1;
|
|
702
714
|
var e_1, _a;
|
|
703
715
|
var _this = this;
|
|
704
716
|
var _b, _c, _d, _e, _f, _g;
|
|
@@ -718,8 +730,11 @@ var ClientAgent = /** @class */ (function () {
|
|
|
718
730
|
_h.sent();
|
|
719
731
|
return [4 /*yield*/, this.getCompletion(mode)];
|
|
720
732
|
case 2:
|
|
733
|
+
rawMessage = _h.sent();
|
|
734
|
+
return [4 /*yield*/, this.params.map(rawMessage, this.params.clientId, this.params.agentName)];
|
|
735
|
+
case 3:
|
|
721
736
|
message = _h.sent();
|
|
722
|
-
if (!message.tool_calls) return [3 /*break*/,
|
|
737
|
+
if (!message.tool_calls) return [3 /*break*/, 13];
|
|
723
738
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " tool call begin"));
|
|
724
739
|
toolCalls = message.tool_calls.map(function (call) {
|
|
725
740
|
var _a, _b;
|
|
@@ -730,7 +745,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
730
745
|
});
|
|
731
746
|
});
|
|
732
747
|
return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
|
|
733
|
-
case
|
|
748
|
+
case 4:
|
|
734
749
|
_h.sent();
|
|
735
750
|
_loop_1 = function (tool) {
|
|
736
751
|
var targetFn, result_2, result_3;
|
|
@@ -787,62 +802,62 @@ var ClientAgent = /** @class */ (function () {
|
|
|
787
802
|
});
|
|
788
803
|
};
|
|
789
804
|
this_1 = this;
|
|
790
|
-
_h.label = 4;
|
|
791
|
-
case 4:
|
|
792
|
-
_h.trys.push([4, 9, 10, 11]);
|
|
793
|
-
toolCalls_1 = __values(toolCalls), toolCalls_1_1 = toolCalls_1.next();
|
|
794
805
|
_h.label = 5;
|
|
795
806
|
case 5:
|
|
796
|
-
|
|
807
|
+
_h.trys.push([5, 10, 11, 12]);
|
|
808
|
+
toolCalls_1 = __values(toolCalls), toolCalls_1_1 = toolCalls_1.next();
|
|
809
|
+
_h.label = 6;
|
|
810
|
+
case 6:
|
|
811
|
+
if (!!toolCalls_1_1.done) return [3 /*break*/, 9];
|
|
797
812
|
tool = toolCalls_1_1.value;
|
|
798
813
|
return [5 /*yield**/, _loop_1(tool)];
|
|
799
|
-
case
|
|
814
|
+
case 7:
|
|
800
815
|
state_1 = _h.sent();
|
|
801
816
|
if (typeof state_1 === "object")
|
|
802
817
|
return [2 /*return*/, state_1.value];
|
|
803
|
-
_h.label =
|
|
804
|
-
case
|
|
818
|
+
_h.label = 8;
|
|
819
|
+
case 8:
|
|
805
820
|
toolCalls_1_1 = toolCalls_1.next();
|
|
806
|
-
return [3 /*break*/,
|
|
807
|
-
case
|
|
808
|
-
case
|
|
821
|
+
return [3 /*break*/, 6];
|
|
822
|
+
case 9: return [3 /*break*/, 12];
|
|
823
|
+
case 10:
|
|
809
824
|
e_1_1 = _h.sent();
|
|
810
825
|
e_1 = { error: e_1_1 };
|
|
811
|
-
return [3 /*break*/,
|
|
812
|
-
case
|
|
826
|
+
return [3 /*break*/, 12];
|
|
827
|
+
case 11:
|
|
813
828
|
try {
|
|
814
829
|
if (toolCalls_1_1 && !toolCalls_1_1.done && (_a = toolCalls_1.return)) _a.call(toolCalls_1);
|
|
815
830
|
}
|
|
816
831
|
finally { if (e_1) throw e_1.error; }
|
|
817
832
|
return [7 /*endfinally*/];
|
|
818
|
-
case
|
|
833
|
+
case 12:
|
|
819
834
|
((_g = this.params.callbacks) === null || _g === void 0 ? void 0 : _g.onAfterToolCalls) &&
|
|
820
835
|
this.params.callbacks.onAfterToolCalls(this.params.clientId, this.params.agentName, toolCalls);
|
|
821
836
|
return [2 /*return*/];
|
|
822
|
-
case
|
|
837
|
+
case 13:
|
|
823
838
|
if (!message.tool_calls) {
|
|
824
839
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute no tool calls detected"));
|
|
825
840
|
}
|
|
826
841
|
result = message.content;
|
|
827
842
|
return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
|
|
828
|
-
case
|
|
843
|
+
case 14:
|
|
829
844
|
_h.sent();
|
|
830
845
|
validation = null;
|
|
831
846
|
return [4 /*yield*/, this.params.validate(result)];
|
|
832
|
-
case
|
|
833
|
-
if (!(validation = _h.sent())) return [3 /*break*/,
|
|
847
|
+
case 15:
|
|
848
|
+
if (!(validation = _h.sent())) return [3 /*break*/, 18];
|
|
834
849
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute invalid tool call detected: ").concat(validation), { result: result });
|
|
835
850
|
return [4 /*yield*/, this._resurrectModel(mode, "Invalid model output: ".concat(result))];
|
|
836
|
-
case
|
|
851
|
+
case 16:
|
|
837
852
|
result1 = _h.sent();
|
|
838
853
|
return [4 /*yield*/, this._emitOuput(mode, result1)];
|
|
839
|
-
case
|
|
854
|
+
case 17:
|
|
840
855
|
_h.sent();
|
|
841
856
|
return [2 /*return*/];
|
|
842
|
-
case
|
|
857
|
+
case 18:
|
|
843
858
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute end result=").concat(result));
|
|
844
859
|
return [4 /*yield*/, this._emitOuput(mode, result)];
|
|
845
|
-
case
|
|
860
|
+
case 19:
|
|
846
861
|
_h.sent();
|
|
847
862
|
return [2 /*return*/];
|
|
848
863
|
}
|
|
@@ -892,10 +907,10 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
892
907
|
var _b = __read(_a, 2), clientId = _b[0], agentName = _b[1];
|
|
893
908
|
return "".concat(clientId, "-").concat(agentName);
|
|
894
909
|
}, function (clientId, agentName) {
|
|
895
|
-
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, callbacks = _a.callbacks, completionName = _a.completion,
|
|
910
|
+
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, completionName = _a.completion, _d = _a.validate, validate = _d === void 0 ? validateDefault : _d;
|
|
896
911
|
var completion = _this.completionSchemaService.get(completionName);
|
|
897
912
|
_this.sessionValidationService.addAgentUsage(clientId, agentName);
|
|
898
|
-
return new ClientAgent(__assign({ clientId: clientId, agentName: agentName, validate: validate, logger: _this.loggerService, history: _this.historyConnectionService.getHistory(clientId, agentName), prompt: prompt, system: system, transform: transform, tools: tools === null || tools === void 0 ? void 0 : tools.map(_this.toolSchemaService.get), completion: completion }, callbacks));
|
|
913
|
+
return new ClientAgent(__assign({ clientId: clientId, agentName: agentName, validate: validate, logger: _this.loggerService, 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));
|
|
899
914
|
});
|
|
900
915
|
/**
|
|
901
916
|
* Executes an input command.
|
|
@@ -1116,20 +1131,21 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1116
1131
|
var commonMessagesRaw, systemMessagesRaw, _a, _b, _c, content, message, e_2_1, systemMessages, commonMessages, promptMessages;
|
|
1117
1132
|
var _this = this;
|
|
1118
1133
|
var _d, e_2, _e, _f;
|
|
1119
|
-
|
|
1120
|
-
|
|
1134
|
+
var _g;
|
|
1135
|
+
return __generator(this, function (_h) {
|
|
1136
|
+
switch (_h.label) {
|
|
1121
1137
|
case 0:
|
|
1122
1138
|
this.params.logger.debug("ClientHistory agentName=".concat(this.params.agentName, " toArrayForAgent"));
|
|
1123
1139
|
commonMessagesRaw = [];
|
|
1124
1140
|
systemMessagesRaw = [];
|
|
1125
|
-
|
|
1141
|
+
_h.label = 1;
|
|
1126
1142
|
case 1:
|
|
1127
|
-
|
|
1143
|
+
_h.trys.push([1, 6, 7, 12]);
|
|
1128
1144
|
_a = true, _b = __asyncValues(this.params.items);
|
|
1129
|
-
|
|
1145
|
+
_h.label = 2;
|
|
1130
1146
|
case 2: return [4 /*yield*/, _b.next()];
|
|
1131
1147
|
case 3:
|
|
1132
|
-
if (!(_c =
|
|
1148
|
+
if (!(_c = _h.sent(), _d = _c.done, !_d)) return [3 /*break*/, 5];
|
|
1133
1149
|
_f = _c.value;
|
|
1134
1150
|
_a = false;
|
|
1135
1151
|
content = _f;
|
|
@@ -1150,22 +1166,22 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1150
1166
|
else {
|
|
1151
1167
|
commonMessagesRaw.push(message);
|
|
1152
1168
|
}
|
|
1153
|
-
|
|
1169
|
+
_h.label = 4;
|
|
1154
1170
|
case 4:
|
|
1155
1171
|
_a = true;
|
|
1156
1172
|
return [3 /*break*/, 2];
|
|
1157
1173
|
case 5: return [3 /*break*/, 12];
|
|
1158
1174
|
case 6:
|
|
1159
|
-
e_2_1 =
|
|
1175
|
+
e_2_1 = _h.sent();
|
|
1160
1176
|
e_2 = { error: e_2_1 };
|
|
1161
1177
|
return [3 /*break*/, 12];
|
|
1162
1178
|
case 7:
|
|
1163
|
-
|
|
1179
|
+
_h.trys.push([7, , 10, 11]);
|
|
1164
1180
|
if (!(!_a && !_d && (_e = _b.return))) return [3 /*break*/, 9];
|
|
1165
1181
|
return [4 /*yield*/, _e.call(_b)];
|
|
1166
1182
|
case 8:
|
|
1167
|
-
|
|
1168
|
-
|
|
1183
|
+
_h.sent();
|
|
1184
|
+
_h.label = 9;
|
|
1169
1185
|
case 9: return [3 /*break*/, 11];
|
|
1170
1186
|
case 10:
|
|
1171
1187
|
if (e_2) throw e_2.error;
|
|
@@ -1183,19 +1199,26 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1183
1199
|
{
|
|
1184
1200
|
promptMessages.push({
|
|
1185
1201
|
agentName: this.params.agentName,
|
|
1186
|
-
mode:
|
|
1202
|
+
mode: "tool",
|
|
1187
1203
|
content: prompt,
|
|
1188
1204
|
role: "system",
|
|
1189
1205
|
});
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
role: "system",
|
|
1197
|
-
});
|
|
1206
|
+
(_g = GLOBAL_CONFIG.CC_AGENT_SYSTEM_PROMPT) === null || _g === void 0 ? void 0 : _g.forEach(function (content) {
|
|
1207
|
+
return promptMessages.push({
|
|
1208
|
+
agentName: _this.params.agentName,
|
|
1209
|
+
mode: "tool",
|
|
1210
|
+
content: content,
|
|
1211
|
+
role: "system",
|
|
1198
1212
|
});
|
|
1213
|
+
});
|
|
1214
|
+
system === null || system === void 0 ? void 0 : system.forEach(function (content) {
|
|
1215
|
+
return promptMessages.push({
|
|
1216
|
+
agentName: _this.params.agentName,
|
|
1217
|
+
mode: "tool",
|
|
1218
|
+
content: content,
|
|
1219
|
+
role: "system",
|
|
1220
|
+
});
|
|
1221
|
+
});
|
|
1199
1222
|
}
|
|
1200
1223
|
return [2 /*return*/, __spreadArray(__spreadArray(__spreadArray([], __read(promptMessages), false), __read(systemMessages), false), __read(commonMessages), false)];
|
|
1201
1224
|
}
|
package/build/index.mjs
CHANGED
|
@@ -354,7 +354,10 @@ var validateDefault = function (output) { return __awaiter(void 0, void 0, void
|
|
|
354
354
|
}); };
|
|
355
355
|
|
|
356
356
|
var removeXmlTags = function (input) {
|
|
357
|
-
return input
|
|
357
|
+
return input
|
|
358
|
+
.replace(/<[^>]+>[\s\S]*?<\/[^>]+>/g, '')
|
|
359
|
+
.replace(/\n\s*\n/g, '\n')
|
|
360
|
+
.trim();
|
|
358
361
|
};
|
|
359
362
|
|
|
360
363
|
/**
|
|
@@ -394,24 +397,25 @@ var CC_SWARM_DEFAULT_AGENT = function (_a, _b, defaultAgent_1) { return __awaite
|
|
|
394
397
|
}); };
|
|
395
398
|
var CC_AGENT_DEFAULT_VALIDATION = validateDefault;
|
|
396
399
|
var CC_AGENT_DISALLOWED_TAGS = ["tool_call", "toolcall", "tool"];
|
|
397
|
-
var CC_AGENT_DISALLOWED_SYMBOLS = [
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
}; };
|
|
400
|
+
var CC_AGENT_DISALLOWED_SYMBOLS = ["{", "}"];
|
|
401
|
+
var CC_AGENT_HISTORY_FILTER = function (agentName) {
|
|
402
|
+
return function (message) {
|
|
403
|
+
var isOk = true;
|
|
404
|
+
if (message.role === "tool") {
|
|
405
|
+
isOk = isOk && message.agentName === agentName;
|
|
406
|
+
}
|
|
407
|
+
if (message.tool_calls) {
|
|
408
|
+
isOk = isOk && message.agentName === agentName;
|
|
409
|
+
}
|
|
410
|
+
return isOk;
|
|
411
|
+
};
|
|
412
|
+
};
|
|
411
413
|
var CC_AGENT_OUTPUT_TRANSFORM = removeXmlTags;
|
|
412
414
|
var CC_KEEP_MESSAGES = 5;
|
|
413
415
|
var CC_GET_AGENT_HISTORY = function () { return new PubsubArrayAdapter(); };
|
|
416
|
+
var CC_AGENT_OUTPUT_MAP = function (message) { return message; };
|
|
414
417
|
var CC_AGENT_SEPARATE_HISTORY = false;
|
|
418
|
+
var CC_AGENT_SYSTEM_PROMPT = undefined;
|
|
415
419
|
var GLOBAL_CONFIG = {
|
|
416
420
|
CC_TOOL_CALL_EXCEPTION_PROMPT: CC_TOOL_CALL_EXCEPTION_PROMPT,
|
|
417
421
|
CC_EMPTY_OUTPUT_PLACEHOLDERS: CC_EMPTY_OUTPUT_PLACEHOLDERS,
|
|
@@ -422,6 +426,8 @@ var GLOBAL_CONFIG = {
|
|
|
422
426
|
CC_AGENT_DEFAULT_VALIDATION: CC_AGENT_DEFAULT_VALIDATION,
|
|
423
427
|
CC_AGENT_HISTORY_FILTER: CC_AGENT_HISTORY_FILTER,
|
|
424
428
|
CC_AGENT_OUTPUT_TRANSFORM: CC_AGENT_OUTPUT_TRANSFORM,
|
|
429
|
+
CC_AGENT_OUTPUT_MAP: CC_AGENT_OUTPUT_MAP,
|
|
430
|
+
CC_AGENT_SYSTEM_PROMPT: CC_AGENT_SYSTEM_PROMPT,
|
|
425
431
|
CC_AGENT_SEPARATE_HISTORY: CC_AGENT_SEPARATE_HISTORY,
|
|
426
432
|
CC_AGENT_DISALLOWED_TAGS: CC_AGENT_DISALLOWED_TAGS,
|
|
427
433
|
CC_AGENT_DISALLOWED_SYMBOLS: CC_AGENT_DISALLOWED_SYMBOLS,
|
|
@@ -457,33 +463,36 @@ var ClientAgent = /** @class */ (function () {
|
|
|
457
463
|
var result, validation, rawResult_1, result_1;
|
|
458
464
|
return __generator(this, function (_a) {
|
|
459
465
|
switch (_a.label) {
|
|
460
|
-
case 0:
|
|
461
|
-
|
|
466
|
+
case 0: return [4 /*yield*/, this.params.transform(rawResult, this.params.clientId, this.params.agentName)];
|
|
467
|
+
case 1:
|
|
468
|
+
result = _a.sent();
|
|
462
469
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " _emitOuput"), { mode: mode, result: result, rawResult: rawResult });
|
|
463
470
|
validation = null;
|
|
464
471
|
return [4 /*yield*/, this.params.validate(result)];
|
|
465
|
-
case 1:
|
|
466
|
-
if (!(validation = _a.sent())) return [3 /*break*/, 5];
|
|
467
|
-
return [4 /*yield*/, this._resurrectModel(mode, validation)];
|
|
468
472
|
case 2:
|
|
473
|
+
if (!(validation = _a.sent())) return [3 /*break*/, 7];
|
|
474
|
+
return [4 /*yield*/, this._resurrectModel(mode, validation)];
|
|
475
|
+
case 3:
|
|
469
476
|
rawResult_1 = _a.sent();
|
|
470
|
-
|
|
477
|
+
return [4 /*yield*/, this.params.transform(rawResult_1, this.params.clientId, this.params.agentName)];
|
|
478
|
+
case 4:
|
|
479
|
+
result_1 = _a.sent();
|
|
471
480
|
return [4 /*yield*/, this.params.validate(result_1)];
|
|
472
|
-
case
|
|
481
|
+
case 5:
|
|
473
482
|
if ((validation = _a.sent())) {
|
|
474
483
|
throw new Error("agent-swarm-kit ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " model ressurect failed: ").concat(validation));
|
|
475
484
|
}
|
|
476
485
|
this.params.onOutput &&
|
|
477
486
|
this.params.onOutput(this.params.clientId, this.params.agentName, result_1);
|
|
478
487
|
return [4 /*yield*/, this._outputSubject.next(result_1)];
|
|
479
|
-
case
|
|
488
|
+
case 6:
|
|
480
489
|
_a.sent();
|
|
481
490
|
return [2 /*return*/];
|
|
482
|
-
case
|
|
491
|
+
case 7:
|
|
483
492
|
this.params.onOutput &&
|
|
484
493
|
this.params.onOutput(this.params.clientId, this.params.agentName, result);
|
|
485
494
|
return [4 /*yield*/, this._outputSubject.next(result)];
|
|
486
|
-
case
|
|
495
|
+
case 8:
|
|
487
496
|
_a.sent();
|
|
488
497
|
return [2 /*return*/];
|
|
489
498
|
}
|
|
@@ -496,7 +505,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
496
505
|
* @private
|
|
497
506
|
*/
|
|
498
507
|
this._resurrectModel = function (mode, reason) { return __awaiter(_this, void 0, void 0, function () {
|
|
499
|
-
var message, result, validation, content;
|
|
508
|
+
var rawMessage, message, result, validation, content;
|
|
500
509
|
return __generator(this, function (_a) {
|
|
501
510
|
switch (_a.label) {
|
|
502
511
|
case 0:
|
|
@@ -521,12 +530,15 @@ var ClientAgent = /** @class */ (function () {
|
|
|
521
530
|
_a.sent();
|
|
522
531
|
return [4 /*yield*/, this.getCompletion(mode)];
|
|
523
532
|
case 3:
|
|
533
|
+
rawMessage = _a.sent();
|
|
534
|
+
return [4 /*yield*/, this.params.map(rawMessage, this.params.clientId, this.params.agentName)];
|
|
535
|
+
case 4:
|
|
524
536
|
message = _a.sent();
|
|
525
537
|
result = message.content;
|
|
526
538
|
validation = null;
|
|
527
539
|
return [4 /*yield*/, this.params.validate(result)];
|
|
528
|
-
case
|
|
529
|
-
if (!(validation = _a.sent())) return [3 /*break*/,
|
|
540
|
+
case 5:
|
|
541
|
+
if (!(validation = _a.sent())) return [3 /*break*/, 7];
|
|
530
542
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " _resurrectModel validation error: ").concat(validation));
|
|
531
543
|
content = getPlaceholder();
|
|
532
544
|
return [4 /*yield*/, this.params.history.push({
|
|
@@ -535,11 +547,11 @@ var ClientAgent = /** @class */ (function () {
|
|
|
535
547
|
mode: "tool",
|
|
536
548
|
content: content,
|
|
537
549
|
})];
|
|
538
|
-
case
|
|
550
|
+
case 6:
|
|
539
551
|
_a.sent();
|
|
540
552
|
return [2 /*return*/, content];
|
|
541
|
-
case
|
|
542
|
-
case
|
|
553
|
+
case 7: return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
|
|
554
|
+
case 8:
|
|
543
555
|
_a.sent();
|
|
544
556
|
return [2 /*return*/, result];
|
|
545
557
|
}
|
|
@@ -696,7 +708,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
696
708
|
* @returns {Promise<void>}
|
|
697
709
|
*/
|
|
698
710
|
this.execute = queued(function (incoming, mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
699
|
-
var message, toolCalls, _loop_1, this_1, toolCalls_1, toolCalls_1_1, tool, state_1, e_1_1, result, validation, result1;
|
|
711
|
+
var rawMessage, message, toolCalls, _loop_1, this_1, toolCalls_1, toolCalls_1_1, tool, state_1, e_1_1, result, validation, result1;
|
|
700
712
|
var e_1, _a;
|
|
701
713
|
var _this = this;
|
|
702
714
|
var _b, _c, _d, _e, _f, _g;
|
|
@@ -716,8 +728,11 @@ var ClientAgent = /** @class */ (function () {
|
|
|
716
728
|
_h.sent();
|
|
717
729
|
return [4 /*yield*/, this.getCompletion(mode)];
|
|
718
730
|
case 2:
|
|
731
|
+
rawMessage = _h.sent();
|
|
732
|
+
return [4 /*yield*/, this.params.map(rawMessage, this.params.clientId, this.params.agentName)];
|
|
733
|
+
case 3:
|
|
719
734
|
message = _h.sent();
|
|
720
|
-
if (!message.tool_calls) return [3 /*break*/,
|
|
735
|
+
if (!message.tool_calls) return [3 /*break*/, 13];
|
|
721
736
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " tool call begin"));
|
|
722
737
|
toolCalls = message.tool_calls.map(function (call) {
|
|
723
738
|
var _a, _b;
|
|
@@ -728,7 +743,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
728
743
|
});
|
|
729
744
|
});
|
|
730
745
|
return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
|
|
731
|
-
case
|
|
746
|
+
case 4:
|
|
732
747
|
_h.sent();
|
|
733
748
|
_loop_1 = function (tool) {
|
|
734
749
|
var targetFn, result_2, result_3;
|
|
@@ -785,62 +800,62 @@ var ClientAgent = /** @class */ (function () {
|
|
|
785
800
|
});
|
|
786
801
|
};
|
|
787
802
|
this_1 = this;
|
|
788
|
-
_h.label = 4;
|
|
789
|
-
case 4:
|
|
790
|
-
_h.trys.push([4, 9, 10, 11]);
|
|
791
|
-
toolCalls_1 = __values(toolCalls), toolCalls_1_1 = toolCalls_1.next();
|
|
792
803
|
_h.label = 5;
|
|
793
804
|
case 5:
|
|
794
|
-
|
|
805
|
+
_h.trys.push([5, 10, 11, 12]);
|
|
806
|
+
toolCalls_1 = __values(toolCalls), toolCalls_1_1 = toolCalls_1.next();
|
|
807
|
+
_h.label = 6;
|
|
808
|
+
case 6:
|
|
809
|
+
if (!!toolCalls_1_1.done) return [3 /*break*/, 9];
|
|
795
810
|
tool = toolCalls_1_1.value;
|
|
796
811
|
return [5 /*yield**/, _loop_1(tool)];
|
|
797
|
-
case
|
|
812
|
+
case 7:
|
|
798
813
|
state_1 = _h.sent();
|
|
799
814
|
if (typeof state_1 === "object")
|
|
800
815
|
return [2 /*return*/, state_1.value];
|
|
801
|
-
_h.label =
|
|
802
|
-
case
|
|
816
|
+
_h.label = 8;
|
|
817
|
+
case 8:
|
|
803
818
|
toolCalls_1_1 = toolCalls_1.next();
|
|
804
|
-
return [3 /*break*/,
|
|
805
|
-
case
|
|
806
|
-
case
|
|
819
|
+
return [3 /*break*/, 6];
|
|
820
|
+
case 9: return [3 /*break*/, 12];
|
|
821
|
+
case 10:
|
|
807
822
|
e_1_1 = _h.sent();
|
|
808
823
|
e_1 = { error: e_1_1 };
|
|
809
|
-
return [3 /*break*/,
|
|
810
|
-
case
|
|
824
|
+
return [3 /*break*/, 12];
|
|
825
|
+
case 11:
|
|
811
826
|
try {
|
|
812
827
|
if (toolCalls_1_1 && !toolCalls_1_1.done && (_a = toolCalls_1.return)) _a.call(toolCalls_1);
|
|
813
828
|
}
|
|
814
829
|
finally { if (e_1) throw e_1.error; }
|
|
815
830
|
return [7 /*endfinally*/];
|
|
816
|
-
case
|
|
831
|
+
case 12:
|
|
817
832
|
((_g = this.params.callbacks) === null || _g === void 0 ? void 0 : _g.onAfterToolCalls) &&
|
|
818
833
|
this.params.callbacks.onAfterToolCalls(this.params.clientId, this.params.agentName, toolCalls);
|
|
819
834
|
return [2 /*return*/];
|
|
820
|
-
case
|
|
835
|
+
case 13:
|
|
821
836
|
if (!message.tool_calls) {
|
|
822
837
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute no tool calls detected"));
|
|
823
838
|
}
|
|
824
839
|
result = message.content;
|
|
825
840
|
return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
|
|
826
|
-
case
|
|
841
|
+
case 14:
|
|
827
842
|
_h.sent();
|
|
828
843
|
validation = null;
|
|
829
844
|
return [4 /*yield*/, this.params.validate(result)];
|
|
830
|
-
case
|
|
831
|
-
if (!(validation = _h.sent())) return [3 /*break*/,
|
|
845
|
+
case 15:
|
|
846
|
+
if (!(validation = _h.sent())) return [3 /*break*/, 18];
|
|
832
847
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute invalid tool call detected: ").concat(validation), { result: result });
|
|
833
848
|
return [4 /*yield*/, this._resurrectModel(mode, "Invalid model output: ".concat(result))];
|
|
834
|
-
case
|
|
849
|
+
case 16:
|
|
835
850
|
result1 = _h.sent();
|
|
836
851
|
return [4 /*yield*/, this._emitOuput(mode, result1)];
|
|
837
|
-
case
|
|
852
|
+
case 17:
|
|
838
853
|
_h.sent();
|
|
839
854
|
return [2 /*return*/];
|
|
840
|
-
case
|
|
855
|
+
case 18:
|
|
841
856
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute end result=").concat(result));
|
|
842
857
|
return [4 /*yield*/, this._emitOuput(mode, result)];
|
|
843
|
-
case
|
|
858
|
+
case 19:
|
|
844
859
|
_h.sent();
|
|
845
860
|
return [2 /*return*/];
|
|
846
861
|
}
|
|
@@ -890,10 +905,10 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
890
905
|
var _b = __read(_a, 2), clientId = _b[0], agentName = _b[1];
|
|
891
906
|
return "".concat(clientId, "-").concat(agentName);
|
|
892
907
|
}, function (clientId, agentName) {
|
|
893
|
-
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, callbacks = _a.callbacks, completionName = _a.completion,
|
|
908
|
+
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, completionName = _a.completion, _d = _a.validate, validate = _d === void 0 ? validateDefault : _d;
|
|
894
909
|
var completion = _this.completionSchemaService.get(completionName);
|
|
895
910
|
_this.sessionValidationService.addAgentUsage(clientId, agentName);
|
|
896
|
-
return new ClientAgent(__assign({ clientId: clientId, agentName: agentName, validate: validate, logger: _this.loggerService, history: _this.historyConnectionService.getHistory(clientId, agentName), prompt: prompt, system: system, transform: transform, tools: tools === null || tools === void 0 ? void 0 : tools.map(_this.toolSchemaService.get), completion: completion }, callbacks));
|
|
911
|
+
return new ClientAgent(__assign({ clientId: clientId, agentName: agentName, validate: validate, logger: _this.loggerService, 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));
|
|
897
912
|
});
|
|
898
913
|
/**
|
|
899
914
|
* Executes an input command.
|
|
@@ -1114,20 +1129,21 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1114
1129
|
var commonMessagesRaw, systemMessagesRaw, _a, _b, _c, content, message, e_2_1, systemMessages, commonMessages, promptMessages;
|
|
1115
1130
|
var _this = this;
|
|
1116
1131
|
var _d, e_2, _e, _f;
|
|
1117
|
-
|
|
1118
|
-
|
|
1132
|
+
var _g;
|
|
1133
|
+
return __generator(this, function (_h) {
|
|
1134
|
+
switch (_h.label) {
|
|
1119
1135
|
case 0:
|
|
1120
1136
|
this.params.logger.debug("ClientHistory agentName=".concat(this.params.agentName, " toArrayForAgent"));
|
|
1121
1137
|
commonMessagesRaw = [];
|
|
1122
1138
|
systemMessagesRaw = [];
|
|
1123
|
-
|
|
1139
|
+
_h.label = 1;
|
|
1124
1140
|
case 1:
|
|
1125
|
-
|
|
1141
|
+
_h.trys.push([1, 6, 7, 12]);
|
|
1126
1142
|
_a = true, _b = __asyncValues(this.params.items);
|
|
1127
|
-
|
|
1143
|
+
_h.label = 2;
|
|
1128
1144
|
case 2: return [4 /*yield*/, _b.next()];
|
|
1129
1145
|
case 3:
|
|
1130
|
-
if (!(_c =
|
|
1146
|
+
if (!(_c = _h.sent(), _d = _c.done, !_d)) return [3 /*break*/, 5];
|
|
1131
1147
|
_f = _c.value;
|
|
1132
1148
|
_a = false;
|
|
1133
1149
|
content = _f;
|
|
@@ -1148,22 +1164,22 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1148
1164
|
else {
|
|
1149
1165
|
commonMessagesRaw.push(message);
|
|
1150
1166
|
}
|
|
1151
|
-
|
|
1167
|
+
_h.label = 4;
|
|
1152
1168
|
case 4:
|
|
1153
1169
|
_a = true;
|
|
1154
1170
|
return [3 /*break*/, 2];
|
|
1155
1171
|
case 5: return [3 /*break*/, 12];
|
|
1156
1172
|
case 6:
|
|
1157
|
-
e_2_1 =
|
|
1173
|
+
e_2_1 = _h.sent();
|
|
1158
1174
|
e_2 = { error: e_2_1 };
|
|
1159
1175
|
return [3 /*break*/, 12];
|
|
1160
1176
|
case 7:
|
|
1161
|
-
|
|
1177
|
+
_h.trys.push([7, , 10, 11]);
|
|
1162
1178
|
if (!(!_a && !_d && (_e = _b.return))) return [3 /*break*/, 9];
|
|
1163
1179
|
return [4 /*yield*/, _e.call(_b)];
|
|
1164
1180
|
case 8:
|
|
1165
|
-
|
|
1166
|
-
|
|
1181
|
+
_h.sent();
|
|
1182
|
+
_h.label = 9;
|
|
1167
1183
|
case 9: return [3 /*break*/, 11];
|
|
1168
1184
|
case 10:
|
|
1169
1185
|
if (e_2) throw e_2.error;
|
|
@@ -1181,19 +1197,26 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1181
1197
|
{
|
|
1182
1198
|
promptMessages.push({
|
|
1183
1199
|
agentName: this.params.agentName,
|
|
1184
|
-
mode:
|
|
1200
|
+
mode: "tool",
|
|
1185
1201
|
content: prompt,
|
|
1186
1202
|
role: "system",
|
|
1187
1203
|
});
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
role: "system",
|
|
1195
|
-
});
|
|
1204
|
+
(_g = GLOBAL_CONFIG.CC_AGENT_SYSTEM_PROMPT) === null || _g === void 0 ? void 0 : _g.forEach(function (content) {
|
|
1205
|
+
return promptMessages.push({
|
|
1206
|
+
agentName: _this.params.agentName,
|
|
1207
|
+
mode: "tool",
|
|
1208
|
+
content: content,
|
|
1209
|
+
role: "system",
|
|
1196
1210
|
});
|
|
1211
|
+
});
|
|
1212
|
+
system === null || system === void 0 ? void 0 : system.forEach(function (content) {
|
|
1213
|
+
return promptMessages.push({
|
|
1214
|
+
agentName: _this.params.agentName,
|
|
1215
|
+
mode: "tool",
|
|
1216
|
+
content: content,
|
|
1217
|
+
role: "system",
|
|
1218
|
+
});
|
|
1219
|
+
});
|
|
1197
1220
|
}
|
|
1198
1221
|
return [2 /*return*/, __spreadArray(__spreadArray(__spreadArray([], __read(promptMessages), false), __read(systemMessages), false), __read(commonMessages), false)];
|
|
1199
1222
|
}
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -671,7 +671,9 @@ interface IAgentSchema {
|
|
|
671
671
|
*/
|
|
672
672
|
validate?: (output: string) => Promise<string | null>;
|
|
673
673
|
/** The transform function for model output */
|
|
674
|
-
transform?: (input: string) => string;
|
|
674
|
+
transform?: (input: string, clientId: string, agentName: AgentName) => Promise<string> | string;
|
|
675
|
+
/** The map function for assistant messages. Use to transform json to tool_call for deepseek r1 on ollama*/
|
|
676
|
+
map?: (message: IModelMessage, clientId: string, agentName: AgentName) => Promise<IModelMessage> | IModelMessage;
|
|
675
677
|
/** The lifecycle calbacks of the agent. */
|
|
676
678
|
callbacks?: Partial<IAgentSchemaCallbacks>;
|
|
677
679
|
}
|
|
@@ -2086,6 +2088,8 @@ declare const GLOBAL_CONFIG: {
|
|
|
2086
2088
|
CC_AGENT_DEFAULT_VALIDATION: (output: string) => Promise<string | null>;
|
|
2087
2089
|
CC_AGENT_HISTORY_FILTER: (agentName: AgentName) => (message: IModelMessage) => boolean;
|
|
2088
2090
|
CC_AGENT_OUTPUT_TRANSFORM: (input: string) => string;
|
|
2091
|
+
CC_AGENT_OUTPUT_MAP: (message: IModelMessage) => IModelMessage | Promise<IModelMessage>;
|
|
2092
|
+
CC_AGENT_SYSTEM_PROMPT: string[];
|
|
2089
2093
|
CC_AGENT_SEPARATE_HISTORY: boolean;
|
|
2090
2094
|
CC_AGENT_DISALLOWED_TAGS: string[];
|
|
2091
2095
|
CC_AGENT_DISALLOWED_SYMBOLS: string[];
|