agent-swarm-kit 1.0.83 → 1.0.84
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 +180 -72
- package/build/index.cjs.map +1 -0
- package/build/index.mjs +180 -72
- package/build/index.mjs.map +1 -0
- package/package.json +1 -1
- package/types.d.ts +7 -0
package/build/index.cjs
CHANGED
|
@@ -396,89 +396,161 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
396
396
|
if (callbacks.filterCondition) {
|
|
397
397
|
this.iterate = function (agentName) {
|
|
398
398
|
return __asyncGenerator(this, arguments, function () {
|
|
399
|
-
var _b, _c, item, e_1_1, _d, _e, item,
|
|
400
|
-
var e_1,
|
|
401
|
-
return __generator(this, function (
|
|
402
|
-
switch (
|
|
399
|
+
var _b, _c, item, e_1_1, _d, _e, content, e_2_1, _f, _g, item, e_3_1, _h, _j, content, e_4_1;
|
|
400
|
+
var e_1, _k, e_2, _l, e_3, _m, e_4, _o;
|
|
401
|
+
return __generator(this, function (_p) {
|
|
402
|
+
switch (_p.label) {
|
|
403
403
|
case 0:
|
|
404
404
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
405
405
|
swarm$1.loggerService.debug(INSTANCE_METHOD_NAME_ITERATE_CONDITION, {
|
|
406
406
|
clientId: this.clientId,
|
|
407
407
|
agentName: agentName,
|
|
408
408
|
});
|
|
409
|
-
if (!this.callbacks.onRead) return [3 /*break*/,
|
|
409
|
+
if (!this.callbacks.onRead) return [3 /*break*/, 22];
|
|
410
410
|
this.callbacks.onReadBegin &&
|
|
411
411
|
this.callbacks.onReadBegin(this.clientId, agentName);
|
|
412
|
-
|
|
412
|
+
_p.label = 1;
|
|
413
413
|
case 1:
|
|
414
|
-
|
|
414
|
+
_p.trys.push([1, 8, 9, 10]);
|
|
415
415
|
_b = __values(this._array), _c = _b.next();
|
|
416
|
-
|
|
416
|
+
_p.label = 2;
|
|
417
417
|
case 2:
|
|
418
418
|
if (!!_c.done) return [3 /*break*/, 7];
|
|
419
419
|
item = _c.value;
|
|
420
420
|
return [4 /*yield*/, __await(this.callbacks.filterCondition(item, this.clientId, agentName))];
|
|
421
421
|
case 3:
|
|
422
|
-
if (!
|
|
422
|
+
if (!_p.sent()) return [3 /*break*/, 6];
|
|
423
423
|
this.callbacks.onRead(item, this.clientId, agentName);
|
|
424
424
|
return [4 /*yield*/, __await(item)];
|
|
425
|
-
case 4: return [4 /*yield*/,
|
|
425
|
+
case 4: return [4 /*yield*/, _p.sent()];
|
|
426
426
|
case 5:
|
|
427
|
-
|
|
428
|
-
|
|
427
|
+
_p.sent();
|
|
428
|
+
_p.label = 6;
|
|
429
429
|
case 6:
|
|
430
430
|
_c = _b.next();
|
|
431
431
|
return [3 /*break*/, 2];
|
|
432
432
|
case 7: return [3 /*break*/, 10];
|
|
433
433
|
case 8:
|
|
434
|
-
e_1_1 =
|
|
434
|
+
e_1_1 = _p.sent();
|
|
435
435
|
e_1 = { error: e_1_1 };
|
|
436
436
|
return [3 /*break*/, 10];
|
|
437
437
|
case 9:
|
|
438
438
|
try {
|
|
439
|
-
if (_c && !_c.done && (
|
|
439
|
+
if (_c && !_c.done && (_k = _b.return)) _k.call(_b);
|
|
440
440
|
}
|
|
441
441
|
finally { if (e_1) throw e_1.error; }
|
|
442
442
|
return [7 /*endfinally*/];
|
|
443
443
|
case 10:
|
|
444
|
-
this.callbacks.
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
444
|
+
if (!this.callbacks.getSystemPrompt) return [3 /*break*/, 20];
|
|
445
|
+
_p.label = 11;
|
|
446
|
+
case 11:
|
|
447
|
+
_p.trys.push([11, 18, 19, 20]);
|
|
448
|
+
return [4 /*yield*/, __await(this.callbacks.getSystemPrompt(this.clientId, agentName))];
|
|
448
449
|
case 12:
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
_h.label = 13;
|
|
450
|
+
_d = __values.apply(void 0, [_p.sent()]), _e = _d.next();
|
|
451
|
+
_p.label = 13;
|
|
452
452
|
case 13:
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
453
|
+
if (!!_e.done) return [3 /*break*/, 17];
|
|
454
|
+
content = _e.value;
|
|
455
|
+
return [4 /*yield*/, __await({
|
|
456
|
+
role: "system",
|
|
457
|
+
content: content,
|
|
458
|
+
agentName: agentName,
|
|
459
|
+
mode: "tool"
|
|
460
|
+
})];
|
|
461
|
+
case 14: return [4 /*yield*/, _p.sent()];
|
|
460
462
|
case 15:
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
case 16:
|
|
464
|
-
case 17:
|
|
465
|
-
_h.sent();
|
|
466
|
-
_h.label = 18;
|
|
467
|
-
case 18:
|
|
463
|
+
_p.sent();
|
|
464
|
+
_p.label = 16;
|
|
465
|
+
case 16:
|
|
468
466
|
_e = _d.next();
|
|
469
|
-
return [3 /*break*/,
|
|
470
|
-
case
|
|
471
|
-
case
|
|
472
|
-
e_2_1 =
|
|
467
|
+
return [3 /*break*/, 13];
|
|
468
|
+
case 17: return [3 /*break*/, 20];
|
|
469
|
+
case 18:
|
|
470
|
+
e_2_1 = _p.sent();
|
|
473
471
|
e_2 = { error: e_2_1 };
|
|
474
|
-
return [3 /*break*/,
|
|
475
|
-
case
|
|
472
|
+
return [3 /*break*/, 20];
|
|
473
|
+
case 19:
|
|
476
474
|
try {
|
|
477
|
-
if (_e && !_e.done && (
|
|
475
|
+
if (_e && !_e.done && (_l = _d.return)) _l.call(_d);
|
|
478
476
|
}
|
|
479
477
|
finally { if (e_2) throw e_2.error; }
|
|
480
478
|
return [7 /*endfinally*/];
|
|
479
|
+
case 20:
|
|
480
|
+
this.callbacks.onReadEnd &&
|
|
481
|
+
this.callbacks.onReadEnd(this.clientId, agentName);
|
|
482
|
+
return [4 /*yield*/, __await(void 0)];
|
|
483
|
+
case 21: return [2 /*return*/, _p.sent()];
|
|
481
484
|
case 22:
|
|
485
|
+
this.callbacks.onReadBegin &&
|
|
486
|
+
this.callbacks.onReadBegin(this.clientId, agentName);
|
|
487
|
+
_p.label = 23;
|
|
488
|
+
case 23:
|
|
489
|
+
_p.trys.push([23, 30, 31, 32]);
|
|
490
|
+
_f = __values(this._array), _g = _f.next();
|
|
491
|
+
_p.label = 24;
|
|
492
|
+
case 24:
|
|
493
|
+
if (!!_g.done) return [3 /*break*/, 29];
|
|
494
|
+
item = _g.value;
|
|
495
|
+
return [4 /*yield*/, __await(this.callbacks.filterCondition(item, this.clientId, agentName))];
|
|
496
|
+
case 25:
|
|
497
|
+
if (!_p.sent()) return [3 /*break*/, 28];
|
|
498
|
+
return [4 /*yield*/, __await(item)];
|
|
499
|
+
case 26: return [4 /*yield*/, _p.sent()];
|
|
500
|
+
case 27:
|
|
501
|
+
_p.sent();
|
|
502
|
+
_p.label = 28;
|
|
503
|
+
case 28:
|
|
504
|
+
_g = _f.next();
|
|
505
|
+
return [3 /*break*/, 24];
|
|
506
|
+
case 29: return [3 /*break*/, 32];
|
|
507
|
+
case 30:
|
|
508
|
+
e_3_1 = _p.sent();
|
|
509
|
+
e_3 = { error: e_3_1 };
|
|
510
|
+
return [3 /*break*/, 32];
|
|
511
|
+
case 31:
|
|
512
|
+
try {
|
|
513
|
+
if (_g && !_g.done && (_m = _f.return)) _m.call(_f);
|
|
514
|
+
}
|
|
515
|
+
finally { if (e_3) throw e_3.error; }
|
|
516
|
+
return [7 /*endfinally*/];
|
|
517
|
+
case 32:
|
|
518
|
+
if (!this.callbacks.getSystemPrompt) return [3 /*break*/, 42];
|
|
519
|
+
_p.label = 33;
|
|
520
|
+
case 33:
|
|
521
|
+
_p.trys.push([33, 40, 41, 42]);
|
|
522
|
+
return [4 /*yield*/, __await(this.callbacks.getSystemPrompt(this.clientId, agentName))];
|
|
523
|
+
case 34:
|
|
524
|
+
_h = __values.apply(void 0, [_p.sent()]), _j = _h.next();
|
|
525
|
+
_p.label = 35;
|
|
526
|
+
case 35:
|
|
527
|
+
if (!!_j.done) return [3 /*break*/, 39];
|
|
528
|
+
content = _j.value;
|
|
529
|
+
return [4 /*yield*/, __await({
|
|
530
|
+
role: "system",
|
|
531
|
+
content: content,
|
|
532
|
+
agentName: agentName,
|
|
533
|
+
mode: "tool"
|
|
534
|
+
})];
|
|
535
|
+
case 36: return [4 /*yield*/, _p.sent()];
|
|
536
|
+
case 37:
|
|
537
|
+
_p.sent();
|
|
538
|
+
_p.label = 38;
|
|
539
|
+
case 38:
|
|
540
|
+
_j = _h.next();
|
|
541
|
+
return [3 /*break*/, 35];
|
|
542
|
+
case 39: return [3 /*break*/, 42];
|
|
543
|
+
case 40:
|
|
544
|
+
e_4_1 = _p.sent();
|
|
545
|
+
e_4 = { error: e_4_1 };
|
|
546
|
+
return [3 /*break*/, 42];
|
|
547
|
+
case 41:
|
|
548
|
+
try {
|
|
549
|
+
if (_j && !_j.done && (_o = _h.return)) _o.call(_h);
|
|
550
|
+
}
|
|
551
|
+
finally { if (e_4) throw e_4.error; }
|
|
552
|
+
return [7 /*endfinally*/];
|
|
553
|
+
case 42:
|
|
482
554
|
this.callbacks.onReadEnd &&
|
|
483
555
|
this.callbacks.onReadEnd(this.clientId, agentName);
|
|
484
556
|
return [2 /*return*/];
|
|
@@ -509,10 +581,10 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
509
581
|
*/
|
|
510
582
|
HistoryInstance.prototype.iterate = function (agentName) {
|
|
511
583
|
return __asyncGenerator(this, arguments, function iterate_1() {
|
|
512
|
-
var _b, _c, item,
|
|
513
|
-
var
|
|
514
|
-
return __generator(this, function (
|
|
515
|
-
switch (
|
|
584
|
+
var _b, _c, item, e_5_1, _d, _e, item, e_6_1, _f, _g, content, e_7_1;
|
|
585
|
+
var e_5, _h, e_6, _j, e_7, _k;
|
|
586
|
+
return __generator(this, function (_l) {
|
|
587
|
+
switch (_l.label) {
|
|
516
588
|
case 0:
|
|
517
589
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
518
590
|
swarm$1.loggerService.debug(INSTANCE_METHOD_NAME_ITERATE, {
|
|
@@ -522,70 +594,106 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
522
594
|
if (!this.callbacks.onRead) return [3 /*break*/, 11];
|
|
523
595
|
this.callbacks.onReadBegin &&
|
|
524
596
|
this.callbacks.onReadBegin(this.clientId, agentName);
|
|
525
|
-
|
|
597
|
+
_l.label = 1;
|
|
526
598
|
case 1:
|
|
527
|
-
|
|
599
|
+
_l.trys.push([1, 7, 8, 9]);
|
|
528
600
|
_b = __values(this._array), _c = _b.next();
|
|
529
|
-
|
|
601
|
+
_l.label = 2;
|
|
530
602
|
case 2:
|
|
531
603
|
if (!!_c.done) return [3 /*break*/, 6];
|
|
532
604
|
item = _c.value;
|
|
533
605
|
this.callbacks.onRead(item, this.clientId, agentName);
|
|
534
606
|
return [4 /*yield*/, __await(item)];
|
|
535
|
-
case 3: return [4 /*yield*/,
|
|
607
|
+
case 3: return [4 /*yield*/, _l.sent()];
|
|
536
608
|
case 4:
|
|
537
|
-
|
|
538
|
-
|
|
609
|
+
_l.sent();
|
|
610
|
+
_l.label = 5;
|
|
539
611
|
case 5:
|
|
540
612
|
_c = _b.next();
|
|
541
613
|
return [3 /*break*/, 2];
|
|
542
614
|
case 6: return [3 /*break*/, 9];
|
|
543
615
|
case 7:
|
|
544
|
-
|
|
545
|
-
|
|
616
|
+
e_5_1 = _l.sent();
|
|
617
|
+
e_5 = { error: e_5_1 };
|
|
546
618
|
return [3 /*break*/, 9];
|
|
547
619
|
case 8:
|
|
548
620
|
try {
|
|
549
|
-
if (_c && !_c.done && (
|
|
621
|
+
if (_c && !_c.done && (_h = _b.return)) _h.call(_b);
|
|
550
622
|
}
|
|
551
|
-
finally { if (
|
|
623
|
+
finally { if (e_5) throw e_5.error; }
|
|
552
624
|
return [7 /*endfinally*/];
|
|
553
625
|
case 9:
|
|
554
626
|
this.callbacks.onReadEnd &&
|
|
555
627
|
this.callbacks.onReadEnd(this.clientId, agentName);
|
|
556
628
|
return [4 /*yield*/, __await(void 0)];
|
|
557
|
-
case 10: return [2 /*return*/,
|
|
629
|
+
case 10: return [2 /*return*/, _l.sent()];
|
|
558
630
|
case 11:
|
|
559
631
|
this.callbacks.onReadBegin &&
|
|
560
632
|
this.callbacks.onReadBegin(this.clientId, agentName);
|
|
561
|
-
|
|
633
|
+
_l.label = 12;
|
|
562
634
|
case 12:
|
|
563
|
-
|
|
635
|
+
_l.trys.push([12, 18, 19, 20]);
|
|
564
636
|
_d = __values(this._array), _e = _d.next();
|
|
565
|
-
|
|
637
|
+
_l.label = 13;
|
|
566
638
|
case 13:
|
|
567
639
|
if (!!_e.done) return [3 /*break*/, 17];
|
|
568
640
|
item = _e.value;
|
|
569
641
|
return [4 /*yield*/, __await(item)];
|
|
570
|
-
case 14: return [4 /*yield*/,
|
|
642
|
+
case 14: return [4 /*yield*/, _l.sent()];
|
|
571
643
|
case 15:
|
|
572
|
-
|
|
573
|
-
|
|
644
|
+
_l.sent();
|
|
645
|
+
_l.label = 16;
|
|
574
646
|
case 16:
|
|
575
647
|
_e = _d.next();
|
|
576
648
|
return [3 /*break*/, 13];
|
|
577
649
|
case 17: return [3 /*break*/, 20];
|
|
578
650
|
case 18:
|
|
579
|
-
|
|
580
|
-
|
|
651
|
+
e_6_1 = _l.sent();
|
|
652
|
+
e_6 = { error: e_6_1 };
|
|
581
653
|
return [3 /*break*/, 20];
|
|
582
654
|
case 19:
|
|
583
655
|
try {
|
|
584
|
-
if (_e && !_e.done && (
|
|
656
|
+
if (_e && !_e.done && (_j = _d.return)) _j.call(_d);
|
|
585
657
|
}
|
|
586
|
-
finally { if (
|
|
658
|
+
finally { if (e_6) throw e_6.error; }
|
|
587
659
|
return [7 /*endfinally*/];
|
|
588
660
|
case 20:
|
|
661
|
+
if (!this.callbacks.getSystemPrompt) return [3 /*break*/, 30];
|
|
662
|
+
_l.label = 21;
|
|
663
|
+
case 21:
|
|
664
|
+
_l.trys.push([21, 28, 29, 30]);
|
|
665
|
+
return [4 /*yield*/, __await(this.callbacks.getSystemPrompt(this.clientId, agentName))];
|
|
666
|
+
case 22:
|
|
667
|
+
_f = __values.apply(void 0, [_l.sent()]), _g = _f.next();
|
|
668
|
+
_l.label = 23;
|
|
669
|
+
case 23:
|
|
670
|
+
if (!!_g.done) return [3 /*break*/, 27];
|
|
671
|
+
content = _g.value;
|
|
672
|
+
return [4 /*yield*/, __await({
|
|
673
|
+
role: "system",
|
|
674
|
+
content: content,
|
|
675
|
+
agentName: agentName,
|
|
676
|
+
mode: "tool"
|
|
677
|
+
})];
|
|
678
|
+
case 24: return [4 /*yield*/, _l.sent()];
|
|
679
|
+
case 25:
|
|
680
|
+
_l.sent();
|
|
681
|
+
_l.label = 26;
|
|
682
|
+
case 26:
|
|
683
|
+
_g = _f.next();
|
|
684
|
+
return [3 /*break*/, 23];
|
|
685
|
+
case 27: return [3 /*break*/, 30];
|
|
686
|
+
case 28:
|
|
687
|
+
e_7_1 = _l.sent();
|
|
688
|
+
e_7 = { error: e_7_1 };
|
|
689
|
+
return [3 /*break*/, 30];
|
|
690
|
+
case 29:
|
|
691
|
+
try {
|
|
692
|
+
if (_g && !_g.done && (_k = _f.return)) _k.call(_f);
|
|
693
|
+
}
|
|
694
|
+
finally { if (e_7) throw e_7.error; }
|
|
695
|
+
return [7 /*endfinally*/];
|
|
696
|
+
case 30:
|
|
589
697
|
this.callbacks.onReadEnd &&
|
|
590
698
|
this.callbacks.onReadEnd(this.clientId, agentName);
|
|
591
699
|
return [2 /*return*/];
|
|
@@ -738,8 +846,8 @@ var HistoryUtils = /** @class */ (function () {
|
|
|
738
846
|
*/
|
|
739
847
|
HistoryUtils.prototype.iterate = function (clientId, agentName) {
|
|
740
848
|
return __asyncGenerator(this, arguments, function iterate_2() {
|
|
741
|
-
var isInitial, history, _b, _c, _d, item,
|
|
742
|
-
var _e,
|
|
849
|
+
var isInitial, history, _b, _c, _d, item, e_8_1;
|
|
850
|
+
var _e, e_8, _f, _g;
|
|
743
851
|
return __generator(this, function (_h) {
|
|
744
852
|
switch (_h.label) {
|
|
745
853
|
case 0:
|
|
@@ -776,8 +884,8 @@ var HistoryUtils = /** @class */ (function () {
|
|
|
776
884
|
return [3 /*break*/, 4];
|
|
777
885
|
case 9: return [3 /*break*/, 16];
|
|
778
886
|
case 10:
|
|
779
|
-
|
|
780
|
-
|
|
887
|
+
e_8_1 = _h.sent();
|
|
888
|
+
e_8 = { error: e_8_1 };
|
|
781
889
|
return [3 /*break*/, 16];
|
|
782
890
|
case 11:
|
|
783
891
|
_h.trys.push([11, , 14, 15]);
|
|
@@ -788,7 +896,7 @@ var HistoryUtils = /** @class */ (function () {
|
|
|
788
896
|
_h.label = 13;
|
|
789
897
|
case 13: return [3 /*break*/, 15];
|
|
790
898
|
case 14:
|
|
791
|
-
if (
|
|
899
|
+
if (e_8) throw e_8.error;
|
|
792
900
|
return [7 /*endfinally*/];
|
|
793
901
|
case 15: return [7 /*endfinally*/];
|
|
794
902
|
case 16: return [2 /*return*/];
|