agent-swarm-kit 1.0.38 → 1.0.39

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 CHANGED
@@ -698,11 +698,11 @@ var ClientAgent = /** @class */ (function () {
698
698
  * @returns {Promise<void>}
699
699
  */
700
700
  this.execute = functoolsKit.queued(function (incoming, mode) { return __awaiter(_this, void 0, void 0, function () {
701
- var message, _loop_1, this_1, _a, _b, tool, state_1, e_1_1, result, validation, result1;
702
- var e_1, _c;
703
- var _d, _e, _f, _g, _h, _j;
704
- return __generator(this, function (_k) {
705
- switch (_k.label) {
701
+ var message, toolCalls, _loop_1, this_1, toolCalls_1, toolCalls_1_1, tool, state_1, e_1_1, result, validation, result1;
702
+ var e_1, _a;
703
+ var _b, _c, _d, _e, _f, _g;
704
+ return __generator(this, function (_h) {
705
+ switch (_h.label) {
706
706
  case 0:
707
707
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute begin"), { incoming: incoming, mode: mode });
708
708
  this.params.onExecute &&
@@ -714,120 +714,131 @@ var ClientAgent = /** @class */ (function () {
714
714
  content: incoming.trim(),
715
715
  })];
716
716
  case 1:
717
- _k.sent();
717
+ _h.sent();
718
718
  return [4 /*yield*/, this.getCompletion(mode)];
719
719
  case 2:
720
- message = _k.sent();
721
- if (!message.tool_calls) return [3 /*break*/, 11];
720
+ message = _h.sent();
721
+ if (!message.tool_calls) return [3 /*break*/, 12];
722
722
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " tool call begin"));
723
+ toolCalls = message.tool_calls.map(function (call) {
724
+ var _a, _b;
725
+ return ({
726
+ function: call.function,
727
+ id: (_a = call.id) !== null && _a !== void 0 ? _a : functoolsKit.randomString(),
728
+ type: (_b = call.type) !== null && _b !== void 0 ? _b : "function",
729
+ });
730
+ });
731
+ return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
732
+ case 3:
733
+ _h.sent();
723
734
  _loop_1 = function (tool) {
724
735
  var targetFn, result_2, result_3;
725
- return __generator(this, function (_l) {
726
- switch (_l.label) {
736
+ return __generator(this, function (_j) {
737
+ switch (_j.label) {
727
738
  case 0:
728
- targetFn = (_d = this_1.params.tools) === null || _d === void 0 ? void 0 : _d.find(function (t) { return t.function.name === tool.function.name; });
729
- return [4 /*yield*/, this_1.params.history.push(__assign(__assign({}, message), { agentName: this_1.params.agentName }))];
730
- case 1:
731
- _l.sent();
732
- if (!!targetFn) return [3 /*break*/, 4];
739
+ targetFn = (_b = this_1.params.tools) === null || _b === void 0 ? void 0 : _b.find(function (t) { return t.function.name === tool.function.name; });
740
+ if (!!targetFn) return [3 /*break*/, 3];
733
741
  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);
734
742
  return [4 /*yield*/, this_1._resurrectModel(mode, "No target function for ".concat(tool.function.name))];
735
- case 2:
736
- result_2 = _l.sent();
743
+ case 1:
744
+ result_2 = _j.sent();
737
745
  this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_2));
738
746
  return [4 /*yield*/, this_1._emitOuput(mode, result_2)];
739
- case 3:
740
- _l.sent();
747
+ case 2:
748
+ _j.sent();
741
749
  return [2 /*return*/, { value: void 0 }];
742
- case 4:
743
- ((_e = targetFn.callbacks) === null || _e === void 0 ? void 0 : _e.onValidate) &&
744
- ((_f = targetFn.callbacks) === null || _f === void 0 ? void 0 : _f.onValidate(this_1.params.clientId, this_1.params.agentName, tool.function.arguments));
750
+ case 3:
751
+ ((_c = targetFn.callbacks) === null || _c === void 0 ? void 0 : _c.onValidate) &&
752
+ ((_d = targetFn.callbacks) === null || _d === void 0 ? void 0 : _d.onValidate(this_1.params.clientId, this_1.params.agentName, tool.function.arguments));
745
753
  return [4 /*yield*/, functoolsKit.not(targetFn.validate(this_1.params.clientId, this_1.params.agentName, tool.function.arguments))];
746
- case 5:
747
- if (!_l.sent()) return [3 /*break*/, 8];
754
+ case 4:
755
+ if (!_j.sent()) return [3 /*break*/, 7];
748
756
  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"));
749
757
  return [4 /*yield*/, this_1._resurrectModel(mode, "Function validation failed: name=".concat(tool.function.name, " arguments=").concat(JSON.stringify(tool.function.arguments)))];
750
- case 6:
751
- result_3 = _l.sent();
758
+ case 5:
759
+ result_3 = _j.sent();
752
760
  this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_3));
753
761
  return [4 /*yield*/, this_1._emitOuput(mode, result_3)];
754
- case 7:
755
- _l.sent();
762
+ case 6:
763
+ _j.sent();
756
764
  return [2 /*return*/, { value: void 0 }];
757
- case 8:
758
- ((_g = targetFn.callbacks) === null || _g === void 0 ? void 0 : _g.onCall) &&
759
- ((_h = targetFn.callbacks) === null || _h === void 0 ? void 0 : _h.onCall(this_1.params.clientId, this_1.params.agentName, tool.function.arguments));
765
+ case 7:
766
+ ((_e = targetFn.callbacks) === null || _e === void 0 ? void 0 : _e.onCall) &&
767
+ ((_f = targetFn.callbacks) === null || _f === void 0 ? void 0 : _f.onCall(this_1.params.clientId, this_1.params.agentName, tool.function.arguments));
760
768
  /**
761
769
  * @description Do not await to avoid deadlock! The tool can send the message to other agents by emulating user messages
762
770
  */
763
- targetFn.call((_j = tool.id) !== null && _j !== void 0 ? _j : functoolsKit.randomString(), this_1.params.clientId, this_1.params.agentName, tool.function.arguments);
771
+ targetFn.call(tool.id, this_1.params.clientId, this_1.params.agentName, tool.function.arguments);
764
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 call executing"));
765
773
  return [4 /*yield*/, Promise.race([
766
774
  this_1._toolCommitSubject.toPromise(),
767
775
  this_1._outputSubject.toPromise(),
768
776
  ])];
769
- case 9:
770
- _l.sent();
777
+ case 8:
778
+ _j.sent();
771
779
  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"));
772
780
  return [2 /*return*/];
773
781
  }
774
782
  });
775
783
  };
776
784
  this_1 = this;
777
- _k.label = 3;
778
- case 3:
779
- _k.trys.push([3, 8, 9, 10]);
780
- _a = __values(message.tool_calls), _b = _a.next();
781
- _k.label = 4;
785
+ _h.label = 4;
782
786
  case 4:
783
- if (!!_b.done) return [3 /*break*/, 7];
784
- tool = _b.value;
785
- return [5 /*yield**/, _loop_1(tool)];
787
+ _h.trys.push([4, 9, 10, 11]);
788
+ toolCalls_1 = __values(toolCalls), toolCalls_1_1 = toolCalls_1.next();
789
+ _h.label = 5;
786
790
  case 5:
787
- state_1 = _k.sent();
791
+ if (!!toolCalls_1_1.done) return [3 /*break*/, 8];
792
+ tool = toolCalls_1_1.value;
793
+ return [5 /*yield**/, _loop_1(tool)];
794
+ case 6:
795
+ state_1 = _h.sent();
788
796
  if (typeof state_1 === "object")
789
797
  return [2 /*return*/, state_1.value];
790
- _k.label = 6;
791
- case 6:
792
- _b = _a.next();
793
- return [3 /*break*/, 4];
794
- case 7: return [3 /*break*/, 10];
795
- case 8:
796
- e_1_1 = _k.sent();
797
- e_1 = { error: e_1_1 };
798
- return [3 /*break*/, 10];
798
+ _h.label = 7;
799
+ case 7:
800
+ toolCalls_1_1 = toolCalls_1.next();
801
+ return [3 /*break*/, 5];
802
+ case 8: return [3 /*break*/, 11];
799
803
  case 9:
804
+ e_1_1 = _h.sent();
805
+ e_1 = { error: e_1_1 };
806
+ return [3 /*break*/, 11];
807
+ case 10:
800
808
  try {
801
- if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
809
+ if (toolCalls_1_1 && !toolCalls_1_1.done && (_a = toolCalls_1.return)) _a.call(toolCalls_1);
802
810
  }
803
811
  finally { if (e_1) throw e_1.error; }
804
812
  return [7 /*endfinally*/];
805
- case 10: return [2 /*return*/];
806
813
  case 11:
814
+ ((_g = this.params.callbacks) === null || _g === void 0 ? void 0 : _g.onAfterToolCalls) &&
815
+ this.params.callbacks.onAfterToolCalls(this.params.clientId, this.params.agentName, toolCalls);
816
+ return [2 /*return*/];
817
+ case 12:
807
818
  if (!message.tool_calls) {
808
819
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute no tool calls detected"));
809
820
  }
810
821
  result = message.content;
811
822
  return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
812
- case 12:
813
- _k.sent();
823
+ case 13:
824
+ _h.sent();
814
825
  validation = null;
815
826
  return [4 /*yield*/, this.params.validate(result)];
816
- case 13:
817
- if (!(validation = _k.sent())) return [3 /*break*/, 16];
827
+ case 14:
828
+ if (!(validation = _h.sent())) return [3 /*break*/, 17];
818
829
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute invalid tool call detected: ").concat(validation), { result: result });
819
830
  return [4 /*yield*/, this._resurrectModel(mode, "Invalid model output: ".concat(result))];
820
- case 14:
821
- result1 = _k.sent();
822
- return [4 /*yield*/, this._emitOuput(mode, result1)];
823
831
  case 15:
824
- _k.sent();
825
- return [2 /*return*/];
832
+ result1 = _h.sent();
833
+ return [4 /*yield*/, this._emitOuput(mode, result1)];
826
834
  case 16:
835
+ _h.sent();
836
+ return [2 /*return*/];
837
+ case 17:
827
838
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute end result=").concat(result));
828
839
  return [4 /*yield*/, this._emitOuput(mode, result)];
829
- case 17:
830
- _k.sent();
840
+ case 18:
841
+ _h.sent();
831
842
  return [2 /*return*/];
832
843
  }
833
844
  });
package/build/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { scoped } from 'di-scoped';
2
- import { ToolRegistry, trycatch, sleep, PubsubArrayAdapter, Subject, queued, randomString, not, memoize, createAwaiter, cancelable, CANCELED_PROMISE_SYMBOL, schedule, ttl, singleshot, Source } from 'functools-kit';
2
+ import { ToolRegistry, trycatch, sleep, PubsubArrayAdapter, Subject, queued, not, randomString, memoize, createAwaiter, cancelable, CANCELED_PROMISE_SYMBOL, schedule, ttl, singleshot, Source } from 'functools-kit';
3
3
  import { createActivator } from 'di-kit';
4
4
  import { omit } from 'lodash-es';
5
5
  import xml2js from 'xml2js';
@@ -696,11 +696,11 @@ var ClientAgent = /** @class */ (function () {
696
696
  * @returns {Promise<void>}
697
697
  */
698
698
  this.execute = queued(function (incoming, mode) { return __awaiter(_this, void 0, void 0, function () {
699
- var message, _loop_1, this_1, _a, _b, tool, state_1, e_1_1, result, validation, result1;
700
- var e_1, _c;
701
- var _d, _e, _f, _g, _h, _j;
702
- return __generator(this, function (_k) {
703
- switch (_k.label) {
699
+ var message, toolCalls, _loop_1, this_1, toolCalls_1, toolCalls_1_1, tool, state_1, e_1_1, result, validation, result1;
700
+ var e_1, _a;
701
+ var _b, _c, _d, _e, _f, _g;
702
+ return __generator(this, function (_h) {
703
+ switch (_h.label) {
704
704
  case 0:
705
705
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute begin"), { incoming: incoming, mode: mode });
706
706
  this.params.onExecute &&
@@ -712,120 +712,131 @@ var ClientAgent = /** @class */ (function () {
712
712
  content: incoming.trim(),
713
713
  })];
714
714
  case 1:
715
- _k.sent();
715
+ _h.sent();
716
716
  return [4 /*yield*/, this.getCompletion(mode)];
717
717
  case 2:
718
- message = _k.sent();
719
- if (!message.tool_calls) return [3 /*break*/, 11];
718
+ message = _h.sent();
719
+ if (!message.tool_calls) return [3 /*break*/, 12];
720
720
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " tool call begin"));
721
+ toolCalls = message.tool_calls.map(function (call) {
722
+ var _a, _b;
723
+ return ({
724
+ function: call.function,
725
+ id: (_a = call.id) !== null && _a !== void 0 ? _a : randomString(),
726
+ type: (_b = call.type) !== null && _b !== void 0 ? _b : "function",
727
+ });
728
+ });
729
+ return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
730
+ case 3:
731
+ _h.sent();
721
732
  _loop_1 = function (tool) {
722
733
  var targetFn, result_2, result_3;
723
- return __generator(this, function (_l) {
724
- switch (_l.label) {
734
+ return __generator(this, function (_j) {
735
+ switch (_j.label) {
725
736
  case 0:
726
- targetFn = (_d = this_1.params.tools) === null || _d === void 0 ? void 0 : _d.find(function (t) { return t.function.name === tool.function.name; });
727
- return [4 /*yield*/, this_1.params.history.push(__assign(__assign({}, message), { agentName: this_1.params.agentName }))];
728
- case 1:
729
- _l.sent();
730
- if (!!targetFn) return [3 /*break*/, 4];
737
+ targetFn = (_b = this_1.params.tools) === null || _b === void 0 ? void 0 : _b.find(function (t) { return t.function.name === tool.function.name; });
738
+ if (!!targetFn) return [3 /*break*/, 3];
731
739
  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);
732
740
  return [4 /*yield*/, this_1._resurrectModel(mode, "No target function for ".concat(tool.function.name))];
733
- case 2:
734
- result_2 = _l.sent();
741
+ case 1:
742
+ result_2 = _j.sent();
735
743
  this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_2));
736
744
  return [4 /*yield*/, this_1._emitOuput(mode, result_2)];
737
- case 3:
738
- _l.sent();
745
+ case 2:
746
+ _j.sent();
739
747
  return [2 /*return*/, { value: void 0 }];
740
- case 4:
741
- ((_e = targetFn.callbacks) === null || _e === void 0 ? void 0 : _e.onValidate) &&
742
- ((_f = targetFn.callbacks) === null || _f === void 0 ? void 0 : _f.onValidate(this_1.params.clientId, this_1.params.agentName, tool.function.arguments));
748
+ case 3:
749
+ ((_c = targetFn.callbacks) === null || _c === void 0 ? void 0 : _c.onValidate) &&
750
+ ((_d = targetFn.callbacks) === null || _d === void 0 ? void 0 : _d.onValidate(this_1.params.clientId, this_1.params.agentName, tool.function.arguments));
743
751
  return [4 /*yield*/, not(targetFn.validate(this_1.params.clientId, this_1.params.agentName, tool.function.arguments))];
744
- case 5:
745
- if (!_l.sent()) return [3 /*break*/, 8];
752
+ case 4:
753
+ if (!_j.sent()) return [3 /*break*/, 7];
746
754
  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"));
747
755
  return [4 /*yield*/, this_1._resurrectModel(mode, "Function validation failed: name=".concat(tool.function.name, " arguments=").concat(JSON.stringify(tool.function.arguments)))];
748
- case 6:
749
- result_3 = _l.sent();
756
+ case 5:
757
+ result_3 = _j.sent();
750
758
  this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_3));
751
759
  return [4 /*yield*/, this_1._emitOuput(mode, result_3)];
752
- case 7:
753
- _l.sent();
760
+ case 6:
761
+ _j.sent();
754
762
  return [2 /*return*/, { value: void 0 }];
755
- case 8:
756
- ((_g = targetFn.callbacks) === null || _g === void 0 ? void 0 : _g.onCall) &&
757
- ((_h = targetFn.callbacks) === null || _h === void 0 ? void 0 : _h.onCall(this_1.params.clientId, this_1.params.agentName, tool.function.arguments));
763
+ case 7:
764
+ ((_e = targetFn.callbacks) === null || _e === void 0 ? void 0 : _e.onCall) &&
765
+ ((_f = targetFn.callbacks) === null || _f === void 0 ? void 0 : _f.onCall(this_1.params.clientId, this_1.params.agentName, tool.function.arguments));
758
766
  /**
759
767
  * @description Do not await to avoid deadlock! The tool can send the message to other agents by emulating user messages
760
768
  */
761
- targetFn.call((_j = tool.id) !== null && _j !== void 0 ? _j : randomString(), this_1.params.clientId, this_1.params.agentName, tool.function.arguments);
769
+ targetFn.call(tool.id, this_1.params.clientId, this_1.params.agentName, tool.function.arguments);
762
770
  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 executing"));
763
771
  return [4 /*yield*/, Promise.race([
764
772
  this_1._toolCommitSubject.toPromise(),
765
773
  this_1._outputSubject.toPromise(),
766
774
  ])];
767
- case 9:
768
- _l.sent();
775
+ case 8:
776
+ _j.sent();
769
777
  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"));
770
778
  return [2 /*return*/];
771
779
  }
772
780
  });
773
781
  };
774
782
  this_1 = this;
775
- _k.label = 3;
776
- case 3:
777
- _k.trys.push([3, 8, 9, 10]);
778
- _a = __values(message.tool_calls), _b = _a.next();
779
- _k.label = 4;
783
+ _h.label = 4;
780
784
  case 4:
781
- if (!!_b.done) return [3 /*break*/, 7];
782
- tool = _b.value;
783
- return [5 /*yield**/, _loop_1(tool)];
785
+ _h.trys.push([4, 9, 10, 11]);
786
+ toolCalls_1 = __values(toolCalls), toolCalls_1_1 = toolCalls_1.next();
787
+ _h.label = 5;
784
788
  case 5:
785
- state_1 = _k.sent();
789
+ if (!!toolCalls_1_1.done) return [3 /*break*/, 8];
790
+ tool = toolCalls_1_1.value;
791
+ return [5 /*yield**/, _loop_1(tool)];
792
+ case 6:
793
+ state_1 = _h.sent();
786
794
  if (typeof state_1 === "object")
787
795
  return [2 /*return*/, state_1.value];
788
- _k.label = 6;
789
- case 6:
790
- _b = _a.next();
791
- return [3 /*break*/, 4];
792
- case 7: return [3 /*break*/, 10];
793
- case 8:
794
- e_1_1 = _k.sent();
795
- e_1 = { error: e_1_1 };
796
- return [3 /*break*/, 10];
796
+ _h.label = 7;
797
+ case 7:
798
+ toolCalls_1_1 = toolCalls_1.next();
799
+ return [3 /*break*/, 5];
800
+ case 8: return [3 /*break*/, 11];
797
801
  case 9:
802
+ e_1_1 = _h.sent();
803
+ e_1 = { error: e_1_1 };
804
+ return [3 /*break*/, 11];
805
+ case 10:
798
806
  try {
799
- if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
807
+ if (toolCalls_1_1 && !toolCalls_1_1.done && (_a = toolCalls_1.return)) _a.call(toolCalls_1);
800
808
  }
801
809
  finally { if (e_1) throw e_1.error; }
802
810
  return [7 /*endfinally*/];
803
- case 10: return [2 /*return*/];
804
811
  case 11:
812
+ ((_g = this.params.callbacks) === null || _g === void 0 ? void 0 : _g.onAfterToolCalls) &&
813
+ this.params.callbacks.onAfterToolCalls(this.params.clientId, this.params.agentName, toolCalls);
814
+ return [2 /*return*/];
815
+ case 12:
805
816
  if (!message.tool_calls) {
806
817
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute no tool calls detected"));
807
818
  }
808
819
  result = message.content;
809
820
  return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
810
- case 12:
811
- _k.sent();
821
+ case 13:
822
+ _h.sent();
812
823
  validation = null;
813
824
  return [4 /*yield*/, this.params.validate(result)];
814
- case 13:
815
- if (!(validation = _k.sent())) return [3 /*break*/, 16];
825
+ case 14:
826
+ if (!(validation = _h.sent())) return [3 /*break*/, 17];
816
827
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute invalid tool call detected: ").concat(validation), { result: result });
817
828
  return [4 /*yield*/, this._resurrectModel(mode, "Invalid model output: ".concat(result))];
818
- case 14:
819
- result1 = _k.sent();
820
- return [4 /*yield*/, this._emitOuput(mode, result1)];
821
829
  case 15:
822
- _k.sent();
823
- return [2 /*return*/];
830
+ result1 = _h.sent();
831
+ return [4 /*yield*/, this._emitOuput(mode, result1)];
824
832
  case 16:
833
+ _h.sent();
834
+ return [2 /*return*/];
835
+ case 17:
825
836
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute end result=").concat(result));
826
837
  return [4 /*yield*/, this._emitOuput(mode, result)];
827
- case 17:
828
- _k.sent();
838
+ case 18:
839
+ _h.sent();
829
840
  return [2 /*return*/];
830
841
  }
831
842
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-swarm-kit",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "description": "A TypeScript library for building orchestrated framework-agnostic multi-agent AI systems",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
package/types.d.ts CHANGED
@@ -631,6 +631,13 @@ interface IAgentSchemaCallbacks {
631
631
  * @param agentName - The name of the agent.
632
632
  */
633
633
  onDispose?: (clientId: string, agentName: AgentName) => void;
634
+ /**
635
+ * Callback triggered after all tools are called
636
+ * @param clientId - The ID of the client.
637
+ * @param agentName - The name of the agent.
638
+ * @param toolCalls - The array of tool calls
639
+ */
640
+ onAfterToolCalls?: (clientId: string, agentName: AgentName, toolCalls: IToolCall[]) => void;
634
641
  }
635
642
  /**
636
643
  * Interface representing the schema for an agent.