agent-swarm-kit 1.0.83 → 1.0.85
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 +432 -96
- package/build/index.cjs.map +1 -0
- package/build/index.mjs +431 -97
- package/build/index.mjs.map +1 -0
- package/package.json +1 -1
- package/types.d.ts +84 -1
package/build/index.cjs
CHANGED
|
@@ -195,6 +195,10 @@ var schemaServices$1 = {
|
|
|
195
195
|
storageSchemaService: Symbol('storageSchemaService'),
|
|
196
196
|
stateSchemaService: Symbol('stateSchemaService'),
|
|
197
197
|
};
|
|
198
|
+
var metaServices$1 = {
|
|
199
|
+
agentMetaService: Symbol('agentMetaService'),
|
|
200
|
+
swarmMetaService: Symbol('swarmMetaService'),
|
|
201
|
+
};
|
|
198
202
|
var publicServices$1 = {
|
|
199
203
|
agentPublicService: Symbol('agentPublicService'),
|
|
200
204
|
historyPublicService: Symbol('historyPublicService'),
|
|
@@ -212,7 +216,7 @@ var validationServices$1 = {
|
|
|
212
216
|
embeddingValidationService: Symbol('embeddingValidationService'),
|
|
213
217
|
storageValidationService: Symbol('storageValidationService'),
|
|
214
218
|
};
|
|
215
|
-
var TYPES = __assign(__assign(__assign(__assign(__assign(__assign({}, baseServices$1), contextServices$1), schemaServices$1), connectionServices$1), publicServices$1), validationServices$1);
|
|
219
|
+
var TYPES = __assign(__assign(__assign(__assign(__assign(__assign(__assign({}, baseServices$1), contextServices$1), schemaServices$1), connectionServices$1), publicServices$1), validationServices$1), metaServices$1);
|
|
216
220
|
|
|
217
221
|
/**
|
|
218
222
|
* Service providing execution context information.
|
|
@@ -396,89 +400,161 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
396
400
|
if (callbacks.filterCondition) {
|
|
397
401
|
this.iterate = function (agentName) {
|
|
398
402
|
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 (
|
|
403
|
+
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;
|
|
404
|
+
var e_1, _k, e_2, _l, e_3, _m, e_4, _o;
|
|
405
|
+
return __generator(this, function (_p) {
|
|
406
|
+
switch (_p.label) {
|
|
403
407
|
case 0:
|
|
404
408
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
405
409
|
swarm$1.loggerService.debug(INSTANCE_METHOD_NAME_ITERATE_CONDITION, {
|
|
406
410
|
clientId: this.clientId,
|
|
407
411
|
agentName: agentName,
|
|
408
412
|
});
|
|
409
|
-
if (!this.callbacks.onRead) return [3 /*break*/,
|
|
413
|
+
if (!this.callbacks.onRead) return [3 /*break*/, 22];
|
|
410
414
|
this.callbacks.onReadBegin &&
|
|
411
415
|
this.callbacks.onReadBegin(this.clientId, agentName);
|
|
412
|
-
|
|
416
|
+
_p.label = 1;
|
|
413
417
|
case 1:
|
|
414
|
-
|
|
418
|
+
_p.trys.push([1, 8, 9, 10]);
|
|
415
419
|
_b = __values(this._array), _c = _b.next();
|
|
416
|
-
|
|
420
|
+
_p.label = 2;
|
|
417
421
|
case 2:
|
|
418
422
|
if (!!_c.done) return [3 /*break*/, 7];
|
|
419
423
|
item = _c.value;
|
|
420
424
|
return [4 /*yield*/, __await(this.callbacks.filterCondition(item, this.clientId, agentName))];
|
|
421
425
|
case 3:
|
|
422
|
-
if (!
|
|
426
|
+
if (!_p.sent()) return [3 /*break*/, 6];
|
|
423
427
|
this.callbacks.onRead(item, this.clientId, agentName);
|
|
424
428
|
return [4 /*yield*/, __await(item)];
|
|
425
|
-
case 4: return [4 /*yield*/,
|
|
429
|
+
case 4: return [4 /*yield*/, _p.sent()];
|
|
426
430
|
case 5:
|
|
427
|
-
|
|
428
|
-
|
|
431
|
+
_p.sent();
|
|
432
|
+
_p.label = 6;
|
|
429
433
|
case 6:
|
|
430
434
|
_c = _b.next();
|
|
431
435
|
return [3 /*break*/, 2];
|
|
432
436
|
case 7: return [3 /*break*/, 10];
|
|
433
437
|
case 8:
|
|
434
|
-
e_1_1 =
|
|
438
|
+
e_1_1 = _p.sent();
|
|
435
439
|
e_1 = { error: e_1_1 };
|
|
436
440
|
return [3 /*break*/, 10];
|
|
437
441
|
case 9:
|
|
438
442
|
try {
|
|
439
|
-
if (_c && !_c.done && (
|
|
443
|
+
if (_c && !_c.done && (_k = _b.return)) _k.call(_b);
|
|
440
444
|
}
|
|
441
445
|
finally { if (e_1) throw e_1.error; }
|
|
442
446
|
return [7 /*endfinally*/];
|
|
443
447
|
case 10:
|
|
444
|
-
this.callbacks.
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
+
if (!this.callbacks.getSystemPrompt) return [3 /*break*/, 20];
|
|
449
|
+
_p.label = 11;
|
|
450
|
+
case 11:
|
|
451
|
+
_p.trys.push([11, 18, 19, 20]);
|
|
452
|
+
return [4 /*yield*/, __await(this.callbacks.getSystemPrompt(this.clientId, agentName))];
|
|
448
453
|
case 12:
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
_h.label = 13;
|
|
454
|
+
_d = __values.apply(void 0, [_p.sent()]), _e = _d.next();
|
|
455
|
+
_p.label = 13;
|
|
452
456
|
case 13:
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
457
|
+
if (!!_e.done) return [3 /*break*/, 17];
|
|
458
|
+
content = _e.value;
|
|
459
|
+
return [4 /*yield*/, __await({
|
|
460
|
+
role: "system",
|
|
461
|
+
content: content,
|
|
462
|
+
agentName: agentName,
|
|
463
|
+
mode: "tool"
|
|
464
|
+
})];
|
|
465
|
+
case 14: return [4 /*yield*/, _p.sent()];
|
|
460
466
|
case 15:
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
case 16:
|
|
464
|
-
case 17:
|
|
465
|
-
_h.sent();
|
|
466
|
-
_h.label = 18;
|
|
467
|
-
case 18:
|
|
467
|
+
_p.sent();
|
|
468
|
+
_p.label = 16;
|
|
469
|
+
case 16:
|
|
468
470
|
_e = _d.next();
|
|
469
|
-
return [3 /*break*/,
|
|
470
|
-
case
|
|
471
|
-
case
|
|
472
|
-
e_2_1 =
|
|
471
|
+
return [3 /*break*/, 13];
|
|
472
|
+
case 17: return [3 /*break*/, 20];
|
|
473
|
+
case 18:
|
|
474
|
+
e_2_1 = _p.sent();
|
|
473
475
|
e_2 = { error: e_2_1 };
|
|
474
|
-
return [3 /*break*/,
|
|
475
|
-
case
|
|
476
|
+
return [3 /*break*/, 20];
|
|
477
|
+
case 19:
|
|
476
478
|
try {
|
|
477
|
-
if (_e && !_e.done && (
|
|
479
|
+
if (_e && !_e.done && (_l = _d.return)) _l.call(_d);
|
|
478
480
|
}
|
|
479
481
|
finally { if (e_2) throw e_2.error; }
|
|
480
482
|
return [7 /*endfinally*/];
|
|
483
|
+
case 20:
|
|
484
|
+
this.callbacks.onReadEnd &&
|
|
485
|
+
this.callbacks.onReadEnd(this.clientId, agentName);
|
|
486
|
+
return [4 /*yield*/, __await(void 0)];
|
|
487
|
+
case 21: return [2 /*return*/, _p.sent()];
|
|
481
488
|
case 22:
|
|
489
|
+
this.callbacks.onReadBegin &&
|
|
490
|
+
this.callbacks.onReadBegin(this.clientId, agentName);
|
|
491
|
+
_p.label = 23;
|
|
492
|
+
case 23:
|
|
493
|
+
_p.trys.push([23, 30, 31, 32]);
|
|
494
|
+
_f = __values(this._array), _g = _f.next();
|
|
495
|
+
_p.label = 24;
|
|
496
|
+
case 24:
|
|
497
|
+
if (!!_g.done) return [3 /*break*/, 29];
|
|
498
|
+
item = _g.value;
|
|
499
|
+
return [4 /*yield*/, __await(this.callbacks.filterCondition(item, this.clientId, agentName))];
|
|
500
|
+
case 25:
|
|
501
|
+
if (!_p.sent()) return [3 /*break*/, 28];
|
|
502
|
+
return [4 /*yield*/, __await(item)];
|
|
503
|
+
case 26: return [4 /*yield*/, _p.sent()];
|
|
504
|
+
case 27:
|
|
505
|
+
_p.sent();
|
|
506
|
+
_p.label = 28;
|
|
507
|
+
case 28:
|
|
508
|
+
_g = _f.next();
|
|
509
|
+
return [3 /*break*/, 24];
|
|
510
|
+
case 29: return [3 /*break*/, 32];
|
|
511
|
+
case 30:
|
|
512
|
+
e_3_1 = _p.sent();
|
|
513
|
+
e_3 = { error: e_3_1 };
|
|
514
|
+
return [3 /*break*/, 32];
|
|
515
|
+
case 31:
|
|
516
|
+
try {
|
|
517
|
+
if (_g && !_g.done && (_m = _f.return)) _m.call(_f);
|
|
518
|
+
}
|
|
519
|
+
finally { if (e_3) throw e_3.error; }
|
|
520
|
+
return [7 /*endfinally*/];
|
|
521
|
+
case 32:
|
|
522
|
+
if (!this.callbacks.getSystemPrompt) return [3 /*break*/, 42];
|
|
523
|
+
_p.label = 33;
|
|
524
|
+
case 33:
|
|
525
|
+
_p.trys.push([33, 40, 41, 42]);
|
|
526
|
+
return [4 /*yield*/, __await(this.callbacks.getSystemPrompt(this.clientId, agentName))];
|
|
527
|
+
case 34:
|
|
528
|
+
_h = __values.apply(void 0, [_p.sent()]), _j = _h.next();
|
|
529
|
+
_p.label = 35;
|
|
530
|
+
case 35:
|
|
531
|
+
if (!!_j.done) return [3 /*break*/, 39];
|
|
532
|
+
content = _j.value;
|
|
533
|
+
return [4 /*yield*/, __await({
|
|
534
|
+
role: "system",
|
|
535
|
+
content: content,
|
|
536
|
+
agentName: agentName,
|
|
537
|
+
mode: "tool"
|
|
538
|
+
})];
|
|
539
|
+
case 36: return [4 /*yield*/, _p.sent()];
|
|
540
|
+
case 37:
|
|
541
|
+
_p.sent();
|
|
542
|
+
_p.label = 38;
|
|
543
|
+
case 38:
|
|
544
|
+
_j = _h.next();
|
|
545
|
+
return [3 /*break*/, 35];
|
|
546
|
+
case 39: return [3 /*break*/, 42];
|
|
547
|
+
case 40:
|
|
548
|
+
e_4_1 = _p.sent();
|
|
549
|
+
e_4 = { error: e_4_1 };
|
|
550
|
+
return [3 /*break*/, 42];
|
|
551
|
+
case 41:
|
|
552
|
+
try {
|
|
553
|
+
if (_j && !_j.done && (_o = _h.return)) _o.call(_h);
|
|
554
|
+
}
|
|
555
|
+
finally { if (e_4) throw e_4.error; }
|
|
556
|
+
return [7 /*endfinally*/];
|
|
557
|
+
case 42:
|
|
482
558
|
this.callbacks.onReadEnd &&
|
|
483
559
|
this.callbacks.onReadEnd(this.clientId, agentName);
|
|
484
560
|
return [2 /*return*/];
|
|
@@ -509,10 +585,10 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
509
585
|
*/
|
|
510
586
|
HistoryInstance.prototype.iterate = function (agentName) {
|
|
511
587
|
return __asyncGenerator(this, arguments, function iterate_1() {
|
|
512
|
-
var _b, _c, item,
|
|
513
|
-
var
|
|
514
|
-
return __generator(this, function (
|
|
515
|
-
switch (
|
|
588
|
+
var _b, _c, item, e_5_1, _d, _e, item, e_6_1, _f, _g, content, e_7_1;
|
|
589
|
+
var e_5, _h, e_6, _j, e_7, _k;
|
|
590
|
+
return __generator(this, function (_l) {
|
|
591
|
+
switch (_l.label) {
|
|
516
592
|
case 0:
|
|
517
593
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
518
594
|
swarm$1.loggerService.debug(INSTANCE_METHOD_NAME_ITERATE, {
|
|
@@ -522,70 +598,106 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
522
598
|
if (!this.callbacks.onRead) return [3 /*break*/, 11];
|
|
523
599
|
this.callbacks.onReadBegin &&
|
|
524
600
|
this.callbacks.onReadBegin(this.clientId, agentName);
|
|
525
|
-
|
|
601
|
+
_l.label = 1;
|
|
526
602
|
case 1:
|
|
527
|
-
|
|
603
|
+
_l.trys.push([1, 7, 8, 9]);
|
|
528
604
|
_b = __values(this._array), _c = _b.next();
|
|
529
|
-
|
|
605
|
+
_l.label = 2;
|
|
530
606
|
case 2:
|
|
531
607
|
if (!!_c.done) return [3 /*break*/, 6];
|
|
532
608
|
item = _c.value;
|
|
533
609
|
this.callbacks.onRead(item, this.clientId, agentName);
|
|
534
610
|
return [4 /*yield*/, __await(item)];
|
|
535
|
-
case 3: return [4 /*yield*/,
|
|
611
|
+
case 3: return [4 /*yield*/, _l.sent()];
|
|
536
612
|
case 4:
|
|
537
|
-
|
|
538
|
-
|
|
613
|
+
_l.sent();
|
|
614
|
+
_l.label = 5;
|
|
539
615
|
case 5:
|
|
540
616
|
_c = _b.next();
|
|
541
617
|
return [3 /*break*/, 2];
|
|
542
618
|
case 6: return [3 /*break*/, 9];
|
|
543
619
|
case 7:
|
|
544
|
-
|
|
545
|
-
|
|
620
|
+
e_5_1 = _l.sent();
|
|
621
|
+
e_5 = { error: e_5_1 };
|
|
546
622
|
return [3 /*break*/, 9];
|
|
547
623
|
case 8:
|
|
548
624
|
try {
|
|
549
|
-
if (_c && !_c.done && (
|
|
625
|
+
if (_c && !_c.done && (_h = _b.return)) _h.call(_b);
|
|
550
626
|
}
|
|
551
|
-
finally { if (
|
|
627
|
+
finally { if (e_5) throw e_5.error; }
|
|
552
628
|
return [7 /*endfinally*/];
|
|
553
629
|
case 9:
|
|
554
630
|
this.callbacks.onReadEnd &&
|
|
555
631
|
this.callbacks.onReadEnd(this.clientId, agentName);
|
|
556
632
|
return [4 /*yield*/, __await(void 0)];
|
|
557
|
-
case 10: return [2 /*return*/,
|
|
633
|
+
case 10: return [2 /*return*/, _l.sent()];
|
|
558
634
|
case 11:
|
|
559
635
|
this.callbacks.onReadBegin &&
|
|
560
636
|
this.callbacks.onReadBegin(this.clientId, agentName);
|
|
561
|
-
|
|
637
|
+
_l.label = 12;
|
|
562
638
|
case 12:
|
|
563
|
-
|
|
639
|
+
_l.trys.push([12, 18, 19, 20]);
|
|
564
640
|
_d = __values(this._array), _e = _d.next();
|
|
565
|
-
|
|
641
|
+
_l.label = 13;
|
|
566
642
|
case 13:
|
|
567
643
|
if (!!_e.done) return [3 /*break*/, 17];
|
|
568
644
|
item = _e.value;
|
|
569
645
|
return [4 /*yield*/, __await(item)];
|
|
570
|
-
case 14: return [4 /*yield*/,
|
|
646
|
+
case 14: return [4 /*yield*/, _l.sent()];
|
|
571
647
|
case 15:
|
|
572
|
-
|
|
573
|
-
|
|
648
|
+
_l.sent();
|
|
649
|
+
_l.label = 16;
|
|
574
650
|
case 16:
|
|
575
651
|
_e = _d.next();
|
|
576
652
|
return [3 /*break*/, 13];
|
|
577
653
|
case 17: return [3 /*break*/, 20];
|
|
578
654
|
case 18:
|
|
579
|
-
|
|
580
|
-
|
|
655
|
+
e_6_1 = _l.sent();
|
|
656
|
+
e_6 = { error: e_6_1 };
|
|
581
657
|
return [3 /*break*/, 20];
|
|
582
658
|
case 19:
|
|
583
659
|
try {
|
|
584
|
-
if (_e && !_e.done && (
|
|
660
|
+
if (_e && !_e.done && (_j = _d.return)) _j.call(_d);
|
|
585
661
|
}
|
|
586
|
-
finally { if (
|
|
662
|
+
finally { if (e_6) throw e_6.error; }
|
|
587
663
|
return [7 /*endfinally*/];
|
|
588
664
|
case 20:
|
|
665
|
+
if (!this.callbacks.getSystemPrompt) return [3 /*break*/, 30];
|
|
666
|
+
_l.label = 21;
|
|
667
|
+
case 21:
|
|
668
|
+
_l.trys.push([21, 28, 29, 30]);
|
|
669
|
+
return [4 /*yield*/, __await(this.callbacks.getSystemPrompt(this.clientId, agentName))];
|
|
670
|
+
case 22:
|
|
671
|
+
_f = __values.apply(void 0, [_l.sent()]), _g = _f.next();
|
|
672
|
+
_l.label = 23;
|
|
673
|
+
case 23:
|
|
674
|
+
if (!!_g.done) return [3 /*break*/, 27];
|
|
675
|
+
content = _g.value;
|
|
676
|
+
return [4 /*yield*/, __await({
|
|
677
|
+
role: "system",
|
|
678
|
+
content: content,
|
|
679
|
+
agentName: agentName,
|
|
680
|
+
mode: "tool"
|
|
681
|
+
})];
|
|
682
|
+
case 24: return [4 /*yield*/, _l.sent()];
|
|
683
|
+
case 25:
|
|
684
|
+
_l.sent();
|
|
685
|
+
_l.label = 26;
|
|
686
|
+
case 26:
|
|
687
|
+
_g = _f.next();
|
|
688
|
+
return [3 /*break*/, 23];
|
|
689
|
+
case 27: return [3 /*break*/, 30];
|
|
690
|
+
case 28:
|
|
691
|
+
e_7_1 = _l.sent();
|
|
692
|
+
e_7 = { error: e_7_1 };
|
|
693
|
+
return [3 /*break*/, 30];
|
|
694
|
+
case 29:
|
|
695
|
+
try {
|
|
696
|
+
if (_g && !_g.done && (_k = _f.return)) _k.call(_f);
|
|
697
|
+
}
|
|
698
|
+
finally { if (e_7) throw e_7.error; }
|
|
699
|
+
return [7 /*endfinally*/];
|
|
700
|
+
case 30:
|
|
589
701
|
this.callbacks.onReadEnd &&
|
|
590
702
|
this.callbacks.onReadEnd(this.clientId, agentName);
|
|
591
703
|
return [2 /*return*/];
|
|
@@ -738,8 +850,8 @@ var HistoryUtils = /** @class */ (function () {
|
|
|
738
850
|
*/
|
|
739
851
|
HistoryUtils.prototype.iterate = function (clientId, agentName) {
|
|
740
852
|
return __asyncGenerator(this, arguments, function iterate_2() {
|
|
741
|
-
var isInitial, history, _b, _c, _d, item,
|
|
742
|
-
var _e,
|
|
853
|
+
var isInitial, history, _b, _c, _d, item, e_8_1;
|
|
854
|
+
var _e, e_8, _f, _g;
|
|
743
855
|
return __generator(this, function (_h) {
|
|
744
856
|
switch (_h.label) {
|
|
745
857
|
case 0:
|
|
@@ -776,8 +888,8 @@ var HistoryUtils = /** @class */ (function () {
|
|
|
776
888
|
return [3 /*break*/, 4];
|
|
777
889
|
case 9: return [3 /*break*/, 16];
|
|
778
890
|
case 10:
|
|
779
|
-
|
|
780
|
-
|
|
891
|
+
e_8_1 = _h.sent();
|
|
892
|
+
e_8 = { error: e_8_1 };
|
|
781
893
|
return [3 /*break*/, 16];
|
|
782
894
|
case 11:
|
|
783
895
|
_h.trys.push([11, , 14, 15]);
|
|
@@ -788,7 +900,7 @@ var HistoryUtils = /** @class */ (function () {
|
|
|
788
900
|
_h.label = 13;
|
|
789
901
|
case 13: return [3 /*break*/, 15];
|
|
790
902
|
case 14:
|
|
791
|
-
if (
|
|
903
|
+
if (e_8) throw e_8.error;
|
|
792
904
|
return [7 /*endfinally*/];
|
|
793
905
|
case 15: return [7 /*endfinally*/];
|
|
794
906
|
case 16: return [2 /*return*/];
|
|
@@ -4825,6 +4937,7 @@ var AgentValidationService = /** @class */ (function () {
|
|
|
4825
4937
|
this.completionValidationService = inject(TYPES.completionValidationService);
|
|
4826
4938
|
this.storageValidationService = inject(TYPES.storageValidationService);
|
|
4827
4939
|
this._agentMap = new Map();
|
|
4940
|
+
this._agentDepsMap = new Map();
|
|
4828
4941
|
/**
|
|
4829
4942
|
* Retrieves the storages used by the agent
|
|
4830
4943
|
* @param {agentName} agentName - The name of the swarm.
|
|
@@ -4865,6 +4978,9 @@ var AgentValidationService = /** @class */ (function () {
|
|
|
4865
4978
|
throw new Error("agent-swarm agent ".concat(agentName, " already exist"));
|
|
4866
4979
|
}
|
|
4867
4980
|
_this._agentMap.set(agentName, agentSchema);
|
|
4981
|
+
if (agentSchema.dependsOn) {
|
|
4982
|
+
_this._agentDepsMap.set(agentName, agentSchema.dependsOn);
|
|
4983
|
+
}
|
|
4868
4984
|
};
|
|
4869
4985
|
/**
|
|
4870
4986
|
* Check if agent got registered storage
|
|
@@ -4884,6 +5000,23 @@ var AgentValidationService = /** @class */ (function () {
|
|
|
4884
5000
|
var _a = _this._agentMap.get(agentName).storages, storages = _a === void 0 ? [] : _a;
|
|
4885
5001
|
return storages.includes(storageName);
|
|
4886
5002
|
});
|
|
5003
|
+
/**
|
|
5004
|
+
* Check if agent got registered dependency
|
|
5005
|
+
*/
|
|
5006
|
+
this.hasDependency = functoolsKit.memoize(function (_a) {
|
|
5007
|
+
var _b = __read(_a, 2), targetAgentName = _b[0], depAgentName = _b[1];
|
|
5008
|
+
return "".concat(targetAgentName, "-").concat(depAgentName);
|
|
5009
|
+
}, function (targetAgentName, depAgentName) {
|
|
5010
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5011
|
+
_this.loggerService.info("agentValidationService hasDependency", {
|
|
5012
|
+
targetAgentName: targetAgentName,
|
|
5013
|
+
depAgentName: depAgentName,
|
|
5014
|
+
});
|
|
5015
|
+
if (_this._agentDepsMap.has(targetAgentName)) {
|
|
5016
|
+
return _this._agentDepsMap.get(targetAgentName).includes(depAgentName);
|
|
5017
|
+
}
|
|
5018
|
+
return true;
|
|
5019
|
+
});
|
|
4887
5020
|
/**
|
|
4888
5021
|
* Check if agent got registered state
|
|
4889
5022
|
*/
|
|
@@ -7081,6 +7214,162 @@ var BusService = /** @class */ (function () {
|
|
|
7081
7214
|
return BusService;
|
|
7082
7215
|
}());
|
|
7083
7216
|
|
|
7217
|
+
var MAX_NESTING = 10;
|
|
7218
|
+
var UML_STEP = "\t";
|
|
7219
|
+
var UML_BULLET = "•";
|
|
7220
|
+
/**
|
|
7221
|
+
* Creates a function to serialize meta nodes to UML format.
|
|
7222
|
+
* @returns {Function} A function that takes an array of IMetaNode and returns a string in UML format.
|
|
7223
|
+
*/
|
|
7224
|
+
var createSerialize = function () { return function (nodes) {
|
|
7225
|
+
var lines = [];
|
|
7226
|
+
var process = function (nodes, level, seen) {
|
|
7227
|
+
var e_1, _a;
|
|
7228
|
+
var _b;
|
|
7229
|
+
if (level === void 0) { level = 0; }
|
|
7230
|
+
if (seen === void 0) { seen = new Set(); }
|
|
7231
|
+
try {
|
|
7232
|
+
for (var nodes_1 = __values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) {
|
|
7233
|
+
var node = nodes_1_1.value;
|
|
7234
|
+
var space = __spreadArray([], __read(new Array(level)), false).fill(UML_STEP).join("");
|
|
7235
|
+
if (seen.has(node.name)) {
|
|
7236
|
+
lines.push("".concat(space).concat(String(node.name), ": \"\""));
|
|
7237
|
+
}
|
|
7238
|
+
else if (((_b = node.child) === null || _b === void 0 ? void 0 : _b.length) && level < MAX_NESTING) {
|
|
7239
|
+
lines.push("".concat(space).concat(String(node.name), ":"));
|
|
7240
|
+
lines.push("".concat(space).concat(UML_STEP).concat(UML_BULLET, " ").concat(String(node.name), ": \"\""));
|
|
7241
|
+
process(node.child, level + 1, seen.add(node.name));
|
|
7242
|
+
}
|
|
7243
|
+
else {
|
|
7244
|
+
lines.push("".concat(space).concat(String(node.name), ": \"\""));
|
|
7245
|
+
}
|
|
7246
|
+
}
|
|
7247
|
+
}
|
|
7248
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
7249
|
+
finally {
|
|
7250
|
+
try {
|
|
7251
|
+
if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) _a.call(nodes_1);
|
|
7252
|
+
}
|
|
7253
|
+
finally { if (e_1) throw e_1.error; }
|
|
7254
|
+
}
|
|
7255
|
+
};
|
|
7256
|
+
process(nodes);
|
|
7257
|
+
var result = __spreadArray(__spreadArray(["@startyaml"], __read(lines), false), ["@endyaml"], false).join("\n");
|
|
7258
|
+
return result;
|
|
7259
|
+
}; };
|
|
7260
|
+
/**
|
|
7261
|
+
* Service class for managing agent meta nodes and converting them to UML format.
|
|
7262
|
+
*/
|
|
7263
|
+
var AgentMetaService = /** @class */ (function () {
|
|
7264
|
+
function AgentMetaService() {
|
|
7265
|
+
var _this = this;
|
|
7266
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
7267
|
+
this.agentSchemaService = inject(TYPES.agentSchemaService);
|
|
7268
|
+
this.serialize = createSerialize();
|
|
7269
|
+
/**
|
|
7270
|
+
* Creates a meta node for the given agent.
|
|
7271
|
+
* @param {AgentName} agentName - The name of the agent.
|
|
7272
|
+
* @param {Set<AgentName>} seen - A set of seen agent names to avoid circular dependencies.
|
|
7273
|
+
* @returns {IMetaNode} The created meta node.
|
|
7274
|
+
*/
|
|
7275
|
+
this.makeAgentNode = function (agentName, seen) {
|
|
7276
|
+
if (seen === void 0) { seen = new Set(); }
|
|
7277
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
7278
|
+
_this.loggerService.info("agentMetaService makeAgentNode", {
|
|
7279
|
+
agentName: agentName,
|
|
7280
|
+
});
|
|
7281
|
+
var _a = _this.agentSchemaService.get(agentName), dependsOn = _a.dependsOn, states = _a.states, storages = _a.storages, tools = _a.tools;
|
|
7282
|
+
var childSeen = seen.add(agentName);
|
|
7283
|
+
var agentTree = [];
|
|
7284
|
+
if (dependsOn && !seen.has(agentName)) {
|
|
7285
|
+
agentTree.push({
|
|
7286
|
+
name: "Agents (".concat(agentName, ")"),
|
|
7287
|
+
child: dependsOn.map(function (dep) { return _this.makeAgentNode(dep, childSeen); }),
|
|
7288
|
+
});
|
|
7289
|
+
}
|
|
7290
|
+
if (states) {
|
|
7291
|
+
agentTree.push({
|
|
7292
|
+
name: "States (".concat(agentName, ")"),
|
|
7293
|
+
child: states.map(function (name) { return ({ name: name }); }),
|
|
7294
|
+
});
|
|
7295
|
+
}
|
|
7296
|
+
if (storages) {
|
|
7297
|
+
agentTree.push({
|
|
7298
|
+
name: "Storages (".concat(agentName, ")"),
|
|
7299
|
+
child: storages.map(function (name) { return ({ name: name }); }),
|
|
7300
|
+
});
|
|
7301
|
+
}
|
|
7302
|
+
if (tools) {
|
|
7303
|
+
agentTree.push({
|
|
7304
|
+
name: "Tools (".concat(agentName, ")"),
|
|
7305
|
+
child: tools.map(function (name) { return ({ name: name }); }),
|
|
7306
|
+
});
|
|
7307
|
+
}
|
|
7308
|
+
return {
|
|
7309
|
+
name: agentName,
|
|
7310
|
+
child: agentTree,
|
|
7311
|
+
};
|
|
7312
|
+
};
|
|
7313
|
+
/**
|
|
7314
|
+
* Converts the meta nodes of the given agent to UML format.
|
|
7315
|
+
* @param {AgentName} agentName - The name of the agent.
|
|
7316
|
+
* @returns {string} The UML representation of the agent's meta nodes.
|
|
7317
|
+
*/
|
|
7318
|
+
this.toUML = function (agentName) {
|
|
7319
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
7320
|
+
_this.loggerService.info("agentMetaService toUML", {
|
|
7321
|
+
agentName: agentName,
|
|
7322
|
+
});
|
|
7323
|
+
var rootNode = _this.makeAgentNode(agentName);
|
|
7324
|
+
return _this.serialize([rootNode]);
|
|
7325
|
+
};
|
|
7326
|
+
}
|
|
7327
|
+
return AgentMetaService;
|
|
7328
|
+
}());
|
|
7329
|
+
|
|
7330
|
+
/**
|
|
7331
|
+
* Service for handling swarm metadata.
|
|
7332
|
+
*/
|
|
7333
|
+
var SwarmMetaService = /** @class */ (function () {
|
|
7334
|
+
function SwarmMetaService() {
|
|
7335
|
+
var _this = this;
|
|
7336
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
7337
|
+
this.swarmSchemaService = inject(TYPES.swarmSchemaService);
|
|
7338
|
+
this.agentMetaService = inject(TYPES.agentMetaService);
|
|
7339
|
+
this.serialize = createSerialize();
|
|
7340
|
+
/**
|
|
7341
|
+
* Creates a swarm node with the given swarm name.
|
|
7342
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
7343
|
+
* @returns {IMetaNode} The metadata node of the swarm.
|
|
7344
|
+
*/
|
|
7345
|
+
this.makeSwarmNode = function (swarmName) {
|
|
7346
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
7347
|
+
_this.loggerService.info("swarmMetaService makeSwarmNode", {
|
|
7348
|
+
swarmName: swarmName,
|
|
7349
|
+
});
|
|
7350
|
+
var agentList = _this.swarmSchemaService.get(swarmName).agentList;
|
|
7351
|
+
return {
|
|
7352
|
+
name: swarmName,
|
|
7353
|
+
child: agentList.map(function (dep) { return _this.agentMetaService.makeAgentNode(dep); }),
|
|
7354
|
+
};
|
|
7355
|
+
};
|
|
7356
|
+
/**
|
|
7357
|
+
* Converts the swarm metadata to UML format.
|
|
7358
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
7359
|
+
* @returns {string} The UML representation of the swarm.
|
|
7360
|
+
*/
|
|
7361
|
+
this.toUML = function (swarmName) {
|
|
7362
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
7363
|
+
_this.loggerService.info("swarmMetaService toUML", {
|
|
7364
|
+
swarmName: swarmName,
|
|
7365
|
+
});
|
|
7366
|
+
var rootNode = _this.makeSwarmNode(swarmName);
|
|
7367
|
+
return _this.serialize([rootNode]);
|
|
7368
|
+
};
|
|
7369
|
+
}
|
|
7370
|
+
return SwarmMetaService;
|
|
7371
|
+
}());
|
|
7372
|
+
|
|
7084
7373
|
{
|
|
7085
7374
|
provide(TYPES.busService, function () { return new BusService(); });
|
|
7086
7375
|
provide(TYPES.loggerService, function () { return new LoggerService(); });
|
|
@@ -7114,6 +7403,10 @@ var BusService = /** @class */ (function () {
|
|
|
7114
7403
|
provide(TYPES.storagePublicService, function () { return new StoragePublicService(); });
|
|
7115
7404
|
provide(TYPES.statePublicService, function () { return new StatePublicService(); });
|
|
7116
7405
|
}
|
|
7406
|
+
{
|
|
7407
|
+
provide(TYPES.swarmMetaService, function () { return new SwarmMetaService(); });
|
|
7408
|
+
provide(TYPES.agentMetaService, function () { return new AgentMetaService(); });
|
|
7409
|
+
}
|
|
7117
7410
|
{
|
|
7118
7411
|
provide(TYPES.agentPublicService, function () { return new AgentPublicService(); });
|
|
7119
7412
|
provide(TYPES.historyPublicService, function () { return new HistoryPublicService(); });
|
|
@@ -7163,6 +7456,10 @@ var publicServices = {
|
|
|
7163
7456
|
storagePublicService: inject(TYPES.storagePublicService),
|
|
7164
7457
|
statePublicService: inject(TYPES.statePublicService),
|
|
7165
7458
|
};
|
|
7459
|
+
var metaServices = {
|
|
7460
|
+
agentMetaService: inject(TYPES.agentMetaService),
|
|
7461
|
+
swarmMetaService: inject(TYPES.swarmMetaService),
|
|
7462
|
+
};
|
|
7166
7463
|
var validationServices = {
|
|
7167
7464
|
agentValidationService: inject(TYPES.agentValidationService),
|
|
7168
7465
|
toolValidationService: inject(TYPES.toolValidationService),
|
|
@@ -7172,10 +7469,42 @@ var validationServices = {
|
|
|
7172
7469
|
storageValidationService: inject(TYPES.storageValidationService),
|
|
7173
7470
|
embeddingValidationService: inject(TYPES.embeddingValidationService),
|
|
7174
7471
|
};
|
|
7175
|
-
var swarm = __assign(__assign(__assign(__assign(__assign(__assign({}, baseServices), contextServices), connectionServices), schemaServices), publicServices), validationServices);
|
|
7472
|
+
var swarm = __assign(__assign(__assign(__assign(__assign(__assign(__assign({}, baseServices), contextServices), connectionServices), schemaServices), publicServices), metaServices), validationServices);
|
|
7176
7473
|
init();
|
|
7177
7474
|
var swarm$1 = swarm;
|
|
7178
7475
|
|
|
7476
|
+
var METHOD_NAME$E = "function.dumpAgent";
|
|
7477
|
+
/**
|
|
7478
|
+
* Dumps the agent information into PlantUML format.
|
|
7479
|
+
*
|
|
7480
|
+
* @param {SwarmName} swarmName - The name of the swarm to be dumped.
|
|
7481
|
+
* @returns {string} The UML representation of the swarm.
|
|
7482
|
+
*/
|
|
7483
|
+
var dumpAgent = function (agentName) {
|
|
7484
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7485
|
+
swarm$1.loggerService.log(METHOD_NAME$E, {
|
|
7486
|
+
agentName: agentName,
|
|
7487
|
+
});
|
|
7488
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$E);
|
|
7489
|
+
return swarm$1.agentMetaService.toUML(agentName);
|
|
7490
|
+
};
|
|
7491
|
+
|
|
7492
|
+
var METHOD_NAME$D = "function.dumpSwarm";
|
|
7493
|
+
/**
|
|
7494
|
+
* Dumps the swarm information into PlantUML format.
|
|
7495
|
+
*
|
|
7496
|
+
* @param {SwarmName} swarmName - The name of the swarm to be dumped.
|
|
7497
|
+
* @returns {string} The UML representation of the swarm.
|
|
7498
|
+
*/
|
|
7499
|
+
var dumpSwarm = function (swarmName) {
|
|
7500
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7501
|
+
swarm$1.loggerService.log(METHOD_NAME$D, {
|
|
7502
|
+
swarmName: swarmName,
|
|
7503
|
+
});
|
|
7504
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$D);
|
|
7505
|
+
return swarm$1.swarmMetaService.toUML(swarmName);
|
|
7506
|
+
};
|
|
7507
|
+
|
|
7179
7508
|
var METHOD_NAME$C = "function.addAgent";
|
|
7180
7509
|
/**
|
|
7181
7510
|
* Adds a new agent to the agent registry. The swarm takes only those agents which was registered
|
|
@@ -7510,26 +7839,22 @@ var CHANGE_AGENT_GC = 60 * 1000;
|
|
|
7510
7839
|
* @returns {TChangeAgentRun} - The change agent function.
|
|
7511
7840
|
*/
|
|
7512
7841
|
var createChangeAgent = functoolsKit.ttl(function (clientId) {
|
|
7513
|
-
return functoolsKit.queued(function (methodName, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7514
|
-
var
|
|
7842
|
+
return functoolsKit.queued(function (methodName, agentName, swarmName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7843
|
+
var _a, _b, _c;
|
|
7515
7844
|
return __generator(this, function (_d) {
|
|
7516
7845
|
switch (_d.label) {
|
|
7517
|
-
case 0:
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
return [2 /*return*/];
|
|
7530
|
-
}
|
|
7531
|
-
});
|
|
7532
|
-
}); }))];
|
|
7846
|
+
case 0: return [4 /*yield*/, Promise.all(swarm$1.swarmValidationService
|
|
7847
|
+
.getAgentList(swarmName)
|
|
7848
|
+
.map(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7849
|
+
return __generator(this, function (_a) {
|
|
7850
|
+
switch (_a.label) {
|
|
7851
|
+
case 0: return [4 /*yield*/, swarm$1.agentPublicService.commitAgentChange(methodName, clientId, agentName)];
|
|
7852
|
+
case 1:
|
|
7853
|
+
_a.sent();
|
|
7854
|
+
return [2 /*return*/];
|
|
7855
|
+
}
|
|
7856
|
+
});
|
|
7857
|
+
}); }))];
|
|
7533
7858
|
case 1:
|
|
7534
7859
|
_d.sent();
|
|
7535
7860
|
return [4 /*yield*/, swarm$1.agentPublicService.dispose(methodName, clientId, agentName)];
|
|
@@ -7581,7 +7906,7 @@ var createGc$1 = functoolsKit.singleshot(function () { return __awaiter(void 0,
|
|
|
7581
7906
|
* @returns {Promise<void>} - A promise that resolves when the agent is changed.
|
|
7582
7907
|
*/
|
|
7583
7908
|
var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7584
|
-
var run;
|
|
7909
|
+
var swarmName, activeAgent, run;
|
|
7585
7910
|
return __generator(this, function (_a) {
|
|
7586
7911
|
switch (_a.label) {
|
|
7587
7912
|
case 0:
|
|
@@ -7590,12 +7915,21 @@ var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void
|
|
|
7590
7915
|
agentName: agentName,
|
|
7591
7916
|
clientId: clientId,
|
|
7592
7917
|
});
|
|
7593
|
-
|
|
7918
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
7919
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$s);
|
|
7920
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$s);
|
|
7921
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$s, clientId, swarmName)];
|
|
7594
7922
|
case 1:
|
|
7923
|
+
activeAgent = _a.sent();
|
|
7924
|
+
if (!swarm$1.agentValidationService.hasDependency(activeAgent, agentName)) {
|
|
7925
|
+
console.error("agent-swarm missing dependency detected for activeAgent=".concat(activeAgent, " dependencyAgent=").concat(agentName));
|
|
7926
|
+
}
|
|
7927
|
+
return [4 /*yield*/, createChangeAgent(clientId)];
|
|
7928
|
+
case 2:
|
|
7595
7929
|
run = _a.sent();
|
|
7596
7930
|
createGc$1();
|
|
7597
|
-
return [4 /*yield*/, run(METHOD_NAME$s, agentName)];
|
|
7598
|
-
case
|
|
7931
|
+
return [4 /*yield*/, run(METHOD_NAME$s, agentName, swarmName)];
|
|
7932
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
7599
7933
|
}
|
|
7600
7934
|
});
|
|
7601
7935
|
}); };
|
|
@@ -9459,6 +9793,8 @@ exports.commitUserMessage = commitUserMessage;
|
|
|
9459
9793
|
exports.commitUserMessageForce = commitUserMessageForce;
|
|
9460
9794
|
exports.complete = complete;
|
|
9461
9795
|
exports.disposeConnection = disposeConnection;
|
|
9796
|
+
exports.dumpAgent = dumpAgent;
|
|
9797
|
+
exports.dumpSwarm = dumpSwarm;
|
|
9462
9798
|
exports.emit = emit;
|
|
9463
9799
|
exports.emitForce = emitForce;
|
|
9464
9800
|
exports.event = event;
|