agent-swarm-kit 1.0.62 → 1.0.64

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
@@ -446,6 +446,8 @@ var HistoryInstance = /** @class */ (function () {
446
446
  clientId: this.clientId,
447
447
  agentName: agentName,
448
448
  });
449
+ this.callbacks.onPush &&
450
+ this.callbacks.onPush(value, this.clientId, agentName);
449
451
  this._array.push(value);
450
452
  this.callbacks.onChange &&
451
453
  this.callbacks.onChange(this._array, this.clientId, agentName);
@@ -489,6 +491,8 @@ var HistoryInstance = /** @class */ (function () {
489
491
  agentName: agentName,
490
492
  });
491
493
  if (!this.callbacks.onRead) return [3 /*break*/, 12];
494
+ this.callbacks.onReadBegin &&
495
+ this.callbacks.onReadBegin(this.clientId, agentName);
492
496
  _g.label = 1;
493
497
  case 1:
494
498
  _g.trys.push([1, 8, 9, 10]);
@@ -497,7 +501,7 @@ var HistoryInstance = /** @class */ (function () {
497
501
  case 2:
498
502
  if (!!_b.done) return [3 /*break*/, 7];
499
503
  item = _b.value;
500
- return [4 /*yield*/, __await(callbacks.filterCondition(item, this.clientId, agentName))];
504
+ return [4 /*yield*/, __await(this.callbacks.filterCondition(item, this.clientId, agentName))];
501
505
  case 3:
502
506
  if (!_g.sent()) return [3 /*break*/, 6];
503
507
  this.callbacks.onRead(item, this.clientId, agentName);
@@ -520,38 +524,48 @@ var HistoryInstance = /** @class */ (function () {
520
524
  }
521
525
  finally { if (e_1) throw e_1.error; }
522
526
  return [7 /*endfinally*/];
523
- case 10: return [4 /*yield*/, __await(void 0)];
527
+ case 10:
528
+ this.callbacks.onReadEnd &&
529
+ this.callbacks.onReadEnd(this.clientId, agentName);
530
+ return [4 /*yield*/, __await(void 0)];
524
531
  case 11: return [2 /*return*/, _g.sent()];
525
532
  case 12:
526
- _g.trys.push([12, 19, 20, 21]);
527
- _c = __values(this._array), _d = _c.next();
533
+ this.callbacks.onReadBegin &&
534
+ this.callbacks.onReadBegin(this.clientId, agentName);
528
535
  _g.label = 13;
529
536
  case 13:
530
- if (!!_d.done) return [3 /*break*/, 18];
531
- item = _d.value;
532
- return [4 /*yield*/, __await(callbacks.filterCondition(item, this.clientId, agentName))];
537
+ _g.trys.push([13, 20, 21, 22]);
538
+ _c = __values(this._array), _d = _c.next();
539
+ _g.label = 14;
533
540
  case 14:
534
- if (!_g.sent()) return [3 /*break*/, 17];
541
+ if (!!_d.done) return [3 /*break*/, 19];
542
+ item = _d.value;
543
+ return [4 /*yield*/, __await(this.callbacks.filterCondition(item, this.clientId, agentName))];
544
+ case 15:
545
+ if (!_g.sent()) return [3 /*break*/, 18];
535
546
  return [4 /*yield*/, __await(item)];
536
- case 15: return [4 /*yield*/, _g.sent()];
537
- case 16:
538
- _g.sent();
539
- _g.label = 17;
547
+ case 16: return [4 /*yield*/, _g.sent()];
540
548
  case 17:
549
+ _g.sent();
550
+ _g.label = 18;
551
+ case 18:
541
552
  _d = _c.next();
542
- return [3 /*break*/, 13];
543
- case 18: return [3 /*break*/, 21];
544
- case 19:
553
+ return [3 /*break*/, 14];
554
+ case 19: return [3 /*break*/, 22];
555
+ case 20:
545
556
  e_2_1 = _g.sent();
546
557
  e_2 = { error: e_2_1 };
547
- return [3 /*break*/, 21];
548
- case 20:
558
+ return [3 /*break*/, 22];
559
+ case 21:
549
560
  try {
550
561
  if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
551
562
  }
552
563
  finally { if (e_2) throw e_2.error; }
553
564
  return [7 /*endfinally*/];
554
- case 21: return [2 /*return*/];
565
+ case 22:
566
+ this.callbacks.onReadEnd &&
567
+ this.callbacks.onReadEnd(this.clientId, agentName);
568
+ return [2 /*return*/];
555
569
  }
556
570
  });
557
571
  });
@@ -575,6 +589,8 @@ var HistoryInstance = /** @class */ (function () {
575
589
  agentName: agentName,
576
590
  });
577
591
  if (!this.callbacks.onRead) return [3 /*break*/, 11];
592
+ this.callbacks.onReadBegin &&
593
+ this.callbacks.onReadBegin(this.clientId, agentName);
578
594
  _g.label = 1;
579
595
  case 1:
580
596
  _g.trys.push([1, 7, 8, 9]);
@@ -603,35 +619,45 @@ var HistoryInstance = /** @class */ (function () {
603
619
  }
604
620
  finally { if (e_3) throw e_3.error; }
605
621
  return [7 /*endfinally*/];
606
- case 9: return [4 /*yield*/, __await(void 0)];
622
+ case 9:
623
+ this.callbacks.onReadEnd &&
624
+ this.callbacks.onReadEnd(this.clientId, agentName);
625
+ return [4 /*yield*/, __await(void 0)];
607
626
  case 10: return [2 /*return*/, _g.sent()];
608
627
  case 11:
609
- _g.trys.push([11, 17, 18, 19]);
610
- _c = __values(this._array), _d = _c.next();
628
+ this.callbacks.onReadBegin &&
629
+ this.callbacks.onReadBegin(this.clientId, agentName);
611
630
  _g.label = 12;
612
631
  case 12:
613
- if (!!_d.done) return [3 /*break*/, 16];
632
+ _g.trys.push([12, 18, 19, 20]);
633
+ _c = __values(this._array), _d = _c.next();
634
+ _g.label = 13;
635
+ case 13:
636
+ if (!!_d.done) return [3 /*break*/, 17];
614
637
  item = _d.value;
615
638
  return [4 /*yield*/, __await(item)];
616
- case 13: return [4 /*yield*/, _g.sent()];
617
- case 14:
618
- _g.sent();
619
- _g.label = 15;
639
+ case 14: return [4 /*yield*/, _g.sent()];
620
640
  case 15:
641
+ _g.sent();
642
+ _g.label = 16;
643
+ case 16:
621
644
  _d = _c.next();
622
- return [3 /*break*/, 12];
623
- case 16: return [3 /*break*/, 19];
624
- case 17:
645
+ return [3 /*break*/, 13];
646
+ case 17: return [3 /*break*/, 20];
647
+ case 18:
625
648
  e_4_1 = _g.sent();
626
649
  e_4 = { error: e_4_1 };
627
- return [3 /*break*/, 19];
628
- case 18:
650
+ return [3 /*break*/, 20];
651
+ case 19:
629
652
  try {
630
653
  if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
631
654
  }
632
655
  finally { if (e_4) throw e_4.error; }
633
656
  return [7 /*endfinally*/];
634
- case 19: return [2 /*return*/];
657
+ case 20:
658
+ this.callbacks.onReadEnd &&
659
+ this.callbacks.onReadEnd(this.clientId, agentName);
660
+ return [2 /*return*/];
635
661
  }
636
662
  });
637
663
  });
@@ -666,7 +692,7 @@ var HistoryUtils = /** @class */ (function () {
666
692
  */
667
693
  this.useHistoryCallbacks = function (Callbacks) {
668
694
  swarm.loggerService.log("HistoryUtils useHistoryCallbacks");
669
- _this.HistoryCallbacks = Callbacks;
695
+ Object.assign(_this.HistoryCallbacks, Callbacks);
670
696
  };
671
697
  /**
672
698
  * Push a new message to the history.
package/build/index.mjs CHANGED
@@ -444,6 +444,8 @@ var HistoryInstance = /** @class */ (function () {
444
444
  clientId: this.clientId,
445
445
  agentName: agentName,
446
446
  });
447
+ this.callbacks.onPush &&
448
+ this.callbacks.onPush(value, this.clientId, agentName);
447
449
  this._array.push(value);
448
450
  this.callbacks.onChange &&
449
451
  this.callbacks.onChange(this._array, this.clientId, agentName);
@@ -487,6 +489,8 @@ var HistoryInstance = /** @class */ (function () {
487
489
  agentName: agentName,
488
490
  });
489
491
  if (!this.callbacks.onRead) return [3 /*break*/, 12];
492
+ this.callbacks.onReadBegin &&
493
+ this.callbacks.onReadBegin(this.clientId, agentName);
490
494
  _g.label = 1;
491
495
  case 1:
492
496
  _g.trys.push([1, 8, 9, 10]);
@@ -495,7 +499,7 @@ var HistoryInstance = /** @class */ (function () {
495
499
  case 2:
496
500
  if (!!_b.done) return [3 /*break*/, 7];
497
501
  item = _b.value;
498
- return [4 /*yield*/, __await(callbacks.filterCondition(item, this.clientId, agentName))];
502
+ return [4 /*yield*/, __await(this.callbacks.filterCondition(item, this.clientId, agentName))];
499
503
  case 3:
500
504
  if (!_g.sent()) return [3 /*break*/, 6];
501
505
  this.callbacks.onRead(item, this.clientId, agentName);
@@ -518,38 +522,48 @@ var HistoryInstance = /** @class */ (function () {
518
522
  }
519
523
  finally { if (e_1) throw e_1.error; }
520
524
  return [7 /*endfinally*/];
521
- case 10: return [4 /*yield*/, __await(void 0)];
525
+ case 10:
526
+ this.callbacks.onReadEnd &&
527
+ this.callbacks.onReadEnd(this.clientId, agentName);
528
+ return [4 /*yield*/, __await(void 0)];
522
529
  case 11: return [2 /*return*/, _g.sent()];
523
530
  case 12:
524
- _g.trys.push([12, 19, 20, 21]);
525
- _c = __values(this._array), _d = _c.next();
531
+ this.callbacks.onReadBegin &&
532
+ this.callbacks.onReadBegin(this.clientId, agentName);
526
533
  _g.label = 13;
527
534
  case 13:
528
- if (!!_d.done) return [3 /*break*/, 18];
529
- item = _d.value;
530
- return [4 /*yield*/, __await(callbacks.filterCondition(item, this.clientId, agentName))];
535
+ _g.trys.push([13, 20, 21, 22]);
536
+ _c = __values(this._array), _d = _c.next();
537
+ _g.label = 14;
531
538
  case 14:
532
- if (!_g.sent()) return [3 /*break*/, 17];
539
+ if (!!_d.done) return [3 /*break*/, 19];
540
+ item = _d.value;
541
+ return [4 /*yield*/, __await(this.callbacks.filterCondition(item, this.clientId, agentName))];
542
+ case 15:
543
+ if (!_g.sent()) return [3 /*break*/, 18];
533
544
  return [4 /*yield*/, __await(item)];
534
- case 15: return [4 /*yield*/, _g.sent()];
535
- case 16:
536
- _g.sent();
537
- _g.label = 17;
545
+ case 16: return [4 /*yield*/, _g.sent()];
538
546
  case 17:
547
+ _g.sent();
548
+ _g.label = 18;
549
+ case 18:
539
550
  _d = _c.next();
540
- return [3 /*break*/, 13];
541
- case 18: return [3 /*break*/, 21];
542
- case 19:
551
+ return [3 /*break*/, 14];
552
+ case 19: return [3 /*break*/, 22];
553
+ case 20:
543
554
  e_2_1 = _g.sent();
544
555
  e_2 = { error: e_2_1 };
545
- return [3 /*break*/, 21];
546
- case 20:
556
+ return [3 /*break*/, 22];
557
+ case 21:
547
558
  try {
548
559
  if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
549
560
  }
550
561
  finally { if (e_2) throw e_2.error; }
551
562
  return [7 /*endfinally*/];
552
- case 21: return [2 /*return*/];
563
+ case 22:
564
+ this.callbacks.onReadEnd &&
565
+ this.callbacks.onReadEnd(this.clientId, agentName);
566
+ return [2 /*return*/];
553
567
  }
554
568
  });
555
569
  });
@@ -573,6 +587,8 @@ var HistoryInstance = /** @class */ (function () {
573
587
  agentName: agentName,
574
588
  });
575
589
  if (!this.callbacks.onRead) return [3 /*break*/, 11];
590
+ this.callbacks.onReadBegin &&
591
+ this.callbacks.onReadBegin(this.clientId, agentName);
576
592
  _g.label = 1;
577
593
  case 1:
578
594
  _g.trys.push([1, 7, 8, 9]);
@@ -601,35 +617,45 @@ var HistoryInstance = /** @class */ (function () {
601
617
  }
602
618
  finally { if (e_3) throw e_3.error; }
603
619
  return [7 /*endfinally*/];
604
- case 9: return [4 /*yield*/, __await(void 0)];
620
+ case 9:
621
+ this.callbacks.onReadEnd &&
622
+ this.callbacks.onReadEnd(this.clientId, agentName);
623
+ return [4 /*yield*/, __await(void 0)];
605
624
  case 10: return [2 /*return*/, _g.sent()];
606
625
  case 11:
607
- _g.trys.push([11, 17, 18, 19]);
608
- _c = __values(this._array), _d = _c.next();
626
+ this.callbacks.onReadBegin &&
627
+ this.callbacks.onReadBegin(this.clientId, agentName);
609
628
  _g.label = 12;
610
629
  case 12:
611
- if (!!_d.done) return [3 /*break*/, 16];
630
+ _g.trys.push([12, 18, 19, 20]);
631
+ _c = __values(this._array), _d = _c.next();
632
+ _g.label = 13;
633
+ case 13:
634
+ if (!!_d.done) return [3 /*break*/, 17];
612
635
  item = _d.value;
613
636
  return [4 /*yield*/, __await(item)];
614
- case 13: return [4 /*yield*/, _g.sent()];
615
- case 14:
616
- _g.sent();
617
- _g.label = 15;
637
+ case 14: return [4 /*yield*/, _g.sent()];
618
638
  case 15:
639
+ _g.sent();
640
+ _g.label = 16;
641
+ case 16:
619
642
  _d = _c.next();
620
- return [3 /*break*/, 12];
621
- case 16: return [3 /*break*/, 19];
622
- case 17:
643
+ return [3 /*break*/, 13];
644
+ case 17: return [3 /*break*/, 20];
645
+ case 18:
623
646
  e_4_1 = _g.sent();
624
647
  e_4 = { error: e_4_1 };
625
- return [3 /*break*/, 19];
626
- case 18:
648
+ return [3 /*break*/, 20];
649
+ case 19:
627
650
  try {
628
651
  if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
629
652
  }
630
653
  finally { if (e_4) throw e_4.error; }
631
654
  return [7 /*endfinally*/];
632
- case 19: return [2 /*return*/];
655
+ case 20:
656
+ this.callbacks.onReadEnd &&
657
+ this.callbacks.onReadEnd(this.clientId, agentName);
658
+ return [2 /*return*/];
633
659
  }
634
660
  });
635
661
  });
@@ -664,7 +690,7 @@ var HistoryUtils = /** @class */ (function () {
664
690
  */
665
691
  this.useHistoryCallbacks = function (Callbacks) {
666
692
  swarm.loggerService.log("HistoryUtils useHistoryCallbacks");
667
- _this.HistoryCallbacks = Callbacks;
693
+ Object.assign(_this.HistoryCallbacks, Callbacks);
668
694
  };
669
695
  /**
670
696
  * Push a new message to the history.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-swarm-kit",
3
- "version": "1.0.62",
3
+ "version": "1.0.64",
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
@@ -401,12 +401,31 @@ interface IHistoryInstanceCallbacks {
401
401
  */
402
402
  onChange: (data: IModelMessage[], clientId: string, agentName: AgentName) => void;
403
403
  /**
404
- * Callback for when the history is read.
404
+ * Callback for when the history get the new message
405
+ * @param data - The array of model messages.
406
+ * @param clientId - The client ID.
407
+ * @param agentName - The agent name.
408
+ */
409
+ onPush: (data: IModelMessage, clientId: string, agentName: AgentName) => void;
410
+ /**
411
+ * Callback for when the history is read. Will be called for each message
405
412
  * @param message - The model message.
406
413
  * @param clientId - The client ID.
407
414
  * @param agentName - The agent name.
408
415
  */
409
416
  onRead: (message: IModelMessage, clientId: string, agentName: AgentName) => void;
417
+ /**
418
+ * Callback for when the read is begin
419
+ * @param clientId - The client ID.
420
+ * @param agentName - The agent name.
421
+ */
422
+ onReadBegin: (clientId: string, agentName: AgentName) => void;
423
+ /**
424
+ * Callback for when the read is end
425
+ * @param clientId - The client ID.
426
+ * @param agentName - The agent name.
427
+ */
428
+ onReadEnd: (clientId: string, agentName: AgentName) => void;
410
429
  /**
411
430
  * Callback for when the history is disposed.
412
431
  * @param clientId - The client ID.