agent-swarm-kit 1.0.45 → 1.0.46

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
@@ -34,6 +34,18 @@ var __assign = function() {
34
34
  return __assign.apply(this, arguments);
35
35
  };
36
36
 
37
+ function __rest(s, e) {
38
+ var t = {};
39
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
40
+ t[p] = s[p];
41
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
42
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
43
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
44
+ t[p[i]] = s[p[i]];
45
+ }
46
+ return t;
47
+ }
48
+
37
49
  function __awaiter(thisArg, _arguments, P, generator) {
38
50
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
39
51
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -771,7 +783,8 @@ var ClientAgent = /** @class */ (function () {
771
783
  return [4 /*yield*/, functoolsKit.not(targetFn.validate({
772
784
  clientId: this_1.params.clientId,
773
785
  agentName: this_1.params.agentName,
774
- params: tool.function.arguments
786
+ params: tool.function.arguments,
787
+ toolCalls: toolCalls,
775
788
  }))];
776
789
  case 4:
777
790
  if (!_h.sent()) return [3 /*break*/, 7];
@@ -796,6 +809,7 @@ var ClientAgent = /** @class */ (function () {
796
809
  agentName: this_1.params.agentName,
797
810
  params: tool.function.arguments,
798
811
  isLast: idx === toolCalls.length - 1,
812
+ toolCalls: toolCalls,
799
813
  })).then(function () {
800
814
  var _a, _b;
801
815
  ((_a = targetFn.callbacks) === null || _a === void 0 ? void 0 : _a.onAfterCall) &&
@@ -1127,7 +1141,7 @@ var ClientHistory = /** @class */ (function () {
1127
1141
  * @returns {Promise<IModelMessage[]>} - The array of messages for the agent.
1128
1142
  */
1129
1143
  this.toArrayForAgent = function (prompt, system) { return __awaiter(_this, void 0, void 0, function () {
1130
- var commonMessagesRaw, systemMessagesRaw, _a, _b, _c, content, message, e_2_1, systemMessages, commonMessages, promptMessages;
1144
+ var commonMessagesRaw, systemMessagesRaw, _a, _b, _c, content, message, e_2_1, systemMessages, commonMessages, assistantToolCallSet, assistantMessages, promptMessages;
1131
1145
  var _this = this;
1132
1146
  var _d, e_2, _e, _f;
1133
1147
  var _g;
@@ -1194,6 +1208,17 @@ var ClientHistory = /** @class */ (function () {
1194
1208
  commonMessages = commonMessagesRaw
1195
1209
  .filter(this._filterCondition)
1196
1210
  .slice(-GLOBAL_CONFIG.CC_KEEP_MESSAGES);
1211
+ assistantToolCallSet = new Set(commonMessages.map(function (_a) {
1212
+ var tool_call_id = _a.tool_call_id;
1213
+ return tool_call_id;
1214
+ }));
1215
+ assistantMessages = commonMessages.map(function (_a) {
1216
+ var tool_calls = _a.tool_calls, message = __rest(_a, ["tool_calls"]);
1217
+ return (__assign(__assign({}, message), { tool_calls: tool_calls === null || tool_calls === void 0 ? void 0 : tool_calls.filter(function (_a) {
1218
+ var id = _a.id;
1219
+ return assistantToolCallSet.has(id);
1220
+ }) }));
1221
+ });
1197
1222
  promptMessages = [];
1198
1223
  {
1199
1224
  promptMessages.push({
@@ -1219,7 +1244,7 @@ var ClientHistory = /** @class */ (function () {
1219
1244
  });
1220
1245
  });
1221
1246
  }
1222
- return [2 /*return*/, __spreadArray(__spreadArray(__spreadArray([], __read(promptMessages), false), __read(systemMessages), false), __read(commonMessages), false)];
1247
+ return [2 /*return*/, __spreadArray(__spreadArray(__spreadArray([], __read(promptMessages), false), __read(systemMessages), false), __read(assistantMessages), false)];
1223
1248
  }
1224
1249
  });
1225
1250
  }); };
package/build/index.mjs CHANGED
@@ -32,6 +32,18 @@ var __assign = function() {
32
32
  return __assign.apply(this, arguments);
33
33
  };
34
34
 
35
+ function __rest(s, e) {
36
+ var t = {};
37
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
38
+ t[p] = s[p];
39
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
40
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
41
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
42
+ t[p[i]] = s[p[i]];
43
+ }
44
+ return t;
45
+ }
46
+
35
47
  function __awaiter(thisArg, _arguments, P, generator) {
36
48
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
49
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -769,7 +781,8 @@ var ClientAgent = /** @class */ (function () {
769
781
  return [4 /*yield*/, not(targetFn.validate({
770
782
  clientId: this_1.params.clientId,
771
783
  agentName: this_1.params.agentName,
772
- params: tool.function.arguments
784
+ params: tool.function.arguments,
785
+ toolCalls: toolCalls,
773
786
  }))];
774
787
  case 4:
775
788
  if (!_h.sent()) return [3 /*break*/, 7];
@@ -794,6 +807,7 @@ var ClientAgent = /** @class */ (function () {
794
807
  agentName: this_1.params.agentName,
795
808
  params: tool.function.arguments,
796
809
  isLast: idx === toolCalls.length - 1,
810
+ toolCalls: toolCalls,
797
811
  })).then(function () {
798
812
  var _a, _b;
799
813
  ((_a = targetFn.callbacks) === null || _a === void 0 ? void 0 : _a.onAfterCall) &&
@@ -1125,7 +1139,7 @@ var ClientHistory = /** @class */ (function () {
1125
1139
  * @returns {Promise<IModelMessage[]>} - The array of messages for the agent.
1126
1140
  */
1127
1141
  this.toArrayForAgent = function (prompt, system) { return __awaiter(_this, void 0, void 0, function () {
1128
- var commonMessagesRaw, systemMessagesRaw, _a, _b, _c, content, message, e_2_1, systemMessages, commonMessages, promptMessages;
1142
+ var commonMessagesRaw, systemMessagesRaw, _a, _b, _c, content, message, e_2_1, systemMessages, commonMessages, assistantToolCallSet, assistantMessages, promptMessages;
1129
1143
  var _this = this;
1130
1144
  var _d, e_2, _e, _f;
1131
1145
  var _g;
@@ -1192,6 +1206,17 @@ var ClientHistory = /** @class */ (function () {
1192
1206
  commonMessages = commonMessagesRaw
1193
1207
  .filter(this._filterCondition)
1194
1208
  .slice(-GLOBAL_CONFIG.CC_KEEP_MESSAGES);
1209
+ assistantToolCallSet = new Set(commonMessages.map(function (_a) {
1210
+ var tool_call_id = _a.tool_call_id;
1211
+ return tool_call_id;
1212
+ }));
1213
+ assistantMessages = commonMessages.map(function (_a) {
1214
+ var tool_calls = _a.tool_calls, message = __rest(_a, ["tool_calls"]);
1215
+ return (__assign(__assign({}, message), { tool_calls: tool_calls === null || tool_calls === void 0 ? void 0 : tool_calls.filter(function (_a) {
1216
+ var id = _a.id;
1217
+ return assistantToolCallSet.has(id);
1218
+ }) }));
1219
+ });
1195
1220
  promptMessages = [];
1196
1221
  {
1197
1222
  promptMessages.push({
@@ -1217,7 +1242,7 @@ var ClientHistory = /** @class */ (function () {
1217
1242
  });
1218
1243
  });
1219
1244
  }
1220
- return [2 /*return*/, __spreadArray(__spreadArray(__spreadArray([], __read(promptMessages), false), __read(systemMessages), false), __read(commonMessages), false)];
1245
+ return [2 /*return*/, __spreadArray(__spreadArray(__spreadArray([], __read(promptMessages), false), __read(systemMessages), false), __read(assistantMessages), false)];
1221
1246
  }
1222
1247
  });
1223
1248
  }); };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-swarm-kit",
3
- "version": "1.0.45",
3
+ "version": "1.0.46",
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
@@ -543,6 +543,7 @@ interface IAgentTool<T = Record<string, unknown>> extends ITool {
543
543
  clientId: string;
544
544
  agentName: AgentName;
545
545
  params: T;
546
+ toolCalls: IToolCall[];
546
547
  isLast: boolean;
547
548
  }): Promise<void>;
548
549
  /**
@@ -555,6 +556,7 @@ interface IAgentTool<T = Record<string, unknown>> extends ITool {
555
556
  validate(dto: {
556
557
  clientId: string;
557
558
  agentName: AgentName;
559
+ toolCalls: IToolCall[];
558
560
  params: T;
559
561
  }): Promise<boolean> | boolean;
560
562
  /** The name of the tool. */