agent-swarm-kit 1.0.60 → 1.0.62
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 +528 -49
- package/build/index.mjs +527 -51
- package/package.json +1 -1
- package/types.d.ts +237 -15
package/build/index.cjs
CHANGED
|
@@ -123,6 +123,23 @@ function __spreadArray(to, from, pack) {
|
|
|
123
123
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
function __await(v) {
|
|
127
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
131
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
132
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
133
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
134
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
135
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
136
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
137
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
138
|
+
function fulfill(value) { resume("next", value); }
|
|
139
|
+
function reject(value) { resume("throw", value); }
|
|
140
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
141
|
+
}
|
|
142
|
+
|
|
126
143
|
function __asyncValues(o) {
|
|
127
144
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
128
145
|
var m = o[Symbol.asyncIterator], i;
|
|
@@ -380,6 +397,415 @@ var removeXmlTags = function (input) {
|
|
|
380
397
|
.trim();
|
|
381
398
|
};
|
|
382
399
|
|
|
400
|
+
/**
|
|
401
|
+
* Class representing a History Instance
|
|
402
|
+
*/
|
|
403
|
+
var HistoryInstance = /** @class */ (function () {
|
|
404
|
+
/**
|
|
405
|
+
* Create a HistoryInstance.
|
|
406
|
+
* @param clientId - The client ID.
|
|
407
|
+
* @param callbacks - The callbacks for the history instance.
|
|
408
|
+
*/
|
|
409
|
+
function HistoryInstance(clientId, callbacks) {
|
|
410
|
+
var _this = this;
|
|
411
|
+
this.clientId = clientId;
|
|
412
|
+
this.callbacks = callbacks;
|
|
413
|
+
this._array = [];
|
|
414
|
+
/**
|
|
415
|
+
* Wait for the history to initialize.
|
|
416
|
+
* @param agentName - The agent name.
|
|
417
|
+
*/
|
|
418
|
+
this.waitForInit = functoolsKit.singleshot(function (agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
419
|
+
var _a;
|
|
420
|
+
return __generator(this, function (_b) {
|
|
421
|
+
switch (_b.label) {
|
|
422
|
+
case 0:
|
|
423
|
+
swarm.loggerService.log("HistoryInstance waitForInit", {
|
|
424
|
+
clientId: this.clientId,
|
|
425
|
+
agentName: agentName,
|
|
426
|
+
});
|
|
427
|
+
if (!this.callbacks.getData) return [3 /*break*/, 2];
|
|
428
|
+
_a = this;
|
|
429
|
+
return [4 /*yield*/, this.callbacks.getData(this.clientId, agentName)];
|
|
430
|
+
case 1:
|
|
431
|
+
_a._array = _b.sent();
|
|
432
|
+
_b.label = 2;
|
|
433
|
+
case 2: return [2 /*return*/];
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
}); });
|
|
437
|
+
/**
|
|
438
|
+
* Push a new message to the history for a given agent.
|
|
439
|
+
* @param value - The model message to push.
|
|
440
|
+
* @param agentName - The agent name.
|
|
441
|
+
* @returns A promise that resolves when the message is pushed.
|
|
442
|
+
*/
|
|
443
|
+
this.push = function (value, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
444
|
+
return __generator(this, function (_a) {
|
|
445
|
+
swarm.loggerService.log("HistoryInstance push", {
|
|
446
|
+
clientId: this.clientId,
|
|
447
|
+
agentName: agentName,
|
|
448
|
+
});
|
|
449
|
+
this._array.push(value);
|
|
450
|
+
this.callbacks.onChange &&
|
|
451
|
+
this.callbacks.onChange(this._array, this.clientId, agentName);
|
|
452
|
+
return [2 /*return*/, Promise.resolve()];
|
|
453
|
+
});
|
|
454
|
+
}); };
|
|
455
|
+
/**
|
|
456
|
+
* Dispose of the history for a given agent.
|
|
457
|
+
* @param agentName - The agent name or null.
|
|
458
|
+
* @returns A promise that resolves when the history is disposed.
|
|
459
|
+
*/
|
|
460
|
+
this.dispose = function (agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
461
|
+
return __generator(this, function (_a) {
|
|
462
|
+
swarm.loggerService.log("HistoryInstance dispose", {
|
|
463
|
+
clientId: this.clientId,
|
|
464
|
+
agentName: agentName,
|
|
465
|
+
});
|
|
466
|
+
if (agentName === null) {
|
|
467
|
+
this.callbacks.onDispose && this.callbacks.onDispose(this.clientId);
|
|
468
|
+
this._array = [];
|
|
469
|
+
}
|
|
470
|
+
return [2 /*return*/, Promise.resolve()];
|
|
471
|
+
});
|
|
472
|
+
}); };
|
|
473
|
+
swarm.loggerService.log("HistoryInstance CTOR", {
|
|
474
|
+
clientId: this.clientId,
|
|
475
|
+
});
|
|
476
|
+
if (callbacks.onInit) {
|
|
477
|
+
callbacks.onInit(clientId);
|
|
478
|
+
}
|
|
479
|
+
if (callbacks.filterCondition) {
|
|
480
|
+
this.iterate = function (agentName) {
|
|
481
|
+
return __asyncGenerator(this, arguments, function () {
|
|
482
|
+
var _a, _b, item, e_1_1, _c, _d, item, e_2_1;
|
|
483
|
+
var e_1, _e, e_2, _f;
|
|
484
|
+
return __generator(this, function (_g) {
|
|
485
|
+
switch (_g.label) {
|
|
486
|
+
case 0:
|
|
487
|
+
swarm.loggerService.log("HistoryInstance iterate condition", {
|
|
488
|
+
clientId: this.clientId,
|
|
489
|
+
agentName: agentName,
|
|
490
|
+
});
|
|
491
|
+
if (!this.callbacks.onRead) return [3 /*break*/, 12];
|
|
492
|
+
_g.label = 1;
|
|
493
|
+
case 1:
|
|
494
|
+
_g.trys.push([1, 8, 9, 10]);
|
|
495
|
+
_a = __values(this._array), _b = _a.next();
|
|
496
|
+
_g.label = 2;
|
|
497
|
+
case 2:
|
|
498
|
+
if (!!_b.done) return [3 /*break*/, 7];
|
|
499
|
+
item = _b.value;
|
|
500
|
+
return [4 /*yield*/, __await(callbacks.filterCondition(item, this.clientId, agentName))];
|
|
501
|
+
case 3:
|
|
502
|
+
if (!_g.sent()) return [3 /*break*/, 6];
|
|
503
|
+
this.callbacks.onRead(item, this.clientId, agentName);
|
|
504
|
+
return [4 /*yield*/, __await(item)];
|
|
505
|
+
case 4: return [4 /*yield*/, _g.sent()];
|
|
506
|
+
case 5:
|
|
507
|
+
_g.sent();
|
|
508
|
+
_g.label = 6;
|
|
509
|
+
case 6:
|
|
510
|
+
_b = _a.next();
|
|
511
|
+
return [3 /*break*/, 2];
|
|
512
|
+
case 7: return [3 /*break*/, 10];
|
|
513
|
+
case 8:
|
|
514
|
+
e_1_1 = _g.sent();
|
|
515
|
+
e_1 = { error: e_1_1 };
|
|
516
|
+
return [3 /*break*/, 10];
|
|
517
|
+
case 9:
|
|
518
|
+
try {
|
|
519
|
+
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
520
|
+
}
|
|
521
|
+
finally { if (e_1) throw e_1.error; }
|
|
522
|
+
return [7 /*endfinally*/];
|
|
523
|
+
case 10: return [4 /*yield*/, __await(void 0)];
|
|
524
|
+
case 11: return [2 /*return*/, _g.sent()];
|
|
525
|
+
case 12:
|
|
526
|
+
_g.trys.push([12, 19, 20, 21]);
|
|
527
|
+
_c = __values(this._array), _d = _c.next();
|
|
528
|
+
_g.label = 13;
|
|
529
|
+
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))];
|
|
533
|
+
case 14:
|
|
534
|
+
if (!_g.sent()) return [3 /*break*/, 17];
|
|
535
|
+
return [4 /*yield*/, __await(item)];
|
|
536
|
+
case 15: return [4 /*yield*/, _g.sent()];
|
|
537
|
+
case 16:
|
|
538
|
+
_g.sent();
|
|
539
|
+
_g.label = 17;
|
|
540
|
+
case 17:
|
|
541
|
+
_d = _c.next();
|
|
542
|
+
return [3 /*break*/, 13];
|
|
543
|
+
case 18: return [3 /*break*/, 21];
|
|
544
|
+
case 19:
|
|
545
|
+
e_2_1 = _g.sent();
|
|
546
|
+
e_2 = { error: e_2_1 };
|
|
547
|
+
return [3 /*break*/, 21];
|
|
548
|
+
case 20:
|
|
549
|
+
try {
|
|
550
|
+
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
551
|
+
}
|
|
552
|
+
finally { if (e_2) throw e_2.error; }
|
|
553
|
+
return [7 /*endfinally*/];
|
|
554
|
+
case 21: return [2 /*return*/];
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Iterate over the history messages for a given agent.
|
|
563
|
+
* @param agentName - The agent name.
|
|
564
|
+
* @returns An async iterable iterator of model messages.
|
|
565
|
+
*/
|
|
566
|
+
HistoryInstance.prototype.iterate = function (agentName) {
|
|
567
|
+
return __asyncGenerator(this, arguments, function iterate_1() {
|
|
568
|
+
var _a, _b, item, e_3_1, _c, _d, item, e_4_1;
|
|
569
|
+
var e_3, _e, e_4, _f;
|
|
570
|
+
return __generator(this, function (_g) {
|
|
571
|
+
switch (_g.label) {
|
|
572
|
+
case 0:
|
|
573
|
+
swarm.loggerService.log("HistoryInstance iterate", {
|
|
574
|
+
clientId: this.clientId,
|
|
575
|
+
agentName: agentName,
|
|
576
|
+
});
|
|
577
|
+
if (!this.callbacks.onRead) return [3 /*break*/, 11];
|
|
578
|
+
_g.label = 1;
|
|
579
|
+
case 1:
|
|
580
|
+
_g.trys.push([1, 7, 8, 9]);
|
|
581
|
+
_a = __values(this._array), _b = _a.next();
|
|
582
|
+
_g.label = 2;
|
|
583
|
+
case 2:
|
|
584
|
+
if (!!_b.done) return [3 /*break*/, 6];
|
|
585
|
+
item = _b.value;
|
|
586
|
+
this.callbacks.onRead(item, this.clientId, agentName);
|
|
587
|
+
return [4 /*yield*/, __await(item)];
|
|
588
|
+
case 3: return [4 /*yield*/, _g.sent()];
|
|
589
|
+
case 4:
|
|
590
|
+
_g.sent();
|
|
591
|
+
_g.label = 5;
|
|
592
|
+
case 5:
|
|
593
|
+
_b = _a.next();
|
|
594
|
+
return [3 /*break*/, 2];
|
|
595
|
+
case 6: return [3 /*break*/, 9];
|
|
596
|
+
case 7:
|
|
597
|
+
e_3_1 = _g.sent();
|
|
598
|
+
e_3 = { error: e_3_1 };
|
|
599
|
+
return [3 /*break*/, 9];
|
|
600
|
+
case 8:
|
|
601
|
+
try {
|
|
602
|
+
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
603
|
+
}
|
|
604
|
+
finally { if (e_3) throw e_3.error; }
|
|
605
|
+
return [7 /*endfinally*/];
|
|
606
|
+
case 9: return [4 /*yield*/, __await(void 0)];
|
|
607
|
+
case 10: return [2 /*return*/, _g.sent()];
|
|
608
|
+
case 11:
|
|
609
|
+
_g.trys.push([11, 17, 18, 19]);
|
|
610
|
+
_c = __values(this._array), _d = _c.next();
|
|
611
|
+
_g.label = 12;
|
|
612
|
+
case 12:
|
|
613
|
+
if (!!_d.done) return [3 /*break*/, 16];
|
|
614
|
+
item = _d.value;
|
|
615
|
+
return [4 /*yield*/, __await(item)];
|
|
616
|
+
case 13: return [4 /*yield*/, _g.sent()];
|
|
617
|
+
case 14:
|
|
618
|
+
_g.sent();
|
|
619
|
+
_g.label = 15;
|
|
620
|
+
case 15:
|
|
621
|
+
_d = _c.next();
|
|
622
|
+
return [3 /*break*/, 12];
|
|
623
|
+
case 16: return [3 /*break*/, 19];
|
|
624
|
+
case 17:
|
|
625
|
+
e_4_1 = _g.sent();
|
|
626
|
+
e_4 = { error: e_4_1 };
|
|
627
|
+
return [3 /*break*/, 19];
|
|
628
|
+
case 18:
|
|
629
|
+
try {
|
|
630
|
+
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
631
|
+
}
|
|
632
|
+
finally { if (e_4) throw e_4.error; }
|
|
633
|
+
return [7 /*endfinally*/];
|
|
634
|
+
case 19: return [2 /*return*/];
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
});
|
|
638
|
+
};
|
|
639
|
+
return HistoryInstance;
|
|
640
|
+
}());
|
|
641
|
+
/**
|
|
642
|
+
* Class representing History Utilities
|
|
643
|
+
*/
|
|
644
|
+
var HistoryUtils = /** @class */ (function () {
|
|
645
|
+
function HistoryUtils() {
|
|
646
|
+
var _this = this;
|
|
647
|
+
this.HistoryFactory = HistoryInstance;
|
|
648
|
+
this.HistoryCallbacks = {};
|
|
649
|
+
this.getHistory = functoolsKit.memoize(function (_a) {
|
|
650
|
+
var _b = __read(_a, 1), clientId = _b[0];
|
|
651
|
+
return clientId;
|
|
652
|
+
}, function (clientId) {
|
|
653
|
+
return new _this.HistoryFactory(clientId, _this.HistoryCallbacks);
|
|
654
|
+
});
|
|
655
|
+
/**
|
|
656
|
+
* Use a custom history adapter.
|
|
657
|
+
* @param Ctor - The constructor for the history instance.
|
|
658
|
+
*/
|
|
659
|
+
this.useHistoryAdapter = function (Ctor) {
|
|
660
|
+
swarm.loggerService.log("HistoryUtils useHistoryAdapter");
|
|
661
|
+
_this.HistoryFactory = Ctor;
|
|
662
|
+
};
|
|
663
|
+
/**
|
|
664
|
+
* Use history lifecycle callbacks.
|
|
665
|
+
* @param Callbacks - The callbacks dictionary.
|
|
666
|
+
*/
|
|
667
|
+
this.useHistoryCallbacks = function (Callbacks) {
|
|
668
|
+
swarm.loggerService.log("HistoryUtils useHistoryCallbacks");
|
|
669
|
+
_this.HistoryCallbacks = Callbacks;
|
|
670
|
+
};
|
|
671
|
+
/**
|
|
672
|
+
* Push a new message to the history.
|
|
673
|
+
* @param value - The model message to push.
|
|
674
|
+
* @param clientId - The client ID.
|
|
675
|
+
* @param agentName - The agent name.
|
|
676
|
+
* @returns A promise that resolves when the message is pushed.
|
|
677
|
+
*/
|
|
678
|
+
this.push = function (value, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
679
|
+
var isInitial, history;
|
|
680
|
+
return __generator(this, function (_a) {
|
|
681
|
+
switch (_a.label) {
|
|
682
|
+
case 0:
|
|
683
|
+
swarm.loggerService.log("HistoryUtils push", {
|
|
684
|
+
clientId: clientId,
|
|
685
|
+
agentName: agentName,
|
|
686
|
+
value: value,
|
|
687
|
+
});
|
|
688
|
+
isInitial = this.getHistory.has(clientId);
|
|
689
|
+
return [4 /*yield*/, this.getHistory(clientId)];
|
|
690
|
+
case 1:
|
|
691
|
+
history = _a.sent();
|
|
692
|
+
return [4 /*yield*/, history.waitForInit(agentName, isInitial)];
|
|
693
|
+
case 2:
|
|
694
|
+
_a.sent();
|
|
695
|
+
return [4 /*yield*/, history.push(value, agentName)];
|
|
696
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
}); };
|
|
700
|
+
/**
|
|
701
|
+
* Dispose of the history for a given client and agent.
|
|
702
|
+
* @param clientId - The client ID.
|
|
703
|
+
* @param agentName - The agent name or null.
|
|
704
|
+
* @returns A promise that resolves when the history is disposed.
|
|
705
|
+
*/
|
|
706
|
+
this.dispose = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
707
|
+
var isInitial, history;
|
|
708
|
+
return __generator(this, function (_a) {
|
|
709
|
+
switch (_a.label) {
|
|
710
|
+
case 0:
|
|
711
|
+
swarm.loggerService.log("HistoryUtils dispose", {
|
|
712
|
+
clientId: clientId,
|
|
713
|
+
agentName: agentName,
|
|
714
|
+
});
|
|
715
|
+
isInitial = this.getHistory.has(clientId);
|
|
716
|
+
return [4 /*yield*/, this.getHistory(clientId)];
|
|
717
|
+
case 1:
|
|
718
|
+
history = _a.sent();
|
|
719
|
+
return [4 /*yield*/, history.waitForInit(agentName, isInitial)];
|
|
720
|
+
case 2:
|
|
721
|
+
_a.sent();
|
|
722
|
+
return [4 /*yield*/, history.dispose(agentName)];
|
|
723
|
+
case 3:
|
|
724
|
+
_a.sent();
|
|
725
|
+
if (agentName === null) {
|
|
726
|
+
this.getHistory.clear(clientId);
|
|
727
|
+
}
|
|
728
|
+
return [2 /*return*/];
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
}); };
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Iterate over the history messages.
|
|
735
|
+
* @param clientId - The client ID.
|
|
736
|
+
* @param agentName - The agent name.
|
|
737
|
+
* @returns An async iterable iterator of model messages.
|
|
738
|
+
*/
|
|
739
|
+
HistoryUtils.prototype.iterate = function (clientId, agentName) {
|
|
740
|
+
return __asyncGenerator(this, arguments, function iterate_2() {
|
|
741
|
+
var isInitial, history, _a, _b, _c, item, e_5_1;
|
|
742
|
+
var _d, e_5, _e, _f;
|
|
743
|
+
return __generator(this, function (_g) {
|
|
744
|
+
switch (_g.label) {
|
|
745
|
+
case 0:
|
|
746
|
+
swarm.loggerService.log("HistoryUtils iterate", {
|
|
747
|
+
clientId: clientId,
|
|
748
|
+
agentName: agentName,
|
|
749
|
+
});
|
|
750
|
+
isInitial = this.getHistory.has(clientId);
|
|
751
|
+
return [4 /*yield*/, __await(this.getHistory(clientId))];
|
|
752
|
+
case 1:
|
|
753
|
+
history = _g.sent();
|
|
754
|
+
return [4 /*yield*/, __await(history.waitForInit(agentName, isInitial))];
|
|
755
|
+
case 2:
|
|
756
|
+
_g.sent();
|
|
757
|
+
_g.label = 3;
|
|
758
|
+
case 3:
|
|
759
|
+
_g.trys.push([3, 10, 11, 16]);
|
|
760
|
+
_a = true, _b = __asyncValues(history.iterate(agentName));
|
|
761
|
+
_g.label = 4;
|
|
762
|
+
case 4: return [4 /*yield*/, __await(_b.next())];
|
|
763
|
+
case 5:
|
|
764
|
+
if (!(_c = _g.sent(), _d = _c.done, !_d)) return [3 /*break*/, 9];
|
|
765
|
+
_f = _c.value;
|
|
766
|
+
_a = false;
|
|
767
|
+
item = _f;
|
|
768
|
+
return [4 /*yield*/, __await(item)];
|
|
769
|
+
case 6: return [4 /*yield*/, _g.sent()];
|
|
770
|
+
case 7:
|
|
771
|
+
_g.sent();
|
|
772
|
+
_g.label = 8;
|
|
773
|
+
case 8:
|
|
774
|
+
_a = true;
|
|
775
|
+
return [3 /*break*/, 4];
|
|
776
|
+
case 9: return [3 /*break*/, 16];
|
|
777
|
+
case 10:
|
|
778
|
+
e_5_1 = _g.sent();
|
|
779
|
+
e_5 = { error: e_5_1 };
|
|
780
|
+
return [3 /*break*/, 16];
|
|
781
|
+
case 11:
|
|
782
|
+
_g.trys.push([11, , 14, 15]);
|
|
783
|
+
if (!(!_a && !_d && (_e = _b.return))) return [3 /*break*/, 13];
|
|
784
|
+
return [4 /*yield*/, __await(_e.call(_b))];
|
|
785
|
+
case 12:
|
|
786
|
+
_g.sent();
|
|
787
|
+
_g.label = 13;
|
|
788
|
+
case 13: return [3 /*break*/, 15];
|
|
789
|
+
case 14:
|
|
790
|
+
if (e_5) throw e_5.error;
|
|
791
|
+
return [7 /*endfinally*/];
|
|
792
|
+
case 15: return [7 /*endfinally*/];
|
|
793
|
+
case 16: return [2 /*return*/];
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
});
|
|
797
|
+
};
|
|
798
|
+
return HistoryUtils;
|
|
799
|
+
}());
|
|
800
|
+
/**
|
|
801
|
+
* Exported History Adapter instance
|
|
802
|
+
*/
|
|
803
|
+
var HistoryAdapter = new HistoryUtils();
|
|
804
|
+
/**
|
|
805
|
+
* Exported History Control instance
|
|
806
|
+
*/
|
|
807
|
+
var History = HistoryAdapter;
|
|
808
|
+
|
|
383
809
|
/**
|
|
384
810
|
* @description `ask for agent function` in `llama3.1:8b` to troubleshoot (need CC_OLLAMA_EMIT_TOOL_PROTOCOL to be turned off)
|
|
385
811
|
*/
|
|
@@ -432,9 +858,8 @@ var CC_AGENT_HISTORY_FILTER = function (agentName) {
|
|
|
432
858
|
};
|
|
433
859
|
var CC_AGENT_OUTPUT_TRANSFORM = removeXmlTags;
|
|
434
860
|
var CC_KEEP_MESSAGES = 5;
|
|
435
|
-
var
|
|
861
|
+
var CC_GET_AGENT_HISTORY_ADAPTER = function () { return HistoryAdapter; };
|
|
436
862
|
var CC_AGENT_OUTPUT_MAP = function (message) { return message; };
|
|
437
|
-
var CC_AGENT_SEPARATE_HISTORY = false;
|
|
438
863
|
var CC_AGENT_SYSTEM_PROMPT = undefined;
|
|
439
864
|
var CC_STORAGE_SEARCH_SIMILARITY = 0.65;
|
|
440
865
|
var CC_STORAGE_SEARCH_POOL = 5;
|
|
@@ -442,7 +867,7 @@ var GLOBAL_CONFIG = {
|
|
|
442
867
|
CC_TOOL_CALL_EXCEPTION_PROMPT: CC_TOOL_CALL_EXCEPTION_PROMPT,
|
|
443
868
|
CC_EMPTY_OUTPUT_PLACEHOLDERS: CC_EMPTY_OUTPUT_PLACEHOLDERS,
|
|
444
869
|
CC_KEEP_MESSAGES: CC_KEEP_MESSAGES,
|
|
445
|
-
|
|
870
|
+
CC_GET_AGENT_HISTORY_ADAPTER: CC_GET_AGENT_HISTORY_ADAPTER,
|
|
446
871
|
CC_SWARM_AGENT_CHANGED: CC_SWARM_AGENT_CHANGED,
|
|
447
872
|
CC_SWARM_DEFAULT_AGENT: CC_SWARM_DEFAULT_AGENT,
|
|
448
873
|
CC_AGENT_DEFAULT_VALIDATION: CC_AGENT_DEFAULT_VALIDATION,
|
|
@@ -450,7 +875,6 @@ var GLOBAL_CONFIG = {
|
|
|
450
875
|
CC_AGENT_OUTPUT_TRANSFORM: CC_AGENT_OUTPUT_TRANSFORM,
|
|
451
876
|
CC_AGENT_OUTPUT_MAP: CC_AGENT_OUTPUT_MAP,
|
|
452
877
|
CC_AGENT_SYSTEM_PROMPT: CC_AGENT_SYSTEM_PROMPT,
|
|
453
|
-
CC_AGENT_SEPARATE_HISTORY: CC_AGENT_SEPARATE_HISTORY,
|
|
454
878
|
CC_AGENT_DISALLOWED_TAGS: CC_AGENT_DISALLOWED_TAGS,
|
|
455
879
|
CC_AGENT_DISALLOWED_SYMBOLS: CC_AGENT_DISALLOWED_SYMBOLS,
|
|
456
880
|
CC_STORAGE_SEARCH_SIMILARITY: CC_STORAGE_SEARCH_SIMILARITY,
|
|
@@ -1149,7 +1573,7 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1149
1573
|
switch (_a.label) {
|
|
1150
1574
|
case 0:
|
|
1151
1575
|
this.params.logger.debug("ClientHistory agentName=".concat(this.params.agentName, " push"), { message: message });
|
|
1152
|
-
return [4 /*yield*/, this.params.items.push(message)];
|
|
1576
|
+
return [4 /*yield*/, this.params.items.push(message, this.params.clientId, this.params.agentName)];
|
|
1153
1577
|
case 1:
|
|
1154
1578
|
_a.sent();
|
|
1155
1579
|
return [2 /*return*/];
|
|
@@ -1171,7 +1595,7 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1171
1595
|
_g.label = 1;
|
|
1172
1596
|
case 1:
|
|
1173
1597
|
_g.trys.push([1, 6, 7, 12]);
|
|
1174
|
-
_a = true, _b = __asyncValues(this.params.items);
|
|
1598
|
+
_a = true, _b = __asyncValues(this.params.items.iterate(this.params.clientId, this.params.agentName));
|
|
1175
1599
|
_g.label = 2;
|
|
1176
1600
|
case 2: return [4 /*yield*/, _b.next()];
|
|
1177
1601
|
case 3:
|
|
@@ -1225,7 +1649,7 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1225
1649
|
_h.label = 1;
|
|
1226
1650
|
case 1:
|
|
1227
1651
|
_h.trys.push([1, 6, 7, 12]);
|
|
1228
|
-
_a = true, _b = __asyncValues(this.params.items);
|
|
1652
|
+
_a = true, _b = __asyncValues(this.params.items.iterate(this.params.clientId, this.params.agentName));
|
|
1229
1653
|
_h.label = 2;
|
|
1230
1654
|
case 2: return [4 /*yield*/, _b.next()];
|
|
1231
1655
|
case 3:
|
|
@@ -1352,6 +1776,22 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1352
1776
|
}
|
|
1353
1777
|
});
|
|
1354
1778
|
}); };
|
|
1779
|
+
/**
|
|
1780
|
+
* Should call on agent dispose
|
|
1781
|
+
* @returns {Promise<void>}
|
|
1782
|
+
*/
|
|
1783
|
+
this.dispose = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1784
|
+
return __generator(this, function (_a) {
|
|
1785
|
+
switch (_a.label) {
|
|
1786
|
+
case 0:
|
|
1787
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " dispose"));
|
|
1788
|
+
return [4 /*yield*/, this.params.items.dispose(this.params.clientId, this.params.agentName)];
|
|
1789
|
+
case 1:
|
|
1790
|
+
_a.sent();
|
|
1791
|
+
return [2 /*return*/];
|
|
1792
|
+
}
|
|
1793
|
+
});
|
|
1794
|
+
}); };
|
|
1355
1795
|
this.params.logger.debug("ClientHistory agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " CTOR"), {
|
|
1356
1796
|
params: params,
|
|
1357
1797
|
});
|
|
@@ -1370,18 +1810,6 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
1370
1810
|
this.loggerService = inject(TYPES.loggerService);
|
|
1371
1811
|
this.contextService = inject(TYPES.contextService);
|
|
1372
1812
|
this.sessionValidationService = inject(TYPES.sessionValidationService);
|
|
1373
|
-
/**
|
|
1374
|
-
* Retrieves items for a given client and agent.
|
|
1375
|
-
* @param {string} clientId - The client ID.
|
|
1376
|
-
* @param {AgentName} agentName - The agent name.
|
|
1377
|
-
* @returns {IPubsubArray<IModelMessage>} The items.
|
|
1378
|
-
*/
|
|
1379
|
-
this.getItems = functoolsKit.memoize(function (_a) {
|
|
1380
|
-
var _b = __read(_a, 1), clientId = _b[0];
|
|
1381
|
-
return clientId;
|
|
1382
|
-
}, function (clientId, agentName) {
|
|
1383
|
-
return GLOBAL_CONFIG.CC_GET_AGENT_HISTORY(clientId, agentName);
|
|
1384
|
-
});
|
|
1385
1813
|
/**
|
|
1386
1814
|
* Retrieves the history for a given client and agent.
|
|
1387
1815
|
* @param {string} clientId - The client ID.
|
|
@@ -1396,7 +1824,7 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
1396
1824
|
return new ClientHistory({
|
|
1397
1825
|
clientId: clientId,
|
|
1398
1826
|
agentName: agentName,
|
|
1399
|
-
items:
|
|
1827
|
+
items: GLOBAL_CONFIG.CC_GET_AGENT_HISTORY_ADAPTER(clientId, agentName),
|
|
1400
1828
|
logger: _this.loggerService,
|
|
1401
1829
|
});
|
|
1402
1830
|
});
|
|
@@ -1466,13 +1894,9 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
1466
1894
|
if (!this.getHistory.has(key)) {
|
|
1467
1895
|
return [2 /*return*/];
|
|
1468
1896
|
}
|
|
1469
|
-
|
|
1470
|
-
return [4 /*yield*/, this.getItems(this.contextService.context.clientId, this.contextService.context.agentName).clear()];
|
|
1897
|
+
return [4 /*yield*/, this.getHistory(this.contextService.context.clientId, this.contextService.context.agentName).dispose()];
|
|
1471
1898
|
case 1:
|
|
1472
1899
|
_a.sent();
|
|
1473
|
-
this.getItems.clear(this.contextService.context.clientId);
|
|
1474
|
-
_a.label = 2;
|
|
1475
|
-
case 2:
|
|
1476
1900
|
this.getHistory.clear(key);
|
|
1477
1901
|
this.sessionValidationService.removeHistoryUsage(this.contextService.context.clientId, this.contextService.context.agentName);
|
|
1478
1902
|
return [2 /*return*/];
|
|
@@ -3399,9 +3823,10 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
3399
3823
|
function SessionValidationService() {
|
|
3400
3824
|
var _this = this;
|
|
3401
3825
|
this.loggerService = inject(TYPES.loggerService);
|
|
3826
|
+
this._storageSwarmMap = new Map();
|
|
3402
3827
|
this._historySwarmMap = new Map();
|
|
3403
|
-
this._sessionSwarmMap = new Map();
|
|
3404
3828
|
this._agentSwarmMap = new Map();
|
|
3829
|
+
this._sessionSwarmMap = new Map();
|
|
3405
3830
|
this._sessionModeMap = new Map();
|
|
3406
3831
|
/**
|
|
3407
3832
|
* Adds a new session.
|
|
@@ -3460,6 +3885,26 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
3460
3885
|
_this._historySwarmMap.set(sessionId, [agentName]);
|
|
3461
3886
|
}
|
|
3462
3887
|
};
|
|
3888
|
+
/**
|
|
3889
|
+
* Adds a storage usage to a session.
|
|
3890
|
+
* @param {SessionId} sessionId - The ID of the session.
|
|
3891
|
+
* @param {StorageName} storageName - The name of the storage.
|
|
3892
|
+
*/
|
|
3893
|
+
this.addStorageUsage = function (sessionId, storageName) {
|
|
3894
|
+
_this.loggerService.log("sessionValidationService addStorageUsage", {
|
|
3895
|
+
sessionId: sessionId,
|
|
3896
|
+
storageName: storageName,
|
|
3897
|
+
});
|
|
3898
|
+
if (_this._storageSwarmMap.has(sessionId)) {
|
|
3899
|
+
var storages = _this._storageSwarmMap.get(sessionId);
|
|
3900
|
+
if (!storages.includes(storageName)) {
|
|
3901
|
+
storages.push(storageName);
|
|
3902
|
+
}
|
|
3903
|
+
}
|
|
3904
|
+
else {
|
|
3905
|
+
_this._storageSwarmMap.set(sessionId, [storageName]);
|
|
3906
|
+
}
|
|
3907
|
+
};
|
|
3463
3908
|
/**
|
|
3464
3909
|
* Removes an agent usage from a session.
|
|
3465
3910
|
* @param {SessionId} sessionId - The ID of the session.
|
|
@@ -3510,6 +3955,31 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
3510
3955
|
throw new Error("No agents found for sessionId=".concat(sessionId));
|
|
3511
3956
|
}
|
|
3512
3957
|
};
|
|
3958
|
+
/**
|
|
3959
|
+
* Removes a storage usage from a session.
|
|
3960
|
+
* @param {SessionId} sessionId - The ID of the session.
|
|
3961
|
+
* @param {StorageName} storageName - The name of the storage.
|
|
3962
|
+
* @throws Will throw an error if no storages are found for the session.
|
|
3963
|
+
*/
|
|
3964
|
+
this.removeStorageUsage = function (sessionId, storageName) {
|
|
3965
|
+
_this.loggerService.log("sessionValidationService removeStorageUsage", {
|
|
3966
|
+
sessionId: sessionId,
|
|
3967
|
+
storageName: storageName,
|
|
3968
|
+
});
|
|
3969
|
+
if (_this._storageSwarmMap.has(sessionId)) {
|
|
3970
|
+
var agents = _this._storageSwarmMap.get(sessionId);
|
|
3971
|
+
var agentIndex = agents.indexOf(storageName);
|
|
3972
|
+
if (agentIndex !== -1) {
|
|
3973
|
+
agents.splice(agentIndex, 1);
|
|
3974
|
+
}
|
|
3975
|
+
if (agents.length === 0) {
|
|
3976
|
+
_this._storageSwarmMap.delete(sessionId);
|
|
3977
|
+
}
|
|
3978
|
+
}
|
|
3979
|
+
else {
|
|
3980
|
+
throw new Error("No agents found for sessionId=".concat(sessionId));
|
|
3981
|
+
}
|
|
3982
|
+
};
|
|
3513
3983
|
/**
|
|
3514
3984
|
* Gets the mode of a session.
|
|
3515
3985
|
* @param {SessionId} clientId - The ID of the client.
|
|
@@ -3869,11 +4339,12 @@ var ClientStorage = /** @class */ (function () {
|
|
|
3869
4339
|
args_1[_i - 2] = arguments[_i];
|
|
3870
4340
|
}
|
|
3871
4341
|
return __awaiter(_this, __spreadArray([search_1, total_1], __read(args_1), false), void 0, function (search, total, score) {
|
|
3872
|
-
var indexed, searchEmbeddings
|
|
4342
|
+
var indexed, searchEmbeddings;
|
|
3873
4343
|
var _this = this;
|
|
4344
|
+
var _a, _b;
|
|
3874
4345
|
if (score === void 0) { score = GLOBAL_CONFIG.CC_STORAGE_SEARCH_SIMILARITY; }
|
|
3875
|
-
return __generator(this, function (
|
|
3876
|
-
switch (
|
|
4346
|
+
return __generator(this, function (_c) {
|
|
4347
|
+
switch (_c.label) {
|
|
3877
4348
|
case 0:
|
|
3878
4349
|
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " take"), {
|
|
3879
4350
|
search: search,
|
|
@@ -3882,7 +4353,7 @@ var ClientStorage = /** @class */ (function () {
|
|
|
3882
4353
|
indexed = new functoolsKit.SortedArray();
|
|
3883
4354
|
return [4 /*yield*/, this.params.createEmbedding(search)];
|
|
3884
4355
|
case 1:
|
|
3885
|
-
searchEmbeddings =
|
|
4356
|
+
searchEmbeddings = _c.sent();
|
|
3886
4357
|
if (this.params.onCreate) {
|
|
3887
4358
|
this.params.onCreate(search, searchEmbeddings, this.params.clientId, this.params.embedding);
|
|
3888
4359
|
}
|
|
@@ -3899,7 +4370,7 @@ var ClientStorage = /** @class */ (function () {
|
|
|
3899
4370
|
if (this.params.onCompare) {
|
|
3900
4371
|
this.params.onCompare(search, index, score, this.params.clientId, this.params.embedding);
|
|
3901
4372
|
}
|
|
3902
|
-
indexed.push(
|
|
4373
|
+
indexed.push(item, score);
|
|
3903
4374
|
return [2 /*return*/];
|
|
3904
4375
|
}
|
|
3905
4376
|
});
|
|
@@ -3908,15 +4379,14 @@ var ClientStorage = /** @class */ (function () {
|
|
|
3908
4379
|
maxExec: GLOBAL_CONFIG.CC_STORAGE_SEARCH_POOL,
|
|
3909
4380
|
})))];
|
|
3910
4381
|
case 2:
|
|
3911
|
-
|
|
4382
|
+
_c.sent();
|
|
3912
4383
|
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " take indexed"), {
|
|
3913
4384
|
indexed: indexed.getEntries(),
|
|
3914
4385
|
});
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
})];
|
|
4386
|
+
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onSearch) {
|
|
4387
|
+
(_b = this.params.callbacks) === null || _b === void 0 ? void 0 : _b.onSearch(search, indexed, this.params.clientId, this.params.storageName);
|
|
4388
|
+
}
|
|
4389
|
+
return [2 /*return*/, indexed.take(total, score)];
|
|
3920
4390
|
}
|
|
3921
4391
|
});
|
|
3922
4392
|
});
|
|
@@ -4040,6 +4510,7 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
4040
4510
|
this.loggerService = inject(TYPES.loggerService);
|
|
4041
4511
|
this.contextService = inject(TYPES.contextService);
|
|
4042
4512
|
this.storageSchemaService = inject(TYPES.storageSchemaService);
|
|
4513
|
+
this.sessionValidationService = inject(TYPES.sessionValidationService);
|
|
4043
4514
|
this.embeddingSchemaService = inject(TYPES.embeddingSchemaService);
|
|
4044
4515
|
/**
|
|
4045
4516
|
* Retrieves a storage instance based on client ID and storage name.
|
|
@@ -4051,6 +4522,7 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
4051
4522
|
var _b = __read(_a, 2), clientId = _b[0], storageName = _b[1];
|
|
4052
4523
|
return "".concat(clientId, "-").concat(storageName);
|
|
4053
4524
|
}, function (clientId, storageName) {
|
|
4525
|
+
_this.sessionValidationService.addStorageUsage(clientId, storageName);
|
|
4054
4526
|
var _a = _this.storageSchemaService.get(storageName), createIndex = _a.createIndex, getData = _a.getData, embeddingName = _a.embedding, callbacks = _a.callbacks;
|
|
4055
4527
|
var _b = _this.embeddingSchemaService.get(embeddingName), calculateSimilarity = _b.calculateSimilarity, createEmbedding = _b.createEmbedding, embedding = _b.callbacks;
|
|
4056
4528
|
return new ClientStorage(__assign(__assign({ clientId: clientId, storageName: storageName, embedding: embeddingName, calculateSimilarity: calculateSimilarity, createEmbedding: createEmbedding, createIndex: createIndex, getData: getData, logger: _this.loggerService }, embedding), { callbacks: callbacks }));
|
|
@@ -4208,6 +4680,7 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
4208
4680
|
return [2 /*return*/];
|
|
4209
4681
|
}
|
|
4210
4682
|
this.getStorage.clear(key);
|
|
4683
|
+
this.sessionValidationService.removeStorageUsage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
4211
4684
|
return [2 /*return*/];
|
|
4212
4685
|
});
|
|
4213
4686
|
}); };
|
|
@@ -5064,6 +5537,9 @@ var disposeConnection = function (clientId, swarmName) { return __awaiter(void 0
|
|
|
5064
5537
|
}); }),
|
|
5065
5538
|
])];
|
|
5066
5539
|
case 4:
|
|
5540
|
+
_a.sent();
|
|
5541
|
+
return [4 /*yield*/, HistoryAdapter.dispose(clientId, null)];
|
|
5542
|
+
case 5:
|
|
5067
5543
|
_a.sent();
|
|
5068
5544
|
return [2 /*return*/];
|
|
5069
5545
|
}
|
|
@@ -5926,14 +6402,14 @@ var StorageUtils = /** @class */ (function () {
|
|
|
5926
6402
|
return __generator(this, function (_a) {
|
|
5927
6403
|
switch (_a.label) {
|
|
5928
6404
|
case 0:
|
|
5929
|
-
swarm.loggerService.log("
|
|
6405
|
+
swarm.loggerService.log("StorageUtils take", {
|
|
5930
6406
|
search: payload.search,
|
|
5931
6407
|
total: payload.total,
|
|
5932
6408
|
clientId: payload.clientId,
|
|
5933
6409
|
storageName: payload.storageName,
|
|
5934
6410
|
score: payload.score,
|
|
5935
6411
|
});
|
|
5936
|
-
swarm.storageValidationService.validate(payload.storageName, "
|
|
6412
|
+
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
5937
6413
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
5938
6414
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (take)"));
|
|
5939
6415
|
}
|
|
@@ -5955,12 +6431,12 @@ var StorageUtils = /** @class */ (function () {
|
|
|
5955
6431
|
return __generator(this, function (_a) {
|
|
5956
6432
|
switch (_a.label) {
|
|
5957
6433
|
case 0:
|
|
5958
|
-
swarm.loggerService.log("
|
|
6434
|
+
swarm.loggerService.log("StorageUtils upsert", {
|
|
5959
6435
|
item: payload.item,
|
|
5960
6436
|
clientId: payload.clientId,
|
|
5961
6437
|
storageName: payload.storageName,
|
|
5962
6438
|
});
|
|
5963
|
-
swarm.storageValidationService.validate(payload.storageName, "
|
|
6439
|
+
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
5964
6440
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
5965
6441
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (upsert)"));
|
|
5966
6442
|
}
|
|
@@ -5981,12 +6457,12 @@ var StorageUtils = /** @class */ (function () {
|
|
|
5981
6457
|
return __generator(this, function (_a) {
|
|
5982
6458
|
switch (_a.label) {
|
|
5983
6459
|
case 0:
|
|
5984
|
-
swarm.loggerService.log("
|
|
6460
|
+
swarm.loggerService.log("StorageUtils remove", {
|
|
5985
6461
|
itemId: payload.itemId,
|
|
5986
6462
|
clientId: payload.clientId,
|
|
5987
6463
|
storageName: payload.storageName,
|
|
5988
6464
|
});
|
|
5989
|
-
swarm.storageValidationService.validate(payload.storageName, "
|
|
6465
|
+
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
5990
6466
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
5991
6467
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (remove)"));
|
|
5992
6468
|
}
|
|
@@ -6008,12 +6484,12 @@ var StorageUtils = /** @class */ (function () {
|
|
|
6008
6484
|
return __generator(this, function (_a) {
|
|
6009
6485
|
switch (_a.label) {
|
|
6010
6486
|
case 0:
|
|
6011
|
-
swarm.loggerService.log("
|
|
6487
|
+
swarm.loggerService.log("StorageUtils get", {
|
|
6012
6488
|
itemId: payload.itemId,
|
|
6013
6489
|
clientId: payload.clientId,
|
|
6014
6490
|
storageName: payload.storageName,
|
|
6015
6491
|
});
|
|
6016
|
-
swarm.storageValidationService.validate(payload.storageName, "
|
|
6492
|
+
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
6017
6493
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
6018
6494
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (get)"));
|
|
6019
6495
|
}
|
|
@@ -6035,11 +6511,11 @@ var StorageUtils = /** @class */ (function () {
|
|
|
6035
6511
|
return __generator(this, function (_a) {
|
|
6036
6512
|
switch (_a.label) {
|
|
6037
6513
|
case 0:
|
|
6038
|
-
swarm.loggerService.log("
|
|
6514
|
+
swarm.loggerService.log("StorageUtils list", {
|
|
6039
6515
|
clientId: payload.clientId,
|
|
6040
6516
|
storageName: payload.storageName,
|
|
6041
6517
|
});
|
|
6042
|
-
swarm.storageValidationService.validate(payload.storageName, "
|
|
6518
|
+
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
6043
6519
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
6044
6520
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (list)"));
|
|
6045
6521
|
}
|
|
@@ -6059,11 +6535,11 @@ var StorageUtils = /** @class */ (function () {
|
|
|
6059
6535
|
return __generator(this, function (_a) {
|
|
6060
6536
|
switch (_a.label) {
|
|
6061
6537
|
case 0:
|
|
6062
|
-
swarm.loggerService.log("
|
|
6538
|
+
swarm.loggerService.log("StorageUtils clear", {
|
|
6063
6539
|
clientId: payload.clientId,
|
|
6064
6540
|
storageName: payload.storageName,
|
|
6065
6541
|
});
|
|
6066
|
-
swarm.storageValidationService.validate(payload.storageName, "
|
|
6542
|
+
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
6067
6543
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
6068
6544
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (clear)"));
|
|
6069
6545
|
}
|
|
@@ -6078,7 +6554,10 @@ var StorageUtils = /** @class */ (function () {
|
|
|
6078
6554
|
var Storage = new StorageUtils();
|
|
6079
6555
|
|
|
6080
6556
|
exports.ContextService = ContextService;
|
|
6557
|
+
exports.History = History;
|
|
6081
6558
|
exports.Storage = Storage;
|
|
6559
|
+
exports._HistoryAdapter = HistoryAdapter;
|
|
6560
|
+
exports._HistoryInstance = HistoryInstance;
|
|
6082
6561
|
exports.addAgent = addAgent;
|
|
6083
6562
|
exports.addCompletion = addCompletion;
|
|
6084
6563
|
exports.addEmbedding = addEmbedding;
|