agent-swarm-kit 1.0.148 → 1.0.149

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
@@ -2300,10 +2300,11 @@ var ClientAgent = /** @class */ (function () {
2300
2300
  */
2301
2301
  ClientAgent.prototype._resurrectModel = function (mode_1) {
2302
2302
  return __awaiter(this, arguments, void 0, function (mode, reason) {
2303
- var rawMessage, message, result, validation, content;
2303
+ var rawMessage, content, message, result, validation, content;
2304
+ var _a;
2304
2305
  if (reason === void 0) { reason = "unknown"; }
2305
- return __generator(this, function (_a) {
2306
- switch (_a.label) {
2306
+ return __generator(this, function (_b) {
2307
+ switch (_b.label) {
2307
2308
  case 0:
2308
2309
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
2309
2310
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " _resurrectModel"));
@@ -2318,7 +2319,7 @@ var ClientAgent = /** @class */ (function () {
2318
2319
  content: GLOBAL_CONFIG.CC_TOOL_CALL_EXCEPTION_RECOMPLETE_PROMPT,
2319
2320
  })];
2320
2321
  case 1:
2321
- _a.sent();
2322
+ _b.sent();
2322
2323
  return [3 /*break*/, 8];
2323
2324
  case 2:
2324
2325
  if (!(GLOBAL_CONFIG.CC_RESQUE_STRATEGY === "flush")) return [3 /*break*/, 5];
@@ -2329,7 +2330,7 @@ var ClientAgent = /** @class */ (function () {
2329
2330
  content: reason || "Unknown error",
2330
2331
  })];
2331
2332
  case 3:
2332
- _a.sent();
2333
+ _b.sent();
2333
2334
  return [4 /*yield*/, this.params.history.push({
2334
2335
  role: "user",
2335
2336
  mode: "tool",
@@ -2337,28 +2338,53 @@ var ClientAgent = /** @class */ (function () {
2337
2338
  content: GLOBAL_CONFIG.CC_TOOL_CALL_EXCEPTION_FLUSH_PROMPT,
2338
2339
  })];
2339
2340
  case 4:
2340
- _a.sent();
2341
+ _b.sent();
2341
2342
  return [3 /*break*/, 8];
2342
2343
  case 5:
2343
2344
  if (!(GLOBAL_CONFIG.CC_RESQUE_STRATEGY === "custom")) return [3 /*break*/, 7];
2344
2345
  return [4 /*yield*/, GLOBAL_CONFIG.CC_TOOL_CALL_EXCEPTION_CUSTOM_FUNCTION(this.params.clientId, this.params.agentName)];
2345
2346
  case 6:
2346
- _a.sent();
2347
+ _b.sent();
2347
2348
  return [3 /*break*/, 8];
2348
2349
  case 7: throw new Error("agent-swarm _resurrectModel invalid strategy value=".concat(GLOBAL_CONFIG.CC_RESQUE_STRATEGY, " agentName=").concat(this.params.agentName, " clientId=").concat(this.params.clientId));
2349
2350
  case 8: return [4 /*yield*/, this.getCompletion(mode)];
2350
2351
  case 9:
2351
- rawMessage = _a.sent();
2352
- return [4 /*yield*/, this.params.map(rawMessage, this.params.clientId, this.params.agentName)];
2352
+ rawMessage = _b.sent();
2353
+ if (!((_a = rawMessage.tool_calls) === null || _a === void 0 ? void 0 : _a.length)) return [3 /*break*/, 13];
2354
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
2355
+ this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " _resurrectModel failed due to tool_calls"));
2356
+ console.warn("agent-swarm model ressurect did not solved the problem (tool_calls) for agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " strategy=").concat(GLOBAL_CONFIG.CC_RESQUE_STRATEGY));
2357
+ content = createPlaceholder();
2358
+ return [4 /*yield*/, this.params.history.push({
2359
+ role: "resque",
2360
+ mode: "tool",
2361
+ agentName: this.params.agentName,
2362
+ content: reason || "Unknown error",
2363
+ })];
2353
2364
  case 10:
2354
- message = _a.sent();
2355
- return [4 /*yield*/, this.params.transform(message.content, this.params.clientId, this.params.agentName)];
2365
+ _b.sent();
2366
+ return [4 /*yield*/, this.params.history.push({
2367
+ agentName: this.params.agentName,
2368
+ role: "assistant",
2369
+ mode: "tool",
2370
+ content: content,
2371
+ })];
2356
2372
  case 11:
2357
- result = _a.sent();
2373
+ _b.sent();
2374
+ return [4 /*yield*/, this._resqueSubject.next(MODEL_RESQUE_SYMBOL)];
2375
+ case 12:
2376
+ _b.sent();
2377
+ return [2 /*return*/, content];
2378
+ case 13: return [4 /*yield*/, this.params.map(rawMessage, this.params.clientId, this.params.agentName)];
2379
+ case 14:
2380
+ message = _b.sent();
2381
+ return [4 /*yield*/, this.params.transform(message.content, this.params.clientId, this.params.agentName)];
2382
+ case 15:
2383
+ result = _b.sent();
2358
2384
  validation = null;
2359
2385
  return [4 /*yield*/, this.params.validate(result)];
2360
- case 12:
2361
- if (!(validation = _a.sent())) return [3 /*break*/, 16];
2386
+ case 16:
2387
+ if (!(validation = _b.sent())) return [3 /*break*/, 20];
2362
2388
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
2363
2389
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " _resurrectModel validation error: ").concat(validation));
2364
2390
  console.warn("agent-swarm model ressurect did not solved the problem for agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " strategy=").concat(GLOBAL_CONFIG.CC_RESQUE_STRATEGY));
@@ -2369,26 +2395,26 @@ var ClientAgent = /** @class */ (function () {
2369
2395
  agentName: this.params.agentName,
2370
2396
  content: reason || "Unknown error",
2371
2397
  })];
2372
- case 13:
2373
- _a.sent();
2398
+ case 17:
2399
+ _b.sent();
2374
2400
  return [4 /*yield*/, this.params.history.push({
2375
2401
  agentName: this.params.agentName,
2376
2402
  role: "assistant",
2377
2403
  mode: "tool",
2378
2404
  content: content,
2379
2405
  })];
2380
- case 14:
2381
- _a.sent();
2406
+ case 18:
2407
+ _b.sent();
2382
2408
  return [4 /*yield*/, this._resqueSubject.next(MODEL_RESQUE_SYMBOL)];
2383
- case 15:
2384
- _a.sent();
2409
+ case 19:
2410
+ _b.sent();
2385
2411
  return [2 /*return*/, content];
2386
- case 16: return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
2387
- case 17:
2388
- _a.sent();
2412
+ case 20: return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
2413
+ case 21:
2414
+ _b.sent();
2389
2415
  return [4 /*yield*/, this._resqueSubject.next(MODEL_RESQUE_SYMBOL)];
2390
- case 18:
2391
- _a.sent();
2416
+ case 22:
2417
+ _b.sent();
2392
2418
  return [2 /*return*/, result];
2393
2419
  }
2394
2420
  });
package/build/index.mjs CHANGED
@@ -2298,10 +2298,11 @@ var ClientAgent = /** @class */ (function () {
2298
2298
  */
2299
2299
  ClientAgent.prototype._resurrectModel = function (mode_1) {
2300
2300
  return __awaiter(this, arguments, void 0, function (mode, reason) {
2301
- var rawMessage, message, result, validation, content;
2301
+ var rawMessage, content, message, result, validation, content;
2302
+ var _a;
2302
2303
  if (reason === void 0) { reason = "unknown"; }
2303
- return __generator(this, function (_a) {
2304
- switch (_a.label) {
2304
+ return __generator(this, function (_b) {
2305
+ switch (_b.label) {
2305
2306
  case 0:
2306
2307
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
2307
2308
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " _resurrectModel"));
@@ -2316,7 +2317,7 @@ var ClientAgent = /** @class */ (function () {
2316
2317
  content: GLOBAL_CONFIG.CC_TOOL_CALL_EXCEPTION_RECOMPLETE_PROMPT,
2317
2318
  })];
2318
2319
  case 1:
2319
- _a.sent();
2320
+ _b.sent();
2320
2321
  return [3 /*break*/, 8];
2321
2322
  case 2:
2322
2323
  if (!(GLOBAL_CONFIG.CC_RESQUE_STRATEGY === "flush")) return [3 /*break*/, 5];
@@ -2327,7 +2328,7 @@ var ClientAgent = /** @class */ (function () {
2327
2328
  content: reason || "Unknown error",
2328
2329
  })];
2329
2330
  case 3:
2330
- _a.sent();
2331
+ _b.sent();
2331
2332
  return [4 /*yield*/, this.params.history.push({
2332
2333
  role: "user",
2333
2334
  mode: "tool",
@@ -2335,28 +2336,53 @@ var ClientAgent = /** @class */ (function () {
2335
2336
  content: GLOBAL_CONFIG.CC_TOOL_CALL_EXCEPTION_FLUSH_PROMPT,
2336
2337
  })];
2337
2338
  case 4:
2338
- _a.sent();
2339
+ _b.sent();
2339
2340
  return [3 /*break*/, 8];
2340
2341
  case 5:
2341
2342
  if (!(GLOBAL_CONFIG.CC_RESQUE_STRATEGY === "custom")) return [3 /*break*/, 7];
2342
2343
  return [4 /*yield*/, GLOBAL_CONFIG.CC_TOOL_CALL_EXCEPTION_CUSTOM_FUNCTION(this.params.clientId, this.params.agentName)];
2343
2344
  case 6:
2344
- _a.sent();
2345
+ _b.sent();
2345
2346
  return [3 /*break*/, 8];
2346
2347
  case 7: throw new Error("agent-swarm _resurrectModel invalid strategy value=".concat(GLOBAL_CONFIG.CC_RESQUE_STRATEGY, " agentName=").concat(this.params.agentName, " clientId=").concat(this.params.clientId));
2347
2348
  case 8: return [4 /*yield*/, this.getCompletion(mode)];
2348
2349
  case 9:
2349
- rawMessage = _a.sent();
2350
- return [4 /*yield*/, this.params.map(rawMessage, this.params.clientId, this.params.agentName)];
2350
+ rawMessage = _b.sent();
2351
+ if (!((_a = rawMessage.tool_calls) === null || _a === void 0 ? void 0 : _a.length)) return [3 /*break*/, 13];
2352
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
2353
+ this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " _resurrectModel failed due to tool_calls"));
2354
+ console.warn("agent-swarm model ressurect did not solved the problem (tool_calls) for agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " strategy=").concat(GLOBAL_CONFIG.CC_RESQUE_STRATEGY));
2355
+ content = createPlaceholder();
2356
+ return [4 /*yield*/, this.params.history.push({
2357
+ role: "resque",
2358
+ mode: "tool",
2359
+ agentName: this.params.agentName,
2360
+ content: reason || "Unknown error",
2361
+ })];
2351
2362
  case 10:
2352
- message = _a.sent();
2353
- return [4 /*yield*/, this.params.transform(message.content, this.params.clientId, this.params.agentName)];
2363
+ _b.sent();
2364
+ return [4 /*yield*/, this.params.history.push({
2365
+ agentName: this.params.agentName,
2366
+ role: "assistant",
2367
+ mode: "tool",
2368
+ content: content,
2369
+ })];
2354
2370
  case 11:
2355
- result = _a.sent();
2371
+ _b.sent();
2372
+ return [4 /*yield*/, this._resqueSubject.next(MODEL_RESQUE_SYMBOL)];
2373
+ case 12:
2374
+ _b.sent();
2375
+ return [2 /*return*/, content];
2376
+ case 13: return [4 /*yield*/, this.params.map(rawMessage, this.params.clientId, this.params.agentName)];
2377
+ case 14:
2378
+ message = _b.sent();
2379
+ return [4 /*yield*/, this.params.transform(message.content, this.params.clientId, this.params.agentName)];
2380
+ case 15:
2381
+ result = _b.sent();
2356
2382
  validation = null;
2357
2383
  return [4 /*yield*/, this.params.validate(result)];
2358
- case 12:
2359
- if (!(validation = _a.sent())) return [3 /*break*/, 16];
2384
+ case 16:
2385
+ if (!(validation = _b.sent())) return [3 /*break*/, 20];
2360
2386
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
2361
2387
  this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " _resurrectModel validation error: ").concat(validation));
2362
2388
  console.warn("agent-swarm model ressurect did not solved the problem for agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " strategy=").concat(GLOBAL_CONFIG.CC_RESQUE_STRATEGY));
@@ -2367,26 +2393,26 @@ var ClientAgent = /** @class */ (function () {
2367
2393
  agentName: this.params.agentName,
2368
2394
  content: reason || "Unknown error",
2369
2395
  })];
2370
- case 13:
2371
- _a.sent();
2396
+ case 17:
2397
+ _b.sent();
2372
2398
  return [4 /*yield*/, this.params.history.push({
2373
2399
  agentName: this.params.agentName,
2374
2400
  role: "assistant",
2375
2401
  mode: "tool",
2376
2402
  content: content,
2377
2403
  })];
2378
- case 14:
2379
- _a.sent();
2404
+ case 18:
2405
+ _b.sent();
2380
2406
  return [4 /*yield*/, this._resqueSubject.next(MODEL_RESQUE_SYMBOL)];
2381
- case 15:
2382
- _a.sent();
2407
+ case 19:
2408
+ _b.sent();
2383
2409
  return [2 /*return*/, content];
2384
- case 16: return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
2385
- case 17:
2386
- _a.sent();
2410
+ case 20: return [4 /*yield*/, this.params.history.push(__assign(__assign({}, message), { agentName: this.params.agentName }))];
2411
+ case 21:
2412
+ _b.sent();
2387
2413
  return [4 /*yield*/, this._resqueSubject.next(MODEL_RESQUE_SYMBOL)];
2388
- case 18:
2389
- _a.sent();
2414
+ case 22:
2415
+ _b.sent();
2390
2416
  return [2 /*return*/, result];
2391
2417
  }
2392
2418
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-swarm-kit",
3
- "version": "1.0.148",
3
+ "version": "1.0.149",
4
4
  "description": "A TypeScript library for building orchestrated framework-agnostic multi-agent AI systems",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",