agent-swarm-kit 1.0.82 → 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 +333 -73
- package/build/index.cjs.map +1 -0
- package/build/index.mjs +333 -73
- package/build/index.mjs.map +1 -0
- package/package.json +1 -1
- package/types.d.ts +38 -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*/];
|
|
@@ -827,7 +935,7 @@ var nameToTitle = function (name) {
|
|
|
827
935
|
};
|
|
828
936
|
|
|
829
937
|
var _a;
|
|
830
|
-
var LOGGER_INSTANCE_WAIT_FOR_INIT = Symbol(
|
|
938
|
+
var LOGGER_INSTANCE_WAIT_FOR_INIT = Symbol("wait-for-init");
|
|
831
939
|
/**
|
|
832
940
|
* @class LoggerInstance
|
|
833
941
|
* @implements ILoggerInstance
|
|
@@ -874,6 +982,7 @@ var LoggerInstance = /** @class */ (function () {
|
|
|
874
982
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
875
983
|
args[_i - 1] = arguments[_i];
|
|
876
984
|
}
|
|
985
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_CONSOLE && console.log.apply(console, __spreadArray(["[clientId=".concat(this.clientId, "]"), topic], __read(args), false));
|
|
877
986
|
if (this.callbacks.onLog) {
|
|
878
987
|
(_b = this.callbacks).onLog.apply(_b, __spreadArray([this.clientId, topic], __read(args), false));
|
|
879
988
|
}
|
|
@@ -890,6 +999,7 @@ var LoggerInstance = /** @class */ (function () {
|
|
|
890
999
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
891
1000
|
args[_i - 1] = arguments[_i];
|
|
892
1001
|
}
|
|
1002
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_CONSOLE && console.debug.apply(console, __spreadArray(["[clientId=".concat(this.clientId, "]"), topic], __read(args), false));
|
|
893
1003
|
if (this.callbacks.onDebug) {
|
|
894
1004
|
(_b = this.callbacks).onDebug.apply(_b, __spreadArray([this.clientId, topic], __read(args), false));
|
|
895
1005
|
}
|
|
@@ -906,6 +1016,7 @@ var LoggerInstance = /** @class */ (function () {
|
|
|
906
1016
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
907
1017
|
args[_i - 1] = arguments[_i];
|
|
908
1018
|
}
|
|
1019
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_CONSOLE && console.info.apply(console, __spreadArray(["[clientId=".concat(this.clientId, "]"), topic], __read(args), false));
|
|
909
1020
|
if (this.callbacks.onInfo) {
|
|
910
1021
|
(_b = this.callbacks).onInfo.apply(_b, __spreadArray([this.clientId, topic], __read(args), false));
|
|
911
1022
|
}
|
|
@@ -960,6 +1071,153 @@ var LoggerUtils = /** @class */ (function () {
|
|
|
960
1071
|
this.useClientAdapter = function (Ctor) {
|
|
961
1072
|
_this.LoggerFactory = Ctor;
|
|
962
1073
|
};
|
|
1074
|
+
/**
|
|
1075
|
+
* @method logClient
|
|
1076
|
+
* @description Logs a message for a specific client.
|
|
1077
|
+
* @param {string} clientId - The client ID.
|
|
1078
|
+
* @param {string} topic - The topic of the log.
|
|
1079
|
+
* @param {...any[]} args - The log arguments.
|
|
1080
|
+
* @returns {Promise<void>}
|
|
1081
|
+
*/
|
|
1082
|
+
this.logClient = function (clientId, topic) {
|
|
1083
|
+
var args = [];
|
|
1084
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1085
|
+
args[_i - 2] = arguments[_i];
|
|
1086
|
+
}
|
|
1087
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
1088
|
+
var _this = this;
|
|
1089
|
+
return __generator(this, function (_b) {
|
|
1090
|
+
switch (_b.label) {
|
|
1091
|
+
case 0:
|
|
1092
|
+
if (!GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG) {
|
|
1093
|
+
return [2 /*return*/];
|
|
1094
|
+
}
|
|
1095
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
1096
|
+
return [2 /*return*/];
|
|
1097
|
+
}
|
|
1098
|
+
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1099
|
+
var _b;
|
|
1100
|
+
return __generator(this, function (_c) {
|
|
1101
|
+
switch (_c.label) {
|
|
1102
|
+
case 0: return [4 /*yield*/, (_b = swarm$1.loggerService).log.apply(_b, __spreadArray([topic], __read(args), false))];
|
|
1103
|
+
case 1:
|
|
1104
|
+
_c.sent();
|
|
1105
|
+
return [2 /*return*/];
|
|
1106
|
+
}
|
|
1107
|
+
});
|
|
1108
|
+
}); }, {
|
|
1109
|
+
clientId: clientId,
|
|
1110
|
+
agentName: "",
|
|
1111
|
+
methodName: "LoggerUtils.logClient",
|
|
1112
|
+
stateName: "",
|
|
1113
|
+
storageName: "",
|
|
1114
|
+
swarmName: "",
|
|
1115
|
+
})];
|
|
1116
|
+
case 1:
|
|
1117
|
+
_b.sent();
|
|
1118
|
+
return [2 /*return*/];
|
|
1119
|
+
}
|
|
1120
|
+
});
|
|
1121
|
+
});
|
|
1122
|
+
};
|
|
1123
|
+
/**
|
|
1124
|
+
* @method infoClient
|
|
1125
|
+
* @description Logs an info message for a specific client.
|
|
1126
|
+
* @param {string} clientId - The client ID.
|
|
1127
|
+
* @param {string} topic - The topic of the info log.
|
|
1128
|
+
* @param {...any[]} args - The info log arguments.
|
|
1129
|
+
* @returns {Promise<void>}
|
|
1130
|
+
*/
|
|
1131
|
+
this.infoClient = function (clientId, topic) {
|
|
1132
|
+
var args = [];
|
|
1133
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1134
|
+
args[_i - 2] = arguments[_i];
|
|
1135
|
+
}
|
|
1136
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
1137
|
+
var _this = this;
|
|
1138
|
+
return __generator(this, function (_b) {
|
|
1139
|
+
switch (_b.label) {
|
|
1140
|
+
case 0:
|
|
1141
|
+
if (!GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO) {
|
|
1142
|
+
return [2 /*return*/];
|
|
1143
|
+
}
|
|
1144
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
1145
|
+
return [2 /*return*/];
|
|
1146
|
+
}
|
|
1147
|
+
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1148
|
+
var _b;
|
|
1149
|
+
return __generator(this, function (_c) {
|
|
1150
|
+
switch (_c.label) {
|
|
1151
|
+
case 0: return [4 /*yield*/, (_b = swarm$1.loggerService).info.apply(_b, __spreadArray([topic], __read(args), false))];
|
|
1152
|
+
case 1:
|
|
1153
|
+
_c.sent();
|
|
1154
|
+
return [2 /*return*/];
|
|
1155
|
+
}
|
|
1156
|
+
});
|
|
1157
|
+
}); }, {
|
|
1158
|
+
clientId: clientId,
|
|
1159
|
+
agentName: "",
|
|
1160
|
+
methodName: "LoggerUtils.infoClient",
|
|
1161
|
+
stateName: "",
|
|
1162
|
+
storageName: "",
|
|
1163
|
+
swarmName: "",
|
|
1164
|
+
})];
|
|
1165
|
+
case 1:
|
|
1166
|
+
_b.sent();
|
|
1167
|
+
return [2 /*return*/];
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1170
|
+
});
|
|
1171
|
+
};
|
|
1172
|
+
/**
|
|
1173
|
+
* @method debugClient
|
|
1174
|
+
* @description Logs a debug message for a specific client.
|
|
1175
|
+
* @param {string} clientId - The client ID.
|
|
1176
|
+
* @param {string} topic - The topic of the debug log.
|
|
1177
|
+
* @param {...any[]} args - The debug log arguments.
|
|
1178
|
+
* @returns {Promise<void>}
|
|
1179
|
+
*/
|
|
1180
|
+
this.debugClient = function (clientId, topic) {
|
|
1181
|
+
var args = [];
|
|
1182
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1183
|
+
args[_i - 2] = arguments[_i];
|
|
1184
|
+
}
|
|
1185
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
1186
|
+
var _this = this;
|
|
1187
|
+
return __generator(this, function (_b) {
|
|
1188
|
+
switch (_b.label) {
|
|
1189
|
+
case 0:
|
|
1190
|
+
if (!GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG) {
|
|
1191
|
+
return [2 /*return*/];
|
|
1192
|
+
}
|
|
1193
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
1194
|
+
return [2 /*return*/];
|
|
1195
|
+
}
|
|
1196
|
+
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1197
|
+
var _b;
|
|
1198
|
+
return __generator(this, function (_c) {
|
|
1199
|
+
switch (_c.label) {
|
|
1200
|
+
case 0: return [4 /*yield*/, (_b = swarm$1.loggerService).debug.apply(_b, __spreadArray([topic], __read(args), false))];
|
|
1201
|
+
case 1:
|
|
1202
|
+
_c.sent();
|
|
1203
|
+
return [2 /*return*/];
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
}); }, {
|
|
1207
|
+
clientId: clientId,
|
|
1208
|
+
agentName: "",
|
|
1209
|
+
methodName: "LoggerUtils.debugClient",
|
|
1210
|
+
stateName: "",
|
|
1211
|
+
storageName: "",
|
|
1212
|
+
swarmName: "",
|
|
1213
|
+
})];
|
|
1214
|
+
case 1:
|
|
1215
|
+
_b.sent();
|
|
1216
|
+
return [2 /*return*/];
|
|
1217
|
+
}
|
|
1218
|
+
});
|
|
1219
|
+
});
|
|
1220
|
+
};
|
|
963
1221
|
/**
|
|
964
1222
|
* @method log
|
|
965
1223
|
* @description Logs a message.
|
|
@@ -1164,6 +1422,7 @@ var CC_STORAGE_SEARCH_POOL = 5;
|
|
|
1164
1422
|
var CC_LOGGER_ENABLE_INFO = false;
|
|
1165
1423
|
var CC_LOGGER_ENABLE_DEBUG = false;
|
|
1166
1424
|
var CC_LOGGER_ENABLE_LOG = true;
|
|
1425
|
+
var CC_LOGGER_ENABLE_CONSOLE = false;
|
|
1167
1426
|
var CC_NAME_TO_TITLE = nameToTitle;
|
|
1168
1427
|
var GLOBAL_CONFIG = {
|
|
1169
1428
|
CC_TOOL_CALL_EXCEPTION_PROMPT: CC_TOOL_CALL_EXCEPTION_PROMPT,
|
|
@@ -1185,6 +1444,7 @@ var GLOBAL_CONFIG = {
|
|
|
1185
1444
|
CC_LOGGER_ENABLE_INFO: CC_LOGGER_ENABLE_INFO,
|
|
1186
1445
|
CC_LOGGER_ENABLE_DEBUG: CC_LOGGER_ENABLE_DEBUG,
|
|
1187
1446
|
CC_LOGGER_ENABLE_LOG: CC_LOGGER_ENABLE_LOG,
|
|
1447
|
+
CC_LOGGER_ENABLE_CONSOLE: CC_LOGGER_ENABLE_CONSOLE,
|
|
1188
1448
|
CC_NAME_TO_TITLE: CC_NAME_TO_TITLE,
|
|
1189
1449
|
};
|
|
1190
1450
|
var setConfig = function (config) {
|