agent-swarm-kit 1.0.43 → 1.0.44
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 +50 -65
- package/build/index.mjs +50 -65
- package/package.json +1 -1
- package/types.d.ts +1 -1
package/build/index.cjs
CHANGED
|
@@ -712,12 +712,11 @@ var ClientAgent = /** @class */ (function () {
|
|
|
712
712
|
* @returns {Promise<void>}
|
|
713
713
|
*/
|
|
714
714
|
this.execute = functoolsKit.queued(function (incoming, mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
715
|
-
var rawMessage, message, toolCalls, _loop_1, this_1,
|
|
716
|
-
var e_1, _a;
|
|
715
|
+
var rawMessage, message, toolCalls, _loop_1, this_1, idx, state_1, result, validation, result1;
|
|
717
716
|
var _this = this;
|
|
718
|
-
var _b, _c, _d, _e, _f
|
|
719
|
-
return __generator(this, function (
|
|
720
|
-
switch (
|
|
717
|
+
var _a, _b, _c, _d, _e, _f;
|
|
718
|
+
return __generator(this, function (_g) {
|
|
719
|
+
switch (_g.label) {
|
|
721
720
|
case 0:
|
|
722
721
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute begin"), { incoming: incoming, mode: mode });
|
|
723
722
|
this.params.onExecute &&
|
|
@@ -729,14 +728,14 @@ var ClientAgent = /** @class */ (function () {
|
|
|
729
728
|
content: incoming.trim(),
|
|
730
729
|
})];
|
|
731
730
|
case 1:
|
|
732
|
-
|
|
731
|
+
_g.sent();
|
|
733
732
|
return [4 /*yield*/, this.getCompletion(mode)];
|
|
734
733
|
case 2:
|
|
735
|
-
rawMessage =
|
|
734
|
+
rawMessage = _g.sent();
|
|
736
735
|
return [4 /*yield*/, this.params.map(rawMessage, this.params.clientId, this.params.agentName)];
|
|
737
736
|
case 3:
|
|
738
|
-
message =
|
|
739
|
-
if (!message.tool_calls) return [3 /*break*/,
|
|
737
|
+
message = _g.sent();
|
|
738
|
+
if (!message.tool_calls) return [3 /*break*/, 9];
|
|
740
739
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " tool call begin"));
|
|
741
740
|
toolCalls = message.tool_calls.map(function (call) {
|
|
742
741
|
var _a, _b;
|
|
@@ -748,45 +747,46 @@ var ClientAgent = /** @class */ (function () {
|
|
|
748
747
|
});
|
|
749
748
|
return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
|
|
750
749
|
case 4:
|
|
751
|
-
|
|
752
|
-
_loop_1 = function (
|
|
753
|
-
var targetFn, result_2, result_3;
|
|
754
|
-
return __generator(this, function (
|
|
755
|
-
switch (
|
|
750
|
+
_g.sent();
|
|
751
|
+
_loop_1 = function (idx) {
|
|
752
|
+
var tool, targetFn, result_2, result_3;
|
|
753
|
+
return __generator(this, function (_h) {
|
|
754
|
+
switch (_h.label) {
|
|
756
755
|
case 0:
|
|
757
|
-
|
|
756
|
+
tool = toolCalls[idx];
|
|
757
|
+
targetFn = (_a = this_1.params.tools) === null || _a === void 0 ? void 0 : _a.find(function (t) { return t.function.name === tool.function.name; });
|
|
758
758
|
if (!!targetFn) return [3 /*break*/, 3];
|
|
759
759
|
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);
|
|
760
760
|
return [4 /*yield*/, this_1._resurrectModel(mode, "No target function for ".concat(tool.function.name))];
|
|
761
761
|
case 1:
|
|
762
|
-
result_2 =
|
|
762
|
+
result_2 = _h.sent();
|
|
763
763
|
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_2));
|
|
764
764
|
return [4 /*yield*/, this_1._emitOuput(mode, result_2)];
|
|
765
765
|
case 2:
|
|
766
|
-
|
|
766
|
+
_h.sent();
|
|
767
767
|
return [2 /*return*/, { value: void 0 }];
|
|
768
768
|
case 3:
|
|
769
|
-
((
|
|
770
|
-
((
|
|
769
|
+
((_b = targetFn.callbacks) === null || _b === void 0 ? void 0 : _b.onValidate) &&
|
|
770
|
+
((_c = targetFn.callbacks) === null || _c === void 0 ? void 0 : _c.onValidate(this_1.params.clientId, this_1.params.agentName, tool.function.arguments));
|
|
771
771
|
return [4 /*yield*/, functoolsKit.not(targetFn.validate(this_1.params.clientId, this_1.params.agentName, tool.function.arguments))];
|
|
772
772
|
case 4:
|
|
773
|
-
if (!
|
|
773
|
+
if (!_h.sent()) return [3 /*break*/, 7];
|
|
774
774
|
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"));
|
|
775
775
|
return [4 /*yield*/, this_1._resurrectModel(mode, "Function validation failed: name=".concat(tool.function.name, " arguments=").concat(JSON.stringify(tool.function.arguments)))];
|
|
776
776
|
case 5:
|
|
777
|
-
result_3 =
|
|
777
|
+
result_3 = _h.sent();
|
|
778
778
|
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_3));
|
|
779
779
|
return [4 /*yield*/, this_1._emitOuput(mode, result_3)];
|
|
780
780
|
case 6:
|
|
781
|
-
|
|
781
|
+
_h.sent();
|
|
782
782
|
return [2 /*return*/, { value: void 0 }];
|
|
783
783
|
case 7:
|
|
784
|
-
((
|
|
785
|
-
((
|
|
784
|
+
((_d = targetFn.callbacks) === null || _d === void 0 ? void 0 : _d.onBeforeCall) &&
|
|
785
|
+
((_e = targetFn.callbacks) === null || _e === void 0 ? void 0 : _e.onBeforeCall(tool.id, this_1.params.clientId, this_1.params.agentName, tool.function.arguments));
|
|
786
786
|
/**
|
|
787
787
|
* @description Do not await to avoid deadlock! The tool can send the message to other agents by emulating user messages
|
|
788
788
|
*/
|
|
789
|
-
Promise.resolve(targetFn.call(tool.id, this_1.params.clientId, this_1.params.agentName, tool.function.arguments)).then(function () {
|
|
789
|
+
Promise.resolve(targetFn.call(tool.id, this_1.params.clientId, this_1.params.agentName, tool.function.arguments, idx === toolCalls.length - 1)).then(function () {
|
|
790
790
|
var _a, _b;
|
|
791
791
|
((_a = targetFn.callbacks) === null || _a === void 0 ? void 0 : _a.onAfterCall) &&
|
|
792
792
|
((_b = targetFn.callbacks) === null || _b === void 0 ? void 0 : _b.onAfterCall(tool.id, _this.params.clientId, _this.params.agentName, tool.function.arguments));
|
|
@@ -797,72 +797,57 @@ var ClientAgent = /** @class */ (function () {
|
|
|
797
797
|
this_1._outputSubject.toPromise(),
|
|
798
798
|
])];
|
|
799
799
|
case 8:
|
|
800
|
-
|
|
800
|
+
_h.sent();
|
|
801
801
|
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"));
|
|
802
802
|
return [2 /*return*/];
|
|
803
803
|
}
|
|
804
804
|
});
|
|
805
805
|
};
|
|
806
806
|
this_1 = this;
|
|
807
|
-
|
|
807
|
+
idx = 0;
|
|
808
|
+
_g.label = 5;
|
|
808
809
|
case 5:
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
_h.label = 6;
|
|
810
|
+
if (!(idx !== toolCalls.length)) return [3 /*break*/, 8];
|
|
811
|
+
return [5 /*yield**/, _loop_1(idx)];
|
|
812
812
|
case 6:
|
|
813
|
-
|
|
814
|
-
tool = toolCalls_1_1.value;
|
|
815
|
-
return [5 /*yield**/, _loop_1(tool)];
|
|
816
|
-
case 7:
|
|
817
|
-
state_1 = _h.sent();
|
|
813
|
+
state_1 = _g.sent();
|
|
818
814
|
if (typeof state_1 === "object")
|
|
819
815
|
return [2 /*return*/, state_1.value];
|
|
820
|
-
|
|
816
|
+
_g.label = 7;
|
|
817
|
+
case 7:
|
|
818
|
+
idx++;
|
|
819
|
+
return [3 /*break*/, 5];
|
|
821
820
|
case 8:
|
|
822
|
-
|
|
823
|
-
return [3 /*break*/, 6];
|
|
824
|
-
case 9: return [3 /*break*/, 12];
|
|
825
|
-
case 10:
|
|
826
|
-
e_1_1 = _h.sent();
|
|
827
|
-
e_1 = { error: e_1_1 };
|
|
828
|
-
return [3 /*break*/, 12];
|
|
829
|
-
case 11:
|
|
830
|
-
try {
|
|
831
|
-
if (toolCalls_1_1 && !toolCalls_1_1.done && (_a = toolCalls_1.return)) _a.call(toolCalls_1);
|
|
832
|
-
}
|
|
833
|
-
finally { if (e_1) throw e_1.error; }
|
|
834
|
-
return [7 /*endfinally*/];
|
|
835
|
-
case 12:
|
|
836
|
-
((_g = this.params.callbacks) === null || _g === void 0 ? void 0 : _g.onAfterToolCalls) &&
|
|
821
|
+
((_f = this.params.callbacks) === null || _f === void 0 ? void 0 : _f.onAfterToolCalls) &&
|
|
837
822
|
this.params.callbacks.onAfterToolCalls(this.params.clientId, this.params.agentName, toolCalls);
|
|
838
823
|
return [2 /*return*/];
|
|
839
|
-
case
|
|
824
|
+
case 9:
|
|
840
825
|
if (!message.tool_calls) {
|
|
841
826
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute no tool calls detected"));
|
|
842
827
|
}
|
|
843
828
|
return [4 /*yield*/, this.params.transform(message.content, this.params.clientId, this.params.agentName)];
|
|
844
|
-
case
|
|
845
|
-
result =
|
|
829
|
+
case 10:
|
|
830
|
+
result = _g.sent();
|
|
846
831
|
return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
|
|
847
|
-
case
|
|
848
|
-
|
|
832
|
+
case 11:
|
|
833
|
+
_g.sent();
|
|
849
834
|
validation = null;
|
|
850
835
|
return [4 /*yield*/, this.params.validate(result)];
|
|
851
|
-
case
|
|
852
|
-
if (!(validation =
|
|
836
|
+
case 12:
|
|
837
|
+
if (!(validation = _g.sent())) return [3 /*break*/, 15];
|
|
853
838
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute invalid tool call detected: ").concat(validation), { result: result });
|
|
854
839
|
return [4 /*yield*/, this._resurrectModel(mode, "Invalid model output: ".concat(result))];
|
|
855
|
-
case
|
|
856
|
-
result1 =
|
|
840
|
+
case 13:
|
|
841
|
+
result1 = _g.sent();
|
|
857
842
|
return [4 /*yield*/, this._emitOuput(mode, result1)];
|
|
858
|
-
case
|
|
859
|
-
|
|
843
|
+
case 14:
|
|
844
|
+
_g.sent();
|
|
860
845
|
return [2 /*return*/];
|
|
861
|
-
case
|
|
846
|
+
case 15:
|
|
862
847
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute end result=").concat(result));
|
|
863
848
|
return [4 /*yield*/, this._emitOuput(mode, result)];
|
|
864
|
-
case
|
|
865
|
-
|
|
849
|
+
case 16:
|
|
850
|
+
_g.sent();
|
|
866
851
|
return [2 /*return*/];
|
|
867
852
|
}
|
|
868
853
|
});
|
package/build/index.mjs
CHANGED
|
@@ -710,12 +710,11 @@ var ClientAgent = /** @class */ (function () {
|
|
|
710
710
|
* @returns {Promise<void>}
|
|
711
711
|
*/
|
|
712
712
|
this.execute = queued(function (incoming, mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
713
|
-
var rawMessage, message, toolCalls, _loop_1, this_1,
|
|
714
|
-
var e_1, _a;
|
|
713
|
+
var rawMessage, message, toolCalls, _loop_1, this_1, idx, state_1, result, validation, result1;
|
|
715
714
|
var _this = this;
|
|
716
|
-
var _b, _c, _d, _e, _f
|
|
717
|
-
return __generator(this, function (
|
|
718
|
-
switch (
|
|
715
|
+
var _a, _b, _c, _d, _e, _f;
|
|
716
|
+
return __generator(this, function (_g) {
|
|
717
|
+
switch (_g.label) {
|
|
719
718
|
case 0:
|
|
720
719
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute begin"), { incoming: incoming, mode: mode });
|
|
721
720
|
this.params.onExecute &&
|
|
@@ -727,14 +726,14 @@ var ClientAgent = /** @class */ (function () {
|
|
|
727
726
|
content: incoming.trim(),
|
|
728
727
|
})];
|
|
729
728
|
case 1:
|
|
730
|
-
|
|
729
|
+
_g.sent();
|
|
731
730
|
return [4 /*yield*/, this.getCompletion(mode)];
|
|
732
731
|
case 2:
|
|
733
|
-
rawMessage =
|
|
732
|
+
rawMessage = _g.sent();
|
|
734
733
|
return [4 /*yield*/, this.params.map(rawMessage, this.params.clientId, this.params.agentName)];
|
|
735
734
|
case 3:
|
|
736
|
-
message =
|
|
737
|
-
if (!message.tool_calls) return [3 /*break*/,
|
|
735
|
+
message = _g.sent();
|
|
736
|
+
if (!message.tool_calls) return [3 /*break*/, 9];
|
|
738
737
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " tool call begin"));
|
|
739
738
|
toolCalls = message.tool_calls.map(function (call) {
|
|
740
739
|
var _a, _b;
|
|
@@ -746,45 +745,46 @@ var ClientAgent = /** @class */ (function () {
|
|
|
746
745
|
});
|
|
747
746
|
return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
|
|
748
747
|
case 4:
|
|
749
|
-
|
|
750
|
-
_loop_1 = function (
|
|
751
|
-
var targetFn, result_2, result_3;
|
|
752
|
-
return __generator(this, function (
|
|
753
|
-
switch (
|
|
748
|
+
_g.sent();
|
|
749
|
+
_loop_1 = function (idx) {
|
|
750
|
+
var tool, targetFn, result_2, result_3;
|
|
751
|
+
return __generator(this, function (_h) {
|
|
752
|
+
switch (_h.label) {
|
|
754
753
|
case 0:
|
|
755
|
-
|
|
754
|
+
tool = toolCalls[idx];
|
|
755
|
+
targetFn = (_a = this_1.params.tools) === null || _a === void 0 ? void 0 : _a.find(function (t) { return t.function.name === tool.function.name; });
|
|
756
756
|
if (!!targetFn) return [3 /*break*/, 3];
|
|
757
757
|
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);
|
|
758
758
|
return [4 /*yield*/, this_1._resurrectModel(mode, "No target function for ".concat(tool.function.name))];
|
|
759
759
|
case 1:
|
|
760
|
-
result_2 =
|
|
760
|
+
result_2 = _h.sent();
|
|
761
761
|
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_2));
|
|
762
762
|
return [4 /*yield*/, this_1._emitOuput(mode, result_2)];
|
|
763
763
|
case 2:
|
|
764
|
-
|
|
764
|
+
_h.sent();
|
|
765
765
|
return [2 /*return*/, { value: void 0 }];
|
|
766
766
|
case 3:
|
|
767
|
-
((
|
|
768
|
-
((
|
|
767
|
+
((_b = targetFn.callbacks) === null || _b === void 0 ? void 0 : _b.onValidate) &&
|
|
768
|
+
((_c = targetFn.callbacks) === null || _c === void 0 ? void 0 : _c.onValidate(this_1.params.clientId, this_1.params.agentName, tool.function.arguments));
|
|
769
769
|
return [4 /*yield*/, not(targetFn.validate(this_1.params.clientId, this_1.params.agentName, tool.function.arguments))];
|
|
770
770
|
case 4:
|
|
771
|
-
if (!
|
|
771
|
+
if (!_h.sent()) return [3 /*break*/, 7];
|
|
772
772
|
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"));
|
|
773
773
|
return [4 /*yield*/, this_1._resurrectModel(mode, "Function validation failed: name=".concat(tool.function.name, " arguments=").concat(JSON.stringify(tool.function.arguments)))];
|
|
774
774
|
case 5:
|
|
775
|
-
result_3 =
|
|
775
|
+
result_3 = _h.sent();
|
|
776
776
|
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_3));
|
|
777
777
|
return [4 /*yield*/, this_1._emitOuput(mode, result_3)];
|
|
778
778
|
case 6:
|
|
779
|
-
|
|
779
|
+
_h.sent();
|
|
780
780
|
return [2 /*return*/, { value: void 0 }];
|
|
781
781
|
case 7:
|
|
782
|
-
((
|
|
783
|
-
((
|
|
782
|
+
((_d = targetFn.callbacks) === null || _d === void 0 ? void 0 : _d.onBeforeCall) &&
|
|
783
|
+
((_e = targetFn.callbacks) === null || _e === void 0 ? void 0 : _e.onBeforeCall(tool.id, this_1.params.clientId, this_1.params.agentName, tool.function.arguments));
|
|
784
784
|
/**
|
|
785
785
|
* @description Do not await to avoid deadlock! The tool can send the message to other agents by emulating user messages
|
|
786
786
|
*/
|
|
787
|
-
Promise.resolve(targetFn.call(tool.id, this_1.params.clientId, this_1.params.agentName, tool.function.arguments)).then(function () {
|
|
787
|
+
Promise.resolve(targetFn.call(tool.id, this_1.params.clientId, this_1.params.agentName, tool.function.arguments, idx === toolCalls.length - 1)).then(function () {
|
|
788
788
|
var _a, _b;
|
|
789
789
|
((_a = targetFn.callbacks) === null || _a === void 0 ? void 0 : _a.onAfterCall) &&
|
|
790
790
|
((_b = targetFn.callbacks) === null || _b === void 0 ? void 0 : _b.onAfterCall(tool.id, _this.params.clientId, _this.params.agentName, tool.function.arguments));
|
|
@@ -795,72 +795,57 @@ var ClientAgent = /** @class */ (function () {
|
|
|
795
795
|
this_1._outputSubject.toPromise(),
|
|
796
796
|
])];
|
|
797
797
|
case 8:
|
|
798
|
-
|
|
798
|
+
_h.sent();
|
|
799
799
|
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"));
|
|
800
800
|
return [2 /*return*/];
|
|
801
801
|
}
|
|
802
802
|
});
|
|
803
803
|
};
|
|
804
804
|
this_1 = this;
|
|
805
|
-
|
|
805
|
+
idx = 0;
|
|
806
|
+
_g.label = 5;
|
|
806
807
|
case 5:
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
_h.label = 6;
|
|
808
|
+
if (!(idx !== toolCalls.length)) return [3 /*break*/, 8];
|
|
809
|
+
return [5 /*yield**/, _loop_1(idx)];
|
|
810
810
|
case 6:
|
|
811
|
-
|
|
812
|
-
tool = toolCalls_1_1.value;
|
|
813
|
-
return [5 /*yield**/, _loop_1(tool)];
|
|
814
|
-
case 7:
|
|
815
|
-
state_1 = _h.sent();
|
|
811
|
+
state_1 = _g.sent();
|
|
816
812
|
if (typeof state_1 === "object")
|
|
817
813
|
return [2 /*return*/, state_1.value];
|
|
818
|
-
|
|
814
|
+
_g.label = 7;
|
|
815
|
+
case 7:
|
|
816
|
+
idx++;
|
|
817
|
+
return [3 /*break*/, 5];
|
|
819
818
|
case 8:
|
|
820
|
-
|
|
821
|
-
return [3 /*break*/, 6];
|
|
822
|
-
case 9: return [3 /*break*/, 12];
|
|
823
|
-
case 10:
|
|
824
|
-
e_1_1 = _h.sent();
|
|
825
|
-
e_1 = { error: e_1_1 };
|
|
826
|
-
return [3 /*break*/, 12];
|
|
827
|
-
case 11:
|
|
828
|
-
try {
|
|
829
|
-
if (toolCalls_1_1 && !toolCalls_1_1.done && (_a = toolCalls_1.return)) _a.call(toolCalls_1);
|
|
830
|
-
}
|
|
831
|
-
finally { if (e_1) throw e_1.error; }
|
|
832
|
-
return [7 /*endfinally*/];
|
|
833
|
-
case 12:
|
|
834
|
-
((_g = this.params.callbacks) === null || _g === void 0 ? void 0 : _g.onAfterToolCalls) &&
|
|
819
|
+
((_f = this.params.callbacks) === null || _f === void 0 ? void 0 : _f.onAfterToolCalls) &&
|
|
835
820
|
this.params.callbacks.onAfterToolCalls(this.params.clientId, this.params.agentName, toolCalls);
|
|
836
821
|
return [2 /*return*/];
|
|
837
|
-
case
|
|
822
|
+
case 9:
|
|
838
823
|
if (!message.tool_calls) {
|
|
839
824
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute no tool calls detected"));
|
|
840
825
|
}
|
|
841
826
|
return [4 /*yield*/, this.params.transform(message.content, this.params.clientId, this.params.agentName)];
|
|
842
|
-
case
|
|
843
|
-
result =
|
|
827
|
+
case 10:
|
|
828
|
+
result = _g.sent();
|
|
844
829
|
return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
|
|
845
|
-
case
|
|
846
|
-
|
|
830
|
+
case 11:
|
|
831
|
+
_g.sent();
|
|
847
832
|
validation = null;
|
|
848
833
|
return [4 /*yield*/, this.params.validate(result)];
|
|
849
|
-
case
|
|
850
|
-
if (!(validation =
|
|
834
|
+
case 12:
|
|
835
|
+
if (!(validation = _g.sent())) return [3 /*break*/, 15];
|
|
851
836
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute invalid tool call detected: ").concat(validation), { result: result });
|
|
852
837
|
return [4 /*yield*/, this._resurrectModel(mode, "Invalid model output: ".concat(result))];
|
|
853
|
-
case
|
|
854
|
-
result1 =
|
|
838
|
+
case 13:
|
|
839
|
+
result1 = _g.sent();
|
|
855
840
|
return [4 /*yield*/, this._emitOuput(mode, result1)];
|
|
856
|
-
case
|
|
857
|
-
|
|
841
|
+
case 14:
|
|
842
|
+
_g.sent();
|
|
858
843
|
return [2 /*return*/];
|
|
859
|
-
case
|
|
844
|
+
case 15:
|
|
860
845
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute end result=").concat(result));
|
|
861
846
|
return [4 /*yield*/, this._emitOuput(mode, result)];
|
|
862
|
-
case
|
|
863
|
-
|
|
847
|
+
case 16:
|
|
848
|
+
_g.sent();
|
|
864
849
|
return [2 /*return*/];
|
|
865
850
|
}
|
|
866
851
|
});
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -538,7 +538,7 @@ interface IAgentTool<T = Record<string, unknown>> extends ITool {
|
|
|
538
538
|
* @param params - The parameters for the tool.
|
|
539
539
|
* @returns A promise that resolves when the tool call is complete.
|
|
540
540
|
*/
|
|
541
|
-
call(toolId: string, clientId: string, agentName: AgentName, params: T): Promise<void>;
|
|
541
|
+
call(toolId: string, clientId: string, agentName: AgentName, params: T, isLast: boolean): Promise<void>;
|
|
542
542
|
/**
|
|
543
543
|
* Validates the parameters for the tool.
|
|
544
544
|
* @param clientId - The ID of the client.
|