agent-swarm-kit 1.0.81 → 1.0.83
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 +1011 -570
- package/build/index.mjs +1011 -572
- package/package.json +1 -1
- package/types.d.ts +215 -25
package/build/index.cjs
CHANGED
|
@@ -167,8 +167,8 @@ var MethodContextService = diScoped.scoped(/** @class */ (function () {
|
|
|
167
167
|
return class_1;
|
|
168
168
|
}()));
|
|
169
169
|
|
|
170
|
-
var _a;
|
|
171
|
-
var init = (_a = diKit.createActivator("agent-swarm"), _a.init), inject = _a.inject, provide = _a.provide;
|
|
170
|
+
var _a$2;
|
|
171
|
+
var init = (_a$2 = diKit.createActivator("agent-swarm"), _a$2.init), inject = _a$2.inject, provide = _a$2.provide;
|
|
172
172
|
|
|
173
173
|
var baseServices$1 = {
|
|
174
174
|
busService: Symbol('busService'),
|
|
@@ -228,103 +228,6 @@ var ExecutionContextService = diScoped.scoped(/** @class */ (function () {
|
|
|
228
228
|
return class_1;
|
|
229
229
|
}()));
|
|
230
230
|
|
|
231
|
-
/**
|
|
232
|
-
* LoggerService class that implements the ILogger interface.
|
|
233
|
-
* Provides methods to log and debug messages.
|
|
234
|
-
*/
|
|
235
|
-
var LoggerService = /** @class */ (function () {
|
|
236
|
-
function LoggerService() {
|
|
237
|
-
var _this = this;
|
|
238
|
-
this.methodContextService = inject(TYPES.methodContextService);
|
|
239
|
-
this.executionContextService = inject(TYPES.executionContextService);
|
|
240
|
-
this._logger = {
|
|
241
|
-
/**
|
|
242
|
-
* Logs messages.
|
|
243
|
-
* @param {...any} args - The messages to log.
|
|
244
|
-
*/
|
|
245
|
-
log: function () {
|
|
246
|
-
},
|
|
247
|
-
/**
|
|
248
|
-
* Logs debug messages.
|
|
249
|
-
* @param {...any} args - The debug messages to log.
|
|
250
|
-
*/
|
|
251
|
-
debug: function () {
|
|
252
|
-
},
|
|
253
|
-
/**
|
|
254
|
-
* Logs info messages.
|
|
255
|
-
* @param {...any} args - The info messages to log.
|
|
256
|
-
*/
|
|
257
|
-
info: function () {
|
|
258
|
-
},
|
|
259
|
-
};
|
|
260
|
-
/**
|
|
261
|
-
* Logs messages using the current logger.
|
|
262
|
-
* @param {...any} args - The messages to log.
|
|
263
|
-
*/
|
|
264
|
-
this.log = function () {
|
|
265
|
-
var _a;
|
|
266
|
-
var args = [];
|
|
267
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
268
|
-
args[_i] = arguments[_i];
|
|
269
|
-
}
|
|
270
|
-
var methodContext = MethodContextService.hasContext()
|
|
271
|
-
? _this.methodContextService.context
|
|
272
|
-
: null;
|
|
273
|
-
var executionContext = ExecutionContextService.hasContext()
|
|
274
|
-
? _this.executionContextService.context
|
|
275
|
-
: null;
|
|
276
|
-
(_a = _this._logger).log.apply(_a, __spreadArray(__spreadArray([], __read(args), false), [{
|
|
277
|
-
methodContext: methodContext,
|
|
278
|
-
executionContext: executionContext,
|
|
279
|
-
}], false));
|
|
280
|
-
};
|
|
281
|
-
/**
|
|
282
|
-
* Logs debug messages using the current logger.
|
|
283
|
-
* @param {...any} args - The debug messages to log.
|
|
284
|
-
*/
|
|
285
|
-
this.debug = function () {
|
|
286
|
-
var _a;
|
|
287
|
-
var args = [];
|
|
288
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
289
|
-
args[_i] = arguments[_i];
|
|
290
|
-
}
|
|
291
|
-
var methodContext = MethodContextService.hasContext()
|
|
292
|
-
? _this.methodContextService.context
|
|
293
|
-
: null;
|
|
294
|
-
var executionContext = ExecutionContextService.hasContext()
|
|
295
|
-
? _this.executionContextService.context
|
|
296
|
-
: null;
|
|
297
|
-
(_a = _this._logger).debug.apply(_a, __spreadArray(__spreadArray([], __read(args), false), [{ methodContext: methodContext, executionContext: executionContext }], false));
|
|
298
|
-
};
|
|
299
|
-
/**
|
|
300
|
-
* Logs info messages using the current logger.
|
|
301
|
-
* @param {...any} args - The info messages to log.
|
|
302
|
-
*/
|
|
303
|
-
this.info = function () {
|
|
304
|
-
var _a;
|
|
305
|
-
var args = [];
|
|
306
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
307
|
-
args[_i] = arguments[_i];
|
|
308
|
-
}
|
|
309
|
-
var methodContext = MethodContextService.hasContext()
|
|
310
|
-
? _this.methodContextService.context
|
|
311
|
-
: null;
|
|
312
|
-
var executionContext = ExecutionContextService.hasContext()
|
|
313
|
-
? _this.executionContextService.context
|
|
314
|
-
: null;
|
|
315
|
-
(_a = _this._logger).info.apply(_a, __spreadArray(__spreadArray([], __read(args), false), [{ methodContext: methodContext, executionContext: executionContext }], false));
|
|
316
|
-
};
|
|
317
|
-
/**
|
|
318
|
-
* Sets a new logger.
|
|
319
|
-
* @param {ILogger} logger - The new logger to set.
|
|
320
|
-
*/
|
|
321
|
-
this.setLogger = function (logger) {
|
|
322
|
-
_this._logger = logger;
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
return LoggerService;
|
|
326
|
-
}());
|
|
327
|
-
|
|
328
231
|
/**
|
|
329
232
|
* Validates that the given output string is not empty.
|
|
330
233
|
*
|
|
@@ -429,6 +332,8 @@ var removeXmlTags = function (input) {
|
|
|
429
332
|
.trim();
|
|
430
333
|
};
|
|
431
334
|
|
|
335
|
+
var _a$1;
|
|
336
|
+
var HISTORY_INSTANCE_WAIT_FOR_INIT = Symbol("wait-for-init");
|
|
432
337
|
var INSTANCE_METHOD_NAME_WAIT_FOR_INIT = "HistoryInstance.waitForInit";
|
|
433
338
|
var INSTANCE_METHOD_NAME_CTOR = "HistoryInstance.CTOR";
|
|
434
339
|
var INSTANCE_METHOD_NAME_ITERATE_CONDITION = "HistoryInstance.iterate condition";
|
|
@@ -455,71 +360,31 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
455
360
|
this.callbacks = callbacks;
|
|
456
361
|
this._array = [];
|
|
457
362
|
/**
|
|
458
|
-
*
|
|
363
|
+
* Makes the singleshot for initialization
|
|
459
364
|
* @param agentName - The agent name.
|
|
460
365
|
*/
|
|
461
|
-
this
|
|
462
|
-
var
|
|
463
|
-
return __generator(this, function (
|
|
464
|
-
switch (
|
|
366
|
+
this[_a$1] = functoolsKit.singleshot(function (agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
367
|
+
var _b;
|
|
368
|
+
return __generator(this, function (_c) {
|
|
369
|
+
switch (_c.label) {
|
|
465
370
|
case 0:
|
|
466
371
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
467
|
-
swarm.loggerService.debug(INSTANCE_METHOD_NAME_WAIT_FOR_INIT, {
|
|
372
|
+
swarm$1.loggerService.debug(INSTANCE_METHOD_NAME_WAIT_FOR_INIT, {
|
|
468
373
|
clientId: this.clientId,
|
|
469
374
|
agentName: agentName,
|
|
470
375
|
});
|
|
471
376
|
if (!this.callbacks.getData) return [3 /*break*/, 2];
|
|
472
|
-
|
|
377
|
+
_b = this;
|
|
473
378
|
return [4 /*yield*/, this.callbacks.getData(this.clientId, agentName)];
|
|
474
379
|
case 1:
|
|
475
|
-
|
|
476
|
-
|
|
380
|
+
_b._array = _c.sent();
|
|
381
|
+
_c.label = 2;
|
|
477
382
|
case 2: return [2 /*return*/];
|
|
478
383
|
}
|
|
479
384
|
});
|
|
480
385
|
}); });
|
|
481
|
-
/**
|
|
482
|
-
* Push a new message to the history for a given agent.
|
|
483
|
-
* @param value - The model message to push.
|
|
484
|
-
* @param agentName - The agent name.
|
|
485
|
-
* @returns A promise that resolves when the message is pushed.
|
|
486
|
-
*/
|
|
487
|
-
this.push = function (value, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
488
|
-
return __generator(this, function (_a) {
|
|
489
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
490
|
-
swarm.loggerService.debug(INSTANCE_METHOD_NAME_PUSH, {
|
|
491
|
-
clientId: this.clientId,
|
|
492
|
-
agentName: agentName,
|
|
493
|
-
});
|
|
494
|
-
this.callbacks.onPush &&
|
|
495
|
-
this.callbacks.onPush(value, this.clientId, agentName);
|
|
496
|
-
this._array.push(value);
|
|
497
|
-
this.callbacks.onChange &&
|
|
498
|
-
this.callbacks.onChange(this._array, this.clientId, agentName);
|
|
499
|
-
return [2 /*return*/, Promise.resolve()];
|
|
500
|
-
});
|
|
501
|
-
}); };
|
|
502
|
-
/**
|
|
503
|
-
* Dispose of the history for a given agent.
|
|
504
|
-
* @param agentName - The agent name or null.
|
|
505
|
-
* @returns A promise that resolves when the history is disposed.
|
|
506
|
-
*/
|
|
507
|
-
this.dispose = function (agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
508
|
-
return __generator(this, function (_a) {
|
|
509
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
510
|
-
swarm.loggerService.debug(INSTANCE_METHOD_NAME_DISPOSE, {
|
|
511
|
-
clientId: this.clientId,
|
|
512
|
-
agentName: agentName,
|
|
513
|
-
});
|
|
514
|
-
if (agentName === null) {
|
|
515
|
-
this.callbacks.onDispose && this.callbacks.onDispose(this.clientId);
|
|
516
|
-
this._array = [];
|
|
517
|
-
}
|
|
518
|
-
return [2 /*return*/, Promise.resolve()];
|
|
519
|
-
});
|
|
520
|
-
}); };
|
|
521
386
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
522
|
-
swarm.loggerService.debug(INSTANCE_METHOD_NAME_CTOR, {
|
|
387
|
+
swarm$1.loggerService.debug(INSTANCE_METHOD_NAME_CTOR, {
|
|
523
388
|
clientId: this.clientId,
|
|
524
389
|
});
|
|
525
390
|
if (callbacks.onInit) {
|
|
@@ -531,47 +396,47 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
531
396
|
if (callbacks.filterCondition) {
|
|
532
397
|
this.iterate = function (agentName) {
|
|
533
398
|
return __asyncGenerator(this, arguments, function () {
|
|
534
|
-
var
|
|
535
|
-
var e_1,
|
|
536
|
-
return __generator(this, function (
|
|
537
|
-
switch (
|
|
399
|
+
var _b, _c, item, e_1_1, _d, _e, item, e_2_1;
|
|
400
|
+
var e_1, _f, e_2, _g;
|
|
401
|
+
return __generator(this, function (_h) {
|
|
402
|
+
switch (_h.label) {
|
|
538
403
|
case 0:
|
|
539
404
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
540
|
-
swarm.loggerService.debug(INSTANCE_METHOD_NAME_ITERATE_CONDITION, {
|
|
405
|
+
swarm$1.loggerService.debug(INSTANCE_METHOD_NAME_ITERATE_CONDITION, {
|
|
541
406
|
clientId: this.clientId,
|
|
542
407
|
agentName: agentName,
|
|
543
408
|
});
|
|
544
409
|
if (!this.callbacks.onRead) return [3 /*break*/, 12];
|
|
545
410
|
this.callbacks.onReadBegin &&
|
|
546
411
|
this.callbacks.onReadBegin(this.clientId, agentName);
|
|
547
|
-
|
|
412
|
+
_h.label = 1;
|
|
548
413
|
case 1:
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
414
|
+
_h.trys.push([1, 8, 9, 10]);
|
|
415
|
+
_b = __values(this._array), _c = _b.next();
|
|
416
|
+
_h.label = 2;
|
|
552
417
|
case 2:
|
|
553
|
-
if (!!
|
|
554
|
-
item =
|
|
418
|
+
if (!!_c.done) return [3 /*break*/, 7];
|
|
419
|
+
item = _c.value;
|
|
555
420
|
return [4 /*yield*/, __await(this.callbacks.filterCondition(item, this.clientId, agentName))];
|
|
556
421
|
case 3:
|
|
557
|
-
if (!
|
|
422
|
+
if (!_h.sent()) return [3 /*break*/, 6];
|
|
558
423
|
this.callbacks.onRead(item, this.clientId, agentName);
|
|
559
424
|
return [4 /*yield*/, __await(item)];
|
|
560
|
-
case 4: return [4 /*yield*/,
|
|
425
|
+
case 4: return [4 /*yield*/, _h.sent()];
|
|
561
426
|
case 5:
|
|
562
|
-
|
|
563
|
-
|
|
427
|
+
_h.sent();
|
|
428
|
+
_h.label = 6;
|
|
564
429
|
case 6:
|
|
565
|
-
|
|
430
|
+
_c = _b.next();
|
|
566
431
|
return [3 /*break*/, 2];
|
|
567
432
|
case 7: return [3 /*break*/, 10];
|
|
568
433
|
case 8:
|
|
569
|
-
e_1_1 =
|
|
434
|
+
e_1_1 = _h.sent();
|
|
570
435
|
e_1 = { error: e_1_1 };
|
|
571
436
|
return [3 /*break*/, 10];
|
|
572
437
|
case 9:
|
|
573
438
|
try {
|
|
574
|
-
if (
|
|
439
|
+
if (_c && !_c.done && (_f = _b.return)) _f.call(_b);
|
|
575
440
|
}
|
|
576
441
|
finally { if (e_1) throw e_1.error; }
|
|
577
442
|
return [7 /*endfinally*/];
|
|
@@ -579,37 +444,37 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
579
444
|
this.callbacks.onReadEnd &&
|
|
580
445
|
this.callbacks.onReadEnd(this.clientId, agentName);
|
|
581
446
|
return [4 /*yield*/, __await(void 0)];
|
|
582
|
-
case 11: return [2 /*return*/,
|
|
447
|
+
case 11: return [2 /*return*/, _h.sent()];
|
|
583
448
|
case 12:
|
|
584
449
|
this.callbacks.onReadBegin &&
|
|
585
450
|
this.callbacks.onReadBegin(this.clientId, agentName);
|
|
586
|
-
|
|
451
|
+
_h.label = 13;
|
|
587
452
|
case 13:
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
453
|
+
_h.trys.push([13, 20, 21, 22]);
|
|
454
|
+
_d = __values(this._array), _e = _d.next();
|
|
455
|
+
_h.label = 14;
|
|
591
456
|
case 14:
|
|
592
|
-
if (!!
|
|
593
|
-
item =
|
|
457
|
+
if (!!_e.done) return [3 /*break*/, 19];
|
|
458
|
+
item = _e.value;
|
|
594
459
|
return [4 /*yield*/, __await(this.callbacks.filterCondition(item, this.clientId, agentName))];
|
|
595
460
|
case 15:
|
|
596
|
-
if (!
|
|
461
|
+
if (!_h.sent()) return [3 /*break*/, 18];
|
|
597
462
|
return [4 /*yield*/, __await(item)];
|
|
598
|
-
case 16: return [4 /*yield*/,
|
|
463
|
+
case 16: return [4 /*yield*/, _h.sent()];
|
|
599
464
|
case 17:
|
|
600
|
-
|
|
601
|
-
|
|
465
|
+
_h.sent();
|
|
466
|
+
_h.label = 18;
|
|
602
467
|
case 18:
|
|
603
|
-
|
|
468
|
+
_e = _d.next();
|
|
604
469
|
return [3 /*break*/, 14];
|
|
605
470
|
case 19: return [3 /*break*/, 22];
|
|
606
471
|
case 20:
|
|
607
|
-
e_2_1 =
|
|
472
|
+
e_2_1 = _h.sent();
|
|
608
473
|
e_2 = { error: e_2_1 };
|
|
609
474
|
return [3 /*break*/, 22];
|
|
610
475
|
case 21:
|
|
611
476
|
try {
|
|
612
|
-
if (
|
|
477
|
+
if (_e && !_e.done && (_g = _d.return)) _g.call(_d);
|
|
613
478
|
}
|
|
614
479
|
finally { if (e_2) throw e_2.error; }
|
|
615
480
|
return [7 /*endfinally*/];
|
|
@@ -623,6 +488,20 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
623
488
|
};
|
|
624
489
|
}
|
|
625
490
|
}
|
|
491
|
+
/**
|
|
492
|
+
* Wait for the history to initialize.
|
|
493
|
+
* @param agentName - The agent name.
|
|
494
|
+
*/
|
|
495
|
+
HistoryInstance.prototype.waitForInit = function (agentName) {
|
|
496
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
497
|
+
return __generator(this, function (_b) {
|
|
498
|
+
switch (_b.label) {
|
|
499
|
+
case 0: return [4 /*yield*/, this[HISTORY_INSTANCE_WAIT_FOR_INIT](agentName)];
|
|
500
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
});
|
|
504
|
+
};
|
|
626
505
|
/**
|
|
627
506
|
* Iterate over the history messages for a given agent.
|
|
628
507
|
* @param agentName - The agent name.
|
|
@@ -630,44 +509,44 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
630
509
|
*/
|
|
631
510
|
HistoryInstance.prototype.iterate = function (agentName) {
|
|
632
511
|
return __asyncGenerator(this, arguments, function iterate_1() {
|
|
633
|
-
var
|
|
634
|
-
var e_3,
|
|
635
|
-
return __generator(this, function (
|
|
636
|
-
switch (
|
|
512
|
+
var _b, _c, item, e_3_1, _d, _e, item, e_4_1;
|
|
513
|
+
var e_3, _f, e_4, _g;
|
|
514
|
+
return __generator(this, function (_h) {
|
|
515
|
+
switch (_h.label) {
|
|
637
516
|
case 0:
|
|
638
517
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
639
|
-
swarm.loggerService.debug(INSTANCE_METHOD_NAME_ITERATE, {
|
|
518
|
+
swarm$1.loggerService.debug(INSTANCE_METHOD_NAME_ITERATE, {
|
|
640
519
|
clientId: this.clientId,
|
|
641
520
|
agentName: agentName,
|
|
642
521
|
});
|
|
643
522
|
if (!this.callbacks.onRead) return [3 /*break*/, 11];
|
|
644
523
|
this.callbacks.onReadBegin &&
|
|
645
524
|
this.callbacks.onReadBegin(this.clientId, agentName);
|
|
646
|
-
|
|
525
|
+
_h.label = 1;
|
|
647
526
|
case 1:
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
527
|
+
_h.trys.push([1, 7, 8, 9]);
|
|
528
|
+
_b = __values(this._array), _c = _b.next();
|
|
529
|
+
_h.label = 2;
|
|
651
530
|
case 2:
|
|
652
|
-
if (!!
|
|
653
|
-
item =
|
|
531
|
+
if (!!_c.done) return [3 /*break*/, 6];
|
|
532
|
+
item = _c.value;
|
|
654
533
|
this.callbacks.onRead(item, this.clientId, agentName);
|
|
655
534
|
return [4 /*yield*/, __await(item)];
|
|
656
|
-
case 3: return [4 /*yield*/,
|
|
535
|
+
case 3: return [4 /*yield*/, _h.sent()];
|
|
657
536
|
case 4:
|
|
658
|
-
|
|
659
|
-
|
|
537
|
+
_h.sent();
|
|
538
|
+
_h.label = 5;
|
|
660
539
|
case 5:
|
|
661
|
-
|
|
540
|
+
_c = _b.next();
|
|
662
541
|
return [3 /*break*/, 2];
|
|
663
542
|
case 6: return [3 /*break*/, 9];
|
|
664
543
|
case 7:
|
|
665
|
-
e_3_1 =
|
|
544
|
+
e_3_1 = _h.sent();
|
|
666
545
|
e_3 = { error: e_3_1 };
|
|
667
546
|
return [3 /*break*/, 9];
|
|
668
547
|
case 8:
|
|
669
548
|
try {
|
|
670
|
-
if (
|
|
549
|
+
if (_c && !_c.done && (_f = _b.return)) _f.call(_b);
|
|
671
550
|
}
|
|
672
551
|
finally { if (e_3) throw e_3.error; }
|
|
673
552
|
return [7 /*endfinally*/];
|
|
@@ -675,34 +554,34 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
675
554
|
this.callbacks.onReadEnd &&
|
|
676
555
|
this.callbacks.onReadEnd(this.clientId, agentName);
|
|
677
556
|
return [4 /*yield*/, __await(void 0)];
|
|
678
|
-
case 10: return [2 /*return*/,
|
|
557
|
+
case 10: return [2 /*return*/, _h.sent()];
|
|
679
558
|
case 11:
|
|
680
559
|
this.callbacks.onReadBegin &&
|
|
681
560
|
this.callbacks.onReadBegin(this.clientId, agentName);
|
|
682
|
-
|
|
561
|
+
_h.label = 12;
|
|
683
562
|
case 12:
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
563
|
+
_h.trys.push([12, 18, 19, 20]);
|
|
564
|
+
_d = __values(this._array), _e = _d.next();
|
|
565
|
+
_h.label = 13;
|
|
687
566
|
case 13:
|
|
688
|
-
if (!!
|
|
689
|
-
item =
|
|
567
|
+
if (!!_e.done) return [3 /*break*/, 17];
|
|
568
|
+
item = _e.value;
|
|
690
569
|
return [4 /*yield*/, __await(item)];
|
|
691
|
-
case 14: return [4 /*yield*/,
|
|
570
|
+
case 14: return [4 /*yield*/, _h.sent()];
|
|
692
571
|
case 15:
|
|
693
|
-
|
|
694
|
-
|
|
572
|
+
_h.sent();
|
|
573
|
+
_h.label = 16;
|
|
695
574
|
case 16:
|
|
696
|
-
|
|
575
|
+
_e = _d.next();
|
|
697
576
|
return [3 /*break*/, 13];
|
|
698
577
|
case 17: return [3 /*break*/, 20];
|
|
699
578
|
case 18:
|
|
700
|
-
e_4_1 =
|
|
579
|
+
e_4_1 = _h.sent();
|
|
701
580
|
e_4 = { error: e_4_1 };
|
|
702
581
|
return [3 /*break*/, 20];
|
|
703
582
|
case 19:
|
|
704
583
|
try {
|
|
705
|
-
if (
|
|
584
|
+
if (_e && !_e.done && (_g = _d.return)) _g.call(_d);
|
|
706
585
|
}
|
|
707
586
|
finally { if (e_4) throw e_4.error; }
|
|
708
587
|
return [7 /*endfinally*/];
|
|
@@ -714,8 +593,45 @@ var HistoryInstance = /** @class */ (function () {
|
|
|
714
593
|
});
|
|
715
594
|
});
|
|
716
595
|
};
|
|
596
|
+
/**
|
|
597
|
+
* Push a new message to the history for a given agent.
|
|
598
|
+
* @param value - The model message to push.
|
|
599
|
+
* @param agentName - The agent name.
|
|
600
|
+
* @returns A promise that resolves when the message is pushed.
|
|
601
|
+
*/
|
|
602
|
+
HistoryInstance.prototype.push = function (value, agentName) {
|
|
603
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
604
|
+
swarm$1.loggerService.debug(INSTANCE_METHOD_NAME_PUSH, {
|
|
605
|
+
clientId: this.clientId,
|
|
606
|
+
agentName: agentName,
|
|
607
|
+
});
|
|
608
|
+
this.callbacks.onPush &&
|
|
609
|
+
this.callbacks.onPush(value, this.clientId, agentName);
|
|
610
|
+
this._array.push(value);
|
|
611
|
+
this.callbacks.onChange &&
|
|
612
|
+
this.callbacks.onChange(this._array, this.clientId, agentName);
|
|
613
|
+
return Promise.resolve();
|
|
614
|
+
};
|
|
615
|
+
/**
|
|
616
|
+
* Dispose of the history for a given agent.
|
|
617
|
+
* @param agentName - The agent name or null.
|
|
618
|
+
* @returns A promise that resolves when the history is disposed.
|
|
619
|
+
*/
|
|
620
|
+
HistoryInstance.prototype.dispose = function (agentName) {
|
|
621
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
622
|
+
swarm$1.loggerService.debug(INSTANCE_METHOD_NAME_DISPOSE, {
|
|
623
|
+
clientId: this.clientId,
|
|
624
|
+
agentName: agentName,
|
|
625
|
+
});
|
|
626
|
+
if (agentName === null) {
|
|
627
|
+
this.callbacks.onDispose && this.callbacks.onDispose(this.clientId);
|
|
628
|
+
this._array = [];
|
|
629
|
+
}
|
|
630
|
+
return Promise.resolve();
|
|
631
|
+
};
|
|
717
632
|
return HistoryInstance;
|
|
718
633
|
}());
|
|
634
|
+
_a$1 = HISTORY_INSTANCE_WAIT_FOR_INIT;
|
|
719
635
|
/**
|
|
720
636
|
* Class representing History Utilities
|
|
721
637
|
*/
|
|
@@ -724,8 +640,8 @@ var HistoryUtils = /** @class */ (function () {
|
|
|
724
640
|
var _this = this;
|
|
725
641
|
this.HistoryFactory = HistoryInstance;
|
|
726
642
|
this.HistoryCallbacks = {};
|
|
727
|
-
this.getHistory = functoolsKit.memoize(function (
|
|
728
|
-
var
|
|
643
|
+
this.getHistory = functoolsKit.memoize(function (_b) {
|
|
644
|
+
var _c = __read(_b, 1), clientId = _c[0];
|
|
729
645
|
return clientId;
|
|
730
646
|
}, function (clientId) {
|
|
731
647
|
return new _this.HistoryFactory(clientId, _this.HistoryCallbacks);
|
|
@@ -736,7 +652,7 @@ var HistoryUtils = /** @class */ (function () {
|
|
|
736
652
|
*/
|
|
737
653
|
this.useHistoryAdapter = function (Ctor) {
|
|
738
654
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
739
|
-
swarm.loggerService.log(METHOD_NAME_USE_HISTORY_ADAPTER);
|
|
655
|
+
swarm$1.loggerService.log(METHOD_NAME_USE_HISTORY_ADAPTER);
|
|
740
656
|
_this.HistoryFactory = Ctor;
|
|
741
657
|
};
|
|
742
658
|
/**
|
|
@@ -745,7 +661,7 @@ var HistoryUtils = /** @class */ (function () {
|
|
|
745
661
|
*/
|
|
746
662
|
this.useHistoryCallbacks = function (Callbacks) {
|
|
747
663
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
748
|
-
swarm.loggerService.log(METHOD_NAME_USE_HISTORY_CALLBACKS);
|
|
664
|
+
swarm$1.loggerService.log(METHOD_NAME_USE_HISTORY_CALLBACKS);
|
|
749
665
|
Object.assign(_this.HistoryCallbacks, Callbacks);
|
|
750
666
|
};
|
|
751
667
|
/**
|
|
@@ -757,11 +673,11 @@ var HistoryUtils = /** @class */ (function () {
|
|
|
757
673
|
*/
|
|
758
674
|
this.push = function (value, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
759
675
|
var isInitial, history;
|
|
760
|
-
return __generator(this, function (
|
|
761
|
-
switch (
|
|
676
|
+
return __generator(this, function (_b) {
|
|
677
|
+
switch (_b.label) {
|
|
762
678
|
case 0:
|
|
763
679
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
764
|
-
swarm.loggerService.log(METHOD_NAME_PUSH, {
|
|
680
|
+
swarm$1.loggerService.log(METHOD_NAME_PUSH, {
|
|
765
681
|
clientId: clientId,
|
|
766
682
|
agentName: agentName,
|
|
767
683
|
value: value,
|
|
@@ -769,12 +685,12 @@ var HistoryUtils = /** @class */ (function () {
|
|
|
769
685
|
isInitial = this.getHistory.has(clientId);
|
|
770
686
|
return [4 /*yield*/, this.getHistory(clientId)];
|
|
771
687
|
case 1:
|
|
772
|
-
history =
|
|
688
|
+
history = _b.sent();
|
|
773
689
|
return [4 /*yield*/, history.waitForInit(agentName, isInitial)];
|
|
774
690
|
case 2:
|
|
775
|
-
|
|
691
|
+
_b.sent();
|
|
776
692
|
return [4 /*yield*/, history.push(value, agentName)];
|
|
777
|
-
case 3: return [2 /*return*/,
|
|
693
|
+
case 3: return [2 /*return*/, _b.sent()];
|
|
778
694
|
}
|
|
779
695
|
});
|
|
780
696
|
}); };
|
|
@@ -785,25 +701,27 @@ var HistoryUtils = /** @class */ (function () {
|
|
|
785
701
|
* @returns A promise that resolves when the history is disposed.
|
|
786
702
|
*/
|
|
787
703
|
this.dispose = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
788
|
-
var
|
|
789
|
-
return __generator(this, function (
|
|
790
|
-
switch (
|
|
704
|
+
var history;
|
|
705
|
+
return __generator(this, function (_b) {
|
|
706
|
+
switch (_b.label) {
|
|
791
707
|
case 0:
|
|
792
708
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
793
|
-
swarm.loggerService.log(METHOD_NAME_DISPOSE, {
|
|
709
|
+
swarm$1.loggerService.log(METHOD_NAME_DISPOSE, {
|
|
794
710
|
clientId: clientId,
|
|
795
711
|
agentName: agentName,
|
|
796
712
|
});
|
|
797
|
-
|
|
713
|
+
if (!this.getHistory.has(clientId)) {
|
|
714
|
+
return [2 /*return*/];
|
|
715
|
+
}
|
|
798
716
|
return [4 /*yield*/, this.getHistory(clientId)];
|
|
799
717
|
case 1:
|
|
800
|
-
history =
|
|
801
|
-
return [4 /*yield*/, history.waitForInit(agentName,
|
|
718
|
+
history = _b.sent();
|
|
719
|
+
return [4 /*yield*/, history.waitForInit(agentName, false)];
|
|
802
720
|
case 2:
|
|
803
|
-
|
|
721
|
+
_b.sent();
|
|
804
722
|
return [4 /*yield*/, history.dispose(agentName)];
|
|
805
723
|
case 3:
|
|
806
|
-
|
|
724
|
+
_b.sent();
|
|
807
725
|
if (agentName === null) {
|
|
808
726
|
this.getHistory.clear(clientId);
|
|
809
727
|
}
|
|
@@ -820,54 +738,54 @@ var HistoryUtils = /** @class */ (function () {
|
|
|
820
738
|
*/
|
|
821
739
|
HistoryUtils.prototype.iterate = function (clientId, agentName) {
|
|
822
740
|
return __asyncGenerator(this, arguments, function iterate_2() {
|
|
823
|
-
var isInitial, history,
|
|
824
|
-
var
|
|
825
|
-
return __generator(this, function (
|
|
826
|
-
switch (
|
|
741
|
+
var isInitial, history, _b, _c, _d, item, e_5_1;
|
|
742
|
+
var _e, e_5, _f, _g;
|
|
743
|
+
return __generator(this, function (_h) {
|
|
744
|
+
switch (_h.label) {
|
|
827
745
|
case 0:
|
|
828
746
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
829
|
-
swarm.loggerService.log(METHOD_NAME_ITERATE, {
|
|
747
|
+
swarm$1.loggerService.log(METHOD_NAME_ITERATE, {
|
|
830
748
|
clientId: clientId,
|
|
831
749
|
agentName: agentName,
|
|
832
750
|
});
|
|
833
751
|
isInitial = this.getHistory.has(clientId);
|
|
834
752
|
return [4 /*yield*/, __await(this.getHistory(clientId))];
|
|
835
753
|
case 1:
|
|
836
|
-
history =
|
|
754
|
+
history = _h.sent();
|
|
837
755
|
return [4 /*yield*/, __await(history.waitForInit(agentName, isInitial))];
|
|
838
756
|
case 2:
|
|
839
|
-
|
|
840
|
-
|
|
757
|
+
_h.sent();
|
|
758
|
+
_h.label = 3;
|
|
841
759
|
case 3:
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
case 4: return [4 /*yield*/, __await(
|
|
760
|
+
_h.trys.push([3, 10, 11, 16]);
|
|
761
|
+
_b = true, _c = __asyncValues(history.iterate(agentName));
|
|
762
|
+
_h.label = 4;
|
|
763
|
+
case 4: return [4 /*yield*/, __await(_c.next())];
|
|
846
764
|
case 5:
|
|
847
|
-
if (!(
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
item =
|
|
765
|
+
if (!(_d = _h.sent(), _e = _d.done, !_e)) return [3 /*break*/, 9];
|
|
766
|
+
_g = _d.value;
|
|
767
|
+
_b = false;
|
|
768
|
+
item = _g;
|
|
851
769
|
return [4 /*yield*/, __await(item)];
|
|
852
|
-
case 6: return [4 /*yield*/,
|
|
770
|
+
case 6: return [4 /*yield*/, _h.sent()];
|
|
853
771
|
case 7:
|
|
854
|
-
|
|
855
|
-
|
|
772
|
+
_h.sent();
|
|
773
|
+
_h.label = 8;
|
|
856
774
|
case 8:
|
|
857
|
-
|
|
775
|
+
_b = true;
|
|
858
776
|
return [3 /*break*/, 4];
|
|
859
777
|
case 9: return [3 /*break*/, 16];
|
|
860
778
|
case 10:
|
|
861
|
-
e_5_1 =
|
|
779
|
+
e_5_1 = _h.sent();
|
|
862
780
|
e_5 = { error: e_5_1 };
|
|
863
781
|
return [3 /*break*/, 16];
|
|
864
782
|
case 11:
|
|
865
|
-
|
|
866
|
-
if (!(!
|
|
867
|
-
return [4 /*yield*/, __await(
|
|
783
|
+
_h.trys.push([11, , 14, 15]);
|
|
784
|
+
if (!(!_b && !_e && (_f = _c.return))) return [3 /*break*/, 13];
|
|
785
|
+
return [4 /*yield*/, __await(_f.call(_c))];
|
|
868
786
|
case 12:
|
|
869
|
-
|
|
870
|
-
|
|
787
|
+
_h.sent();
|
|
788
|
+
_h.label = 13;
|
|
871
789
|
case 13: return [3 /*break*/, 15];
|
|
872
790
|
case 14:
|
|
873
791
|
if (e_5) throw e_5.error;
|
|
@@ -908,6 +826,441 @@ var nameToTitle = function (name) {
|
|
|
908
826
|
return __spreadArray(["".concat(word.charAt(0).toUpperCase()).concat(word.slice(1))], __read(rest), false).join(' ');
|
|
909
827
|
};
|
|
910
828
|
|
|
829
|
+
var _a;
|
|
830
|
+
var LOGGER_INSTANCE_WAIT_FOR_INIT = Symbol("wait-for-init");
|
|
831
|
+
/**
|
|
832
|
+
* @class LoggerInstance
|
|
833
|
+
* @implements ILoggerInstance
|
|
834
|
+
* @description Logger instance class.
|
|
835
|
+
*/
|
|
836
|
+
var LoggerInstance = /** @class */ (function () {
|
|
837
|
+
function LoggerInstance(clientId, callbacks) {
|
|
838
|
+
var _this = this;
|
|
839
|
+
this.clientId = clientId;
|
|
840
|
+
this.callbacks = callbacks;
|
|
841
|
+
this[_a] = functoolsKit.singleshot(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
842
|
+
return __generator(this, function (_b) {
|
|
843
|
+
if (this.callbacks.onInit) {
|
|
844
|
+
this.callbacks.onInit(this.clientId);
|
|
845
|
+
}
|
|
846
|
+
return [2 /*return*/];
|
|
847
|
+
});
|
|
848
|
+
}); });
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* @method waitForInit
|
|
852
|
+
* @description Waits for initialization.
|
|
853
|
+
* @returns {Promise<void>}
|
|
854
|
+
*/
|
|
855
|
+
LoggerInstance.prototype.waitForInit = function () {
|
|
856
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
857
|
+
return __generator(this, function (_b) {
|
|
858
|
+
switch (_b.label) {
|
|
859
|
+
case 0: return [4 /*yield*/, this[LOGGER_INSTANCE_WAIT_FOR_INIT]()];
|
|
860
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
861
|
+
}
|
|
862
|
+
});
|
|
863
|
+
});
|
|
864
|
+
};
|
|
865
|
+
/**
|
|
866
|
+
* @method log
|
|
867
|
+
* @description Logs a message.
|
|
868
|
+
* @param {string} topic - The topic of the log.
|
|
869
|
+
* @param {...any[]} args - The log arguments.
|
|
870
|
+
*/
|
|
871
|
+
LoggerInstance.prototype.log = function (topic) {
|
|
872
|
+
var _b;
|
|
873
|
+
var args = [];
|
|
874
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
875
|
+
args[_i - 1] = arguments[_i];
|
|
876
|
+
}
|
|
877
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_CONSOLE && console.log.apply(console, __spreadArray(["[clientId=".concat(this.clientId, "]"), topic], __read(args), false));
|
|
878
|
+
if (this.callbacks.onLog) {
|
|
879
|
+
(_b = this.callbacks).onLog.apply(_b, __spreadArray([this.clientId, topic], __read(args), false));
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
/**
|
|
883
|
+
* @method debug
|
|
884
|
+
* @description Logs a debug message.
|
|
885
|
+
* @param {string} topic - The topic of the debug log.
|
|
886
|
+
* @param {...any[]} args - The debug log arguments.
|
|
887
|
+
*/
|
|
888
|
+
LoggerInstance.prototype.debug = function (topic) {
|
|
889
|
+
var _b;
|
|
890
|
+
var args = [];
|
|
891
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
892
|
+
args[_i - 1] = arguments[_i];
|
|
893
|
+
}
|
|
894
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_CONSOLE && console.debug.apply(console, __spreadArray(["[clientId=".concat(this.clientId, "]"), topic], __read(args), false));
|
|
895
|
+
if (this.callbacks.onDebug) {
|
|
896
|
+
(_b = this.callbacks).onDebug.apply(_b, __spreadArray([this.clientId, topic], __read(args), false));
|
|
897
|
+
}
|
|
898
|
+
};
|
|
899
|
+
/**
|
|
900
|
+
* @method info
|
|
901
|
+
* @description Logs an info message.
|
|
902
|
+
* @param {string} topic - The topic of the info log.
|
|
903
|
+
* @param {...any[]} args - The info log arguments.
|
|
904
|
+
*/
|
|
905
|
+
LoggerInstance.prototype.info = function (topic) {
|
|
906
|
+
var _b;
|
|
907
|
+
var args = [];
|
|
908
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
909
|
+
args[_i - 1] = arguments[_i];
|
|
910
|
+
}
|
|
911
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_CONSOLE && console.info.apply(console, __spreadArray(["[clientId=".concat(this.clientId, "]"), topic], __read(args), false));
|
|
912
|
+
if (this.callbacks.onInfo) {
|
|
913
|
+
(_b = this.callbacks).onInfo.apply(_b, __spreadArray([this.clientId, topic], __read(args), false));
|
|
914
|
+
}
|
|
915
|
+
};
|
|
916
|
+
/**
|
|
917
|
+
* @method dispose
|
|
918
|
+
* @description Disposes the logger instance.
|
|
919
|
+
*/
|
|
920
|
+
LoggerInstance.prototype.dispose = function () {
|
|
921
|
+
if (this.callbacks.onDispose) {
|
|
922
|
+
this.callbacks.onDispose(this.clientId);
|
|
923
|
+
}
|
|
924
|
+
};
|
|
925
|
+
return LoggerInstance;
|
|
926
|
+
}());
|
|
927
|
+
_a = LOGGER_INSTANCE_WAIT_FOR_INIT;
|
|
928
|
+
/**
|
|
929
|
+
* @class LoggerUtils
|
|
930
|
+
* @implements ILoggerAdapter, ILoggerControl
|
|
931
|
+
* @description Utility class for logger.
|
|
932
|
+
*/
|
|
933
|
+
var LoggerUtils = /** @class */ (function () {
|
|
934
|
+
function LoggerUtils() {
|
|
935
|
+
var _this = this;
|
|
936
|
+
this.LoggerFactory = LoggerInstance;
|
|
937
|
+
this.LoggerCallbacks = {};
|
|
938
|
+
this.getLogger = functoolsKit.memoize(function (_b) {
|
|
939
|
+
var _c = __read(_b, 1), clientId = _c[0];
|
|
940
|
+
return clientId;
|
|
941
|
+
}, function (clientId) { return new _this.LoggerFactory(clientId, _this.LoggerCallbacks); });
|
|
942
|
+
/**
|
|
943
|
+
* @method useCommonAdapter
|
|
944
|
+
* @description Sets the common logger adapter.
|
|
945
|
+
* @param {ILogger} logger - The logger instance.
|
|
946
|
+
*/
|
|
947
|
+
this.useCommonAdapter = function (logger) {
|
|
948
|
+
swarm$1.loggerService.setLogger(logger);
|
|
949
|
+
};
|
|
950
|
+
/**
|
|
951
|
+
* @method useClientCallbacks
|
|
952
|
+
* @description Sets the client-specific callbacks.
|
|
953
|
+
* @param {Partial<ILoggerInstanceCallbacks>} Callbacks - The callbacks.
|
|
954
|
+
*/
|
|
955
|
+
this.useClientCallbacks = function (Callbacks) {
|
|
956
|
+
Object.assign(_this.LoggerCallbacks, Callbacks);
|
|
957
|
+
};
|
|
958
|
+
/**
|
|
959
|
+
* @method useClientAdapter
|
|
960
|
+
* @description Sets the client-specific logger adapter.
|
|
961
|
+
* @param {TLoggerInstanceCtor} Ctor - The logger instance constructor.
|
|
962
|
+
*/
|
|
963
|
+
this.useClientAdapter = function (Ctor) {
|
|
964
|
+
_this.LoggerFactory = Ctor;
|
|
965
|
+
};
|
|
966
|
+
/**
|
|
967
|
+
* @method logClient
|
|
968
|
+
* @description Logs a message for a specific client.
|
|
969
|
+
* @param {string} clientId - The client ID.
|
|
970
|
+
* @param {string} topic - The topic of the log.
|
|
971
|
+
* @param {...any[]} args - The log arguments.
|
|
972
|
+
* @returns {Promise<void>}
|
|
973
|
+
*/
|
|
974
|
+
this.logClient = function (clientId, topic) {
|
|
975
|
+
var args = [];
|
|
976
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
977
|
+
args[_i - 2] = arguments[_i];
|
|
978
|
+
}
|
|
979
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
980
|
+
var _this = this;
|
|
981
|
+
return __generator(this, function (_b) {
|
|
982
|
+
switch (_b.label) {
|
|
983
|
+
case 0:
|
|
984
|
+
if (!GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG) {
|
|
985
|
+
return [2 /*return*/];
|
|
986
|
+
}
|
|
987
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
988
|
+
return [2 /*return*/];
|
|
989
|
+
}
|
|
990
|
+
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
991
|
+
var _b;
|
|
992
|
+
return __generator(this, function (_c) {
|
|
993
|
+
switch (_c.label) {
|
|
994
|
+
case 0: return [4 /*yield*/, (_b = swarm$1.loggerService).log.apply(_b, __spreadArray([topic], __read(args), false))];
|
|
995
|
+
case 1:
|
|
996
|
+
_c.sent();
|
|
997
|
+
return [2 /*return*/];
|
|
998
|
+
}
|
|
999
|
+
});
|
|
1000
|
+
}); }, {
|
|
1001
|
+
clientId: clientId,
|
|
1002
|
+
agentName: "",
|
|
1003
|
+
methodName: "LoggerUtils.logClient",
|
|
1004
|
+
stateName: "",
|
|
1005
|
+
storageName: "",
|
|
1006
|
+
swarmName: "",
|
|
1007
|
+
})];
|
|
1008
|
+
case 1:
|
|
1009
|
+
_b.sent();
|
|
1010
|
+
return [2 /*return*/];
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1013
|
+
});
|
|
1014
|
+
};
|
|
1015
|
+
/**
|
|
1016
|
+
* @method infoClient
|
|
1017
|
+
* @description Logs an info message for a specific client.
|
|
1018
|
+
* @param {string} clientId - The client ID.
|
|
1019
|
+
* @param {string} topic - The topic of the info log.
|
|
1020
|
+
* @param {...any[]} args - The info log arguments.
|
|
1021
|
+
* @returns {Promise<void>}
|
|
1022
|
+
*/
|
|
1023
|
+
this.infoClient = function (clientId, topic) {
|
|
1024
|
+
var args = [];
|
|
1025
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1026
|
+
args[_i - 2] = arguments[_i];
|
|
1027
|
+
}
|
|
1028
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
1029
|
+
var _this = this;
|
|
1030
|
+
return __generator(this, function (_b) {
|
|
1031
|
+
switch (_b.label) {
|
|
1032
|
+
case 0:
|
|
1033
|
+
if (!GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO) {
|
|
1034
|
+
return [2 /*return*/];
|
|
1035
|
+
}
|
|
1036
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
1037
|
+
return [2 /*return*/];
|
|
1038
|
+
}
|
|
1039
|
+
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1040
|
+
var _b;
|
|
1041
|
+
return __generator(this, function (_c) {
|
|
1042
|
+
switch (_c.label) {
|
|
1043
|
+
case 0: return [4 /*yield*/, (_b = swarm$1.loggerService).info.apply(_b, __spreadArray([topic], __read(args), false))];
|
|
1044
|
+
case 1:
|
|
1045
|
+
_c.sent();
|
|
1046
|
+
return [2 /*return*/];
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
}); }, {
|
|
1050
|
+
clientId: clientId,
|
|
1051
|
+
agentName: "",
|
|
1052
|
+
methodName: "LoggerUtils.infoClient",
|
|
1053
|
+
stateName: "",
|
|
1054
|
+
storageName: "",
|
|
1055
|
+
swarmName: "",
|
|
1056
|
+
})];
|
|
1057
|
+
case 1:
|
|
1058
|
+
_b.sent();
|
|
1059
|
+
return [2 /*return*/];
|
|
1060
|
+
}
|
|
1061
|
+
});
|
|
1062
|
+
});
|
|
1063
|
+
};
|
|
1064
|
+
/**
|
|
1065
|
+
* @method debugClient
|
|
1066
|
+
* @description Logs a debug message for a specific client.
|
|
1067
|
+
* @param {string} clientId - The client ID.
|
|
1068
|
+
* @param {string} topic - The topic of the debug log.
|
|
1069
|
+
* @param {...any[]} args - The debug log arguments.
|
|
1070
|
+
* @returns {Promise<void>}
|
|
1071
|
+
*/
|
|
1072
|
+
this.debugClient = function (clientId, topic) {
|
|
1073
|
+
var args = [];
|
|
1074
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1075
|
+
args[_i - 2] = arguments[_i];
|
|
1076
|
+
}
|
|
1077
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
1078
|
+
var _this = this;
|
|
1079
|
+
return __generator(this, function (_b) {
|
|
1080
|
+
switch (_b.label) {
|
|
1081
|
+
case 0:
|
|
1082
|
+
if (!GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG) {
|
|
1083
|
+
return [2 /*return*/];
|
|
1084
|
+
}
|
|
1085
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
1086
|
+
return [2 /*return*/];
|
|
1087
|
+
}
|
|
1088
|
+
return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1089
|
+
var _b;
|
|
1090
|
+
return __generator(this, function (_c) {
|
|
1091
|
+
switch (_c.label) {
|
|
1092
|
+
case 0: return [4 /*yield*/, (_b = swarm$1.loggerService).debug.apply(_b, __spreadArray([topic], __read(args), false))];
|
|
1093
|
+
case 1:
|
|
1094
|
+
_c.sent();
|
|
1095
|
+
return [2 /*return*/];
|
|
1096
|
+
}
|
|
1097
|
+
});
|
|
1098
|
+
}); }, {
|
|
1099
|
+
clientId: clientId,
|
|
1100
|
+
agentName: "",
|
|
1101
|
+
methodName: "LoggerUtils.debugClient",
|
|
1102
|
+
stateName: "",
|
|
1103
|
+
storageName: "",
|
|
1104
|
+
swarmName: "",
|
|
1105
|
+
})];
|
|
1106
|
+
case 1:
|
|
1107
|
+
_b.sent();
|
|
1108
|
+
return [2 /*return*/];
|
|
1109
|
+
}
|
|
1110
|
+
});
|
|
1111
|
+
});
|
|
1112
|
+
};
|
|
1113
|
+
/**
|
|
1114
|
+
* @method log
|
|
1115
|
+
* @description Logs a message.
|
|
1116
|
+
* @param {string} clientId - The client ID.
|
|
1117
|
+
* @param {string} topic - The topic of the log.
|
|
1118
|
+
* @param {...any[]} args - The log arguments.
|
|
1119
|
+
* @returns {Promise<void>}
|
|
1120
|
+
*/
|
|
1121
|
+
this.log = function (clientId, topic) {
|
|
1122
|
+
var args = [];
|
|
1123
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1124
|
+
args[_i - 2] = arguments[_i];
|
|
1125
|
+
}
|
|
1126
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
1127
|
+
var isInitial, logger;
|
|
1128
|
+
return __generator(this, function (_b) {
|
|
1129
|
+
switch (_b.label) {
|
|
1130
|
+
case 0:
|
|
1131
|
+
if (!GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG) {
|
|
1132
|
+
return [2 /*return*/];
|
|
1133
|
+
}
|
|
1134
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
1135
|
+
return [2 /*return*/];
|
|
1136
|
+
}
|
|
1137
|
+
isInitial = this.getLogger.has(clientId);
|
|
1138
|
+
logger = this.getLogger(clientId);
|
|
1139
|
+
return [4 /*yield*/, logger.waitForInit(isInitial)];
|
|
1140
|
+
case 1:
|
|
1141
|
+
_b.sent();
|
|
1142
|
+
return [4 /*yield*/, logger.log.apply(logger, __spreadArray([topic], __read(args), false))];
|
|
1143
|
+
case 2:
|
|
1144
|
+
_b.sent();
|
|
1145
|
+
return [2 /*return*/];
|
|
1146
|
+
}
|
|
1147
|
+
});
|
|
1148
|
+
});
|
|
1149
|
+
};
|
|
1150
|
+
/**
|
|
1151
|
+
* @method debug
|
|
1152
|
+
* @description Logs a debug message.
|
|
1153
|
+
* @param {string} clientId - The client ID.
|
|
1154
|
+
* @param {string} topic - The topic of the debug log.
|
|
1155
|
+
* @param {...any[]} args - The debug log arguments.
|
|
1156
|
+
* @returns {Promise<void>}
|
|
1157
|
+
*/
|
|
1158
|
+
this.debug = function (clientId, topic) {
|
|
1159
|
+
var args = [];
|
|
1160
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1161
|
+
args[_i - 2] = arguments[_i];
|
|
1162
|
+
}
|
|
1163
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
1164
|
+
var isInitial, logger;
|
|
1165
|
+
return __generator(this, function (_b) {
|
|
1166
|
+
switch (_b.label) {
|
|
1167
|
+
case 0:
|
|
1168
|
+
if (!GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG) {
|
|
1169
|
+
return [2 /*return*/];
|
|
1170
|
+
}
|
|
1171
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
1172
|
+
return [2 /*return*/];
|
|
1173
|
+
}
|
|
1174
|
+
isInitial = this.getLogger.has(clientId);
|
|
1175
|
+
logger = this.getLogger(clientId);
|
|
1176
|
+
return [4 /*yield*/, logger.waitForInit(isInitial)];
|
|
1177
|
+
case 1:
|
|
1178
|
+
_b.sent();
|
|
1179
|
+
return [4 /*yield*/, logger.debug.apply(logger, __spreadArray([topic], __read(args), false))];
|
|
1180
|
+
case 2:
|
|
1181
|
+
_b.sent();
|
|
1182
|
+
return [2 /*return*/];
|
|
1183
|
+
}
|
|
1184
|
+
});
|
|
1185
|
+
});
|
|
1186
|
+
};
|
|
1187
|
+
/**
|
|
1188
|
+
* @method info
|
|
1189
|
+
* @description Logs an info message.
|
|
1190
|
+
* @param {string} clientId - The client ID.
|
|
1191
|
+
* @param {string} topic - The topic of the info log.
|
|
1192
|
+
* @param {...any[]} args - The info log arguments.
|
|
1193
|
+
* @returns {Promise<void>}
|
|
1194
|
+
*/
|
|
1195
|
+
this.info = function (clientId, topic) {
|
|
1196
|
+
var args = [];
|
|
1197
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1198
|
+
args[_i - 2] = arguments[_i];
|
|
1199
|
+
}
|
|
1200
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
1201
|
+
var isInitial, logger;
|
|
1202
|
+
return __generator(this, function (_b) {
|
|
1203
|
+
switch (_b.label) {
|
|
1204
|
+
case 0:
|
|
1205
|
+
if (!GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO) {
|
|
1206
|
+
return [2 /*return*/];
|
|
1207
|
+
}
|
|
1208
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
1209
|
+
return [2 /*return*/];
|
|
1210
|
+
}
|
|
1211
|
+
isInitial = this.getLogger.has(clientId);
|
|
1212
|
+
logger = this.getLogger(clientId);
|
|
1213
|
+
return [4 /*yield*/, logger.waitForInit(isInitial)];
|
|
1214
|
+
case 1:
|
|
1215
|
+
_b.sent();
|
|
1216
|
+
return [4 /*yield*/, logger.info.apply(logger, __spreadArray([topic], __read(args), false))];
|
|
1217
|
+
case 2:
|
|
1218
|
+
_b.sent();
|
|
1219
|
+
return [2 /*return*/];
|
|
1220
|
+
}
|
|
1221
|
+
});
|
|
1222
|
+
});
|
|
1223
|
+
};
|
|
1224
|
+
/**
|
|
1225
|
+
* @method dispose
|
|
1226
|
+
* @description Disposes the logger instance.
|
|
1227
|
+
* @param {string} clientId - The client ID.
|
|
1228
|
+
* @returns {Promise<void>}
|
|
1229
|
+
*/
|
|
1230
|
+
this.dispose = function (clientId) { return __awaiter(_this, void 0, void 0, function () {
|
|
1231
|
+
var logger;
|
|
1232
|
+
return __generator(this, function (_b) {
|
|
1233
|
+
switch (_b.label) {
|
|
1234
|
+
case 0:
|
|
1235
|
+
if (!this.getLogger.has(clientId)) {
|
|
1236
|
+
return [2 /*return*/];
|
|
1237
|
+
}
|
|
1238
|
+
logger = this.getLogger(clientId);
|
|
1239
|
+
return [4 /*yield*/, logger.waitForInit(false)];
|
|
1240
|
+
case 1:
|
|
1241
|
+
_b.sent();
|
|
1242
|
+
return [4 /*yield*/, logger.dispose()];
|
|
1243
|
+
case 2:
|
|
1244
|
+
_b.sent();
|
|
1245
|
+
this.getLogger.clear(clientId);
|
|
1246
|
+
return [2 /*return*/];
|
|
1247
|
+
}
|
|
1248
|
+
});
|
|
1249
|
+
}); };
|
|
1250
|
+
}
|
|
1251
|
+
return LoggerUtils;
|
|
1252
|
+
}());
|
|
1253
|
+
/**
|
|
1254
|
+
* @constant LoggerAdapter
|
|
1255
|
+
* @description Singleton instance of LoggerUtils.
|
|
1256
|
+
*/
|
|
1257
|
+
var LoggerAdapter = new LoggerUtils();
|
|
1258
|
+
/**
|
|
1259
|
+
* @constant Logger
|
|
1260
|
+
* @description Logger control interface.
|
|
1261
|
+
*/
|
|
1262
|
+
var Logger = LoggerAdapter;
|
|
1263
|
+
|
|
911
1264
|
/**
|
|
912
1265
|
* @description `ask for agent function` in `llama3.1:8b` to troubleshoot (need CC_OLLAMA_EMIT_TOOL_PROTOCOL to be turned off)
|
|
913
1266
|
*/
|
|
@@ -928,19 +1281,11 @@ var CC_EMPTY_OUTPUT_PLACEHOLDERS = [
|
|
|
928
1281
|
"Could you please repeat that? I didn’t catch it.",
|
|
929
1282
|
];
|
|
930
1283
|
var CC_SWARM_AGENT_CHANGED = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
931
|
-
|
|
932
|
-
case 0: return [4 /*yield*/, functoolsKit.sleep(100)];
|
|
933
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
934
|
-
}
|
|
1284
|
+
return [2 /*return*/, Promise.resolve()];
|
|
935
1285
|
}); }); };
|
|
936
1286
|
var CC_SWARM_DEFAULT_AGENT = function (_a, _b, defaultAgent_1) { return __awaiter(void 0, [_a, _b, defaultAgent_1], void 0, function (_c, _d, defaultAgent) {
|
|
937
1287
|
return __generator(this, function (_e) {
|
|
938
|
-
|
|
939
|
-
case 0: return [4 /*yield*/, functoolsKit.sleep(100)];
|
|
940
|
-
case 1:
|
|
941
|
-
_e.sent();
|
|
942
|
-
return [2 /*return*/, defaultAgent];
|
|
943
|
-
}
|
|
1288
|
+
return [2 /*return*/, defaultAgent];
|
|
944
1289
|
});
|
|
945
1290
|
}); };
|
|
946
1291
|
var CC_AGENT_DEFAULT_VALIDATION = validateDefault;
|
|
@@ -961,6 +1306,7 @@ var CC_AGENT_HISTORY_FILTER = function (agentName) {
|
|
|
961
1306
|
var CC_AGENT_OUTPUT_TRANSFORM = removeXmlTags;
|
|
962
1307
|
var CC_KEEP_MESSAGES = 5;
|
|
963
1308
|
var CC_GET_AGENT_HISTORY_ADAPTER = function () { return HistoryAdapter; };
|
|
1309
|
+
var CC_GET_CLIENT_LOGGER_ADAPTER = function () { return LoggerAdapter; };
|
|
964
1310
|
var CC_AGENT_OUTPUT_MAP = function (message) { return message; };
|
|
965
1311
|
var CC_AGENT_SYSTEM_PROMPT = undefined;
|
|
966
1312
|
var CC_STORAGE_SEARCH_SIMILARITY = 0.65;
|
|
@@ -968,12 +1314,14 @@ var CC_STORAGE_SEARCH_POOL = 5;
|
|
|
968
1314
|
var CC_LOGGER_ENABLE_INFO = false;
|
|
969
1315
|
var CC_LOGGER_ENABLE_DEBUG = false;
|
|
970
1316
|
var CC_LOGGER_ENABLE_LOG = true;
|
|
1317
|
+
var CC_LOGGER_ENABLE_CONSOLE = false;
|
|
971
1318
|
var CC_NAME_TO_TITLE = nameToTitle;
|
|
972
1319
|
var GLOBAL_CONFIG = {
|
|
973
1320
|
CC_TOOL_CALL_EXCEPTION_PROMPT: CC_TOOL_CALL_EXCEPTION_PROMPT,
|
|
974
1321
|
CC_EMPTY_OUTPUT_PLACEHOLDERS: CC_EMPTY_OUTPUT_PLACEHOLDERS,
|
|
975
1322
|
CC_KEEP_MESSAGES: CC_KEEP_MESSAGES,
|
|
976
1323
|
CC_GET_AGENT_HISTORY_ADAPTER: CC_GET_AGENT_HISTORY_ADAPTER,
|
|
1324
|
+
CC_GET_CLIENT_LOGGER_ADAPTER: CC_GET_CLIENT_LOGGER_ADAPTER,
|
|
977
1325
|
CC_SWARM_AGENT_CHANGED: CC_SWARM_AGENT_CHANGED,
|
|
978
1326
|
CC_SWARM_DEFAULT_AGENT: CC_SWARM_DEFAULT_AGENT,
|
|
979
1327
|
CC_AGENT_DEFAULT_VALIDATION: CC_AGENT_DEFAULT_VALIDATION,
|
|
@@ -988,12 +1336,130 @@ var GLOBAL_CONFIG = {
|
|
|
988
1336
|
CC_LOGGER_ENABLE_INFO: CC_LOGGER_ENABLE_INFO,
|
|
989
1337
|
CC_LOGGER_ENABLE_DEBUG: CC_LOGGER_ENABLE_DEBUG,
|
|
990
1338
|
CC_LOGGER_ENABLE_LOG: CC_LOGGER_ENABLE_LOG,
|
|
1339
|
+
CC_LOGGER_ENABLE_CONSOLE: CC_LOGGER_ENABLE_CONSOLE,
|
|
991
1340
|
CC_NAME_TO_TITLE: CC_NAME_TO_TITLE,
|
|
992
1341
|
};
|
|
993
1342
|
var setConfig = function (config) {
|
|
994
1343
|
Object.assign(GLOBAL_CONFIG, config);
|
|
995
1344
|
};
|
|
996
1345
|
|
|
1346
|
+
var NOOP_LOGGER = {
|
|
1347
|
+
/**
|
|
1348
|
+
* Logs normal level messages.
|
|
1349
|
+
*/
|
|
1350
|
+
log: function () {
|
|
1351
|
+
},
|
|
1352
|
+
/**
|
|
1353
|
+
* Logs debug level messages.
|
|
1354
|
+
*/
|
|
1355
|
+
debug: function () {
|
|
1356
|
+
},
|
|
1357
|
+
/**
|
|
1358
|
+
* Logs info level messages.
|
|
1359
|
+
*/
|
|
1360
|
+
info: function () {
|
|
1361
|
+
},
|
|
1362
|
+
};
|
|
1363
|
+
/**
|
|
1364
|
+
* LoggerService class that implements the ILogger interface.
|
|
1365
|
+
* Provides methods to log and debug messages.
|
|
1366
|
+
*/
|
|
1367
|
+
var LoggerService = /** @class */ (function () {
|
|
1368
|
+
function LoggerService() {
|
|
1369
|
+
var _this = this;
|
|
1370
|
+
this.methodContextService = inject(TYPES.methodContextService);
|
|
1371
|
+
this.executionContextService = inject(TYPES.executionContextService);
|
|
1372
|
+
this._commonLogger = NOOP_LOGGER;
|
|
1373
|
+
/**
|
|
1374
|
+
* Creates the client logs adapter using factory
|
|
1375
|
+
*/
|
|
1376
|
+
this.getLoggerAdapter = functoolsKit.singleshot(GLOBAL_CONFIG.CC_GET_CLIENT_LOGGER_ADAPTER);
|
|
1377
|
+
/**
|
|
1378
|
+
* Logs messages using the current logger.
|
|
1379
|
+
* @param {...any} args - The messages to log.
|
|
1380
|
+
*/
|
|
1381
|
+
this.log = function (topic) {
|
|
1382
|
+
var _a, _b;
|
|
1383
|
+
var _c;
|
|
1384
|
+
var args = [];
|
|
1385
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1386
|
+
args[_i - 1] = arguments[_i];
|
|
1387
|
+
}
|
|
1388
|
+
var methodContext = MethodContextService.hasContext()
|
|
1389
|
+
? _this.methodContextService.context
|
|
1390
|
+
: null;
|
|
1391
|
+
var executionContext = ExecutionContextService.hasContext()
|
|
1392
|
+
? _this.executionContextService.context
|
|
1393
|
+
: null;
|
|
1394
|
+
var clientId = (_c = methodContext === null || methodContext === void 0 ? void 0 : methodContext.clientId) !== null && _c !== void 0 ? _c : executionContext === null || executionContext === void 0 ? void 0 : executionContext.clientId;
|
|
1395
|
+
var context = {
|
|
1396
|
+
methodContext: methodContext,
|
|
1397
|
+
executionContext: executionContext,
|
|
1398
|
+
};
|
|
1399
|
+
clientId && (_a = _this.getLoggerAdapter()).log.apply(_a, __spreadArray(__spreadArray([clientId, topic], __read(args), false), [context], false));
|
|
1400
|
+
(_b = _this._commonLogger).log.apply(_b, __spreadArray(__spreadArray([topic], __read(args), false), [context], false));
|
|
1401
|
+
};
|
|
1402
|
+
/**
|
|
1403
|
+
* Logs debug messages using the current logger.
|
|
1404
|
+
* @param {...any} args - The debug messages to log.
|
|
1405
|
+
*/
|
|
1406
|
+
this.debug = function (topic) {
|
|
1407
|
+
var _a, _b;
|
|
1408
|
+
var _c;
|
|
1409
|
+
var args = [];
|
|
1410
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1411
|
+
args[_i - 1] = arguments[_i];
|
|
1412
|
+
}
|
|
1413
|
+
var methodContext = MethodContextService.hasContext()
|
|
1414
|
+
? _this.methodContextService.context
|
|
1415
|
+
: null;
|
|
1416
|
+
var executionContext = ExecutionContextService.hasContext()
|
|
1417
|
+
? _this.executionContextService.context
|
|
1418
|
+
: null;
|
|
1419
|
+
var clientId = (_c = methodContext === null || methodContext === void 0 ? void 0 : methodContext.clientId) !== null && _c !== void 0 ? _c : executionContext === null || executionContext === void 0 ? void 0 : executionContext.clientId;
|
|
1420
|
+
var context = {
|
|
1421
|
+
methodContext: methodContext,
|
|
1422
|
+
executionContext: executionContext,
|
|
1423
|
+
};
|
|
1424
|
+
clientId && (_a = _this.getLoggerAdapter()).debug.apply(_a, __spreadArray(__spreadArray([clientId, topic], __read(args), false), [context], false));
|
|
1425
|
+
(_b = _this._commonLogger).debug.apply(_b, __spreadArray(__spreadArray([topic], __read(args), false), [context], false));
|
|
1426
|
+
};
|
|
1427
|
+
/**
|
|
1428
|
+
* Logs info messages using the current logger.
|
|
1429
|
+
* @param {...any} args - The info messages to log.
|
|
1430
|
+
*/
|
|
1431
|
+
this.info = function (topic) {
|
|
1432
|
+
var _a, _b;
|
|
1433
|
+
var _c;
|
|
1434
|
+
var args = [];
|
|
1435
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1436
|
+
args[_i - 1] = arguments[_i];
|
|
1437
|
+
}
|
|
1438
|
+
var methodContext = MethodContextService.hasContext()
|
|
1439
|
+
? _this.methodContextService.context
|
|
1440
|
+
: null;
|
|
1441
|
+
var executionContext = ExecutionContextService.hasContext()
|
|
1442
|
+
? _this.executionContextService.context
|
|
1443
|
+
: null;
|
|
1444
|
+
var clientId = (_c = methodContext === null || methodContext === void 0 ? void 0 : methodContext.clientId) !== null && _c !== void 0 ? _c : executionContext === null || executionContext === void 0 ? void 0 : executionContext.clientId;
|
|
1445
|
+
var context = {
|
|
1446
|
+
methodContext: methodContext,
|
|
1447
|
+
executionContext: executionContext,
|
|
1448
|
+
};
|
|
1449
|
+
clientId && (_a = _this.getLoggerAdapter()).info.apply(_a, __spreadArray(__spreadArray([clientId, topic], __read(args), false), [context], false));
|
|
1450
|
+
(_b = _this._commonLogger).info.apply(_b, __spreadArray(__spreadArray([topic], __read(args), false), [context], false));
|
|
1451
|
+
};
|
|
1452
|
+
/**
|
|
1453
|
+
* Sets a new logger.
|
|
1454
|
+
* @param {ILogger} logger - The new logger to set.
|
|
1455
|
+
*/
|
|
1456
|
+
this.setLogger = function (logger) {
|
|
1457
|
+
_this._commonLogger = logger;
|
|
1458
|
+
};
|
|
1459
|
+
}
|
|
1460
|
+
return LoggerService;
|
|
1461
|
+
}());
|
|
1462
|
+
|
|
997
1463
|
/**
|
|
998
1464
|
* Service for managing agent schemas.
|
|
999
1465
|
*/
|
|
@@ -2377,7 +2843,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2377
2843
|
this.params.logger.debug("ClientSwarm swarmName=".concat(this.params.swarmName, " clientId=").concat(this.params.clientId, " getAgentName"));
|
|
2378
2844
|
if (!(this._activeAgent === AGENT_NEED_FETCH)) return [3 /*break*/, 2];
|
|
2379
2845
|
_a = this;
|
|
2380
|
-
return [4 /*yield*/,
|
|
2846
|
+
return [4 /*yield*/, this.params.getActiveAgent(this.params.clientId, this.params.swarmName, this.params.defaultAgent)];
|
|
2381
2847
|
case 1:
|
|
2382
2848
|
_a._activeAgent = _b.sent();
|
|
2383
2849
|
_b.label = 2;
|
|
@@ -2475,15 +2941,19 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2475
2941
|
* @param {AgentName} agentName - The name of the agent to set as active.
|
|
2476
2942
|
*/
|
|
2477
2943
|
this.setAgentName = function (agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
2478
|
-
|
|
2479
|
-
|
|
2944
|
+
var _a;
|
|
2945
|
+
return __generator(this, function (_b) {
|
|
2946
|
+
switch (_b.label) {
|
|
2480
2947
|
case 0:
|
|
2481
2948
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
2482
2949
|
this.params.logger.debug("ClientSwarm swarmName=".concat(this.params.swarmName, " clientId=").concat(this.params.clientId, " setAgentName agentName=").concat(agentName));
|
|
2483
2950
|
this._activeAgent = agentName;
|
|
2484
|
-
return [4 /*yield*/, this.params.
|
|
2951
|
+
return [4 /*yield*/, this.params.setActiveAgent(this.params.clientId, agentName, this.params.swarmName)];
|
|
2485
2952
|
case 1:
|
|
2486
|
-
|
|
2953
|
+
_b.sent();
|
|
2954
|
+
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onAgentChanged) {
|
|
2955
|
+
this.params.callbacks.onAgentChanged(this.params.clientId, agentName, this.params.swarmName);
|
|
2956
|
+
}
|
|
2487
2957
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2488
2958
|
type: "set-agent-name",
|
|
2489
2959
|
source: "swarm-bus",
|
|
@@ -2497,7 +2967,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2497
2967
|
clientId: this.params.clientId,
|
|
2498
2968
|
})];
|
|
2499
2969
|
case 2:
|
|
2500
|
-
|
|
2970
|
+
_b.sent();
|
|
2501
2971
|
return [2 /*return*/];
|
|
2502
2972
|
}
|
|
2503
2973
|
});
|
|
@@ -2540,7 +3010,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2540
3010
|
return "".concat(clientId, "-").concat(swarmName);
|
|
2541
3011
|
}, function (clientId, swarmName) {
|
|
2542
3012
|
var e_1, _a;
|
|
2543
|
-
var _b = _this.swarmSchemaService.get(swarmName), agentList = _b.agentList, defaultAgent = _b.defaultAgent, callbacks = _b.callbacks;
|
|
3013
|
+
var _b = _this.swarmSchemaService.get(swarmName), agentList = _b.agentList, defaultAgent = _b.defaultAgent, callbacks = _b.callbacks, _c = _b.getActiveAgent, getActiveAgent = _c === void 0 ? GLOBAL_CONFIG.CC_SWARM_DEFAULT_AGENT : _c, _d = _b.setActiveAgent, setActiveAgent = _d === void 0 ? GLOBAL_CONFIG.CC_SWARM_AGENT_CHANGED : _d;
|
|
2544
3014
|
var agentMap = {};
|
|
2545
3015
|
try {
|
|
2546
3016
|
for (var agentList_1 = __values(agentList), agentList_1_1 = agentList_1.next(); !agentList_1_1.done; agentList_1_1 = agentList_1.next()) {
|
|
@@ -2562,22 +3032,8 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2562
3032
|
swarmName: swarmName,
|
|
2563
3033
|
logger: _this.loggerService,
|
|
2564
3034
|
bus: _this.busService,
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
return __generator(this, function (_a) {
|
|
2568
|
-
switch (_a.label) {
|
|
2569
|
-
case 0:
|
|
2570
|
-
if (callbacks && callbacks.onAgentChanged) {
|
|
2571
|
-
callbacks.onAgentChanged(clientId, agentName, swarmName);
|
|
2572
|
-
}
|
|
2573
|
-
return [4 /*yield*/, GLOBAL_CONFIG.CC_SWARM_AGENT_CHANGED(clientId, agentName, swarmName)];
|
|
2574
|
-
case 1:
|
|
2575
|
-
_a.sent();
|
|
2576
|
-
return [2 /*return*/];
|
|
2577
|
-
}
|
|
2578
|
-
});
|
|
2579
|
-
});
|
|
2580
|
-
},
|
|
3035
|
+
getActiveAgent: getActiveAgent,
|
|
3036
|
+
setActiveAgent: setActiveAgent,
|
|
2581
3037
|
callbacks: callbacks,
|
|
2582
3038
|
});
|
|
2583
3039
|
});
|
|
@@ -6718,6 +7174,7 @@ var validationServices = {
|
|
|
6718
7174
|
};
|
|
6719
7175
|
var swarm = __assign(__assign(__assign(__assign(__assign(__assign({}, baseServices), contextServices), connectionServices), schemaServices), publicServices), validationServices);
|
|
6720
7176
|
init();
|
|
7177
|
+
var swarm$1 = swarm;
|
|
6721
7178
|
|
|
6722
7179
|
var METHOD_NAME$C = "function.addAgent";
|
|
6723
7180
|
/**
|
|
@@ -6728,11 +7185,11 @@ var METHOD_NAME$C = "function.addAgent";
|
|
|
6728
7185
|
*/
|
|
6729
7186
|
var addAgent = function (agentSchema) {
|
|
6730
7187
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6731
|
-
swarm.loggerService.log(METHOD_NAME$C, {
|
|
7188
|
+
swarm$1.loggerService.log(METHOD_NAME$C, {
|
|
6732
7189
|
agentSchema: agentSchema,
|
|
6733
7190
|
});
|
|
6734
|
-
swarm.agentValidationService.addAgent(agentSchema.agentName, agentSchema);
|
|
6735
|
-
swarm.agentSchemaService.register(agentSchema.agentName, agentSchema);
|
|
7191
|
+
swarm$1.agentValidationService.addAgent(agentSchema.agentName, agentSchema);
|
|
7192
|
+
swarm$1.agentSchemaService.register(agentSchema.agentName, agentSchema);
|
|
6736
7193
|
return agentSchema.agentName;
|
|
6737
7194
|
};
|
|
6738
7195
|
|
|
@@ -6746,11 +7203,11 @@ var METHOD_NAME$B = "function.addCompletion";
|
|
|
6746
7203
|
*/
|
|
6747
7204
|
var addCompletion = function (completionSchema) {
|
|
6748
7205
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6749
|
-
swarm.loggerService.log(METHOD_NAME$B, {
|
|
7206
|
+
swarm$1.loggerService.log(METHOD_NAME$B, {
|
|
6750
7207
|
completionSchema: completionSchema,
|
|
6751
7208
|
});
|
|
6752
|
-
swarm.completionValidationService.addCompletion(completionSchema.completionName);
|
|
6753
|
-
swarm.completionSchemaService.register(completionSchema.completionName, completionSchema);
|
|
7209
|
+
swarm$1.completionValidationService.addCompletion(completionSchema.completionName);
|
|
7210
|
+
swarm$1.completionSchemaService.register(completionSchema.completionName, completionSchema);
|
|
6754
7211
|
return completionSchema.completionName;
|
|
6755
7212
|
};
|
|
6756
7213
|
|
|
@@ -6763,11 +7220,11 @@ var METHOD_NAME$A = "function.addSwarm";
|
|
|
6763
7220
|
*/
|
|
6764
7221
|
var addSwarm = function (swarmSchema) {
|
|
6765
7222
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6766
|
-
swarm.loggerService.log(METHOD_NAME$A, {
|
|
7223
|
+
swarm$1.loggerService.log(METHOD_NAME$A, {
|
|
6767
7224
|
swarmSchema: swarmSchema,
|
|
6768
7225
|
});
|
|
6769
|
-
swarm.swarmValidationService.addSwarm(swarmSchema.swarmName, swarmSchema);
|
|
6770
|
-
swarm.swarmSchemaService.register(swarmSchema.swarmName, swarmSchema);
|
|
7226
|
+
swarm$1.swarmValidationService.addSwarm(swarmSchema.swarmName, swarmSchema);
|
|
7227
|
+
swarm$1.swarmSchemaService.register(swarmSchema.swarmName, swarmSchema);
|
|
6771
7228
|
return swarmSchema.swarmName;
|
|
6772
7229
|
};
|
|
6773
7230
|
|
|
@@ -6781,11 +7238,11 @@ var METHOD_NAME$z = "function.addTool";
|
|
|
6781
7238
|
*/
|
|
6782
7239
|
var addTool = function (toolSchema) {
|
|
6783
7240
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6784
|
-
swarm.loggerService.log(METHOD_NAME$z, {
|
|
7241
|
+
swarm$1.loggerService.log(METHOD_NAME$z, {
|
|
6785
7242
|
toolSchema: toolSchema,
|
|
6786
7243
|
});
|
|
6787
|
-
swarm.toolValidationService.addTool(toolSchema.toolName, toolSchema);
|
|
6788
|
-
swarm.toolSchemaService.register(toolSchema.toolName, toolSchema);
|
|
7244
|
+
swarm$1.toolValidationService.addTool(toolSchema.toolName, toolSchema);
|
|
7245
|
+
swarm$1.toolSchemaService.register(toolSchema.toolName, toolSchema);
|
|
6789
7246
|
return toolSchema.toolName;
|
|
6790
7247
|
};
|
|
6791
7248
|
|
|
@@ -6798,12 +7255,12 @@ var METHOD_NAME$y = "function.addState";
|
|
|
6798
7255
|
*/
|
|
6799
7256
|
var addState = function (stateSchema) {
|
|
6800
7257
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6801
|
-
swarm.loggerService.log(METHOD_NAME$y, {
|
|
7258
|
+
swarm$1.loggerService.log(METHOD_NAME$y, {
|
|
6802
7259
|
stateSchema: stateSchema,
|
|
6803
7260
|
});
|
|
6804
|
-
swarm.stateSchemaService.register(stateSchema.stateName, stateSchema);
|
|
7261
|
+
swarm$1.stateSchemaService.register(stateSchema.stateName, stateSchema);
|
|
6805
7262
|
if (stateSchema.shared) {
|
|
6806
|
-
swarm.stateConnectionService
|
|
7263
|
+
swarm$1.stateConnectionService
|
|
6807
7264
|
.getSharedStateRef("shared", stateSchema.stateName)
|
|
6808
7265
|
.waitForInit();
|
|
6809
7266
|
}
|
|
@@ -6819,11 +7276,11 @@ var METHOD_NAME$x = "function.addEmbedding";
|
|
|
6819
7276
|
*/
|
|
6820
7277
|
var addEmbedding = function (embeddingSchema) {
|
|
6821
7278
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6822
|
-
swarm.loggerService.log(METHOD_NAME$x, {
|
|
7279
|
+
swarm$1.loggerService.log(METHOD_NAME$x, {
|
|
6823
7280
|
embeddingSchema: embeddingSchema,
|
|
6824
7281
|
});
|
|
6825
|
-
swarm.embeddingValidationService.addEmbedding(embeddingSchema.embeddingName, embeddingSchema);
|
|
6826
|
-
swarm.embeddingSchemaService.register(embeddingSchema.embeddingName, embeddingSchema);
|
|
7282
|
+
swarm$1.embeddingValidationService.addEmbedding(embeddingSchema.embeddingName, embeddingSchema);
|
|
7283
|
+
swarm$1.embeddingSchemaService.register(embeddingSchema.embeddingName, embeddingSchema);
|
|
6827
7284
|
return embeddingSchema.embeddingName;
|
|
6828
7285
|
};
|
|
6829
7286
|
|
|
@@ -6836,13 +7293,13 @@ var METHOD_NAME$w = "function.addStorage";
|
|
|
6836
7293
|
*/
|
|
6837
7294
|
var addStorage = function (storageSchema) {
|
|
6838
7295
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6839
|
-
swarm.loggerService.log(METHOD_NAME$w, {
|
|
7296
|
+
swarm$1.loggerService.log(METHOD_NAME$w, {
|
|
6840
7297
|
storageSchema: storageSchema,
|
|
6841
7298
|
});
|
|
6842
|
-
swarm.storageValidationService.addStorage(storageSchema.storageName, storageSchema);
|
|
6843
|
-
swarm.storageSchemaService.register(storageSchema.storageName, storageSchema);
|
|
7299
|
+
swarm$1.storageValidationService.addStorage(storageSchema.storageName, storageSchema);
|
|
7300
|
+
swarm$1.storageSchemaService.register(storageSchema.storageName, storageSchema);
|
|
6844
7301
|
if (storageSchema.shared) {
|
|
6845
|
-
swarm.storageConnectionService
|
|
7302
|
+
swarm$1.storageConnectionService
|
|
6846
7303
|
.getSharedStorage("shared", storageSchema.storageName)
|
|
6847
7304
|
.waitForInit();
|
|
6848
7305
|
}
|
|
@@ -6864,28 +7321,28 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
|
|
|
6864
7321
|
switch (_a.label) {
|
|
6865
7322
|
case 0:
|
|
6866
7323
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6867
|
-
swarm.loggerService.log(METHOD_NAME$v, {
|
|
7324
|
+
swarm$1.loggerService.log(METHOD_NAME$v, {
|
|
6868
7325
|
content: content,
|
|
6869
7326
|
clientId: clientId,
|
|
6870
7327
|
agentName: agentName,
|
|
6871
7328
|
});
|
|
6872
|
-
swarm.agentValidationService.validate(agentName, METHOD_NAME$v);
|
|
6873
|
-
swarm.sessionValidationService.validate(clientId, METHOD_NAME$v);
|
|
6874
|
-
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
6875
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$v);
|
|
6876
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(METHOD_NAME$v, clientId, swarmName)];
|
|
7329
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$v);
|
|
7330
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$v);
|
|
7331
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
7332
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$v);
|
|
7333
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$v, clientId, swarmName)];
|
|
6877
7334
|
case 1:
|
|
6878
7335
|
currentAgentName = _a.sent();
|
|
6879
7336
|
if (currentAgentName !== agentName) {
|
|
6880
7337
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6881
|
-
swarm.loggerService.log('function "commitUserMessage" skipped due to the agent change', {
|
|
7338
|
+
swarm$1.loggerService.log('function "commitUserMessage" skipped due to the agent change', {
|
|
6882
7339
|
currentAgentName: currentAgentName,
|
|
6883
7340
|
agentName: agentName,
|
|
6884
7341
|
clientId: clientId,
|
|
6885
7342
|
});
|
|
6886
7343
|
return [2 /*return*/];
|
|
6887
7344
|
}
|
|
6888
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, METHOD_NAME$v, clientId, swarmName)];
|
|
7345
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$v, clientId, swarmName)];
|
|
6889
7346
|
case 2:
|
|
6890
7347
|
_a.sent();
|
|
6891
7348
|
return [2 /*return*/];
|
|
@@ -6907,13 +7364,13 @@ var getAgentName = function (clientId) { return __awaiter(void 0, void 0, void 0
|
|
|
6907
7364
|
switch (_a.label) {
|
|
6908
7365
|
case 0:
|
|
6909
7366
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6910
|
-
swarm.loggerService.log(METHOD_NAME$u, {
|
|
7367
|
+
swarm$1.loggerService.log(METHOD_NAME$u, {
|
|
6911
7368
|
clientId: clientId,
|
|
6912
7369
|
});
|
|
6913
|
-
swarm.sessionValidationService.validate(clientId, METHOD_NAME$u);
|
|
6914
|
-
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
6915
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$u);
|
|
6916
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(METHOD_NAME$u, clientId, swarmName)];
|
|
7370
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$u);
|
|
7371
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
7372
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$u);
|
|
7373
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$u, clientId, swarmName)];
|
|
6917
7374
|
case 1: return [2 /*return*/, _a.sent()];
|
|
6918
7375
|
}
|
|
6919
7376
|
});
|
|
@@ -6931,25 +7388,25 @@ var METHOD_NAME$t = "function.makeConnection";
|
|
|
6931
7388
|
*/
|
|
6932
7389
|
var makeConnection = function (connector, clientId, swarmName) {
|
|
6933
7390
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
6934
|
-
swarm.loggerService.log(METHOD_NAME$t, {
|
|
7391
|
+
swarm$1.loggerService.log(METHOD_NAME$t, {
|
|
6935
7392
|
clientId: clientId,
|
|
6936
7393
|
swarmName: swarmName,
|
|
6937
7394
|
});
|
|
6938
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$t);
|
|
6939
|
-
swarm.sessionValidationService.addSession(clientId, swarmName, "makeConnection");
|
|
6940
|
-
var send = swarm.sessionPublicService.connect(connector, METHOD_NAME$t, clientId, swarmName);
|
|
7395
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$t);
|
|
7396
|
+
swarm$1.sessionValidationService.addSession(clientId, swarmName, "makeConnection");
|
|
7397
|
+
var send = swarm$1.sessionPublicService.connect(connector, METHOD_NAME$t, clientId, swarmName);
|
|
6941
7398
|
return functoolsKit.queued(function (outgoing) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6942
7399
|
var _a;
|
|
6943
7400
|
var _b;
|
|
6944
7401
|
return __generator(this, function (_c) {
|
|
6945
7402
|
switch (_c.label) {
|
|
6946
7403
|
case 0:
|
|
6947
|
-
swarm.sessionValidationService.validate(clientId, METHOD_NAME$t);
|
|
7404
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$t);
|
|
6948
7405
|
_a = send;
|
|
6949
7406
|
_b = {
|
|
6950
7407
|
data: outgoing
|
|
6951
7408
|
};
|
|
6952
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(METHOD_NAME$t, clientId, swarmName)];
|
|
7409
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$t, clientId, swarmName)];
|
|
6953
7410
|
case 1: return [4 /*yield*/, _a.apply(void 0, [(_b.agentName = _c.sent(),
|
|
6954
7411
|
_b.clientId = clientId,
|
|
6955
7412
|
_b)])];
|
|
@@ -6980,7 +7437,7 @@ makeConnection.scheduled = function (connector, clientId, swarmName, _a) {
|
|
|
6980
7437
|
return __generator(this, function (_a) {
|
|
6981
7438
|
switch (_a.label) {
|
|
6982
7439
|
case 0:
|
|
6983
|
-
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
7440
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
6984
7441
|
return [2 /*return*/];
|
|
6985
7442
|
}
|
|
6986
7443
|
return [4 /*yield*/, send(content)];
|
|
@@ -7000,7 +7457,7 @@ makeConnection.scheduled = function (connector, clientId, swarmName, _a) {
|
|
|
7000
7457
|
return __generator(this, function (_f) {
|
|
7001
7458
|
switch (_f.label) {
|
|
7002
7459
|
case 0:
|
|
7003
|
-
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
7460
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
7004
7461
|
return [2 /*return*/];
|
|
7005
7462
|
}
|
|
7006
7463
|
_c = commitUserMessage;
|
|
@@ -7058,15 +7515,15 @@ var createChangeAgent = functoolsKit.ttl(function (clientId) {
|
|
|
7058
7515
|
return __generator(this, function (_d) {
|
|
7059
7516
|
switch (_d.label) {
|
|
7060
7517
|
case 0:
|
|
7061
|
-
swarm.sessionValidationService.validate(clientId, METHOD_NAME$s);
|
|
7062
|
-
swarm.agentValidationService.validate(agentName, METHOD_NAME$s);
|
|
7063
|
-
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7064
|
-
return [4 /*yield*/, Promise.all(swarm.swarmValidationService
|
|
7518
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$s);
|
|
7519
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$s);
|
|
7520
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
7521
|
+
return [4 /*yield*/, Promise.all(swarm$1.swarmValidationService
|
|
7065
7522
|
.getAgentList(swarmName)
|
|
7066
7523
|
.map(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7067
7524
|
return __generator(this, function (_a) {
|
|
7068
7525
|
switch (_a.label) {
|
|
7069
|
-
case 0: return [4 /*yield*/, swarm.agentPublicService.commitAgentChange(methodName, clientId, agentName)];
|
|
7526
|
+
case 0: return [4 /*yield*/, swarm$1.agentPublicService.commitAgentChange(methodName, clientId, agentName)];
|
|
7070
7527
|
case 1:
|
|
7071
7528
|
_a.sent();
|
|
7072
7529
|
return [2 /*return*/];
|
|
@@ -7075,22 +7532,22 @@ var createChangeAgent = functoolsKit.ttl(function (clientId) {
|
|
|
7075
7532
|
}); }))];
|
|
7076
7533
|
case 1:
|
|
7077
7534
|
_d.sent();
|
|
7078
|
-
return [4 /*yield*/, swarm.agentPublicService.dispose(methodName, clientId, agentName)];
|
|
7535
|
+
return [4 /*yield*/, swarm$1.agentPublicService.dispose(methodName, clientId, agentName)];
|
|
7079
7536
|
case 2:
|
|
7080
7537
|
_d.sent();
|
|
7081
|
-
return [4 /*yield*/, swarm.historyPublicService.dispose(methodName, clientId, agentName)];
|
|
7538
|
+
return [4 /*yield*/, swarm$1.historyPublicService.dispose(methodName, clientId, agentName)];
|
|
7082
7539
|
case 3:
|
|
7083
7540
|
_d.sent();
|
|
7084
|
-
_b = (_a = swarm.swarmPublicService).setAgentRef;
|
|
7541
|
+
_b = (_a = swarm$1.swarmPublicService).setAgentRef;
|
|
7085
7542
|
_c = [methodName,
|
|
7086
7543
|
clientId,
|
|
7087
7544
|
swarmName,
|
|
7088
7545
|
agentName];
|
|
7089
|
-
return [4 /*yield*/, swarm.agentPublicService.createAgentRef(methodName, clientId, agentName)];
|
|
7546
|
+
return [4 /*yield*/, swarm$1.agentPublicService.createAgentRef(methodName, clientId, agentName)];
|
|
7090
7547
|
case 4: return [4 /*yield*/, _b.apply(_a, _c.concat([_d.sent()]))];
|
|
7091
7548
|
case 5:
|
|
7092
7549
|
_d.sent();
|
|
7093
|
-
return [4 /*yield*/, swarm.swarmPublicService.setAgentName(agentName, methodName, clientId, swarmName)];
|
|
7550
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.setAgentName(agentName, methodName, clientId, swarmName)];
|
|
7094
7551
|
case 6:
|
|
7095
7552
|
_d.sent();
|
|
7096
7553
|
return [2 /*return*/];
|
|
@@ -7129,7 +7586,7 @@ var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void
|
|
|
7129
7586
|
switch (_a.label) {
|
|
7130
7587
|
case 0:
|
|
7131
7588
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7132
|
-
swarm.loggerService.log(METHOD_NAME$s, {
|
|
7589
|
+
swarm$1.loggerService.log(METHOD_NAME$s, {
|
|
7133
7590
|
agentName: agentName,
|
|
7134
7591
|
clientId: clientId,
|
|
7135
7592
|
});
|
|
@@ -7162,28 +7619,26 @@ var disposeConnection = function (clientId_1, swarmName_1) {
|
|
|
7162
7619
|
switch (_a.label) {
|
|
7163
7620
|
case 0:
|
|
7164
7621
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7165
|
-
swarm.loggerService.log(METHOD_NAME$r, {
|
|
7622
|
+
swarm$1.loggerService.log(METHOD_NAME$r, {
|
|
7166
7623
|
clientId: clientId,
|
|
7167
7624
|
swarmName: swarmName,
|
|
7168
7625
|
});
|
|
7169
|
-
swarm.swarmValidationService.validate(swarmName, methodName);
|
|
7170
|
-
swarm.
|
|
7171
|
-
swarm.busService.dispose(clientId);
|
|
7172
|
-
return [4 /*yield*/, swarm.sessionPublicService.dispose(methodName, clientId, swarmName)];
|
|
7626
|
+
swarm$1.swarmValidationService.validate(swarmName, methodName);
|
|
7627
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.dispose(methodName, clientId, swarmName)];
|
|
7173
7628
|
case 1:
|
|
7174
7629
|
_a.sent();
|
|
7175
|
-
return [4 /*yield*/, swarm.swarmPublicService.dispose(methodName, clientId, swarmName)];
|
|
7630
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.dispose(methodName, clientId, swarmName)];
|
|
7176
7631
|
case 2:
|
|
7177
7632
|
_a.sent();
|
|
7178
|
-
return [4 /*yield*/, Promise.all(swarm.swarmValidationService
|
|
7633
|
+
return [4 /*yield*/, Promise.all(swarm$1.swarmValidationService
|
|
7179
7634
|
.getAgentList(swarmName)
|
|
7180
7635
|
.map(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7181
7636
|
return __generator(this, function (_a) {
|
|
7182
7637
|
switch (_a.label) {
|
|
7183
|
-
case 0: return [4 /*yield*/, swarm.agentPublicService.dispose(methodName, clientId, agentName)];
|
|
7638
|
+
case 0: return [4 /*yield*/, swarm$1.agentPublicService.dispose(methodName, clientId, agentName)];
|
|
7184
7639
|
case 1:
|
|
7185
7640
|
_a.sent();
|
|
7186
|
-
return [4 /*yield*/, swarm.historyPublicService.dispose(methodName, clientId, agentName)];
|
|
7641
|
+
return [4 /*yield*/, swarm$1.historyPublicService.dispose(methodName, clientId, agentName)];
|
|
7187
7642
|
case 2:
|
|
7188
7643
|
_a.sent();
|
|
7189
7644
|
return [2 /*return*/];
|
|
@@ -7192,16 +7647,16 @@ var disposeConnection = function (clientId_1, swarmName_1) {
|
|
|
7192
7647
|
}); }))];
|
|
7193
7648
|
case 3:
|
|
7194
7649
|
_a.sent();
|
|
7195
|
-
return [4 /*yield*/, Promise.all(swarm.swarmValidationService
|
|
7650
|
+
return [4 /*yield*/, Promise.all(swarm$1.swarmValidationService
|
|
7196
7651
|
.getAgentList(swarmName)
|
|
7197
7652
|
.flatMap(function (agentName) {
|
|
7198
|
-
return swarm.agentValidationService.getStorageList(agentName);
|
|
7653
|
+
return swarm$1.agentValidationService.getStorageList(agentName);
|
|
7199
7654
|
})
|
|
7200
7655
|
.filter(function (storageName) { return !!storageName; })
|
|
7201
7656
|
.map(function (storageName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7202
7657
|
return __generator(this, function (_a) {
|
|
7203
7658
|
switch (_a.label) {
|
|
7204
|
-
case 0: return [4 /*yield*/, swarm.storagePublicService.dispose(methodName, clientId, storageName)];
|
|
7659
|
+
case 0: return [4 /*yield*/, swarm$1.storagePublicService.dispose(methodName, clientId, storageName)];
|
|
7205
7660
|
case 1:
|
|
7206
7661
|
_a.sent();
|
|
7207
7662
|
return [2 /*return*/];
|
|
@@ -7210,16 +7665,16 @@ var disposeConnection = function (clientId_1, swarmName_1) {
|
|
|
7210
7665
|
}); }))];
|
|
7211
7666
|
case 4:
|
|
7212
7667
|
_a.sent();
|
|
7213
|
-
return [4 /*yield*/, Promise.all(swarm.swarmValidationService
|
|
7668
|
+
return [4 /*yield*/, Promise.all(swarm$1.swarmValidationService
|
|
7214
7669
|
.getAgentList(swarmName)
|
|
7215
7670
|
.flatMap(function (agentName) {
|
|
7216
|
-
return swarm.agentValidationService.getStateList(agentName);
|
|
7671
|
+
return swarm$1.agentValidationService.getStateList(agentName);
|
|
7217
7672
|
})
|
|
7218
7673
|
.filter(function (stateName) { return !!stateName; })
|
|
7219
7674
|
.map(function (stateName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7220
7675
|
return __generator(this, function (_a) {
|
|
7221
7676
|
switch (_a.label) {
|
|
7222
|
-
case 0: return [4 /*yield*/, swarm.statePublicService.dispose(methodName, clientId, stateName)];
|
|
7677
|
+
case 0: return [4 /*yield*/, swarm$1.statePublicService.dispose(methodName, clientId, stateName)];
|
|
7223
7678
|
case 1:
|
|
7224
7679
|
_a.sent();
|
|
7225
7680
|
return [2 /*return*/];
|
|
@@ -7231,6 +7686,11 @@ var disposeConnection = function (clientId_1, swarmName_1) {
|
|
|
7231
7686
|
return [4 /*yield*/, HistoryAdapter.dispose(clientId, null)];
|
|
7232
7687
|
case 6:
|
|
7233
7688
|
_a.sent();
|
|
7689
|
+
return [4 /*yield*/, LoggerAdapter.dispose(clientId)];
|
|
7690
|
+
case 7:
|
|
7691
|
+
_a.sent();
|
|
7692
|
+
swarm$1.sessionValidationService.removeSession(clientId);
|
|
7693
|
+
swarm$1.busService.dispose(clientId);
|
|
7234
7694
|
return [2 /*return*/];
|
|
7235
7695
|
}
|
|
7236
7696
|
});
|
|
@@ -7252,9 +7712,9 @@ var createComplete = functoolsKit.ttl(function (clientId, swarmName) {
|
|
|
7252
7712
|
return __generator(this, function (_a) {
|
|
7253
7713
|
switch (_a.label) {
|
|
7254
7714
|
case 0:
|
|
7255
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME);
|
|
7256
|
-
swarm.sessionValidationService.addSession(clientId, swarmName, "complete");
|
|
7257
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", METHOD_NAME, clientId, swarmName)];
|
|
7715
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME);
|
|
7716
|
+
swarm$1.sessionValidationService.addSession(clientId, swarmName, "complete");
|
|
7717
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.execute(content, "user", METHOD_NAME, clientId, swarmName)];
|
|
7258
7718
|
case 1:
|
|
7259
7719
|
result = _a.sent();
|
|
7260
7720
|
return [4 /*yield*/, disposeConnection(clientId, swarmName, METHOD_NAME)];
|
|
@@ -7297,7 +7757,7 @@ var complete = function (content, clientId, swarmName) { return __awaiter(void 0
|
|
|
7297
7757
|
case 0:
|
|
7298
7758
|
executionId = functoolsKit.randomString();
|
|
7299
7759
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7300
|
-
swarm.loggerService.log(METHOD_NAME$q, {
|
|
7760
|
+
swarm$1.loggerService.log(METHOD_NAME$q, {
|
|
7301
7761
|
content: content,
|
|
7302
7762
|
clientId: clientId,
|
|
7303
7763
|
executionId: executionId,
|
|
@@ -7336,13 +7796,13 @@ var METHOD_NAME$p = "function.session";
|
|
|
7336
7796
|
var session = function (clientId, swarmName) {
|
|
7337
7797
|
var executionId = functoolsKit.randomString();
|
|
7338
7798
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7339
|
-
swarm.loggerService.log(METHOD_NAME$p, {
|
|
7799
|
+
swarm$1.loggerService.log(METHOD_NAME$p, {
|
|
7340
7800
|
clientId: clientId,
|
|
7341
7801
|
swarmName: swarmName,
|
|
7342
7802
|
executionId: executionId,
|
|
7343
7803
|
});
|
|
7344
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$p);
|
|
7345
|
-
swarm.sessionValidationService.addSession(clientId, swarmName, "session");
|
|
7804
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$p);
|
|
7805
|
+
swarm$1.sessionValidationService.addSession(clientId, swarmName, "session");
|
|
7346
7806
|
return {
|
|
7347
7807
|
/**
|
|
7348
7808
|
* Completes the session with the given content.
|
|
@@ -7352,11 +7812,11 @@ var session = function (clientId, swarmName) {
|
|
|
7352
7812
|
*/
|
|
7353
7813
|
complete: functoolsKit.queued(function (content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7354
7814
|
return __generator(this, function (_a) {
|
|
7355
|
-
swarm.sessionValidationService.validate(clientId, METHOD_NAME$p);
|
|
7815
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$p);
|
|
7356
7816
|
return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
7357
7817
|
return __generator(this, function (_a) {
|
|
7358
7818
|
switch (_a.label) {
|
|
7359
|
-
case 0: return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", METHOD_NAME$p, clientId, swarmName)];
|
|
7819
|
+
case 0: return [4 /*yield*/, swarm$1.sessionPublicService.execute(content, "user", METHOD_NAME$p, clientId, swarmName)];
|
|
7360
7820
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7361
7821
|
}
|
|
7362
7822
|
});
|
|
@@ -7492,16 +7952,16 @@ var getRawHistory = function (clientId_1) {
|
|
|
7492
7952
|
switch (_a.label) {
|
|
7493
7953
|
case 0:
|
|
7494
7954
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7495
|
-
swarm.loggerService.log(METHOD_NAME$o, {
|
|
7955
|
+
swarm$1.loggerService.log(METHOD_NAME$o, {
|
|
7496
7956
|
clientId: clientId,
|
|
7497
7957
|
});
|
|
7498
|
-
swarm.sessionValidationService.validate(clientId, methodName);
|
|
7499
|
-
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7500
|
-
swarm.swarmValidationService.validate(swarmName, methodName);
|
|
7501
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(methodName, clientId, swarmName)];
|
|
7958
|
+
swarm$1.sessionValidationService.validate(clientId, methodName);
|
|
7959
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
7960
|
+
swarm$1.swarmValidationService.validate(swarmName, methodName);
|
|
7961
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(methodName, clientId, swarmName)];
|
|
7502
7962
|
case 1:
|
|
7503
7963
|
agentName = _a.sent();
|
|
7504
|
-
return [4 /*yield*/, swarm.historyPublicService.toArrayForRaw(methodName, clientId, agentName)];
|
|
7964
|
+
return [4 /*yield*/, swarm$1.historyPublicService.toArrayForRaw(methodName, clientId, agentName)];
|
|
7505
7965
|
case 2:
|
|
7506
7966
|
history = _a.sent();
|
|
7507
7967
|
return [2 /*return*/, __spreadArray([], __read(history), false)];
|
|
@@ -7524,13 +7984,13 @@ var getAgentHistory = function (clientId, agentName) { return __awaiter(void 0,
|
|
|
7524
7984
|
switch (_a.label) {
|
|
7525
7985
|
case 0:
|
|
7526
7986
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7527
|
-
swarm.loggerService.log(METHOD_NAME$n, {
|
|
7987
|
+
swarm$1.loggerService.log(METHOD_NAME$n, {
|
|
7528
7988
|
clientId: clientId,
|
|
7529
7989
|
agentName: agentName,
|
|
7530
7990
|
});
|
|
7531
|
-
swarm.agentValidationService.validate(agentName, METHOD_NAME$n);
|
|
7532
|
-
prompt = swarm.agentSchemaService.get(agentName).prompt;
|
|
7533
|
-
return [4 /*yield*/, swarm.historyPublicService.toArrayForAgent(prompt, METHOD_NAME$n, clientId, agentName)];
|
|
7991
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$n);
|
|
7992
|
+
prompt = swarm$1.agentSchemaService.get(agentName).prompt;
|
|
7993
|
+
return [4 /*yield*/, swarm$1.historyPublicService.toArrayForAgent(prompt, METHOD_NAME$n, clientId, agentName)];
|
|
7534
7994
|
case 1:
|
|
7535
7995
|
history = _a.sent();
|
|
7536
7996
|
return [2 /*return*/, __spreadArray([], __read(history), false)];
|
|
@@ -7548,12 +8008,12 @@ var getSessionMode = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
7548
8008
|
var swarmName;
|
|
7549
8009
|
return __generator(this, function (_a) {
|
|
7550
8010
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7551
|
-
swarm.loggerService.log(METHOD_NAME$m, {
|
|
8011
|
+
swarm$1.loggerService.log(METHOD_NAME$m, {
|
|
7552
8012
|
clientId: clientId,
|
|
7553
8013
|
});
|
|
7554
|
-
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7555
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$m);
|
|
7556
|
-
return [2 /*return*/, swarm.sessionValidationService.getSessionMode(clientId)];
|
|
8014
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8015
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$m);
|
|
8016
|
+
return [2 /*return*/, swarm$1.sessionValidationService.getSessionMode(clientId)];
|
|
7557
8017
|
});
|
|
7558
8018
|
}); };
|
|
7559
8019
|
|
|
@@ -7572,22 +8032,22 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
|
|
|
7572
8032
|
switch (_a.label) {
|
|
7573
8033
|
case 0:
|
|
7574
8034
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7575
|
-
swarm.loggerService.log(METHOD_NAME$l, {
|
|
8035
|
+
swarm$1.loggerService.log(METHOD_NAME$l, {
|
|
7576
8036
|
toolId: toolId,
|
|
7577
8037
|
content: content,
|
|
7578
8038
|
clientId: clientId,
|
|
7579
8039
|
agentName: agentName,
|
|
7580
8040
|
});
|
|
7581
|
-
swarm.agentValidationService.validate(agentName, METHOD_NAME$l);
|
|
7582
|
-
swarm.sessionValidationService.validate(clientId, METHOD_NAME$l);
|
|
7583
|
-
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7584
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$l);
|
|
7585
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(METHOD_NAME$l, clientId, swarmName)];
|
|
8041
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$l);
|
|
8042
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$l);
|
|
8043
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8044
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$l);
|
|
8045
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$l, clientId, swarmName)];
|
|
7586
8046
|
case 1:
|
|
7587
8047
|
currentAgentName = _a.sent();
|
|
7588
8048
|
if (currentAgentName !== agentName) {
|
|
7589
8049
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7590
|
-
swarm.loggerService.log('function "commitToolOutput" skipped due to the agent change', {
|
|
8050
|
+
swarm$1.loggerService.log('function "commitToolOutput" skipped due to the agent change', {
|
|
7591
8051
|
toolId: toolId,
|
|
7592
8052
|
currentAgentName: currentAgentName,
|
|
7593
8053
|
agentName: agentName,
|
|
@@ -7595,7 +8055,7 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
|
|
|
7595
8055
|
});
|
|
7596
8056
|
return [2 /*return*/];
|
|
7597
8057
|
}
|
|
7598
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$l, clientId, swarmName)];
|
|
8058
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$l, clientId, swarmName)];
|
|
7599
8059
|
case 2:
|
|
7600
8060
|
_a.sent();
|
|
7601
8061
|
return [2 /*return*/];
|
|
@@ -7618,28 +8078,28 @@ var commitSystemMessage = function (content, clientId, agentName) { return __awa
|
|
|
7618
8078
|
switch (_a.label) {
|
|
7619
8079
|
case 0:
|
|
7620
8080
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7621
|
-
swarm.loggerService.log(METHOD_NAME$k, {
|
|
8081
|
+
swarm$1.loggerService.log(METHOD_NAME$k, {
|
|
7622
8082
|
content: content,
|
|
7623
8083
|
clientId: clientId,
|
|
7624
8084
|
agentName: agentName,
|
|
7625
8085
|
});
|
|
7626
|
-
swarm.agentValidationService.validate(agentName, METHOD_NAME$k);
|
|
7627
|
-
swarm.sessionValidationService.validate(clientId, METHOD_NAME$k);
|
|
7628
|
-
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7629
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$k);
|
|
7630
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(METHOD_NAME$k, clientId, swarmName)];
|
|
8086
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$k);
|
|
8087
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$k);
|
|
8088
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8089
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$k);
|
|
8090
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$k, clientId, swarmName)];
|
|
7631
8091
|
case 1:
|
|
7632
8092
|
currentAgentName = _a.sent();
|
|
7633
8093
|
if (currentAgentName !== agentName) {
|
|
7634
8094
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7635
|
-
swarm.loggerService.log('function "commitSystemMessage" skipped due to the agent change', {
|
|
8095
|
+
swarm$1.loggerService.log('function "commitSystemMessage" skipped due to the agent change', {
|
|
7636
8096
|
currentAgentName: currentAgentName,
|
|
7637
8097
|
agentName: agentName,
|
|
7638
8098
|
clientId: clientId,
|
|
7639
8099
|
});
|
|
7640
8100
|
return [2 /*return*/];
|
|
7641
8101
|
}
|
|
7642
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, METHOD_NAME$k, clientId, swarmName)];
|
|
8102
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$k, clientId, swarmName)];
|
|
7643
8103
|
case 2:
|
|
7644
8104
|
_a.sent();
|
|
7645
8105
|
return [2 /*return*/];
|
|
@@ -7661,27 +8121,27 @@ var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void
|
|
|
7661
8121
|
switch (_a.label) {
|
|
7662
8122
|
case 0:
|
|
7663
8123
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7664
|
-
swarm.loggerService.log(METHOD_NAME$j, {
|
|
8124
|
+
swarm$1.loggerService.log(METHOD_NAME$j, {
|
|
7665
8125
|
clientId: clientId,
|
|
7666
8126
|
agentName: agentName,
|
|
7667
8127
|
});
|
|
7668
|
-
swarm.agentValidationService.validate(agentName, METHOD_NAME$j);
|
|
7669
|
-
swarm.sessionValidationService.validate(clientId, METHOD_NAME$j);
|
|
7670
|
-
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7671
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$j);
|
|
7672
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(METHOD_NAME$j, clientId, swarmName)];
|
|
8128
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$j);
|
|
8129
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$j);
|
|
8130
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8131
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$j);
|
|
8132
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$j, clientId, swarmName)];
|
|
7673
8133
|
case 1:
|
|
7674
8134
|
currentAgentName = _a.sent();
|
|
7675
8135
|
if (currentAgentName !== agentName) {
|
|
7676
8136
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7677
|
-
swarm.loggerService.log('function "commitFlush" skipped due to the agent change', {
|
|
8137
|
+
swarm$1.loggerService.log('function "commitFlush" skipped due to the agent change', {
|
|
7678
8138
|
currentAgentName: currentAgentName,
|
|
7679
8139
|
agentName: agentName,
|
|
7680
8140
|
clientId: clientId,
|
|
7681
8141
|
});
|
|
7682
8142
|
return [2 /*return*/];
|
|
7683
8143
|
}
|
|
7684
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitFlush(METHOD_NAME$j, clientId, swarmName)];
|
|
8144
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitFlush(METHOD_NAME$j, clientId, swarmName)];
|
|
7685
8145
|
case 2:
|
|
7686
8146
|
_a.sent();
|
|
7687
8147
|
return [2 /*return*/];
|
|
@@ -7706,22 +8166,22 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
|
|
|
7706
8166
|
case 0:
|
|
7707
8167
|
executionId = functoolsKit.randomString();
|
|
7708
8168
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7709
|
-
swarm.loggerService.log(METHOD_NAME$i, {
|
|
8169
|
+
swarm$1.loggerService.log(METHOD_NAME$i, {
|
|
7710
8170
|
content: content,
|
|
7711
8171
|
clientId: clientId,
|
|
7712
8172
|
agentName: agentName,
|
|
7713
8173
|
executionId: executionId,
|
|
7714
8174
|
});
|
|
7715
|
-
swarm.agentValidationService.validate(agentName, METHOD_NAME$i);
|
|
7716
|
-
swarm.sessionValidationService.validate(clientId, METHOD_NAME$i);
|
|
7717
|
-
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7718
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$i);
|
|
7719
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(METHOD_NAME$i, clientId, swarmName)];
|
|
8175
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$i);
|
|
8176
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$i);
|
|
8177
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8178
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$i);
|
|
8179
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$i, clientId, swarmName)];
|
|
7720
8180
|
case 1:
|
|
7721
8181
|
currentAgentName = _a.sent();
|
|
7722
8182
|
if (currentAgentName !== agentName) {
|
|
7723
8183
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7724
|
-
swarm.loggerService.log('function "execute" skipped due to the agent change', {
|
|
8184
|
+
swarm$1.loggerService.log('function "execute" skipped due to the agent change', {
|
|
7725
8185
|
currentAgentName: currentAgentName,
|
|
7726
8186
|
agentName: agentName,
|
|
7727
8187
|
clientId: clientId,
|
|
@@ -7731,7 +8191,7 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
|
|
|
7731
8191
|
return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
7732
8192
|
return __generator(this, function (_a) {
|
|
7733
8193
|
switch (_a.label) {
|
|
7734
|
-
case 0: return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", METHOD_NAME$i, clientId, swarmName)];
|
|
8194
|
+
case 0: return [4 /*yield*/, swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$i, clientId, swarmName)];
|
|
7735
8195
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7736
8196
|
}
|
|
7737
8197
|
});
|
|
@@ -7760,31 +8220,31 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
|
|
|
7760
8220
|
switch (_a.label) {
|
|
7761
8221
|
case 0:
|
|
7762
8222
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7763
|
-
swarm.loggerService.log(METHOD_NAME$h, {
|
|
8223
|
+
swarm$1.loggerService.log(METHOD_NAME$h, {
|
|
7764
8224
|
content: content,
|
|
7765
8225
|
clientId: clientId,
|
|
7766
8226
|
agentName: agentName,
|
|
7767
8227
|
});
|
|
7768
|
-
if (swarm.sessionValidationService.getSessionMode(clientId) !== "makeConnection") {
|
|
8228
|
+
if (swarm$1.sessionValidationService.getSessionMode(clientId) !== "makeConnection") {
|
|
7769
8229
|
throw new Error("agent-swarm-kit emit session is not makeConnection clientId=".concat(clientId));
|
|
7770
8230
|
}
|
|
7771
|
-
swarm.agentValidationService.validate(agentName, METHOD_NAME$h);
|
|
7772
|
-
swarm.sessionValidationService.validate(clientId, METHOD_NAME$h);
|
|
7773
|
-
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7774
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$h);
|
|
7775
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(METHOD_NAME$h, clientId, swarmName)];
|
|
8231
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$h);
|
|
8232
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$h);
|
|
8233
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8234
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$h);
|
|
8235
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$h, clientId, swarmName)];
|
|
7776
8236
|
case 1:
|
|
7777
8237
|
currentAgentName = _a.sent();
|
|
7778
8238
|
if (currentAgentName !== agentName) {
|
|
7779
8239
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7780
|
-
swarm.loggerService.log('function "emit" skipped due to the agent change', {
|
|
8240
|
+
swarm$1.loggerService.log('function "emit" skipped due to the agent change', {
|
|
7781
8241
|
currentAgentName: currentAgentName,
|
|
7782
8242
|
agentName: agentName,
|
|
7783
8243
|
clientId: clientId,
|
|
7784
8244
|
});
|
|
7785
8245
|
return [2 /*return*/];
|
|
7786
8246
|
}
|
|
7787
|
-
return [4 /*yield*/, swarm.sessionPublicService.emit(content, METHOD_NAME$h, clientId, swarmName)];
|
|
8247
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.emit(content, METHOD_NAME$h, clientId, swarmName)];
|
|
7788
8248
|
case 2: return [2 /*return*/, _a.sent()];
|
|
7789
8249
|
}
|
|
7790
8250
|
});
|
|
@@ -7804,15 +8264,15 @@ var commitToolOutputForce = function (toolId, content, clientId) { return __awai
|
|
|
7804
8264
|
switch (_a.label) {
|
|
7805
8265
|
case 0:
|
|
7806
8266
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7807
|
-
swarm.loggerService.log(METHOD_NAME$g, {
|
|
8267
|
+
swarm$1.loggerService.log(METHOD_NAME$g, {
|
|
7808
8268
|
toolId: toolId,
|
|
7809
8269
|
content: content,
|
|
7810
8270
|
clientId: clientId,
|
|
7811
8271
|
});
|
|
7812
|
-
swarm.sessionValidationService.validate(clientId, METHOD_NAME$g);
|
|
7813
|
-
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7814
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$g);
|
|
7815
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$g, clientId, swarmName)];
|
|
8272
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$g);
|
|
8273
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8274
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$g);
|
|
8275
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$g, clientId, swarmName)];
|
|
7816
8276
|
case 1:
|
|
7817
8277
|
_a.sent();
|
|
7818
8278
|
return [2 /*return*/];
|
|
@@ -7834,14 +8294,14 @@ var commitSystemMessageForce = function (content, clientId) { return __awaiter(v
|
|
|
7834
8294
|
switch (_a.label) {
|
|
7835
8295
|
case 0:
|
|
7836
8296
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7837
|
-
swarm.loggerService.log(METHOD_NAME$f, {
|
|
8297
|
+
swarm$1.loggerService.log(METHOD_NAME$f, {
|
|
7838
8298
|
content: content,
|
|
7839
8299
|
clientId: clientId,
|
|
7840
8300
|
});
|
|
7841
|
-
swarm.sessionValidationService.validate(clientId, METHOD_NAME$f);
|
|
7842
|
-
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7843
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$f);
|
|
7844
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, METHOD_NAME$f, clientId, swarmName)];
|
|
8301
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$f);
|
|
8302
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8303
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$f);
|
|
8304
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$f, clientId, swarmName)];
|
|
7845
8305
|
case 1:
|
|
7846
8306
|
_a.sent();
|
|
7847
8307
|
return [2 /*return*/];
|
|
@@ -7862,14 +8322,14 @@ var commitFlushForce = function (clientId) { return __awaiter(void 0, void 0, vo
|
|
|
7862
8322
|
switch (_a.label) {
|
|
7863
8323
|
case 0:
|
|
7864
8324
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7865
|
-
swarm.loggerService.log(METHOD_NAME$e, {
|
|
8325
|
+
swarm$1.loggerService.log(METHOD_NAME$e, {
|
|
7866
8326
|
clientId: clientId,
|
|
7867
8327
|
METHOD_NAME: METHOD_NAME$e,
|
|
7868
8328
|
});
|
|
7869
|
-
swarm.sessionValidationService.validate(clientId, METHOD_NAME$e);
|
|
7870
|
-
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7871
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$e);
|
|
7872
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitFlush(METHOD_NAME$e, clientId, swarmName)];
|
|
8329
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$e);
|
|
8330
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8331
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$e);
|
|
8332
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitFlush(METHOD_NAME$e, clientId, swarmName)];
|
|
7873
8333
|
case 1:
|
|
7874
8334
|
_a.sent();
|
|
7875
8335
|
return [2 /*return*/];
|
|
@@ -7891,14 +8351,14 @@ var commitUserMessageForce = function (content, clientId) { return __awaiter(voi
|
|
|
7891
8351
|
switch (_a.label) {
|
|
7892
8352
|
case 0:
|
|
7893
8353
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7894
|
-
swarm.loggerService.log(METHOD_NAME$d, {
|
|
8354
|
+
swarm$1.loggerService.log(METHOD_NAME$d, {
|
|
7895
8355
|
content: content,
|
|
7896
8356
|
clientId: clientId,
|
|
7897
8357
|
});
|
|
7898
|
-
swarm.sessionValidationService.validate(clientId, METHOD_NAME$d);
|
|
7899
|
-
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7900
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$d);
|
|
7901
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, METHOD_NAME$d, clientId, swarmName)];
|
|
8358
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$d);
|
|
8359
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8360
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$d);
|
|
8361
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$d, clientId, swarmName)];
|
|
7902
8362
|
case 1:
|
|
7903
8363
|
_a.sent();
|
|
7904
8364
|
return [2 /*return*/];
|
|
@@ -7923,17 +8383,17 @@ var emitForce = function (content, clientId) { return __awaiter(void 0, void 0,
|
|
|
7923
8383
|
switch (_a.label) {
|
|
7924
8384
|
case 0:
|
|
7925
8385
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7926
|
-
swarm.loggerService.log(METHOD_NAME$c, {
|
|
8386
|
+
swarm$1.loggerService.log(METHOD_NAME$c, {
|
|
7927
8387
|
content: content,
|
|
7928
8388
|
clientId: clientId,
|
|
7929
8389
|
});
|
|
7930
|
-
if (swarm.sessionValidationService.getSessionMode(clientId) !== "makeConnection") {
|
|
8390
|
+
if (swarm$1.sessionValidationService.getSessionMode(clientId) !== "makeConnection") {
|
|
7931
8391
|
throw new Error("agent-swarm-kit emitForce session is not makeConnection clientId=".concat(clientId));
|
|
7932
8392
|
}
|
|
7933
|
-
swarm.sessionValidationService.validate(clientId, METHOD_NAME$c);
|
|
7934
|
-
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7935
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$c);
|
|
7936
|
-
return [4 /*yield*/, swarm.sessionPublicService.emit(content, METHOD_NAME$c, clientId, swarmName)];
|
|
8393
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$c);
|
|
8394
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8395
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$c);
|
|
8396
|
+
return [4 /*yield*/, swarm$1.sessionPublicService.emit(content, METHOD_NAME$c, clientId, swarmName)];
|
|
7937
8397
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7938
8398
|
}
|
|
7939
8399
|
});
|
|
@@ -7955,18 +8415,18 @@ var executeForce = function (content, clientId) { return __awaiter(void 0, void
|
|
|
7955
8415
|
return __generator(this, function (_a) {
|
|
7956
8416
|
executionId = functoolsKit.randomString();
|
|
7957
8417
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7958
|
-
swarm.loggerService.log(METHOD_NAME$b, {
|
|
8418
|
+
swarm$1.loggerService.log(METHOD_NAME$b, {
|
|
7959
8419
|
content: content,
|
|
7960
8420
|
clientId: clientId,
|
|
7961
8421
|
executionId: executionId,
|
|
7962
8422
|
});
|
|
7963
|
-
swarm.sessionValidationService.validate(clientId, METHOD_NAME$b);
|
|
7964
|
-
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7965
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$b);
|
|
8423
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$b);
|
|
8424
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8425
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$b);
|
|
7966
8426
|
return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
7967
8427
|
return __generator(this, function (_a) {
|
|
7968
8428
|
switch (_a.label) {
|
|
7969
|
-
case 0: return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", METHOD_NAME$b, clientId, swarmName)];
|
|
8429
|
+
case 0: return [4 /*yield*/, swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$b, clientId, swarmName)];
|
|
7970
8430
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7971
8431
|
}
|
|
7972
8432
|
});
|
|
@@ -7990,7 +8450,7 @@ var validateClientId$d = function (clientId) {
|
|
|
7990
8450
|
if (clientId === "*") {
|
|
7991
8451
|
return;
|
|
7992
8452
|
}
|
|
7993
|
-
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8453
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
7994
8454
|
throw new Error("agent-swarm listenEvent session not found for clientId=".concat(clientId));
|
|
7995
8455
|
}
|
|
7996
8456
|
};
|
|
@@ -8003,14 +8463,14 @@ var validateClientId$d = function (clientId) {
|
|
|
8003
8463
|
*/
|
|
8004
8464
|
var listenEvent = function (clientId, topicName, fn) {
|
|
8005
8465
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8006
|
-
swarm.loggerService.log(METHOD_NAME$a, {
|
|
8466
|
+
swarm$1.loggerService.log(METHOD_NAME$a, {
|
|
8007
8467
|
clientId: clientId,
|
|
8008
8468
|
});
|
|
8009
8469
|
if (DISALLOWED_EVENT_SOURCE_LIST$2.has(topicName)) {
|
|
8010
8470
|
throw new Error("agent-swarm listenEvent topic is reserved topicName=".concat(topicName));
|
|
8011
8471
|
}
|
|
8012
8472
|
validateClientId$d(clientId);
|
|
8013
|
-
return swarm.busService.subscribe(clientId, topicName, function (_a) {
|
|
8473
|
+
return swarm$1.busService.subscribe(clientId, topicName, function (_a) {
|
|
8014
8474
|
var payload = _a.payload;
|
|
8015
8475
|
return fn(payload);
|
|
8016
8476
|
});
|
|
@@ -8029,7 +8489,7 @@ var validateClientId$c = function (clientId) {
|
|
|
8029
8489
|
if (clientId === "*") {
|
|
8030
8490
|
return;
|
|
8031
8491
|
}
|
|
8032
|
-
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8492
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
8033
8493
|
throw new Error("agent-swarm listenEventOnce session not found for clientId=".concat(clientId));
|
|
8034
8494
|
}
|
|
8035
8495
|
};
|
|
@@ -8042,14 +8502,14 @@ var validateClientId$c = function (clientId) {
|
|
|
8042
8502
|
*/
|
|
8043
8503
|
var listenEventOnce = function (clientId, topicName, filterFn, fn) {
|
|
8044
8504
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8045
|
-
swarm.loggerService.log(METHOD_NAME$9, {
|
|
8505
|
+
swarm$1.loggerService.log(METHOD_NAME$9, {
|
|
8046
8506
|
clientId: clientId,
|
|
8047
8507
|
});
|
|
8048
8508
|
if (DISALLOWED_EVENT_SOURCE_LIST$1.has(topicName)) {
|
|
8049
8509
|
throw new Error("agent-swarm listenEventOnce topic is reserved topicName=".concat(topicName));
|
|
8050
8510
|
}
|
|
8051
8511
|
validateClientId$c(clientId);
|
|
8052
|
-
return swarm.busService.once(clientId, topicName, function (_a) {
|
|
8512
|
+
return swarm$1.busService.once(clientId, topicName, function (_a) {
|
|
8053
8513
|
var payload = _a.payload;
|
|
8054
8514
|
return filterFn(payload);
|
|
8055
8515
|
}, function (_a) {
|
|
@@ -8071,7 +8531,7 @@ var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0,
|
|
|
8071
8531
|
switch (_a.label) {
|
|
8072
8532
|
case 0:
|
|
8073
8533
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8074
|
-
swarm.loggerService.log(METHOD_NAME$8, {
|
|
8534
|
+
swarm$1.loggerService.log(METHOD_NAME$8, {
|
|
8075
8535
|
clientId: clientId,
|
|
8076
8536
|
});
|
|
8077
8537
|
return [4 /*yield*/, getRawHistory(clientId, METHOD_NAME$8)];
|
|
@@ -8099,7 +8559,7 @@ var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
8099
8559
|
switch (_a.label) {
|
|
8100
8560
|
case 0:
|
|
8101
8561
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8102
|
-
swarm.loggerService.log(METHOD_NAME$7, {
|
|
8562
|
+
swarm$1.loggerService.log(METHOD_NAME$7, {
|
|
8103
8563
|
clientId: clientId,
|
|
8104
8564
|
});
|
|
8105
8565
|
return [4 /*yield*/, getRawHistory(clientId, METHOD_NAME$7)];
|
|
@@ -8126,7 +8586,7 @@ var getAssistantHistory = function (clientId) { return __awaiter(void 0, void 0,
|
|
|
8126
8586
|
switch (_a.label) {
|
|
8127
8587
|
case 0:
|
|
8128
8588
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8129
|
-
swarm.loggerService.log(METHOD_NAME$6, {
|
|
8589
|
+
swarm$1.loggerService.log(METHOD_NAME$6, {
|
|
8130
8590
|
clientId: clientId,
|
|
8131
8591
|
});
|
|
8132
8592
|
return [4 /*yield*/, getRawHistory(clientId, METHOD_NAME$6)];
|
|
@@ -8153,7 +8613,7 @@ var getLastAssistantMessage = function (clientId) { return __awaiter(void 0, voi
|
|
|
8153
8613
|
switch (_a.label) {
|
|
8154
8614
|
case 0:
|
|
8155
8615
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8156
|
-
swarm.loggerService.log(METHOD_NAME$5, {
|
|
8616
|
+
swarm$1.loggerService.log(METHOD_NAME$5, {
|
|
8157
8617
|
clientId: clientId,
|
|
8158
8618
|
});
|
|
8159
8619
|
return [4 /*yield*/, getRawHistory(clientId, METHOD_NAME$5)];
|
|
@@ -8181,7 +8641,7 @@ var getLastSystemMessage = function (clientId) { return __awaiter(void 0, void 0
|
|
|
8181
8641
|
switch (_a.label) {
|
|
8182
8642
|
case 0:
|
|
8183
8643
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8184
|
-
swarm.loggerService.log(METHOD_NAME$4, {
|
|
8644
|
+
swarm$1.loggerService.log(METHOD_NAME$4, {
|
|
8185
8645
|
clientId: clientId,
|
|
8186
8646
|
});
|
|
8187
8647
|
return [4 /*yield*/, getRawHistory(clientId, METHOD_NAME$4)];
|
|
@@ -8209,7 +8669,7 @@ var DEFAULT_TIMEOUT = 15 * 60;
|
|
|
8209
8669
|
var makeAutoDispose = function (clientId, swarmName, _a) {
|
|
8210
8670
|
var _b = _a === void 0 ? {} : _a, _c = _b.timeoutSeconds, timeoutSeconds = _c === void 0 ? DEFAULT_TIMEOUT : _c, onDestroy = _b.onDestroy;
|
|
8211
8671
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8212
|
-
swarm.loggerService.log(METHOD_NAME$3, {
|
|
8672
|
+
swarm$1.loggerService.log(METHOD_NAME$3, {
|
|
8213
8673
|
clientId: clientId,
|
|
8214
8674
|
swarmName: swarmName,
|
|
8215
8675
|
});
|
|
@@ -8228,7 +8688,7 @@ var makeAutoDispose = function (clientId, swarmName, _a) {
|
|
|
8228
8688
|
switch (_a.label) {
|
|
8229
8689
|
case 0:
|
|
8230
8690
|
unSource();
|
|
8231
|
-
if (!swarm.sessionValidationService.hasSession(clientId)) return [3 /*break*/, 2];
|
|
8691
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) return [3 /*break*/, 2];
|
|
8232
8692
|
return [4 /*yield*/, disposeConnection(clientId, swarmName)];
|
|
8233
8693
|
case 1:
|
|
8234
8694
|
_a.sent();
|
|
@@ -8275,13 +8735,13 @@ var DISALLOWED_EVENT_SOURCE_LIST = new Set([
|
|
|
8275
8735
|
*/
|
|
8276
8736
|
var event = function (clientId, topicName, payload) {
|
|
8277
8737
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8278
|
-
swarm.loggerService.log(METHOD_NAME$2, {
|
|
8738
|
+
swarm$1.loggerService.log(METHOD_NAME$2, {
|
|
8279
8739
|
clientId: clientId,
|
|
8280
8740
|
});
|
|
8281
8741
|
if (DISALLOWED_EVENT_SOURCE_LIST.has(topicName)) {
|
|
8282
8742
|
throw new Error("agent-swarm event topic is reserved topicName=".concat(topicName));
|
|
8283
8743
|
}
|
|
8284
|
-
return swarm.busService.emit(clientId, {
|
|
8744
|
+
return swarm$1.busService.emit(clientId, {
|
|
8285
8745
|
source: topicName,
|
|
8286
8746
|
payload: payload,
|
|
8287
8747
|
clientId: clientId,
|
|
@@ -8302,27 +8762,27 @@ var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, voi
|
|
|
8302
8762
|
switch (_a.label) {
|
|
8303
8763
|
case 0:
|
|
8304
8764
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8305
|
-
swarm.loggerService.log(METHOD_NAME$1, {
|
|
8765
|
+
swarm$1.loggerService.log(METHOD_NAME$1, {
|
|
8306
8766
|
clientId: clientId,
|
|
8307
8767
|
agentName: agentName,
|
|
8308
8768
|
});
|
|
8309
|
-
swarm.agentValidationService.validate(agentName, METHOD_NAME$1);
|
|
8310
|
-
swarm.sessionValidationService.validate(clientId, METHOD_NAME$1);
|
|
8311
|
-
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
8312
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$1);
|
|
8313
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(METHOD_NAME$1, clientId, swarmName)];
|
|
8769
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$1);
|
|
8770
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$1);
|
|
8771
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8772
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$1);
|
|
8773
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$1, clientId, swarmName)];
|
|
8314
8774
|
case 1:
|
|
8315
8775
|
currentAgentName = _a.sent();
|
|
8316
8776
|
if (currentAgentName !== agentName) {
|
|
8317
8777
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8318
|
-
swarm.loggerService.log('function "cancelOutput" skipped due to the agent change', {
|
|
8778
|
+
swarm$1.loggerService.log('function "cancelOutput" skipped due to the agent change', {
|
|
8319
8779
|
currentAgentName: currentAgentName,
|
|
8320
8780
|
agentName: agentName,
|
|
8321
8781
|
clientId: clientId,
|
|
8322
8782
|
});
|
|
8323
8783
|
return [2 /*return*/];
|
|
8324
8784
|
}
|
|
8325
|
-
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(METHOD_NAME$1, clientId, swarmName)];
|
|
8785
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$1, clientId, swarmName)];
|
|
8326
8786
|
case 2:
|
|
8327
8787
|
_a.sent();
|
|
8328
8788
|
return [2 /*return*/];
|
|
@@ -8344,13 +8804,13 @@ var cancelOutputForce = function (clientId) { return __awaiter(void 0, void 0, v
|
|
|
8344
8804
|
switch (_a.label) {
|
|
8345
8805
|
case 0:
|
|
8346
8806
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8347
|
-
swarm.loggerService.log(METHOD_NAME, {
|
|
8807
|
+
swarm$1.loggerService.log(METHOD_NAME, {
|
|
8348
8808
|
clientId: clientId,
|
|
8349
8809
|
});
|
|
8350
|
-
swarm.sessionValidationService.validate(clientId, METHOD_NAME);
|
|
8351
|
-
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
8352
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME);
|
|
8353
|
-
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(METHOD_NAME, clientId, swarmName)];
|
|
8810
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME);
|
|
8811
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
8812
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME);
|
|
8813
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.cancelOutput(METHOD_NAME, clientId, swarmName)];
|
|
8354
8814
|
case 1:
|
|
8355
8815
|
_a.sent();
|
|
8356
8816
|
return [2 /*return*/];
|
|
@@ -8362,7 +8822,7 @@ var validateClientId$b = function (clientId) {
|
|
|
8362
8822
|
if (clientId === "*") {
|
|
8363
8823
|
return;
|
|
8364
8824
|
}
|
|
8365
|
-
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8825
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
8366
8826
|
throw new Error("agent-swarm listenAgentEvent session not found for clientId=".concat(clientId));
|
|
8367
8827
|
}
|
|
8368
8828
|
};
|
|
@@ -8373,18 +8833,18 @@ var validateClientId$b = function (clientId) {
|
|
|
8373
8833
|
* @param {function} fn - The callback function to handle the event.
|
|
8374
8834
|
*/
|
|
8375
8835
|
var listenAgentEvent = function (clientId, fn) {
|
|
8376
|
-
swarm.loggerService.log("middleware listenAgentEvent", {
|
|
8836
|
+
swarm$1.loggerService.log("middleware listenAgentEvent", {
|
|
8377
8837
|
clientId: clientId,
|
|
8378
8838
|
});
|
|
8379
8839
|
validateClientId$b(clientId);
|
|
8380
|
-
return swarm.busService.subscribe(clientId, "agent-bus", fn);
|
|
8840
|
+
return swarm$1.busService.subscribe(clientId, "agent-bus", fn);
|
|
8381
8841
|
};
|
|
8382
8842
|
|
|
8383
8843
|
var validateClientId$a = function (clientId) {
|
|
8384
8844
|
if (clientId === "*") {
|
|
8385
8845
|
return;
|
|
8386
8846
|
}
|
|
8387
|
-
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8847
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
8388
8848
|
throw new Error("agent-swarm listenHistoryEvent session not found for clientId=".concat(clientId));
|
|
8389
8849
|
}
|
|
8390
8850
|
};
|
|
@@ -8395,18 +8855,18 @@ var validateClientId$a = function (clientId) {
|
|
|
8395
8855
|
* @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
|
|
8396
8856
|
*/
|
|
8397
8857
|
var listenHistoryEvent = function (clientId, fn) {
|
|
8398
|
-
swarm.loggerService.log("middleware listenHistoryEvent", {
|
|
8858
|
+
swarm$1.loggerService.log("middleware listenHistoryEvent", {
|
|
8399
8859
|
clientId: clientId,
|
|
8400
8860
|
});
|
|
8401
8861
|
validateClientId$a(clientId);
|
|
8402
|
-
return swarm.busService.subscribe(clientId, "history-bus", fn);
|
|
8862
|
+
return swarm$1.busService.subscribe(clientId, "history-bus", fn);
|
|
8403
8863
|
};
|
|
8404
8864
|
|
|
8405
8865
|
var validateClientId$9 = function (clientId) {
|
|
8406
8866
|
if (clientId === "*") {
|
|
8407
8867
|
return;
|
|
8408
8868
|
}
|
|
8409
|
-
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8869
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
8410
8870
|
throw new Error("agent-swarm listenSessionEvent session not found for clientId=".concat(clientId));
|
|
8411
8871
|
}
|
|
8412
8872
|
};
|
|
@@ -8417,18 +8877,18 @@ var validateClientId$9 = function (clientId) {
|
|
|
8417
8877
|
* @param {function} fn - The callback function to handle the session events.
|
|
8418
8878
|
*/
|
|
8419
8879
|
var listenSessionEvent = function (clientId, fn) {
|
|
8420
|
-
swarm.loggerService.log("middleware listenSessionEvent", {
|
|
8880
|
+
swarm$1.loggerService.log("middleware listenSessionEvent", {
|
|
8421
8881
|
clientId: clientId,
|
|
8422
8882
|
});
|
|
8423
8883
|
validateClientId$9(clientId);
|
|
8424
|
-
return swarm.busService.subscribe(clientId, "session-bus", fn);
|
|
8884
|
+
return swarm$1.busService.subscribe(clientId, "session-bus", fn);
|
|
8425
8885
|
};
|
|
8426
8886
|
|
|
8427
8887
|
var validateClientId$8 = function (clientId) {
|
|
8428
8888
|
if (clientId === "*") {
|
|
8429
8889
|
return;
|
|
8430
8890
|
}
|
|
8431
|
-
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8891
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
8432
8892
|
throw new Error("agent-swarm listenStateEvent session not found for clientId=".concat(clientId));
|
|
8433
8893
|
}
|
|
8434
8894
|
};
|
|
@@ -8439,18 +8899,18 @@ var validateClientId$8 = function (clientId) {
|
|
|
8439
8899
|
* @param {function} fn - The callback function to handle the event.
|
|
8440
8900
|
*/
|
|
8441
8901
|
var listenStateEvent = function (clientId, fn) {
|
|
8442
|
-
swarm.loggerService.log("middleware listenStateEvent", {
|
|
8902
|
+
swarm$1.loggerService.log("middleware listenStateEvent", {
|
|
8443
8903
|
clientId: clientId,
|
|
8444
8904
|
});
|
|
8445
8905
|
validateClientId$8(clientId);
|
|
8446
|
-
return swarm.busService.subscribe(clientId, "state-bus", fn);
|
|
8906
|
+
return swarm$1.busService.subscribe(clientId, "state-bus", fn);
|
|
8447
8907
|
};
|
|
8448
8908
|
|
|
8449
8909
|
var validateClientId$7 = function (clientId) {
|
|
8450
8910
|
if (clientId === "*") {
|
|
8451
8911
|
return;
|
|
8452
8912
|
}
|
|
8453
|
-
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8913
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
8454
8914
|
throw new Error("agent-swarm listenStorageEvent session not found for clientId=".concat(clientId));
|
|
8455
8915
|
}
|
|
8456
8916
|
};
|
|
@@ -8461,18 +8921,18 @@ var validateClientId$7 = function (clientId) {
|
|
|
8461
8921
|
* @param {function} fn - The callback function to handle the storage event.
|
|
8462
8922
|
*/
|
|
8463
8923
|
var listenStorageEvent = function (clientId, fn) {
|
|
8464
|
-
swarm.loggerService.log("middleware listenStorageEvent", {
|
|
8924
|
+
swarm$1.loggerService.log("middleware listenStorageEvent", {
|
|
8465
8925
|
clientId: clientId,
|
|
8466
8926
|
});
|
|
8467
8927
|
validateClientId$7(clientId);
|
|
8468
|
-
return swarm.busService.subscribe(clientId, "storage-bus", fn);
|
|
8928
|
+
return swarm$1.busService.subscribe(clientId, "storage-bus", fn);
|
|
8469
8929
|
};
|
|
8470
8930
|
|
|
8471
8931
|
var validateClientId$6 = function (clientId) {
|
|
8472
8932
|
if (clientId === "*") {
|
|
8473
8933
|
return;
|
|
8474
8934
|
}
|
|
8475
|
-
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8935
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
8476
8936
|
throw new Error("agent-swarm listenSwarmEvent session not found for clientId=".concat(clientId));
|
|
8477
8937
|
}
|
|
8478
8938
|
};
|
|
@@ -8483,18 +8943,18 @@ var validateClientId$6 = function (clientId) {
|
|
|
8483
8943
|
* @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
|
|
8484
8944
|
*/
|
|
8485
8945
|
var listenSwarmEvent = function (clientId, fn) {
|
|
8486
|
-
swarm.loggerService.log("middleware listenSwarmEvent", {
|
|
8946
|
+
swarm$1.loggerService.log("middleware listenSwarmEvent", {
|
|
8487
8947
|
clientId: clientId,
|
|
8488
8948
|
});
|
|
8489
8949
|
validateClientId$6(clientId);
|
|
8490
|
-
return swarm.busService.subscribe(clientId, "swarm-bus", fn);
|
|
8950
|
+
return swarm$1.busService.subscribe(clientId, "swarm-bus", fn);
|
|
8491
8951
|
};
|
|
8492
8952
|
|
|
8493
8953
|
var validateClientId$5 = function (clientId) {
|
|
8494
8954
|
if (clientId === "*") {
|
|
8495
8955
|
return;
|
|
8496
8956
|
}
|
|
8497
|
-
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8957
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
8498
8958
|
throw new Error("agent-swarm listenAgentEventOnce session not found for clientId=".concat(clientId));
|
|
8499
8959
|
}
|
|
8500
8960
|
};
|
|
@@ -8505,18 +8965,18 @@ var validateClientId$5 = function (clientId) {
|
|
|
8505
8965
|
* @param {function} fn - The callback function to handle the event.
|
|
8506
8966
|
*/
|
|
8507
8967
|
var listenAgentEventOnce = function (clientId, filterFn, fn) {
|
|
8508
|
-
swarm.loggerService.log("middleware listenAgentEventOnce", {
|
|
8968
|
+
swarm$1.loggerService.log("middleware listenAgentEventOnce", {
|
|
8509
8969
|
clientId: clientId,
|
|
8510
8970
|
});
|
|
8511
8971
|
validateClientId$5(clientId);
|
|
8512
|
-
return swarm.busService.once(clientId, "agent-bus", filterFn, fn);
|
|
8972
|
+
return swarm$1.busService.once(clientId, "agent-bus", filterFn, fn);
|
|
8513
8973
|
};
|
|
8514
8974
|
|
|
8515
8975
|
var validateClientId$4 = function (clientId) {
|
|
8516
8976
|
if (clientId === "*") {
|
|
8517
8977
|
return;
|
|
8518
8978
|
}
|
|
8519
|
-
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8979
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
8520
8980
|
throw new Error("agent-swarm listenHistoryEventOnce session not found for clientId=".concat(clientId));
|
|
8521
8981
|
}
|
|
8522
8982
|
};
|
|
@@ -8527,18 +8987,18 @@ var validateClientId$4 = function (clientId) {
|
|
|
8527
8987
|
* @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
|
|
8528
8988
|
*/
|
|
8529
8989
|
var listenHistoryEventOnce = function (clientId, filterFn, fn) {
|
|
8530
|
-
swarm.loggerService.log("middleware listenHistoryEventOnce", {
|
|
8990
|
+
swarm$1.loggerService.log("middleware listenHistoryEventOnce", {
|
|
8531
8991
|
clientId: clientId,
|
|
8532
8992
|
});
|
|
8533
8993
|
validateClientId$4(clientId);
|
|
8534
|
-
return swarm.busService.once(clientId, "history-bus", filterFn, fn);
|
|
8994
|
+
return swarm$1.busService.once(clientId, "history-bus", filterFn, fn);
|
|
8535
8995
|
};
|
|
8536
8996
|
|
|
8537
8997
|
var validateClientId$3 = function (clientId) {
|
|
8538
8998
|
if (clientId === "*") {
|
|
8539
8999
|
return;
|
|
8540
9000
|
}
|
|
8541
|
-
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
9001
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
8542
9002
|
throw new Error("agent-swarm listenSessionEventOnce session not found for clientId=".concat(clientId));
|
|
8543
9003
|
}
|
|
8544
9004
|
};
|
|
@@ -8549,18 +9009,18 @@ var validateClientId$3 = function (clientId) {
|
|
|
8549
9009
|
* @param {function} fn - The callback function to handle the session events.
|
|
8550
9010
|
*/
|
|
8551
9011
|
var listenSessionEventOnce = function (clientId, filterFn, fn) {
|
|
8552
|
-
swarm.loggerService.log("middleware listenSessionEventOnce", {
|
|
9012
|
+
swarm$1.loggerService.log("middleware listenSessionEventOnce", {
|
|
8553
9013
|
clientId: clientId,
|
|
8554
9014
|
});
|
|
8555
9015
|
validateClientId$3(clientId);
|
|
8556
|
-
return swarm.busService.once(clientId, "session-bus", filterFn, fn);
|
|
9016
|
+
return swarm$1.busService.once(clientId, "session-bus", filterFn, fn);
|
|
8557
9017
|
};
|
|
8558
9018
|
|
|
8559
9019
|
var validateClientId$2 = function (clientId) {
|
|
8560
9020
|
if (clientId === "*") {
|
|
8561
9021
|
return;
|
|
8562
9022
|
}
|
|
8563
|
-
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
9023
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
8564
9024
|
throw new Error("agent-swarm listenStateEventOnce session not found for clientId=".concat(clientId));
|
|
8565
9025
|
}
|
|
8566
9026
|
};
|
|
@@ -8571,18 +9031,18 @@ var validateClientId$2 = function (clientId) {
|
|
|
8571
9031
|
* @param {function} fn - The callback function to handle the event.
|
|
8572
9032
|
*/
|
|
8573
9033
|
var listenStateEventOnce = function (clientId, filterFn, fn) {
|
|
8574
|
-
swarm.loggerService.log("middleware listenStateEventOnce", {
|
|
9034
|
+
swarm$1.loggerService.log("middleware listenStateEventOnce", {
|
|
8575
9035
|
clientId: clientId,
|
|
8576
9036
|
});
|
|
8577
9037
|
validateClientId$2(clientId);
|
|
8578
|
-
return swarm.busService.once(clientId, "state-bus", filterFn, fn);
|
|
9038
|
+
return swarm$1.busService.once(clientId, "state-bus", filterFn, fn);
|
|
8579
9039
|
};
|
|
8580
9040
|
|
|
8581
9041
|
var validateClientId$1 = function (clientId) {
|
|
8582
9042
|
if (clientId === "*") {
|
|
8583
9043
|
return;
|
|
8584
9044
|
}
|
|
8585
|
-
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
9045
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
8586
9046
|
throw new Error("agent-swarm listenStorageEventOnce session not found for clientId=".concat(clientId));
|
|
8587
9047
|
}
|
|
8588
9048
|
};
|
|
@@ -8593,18 +9053,18 @@ var validateClientId$1 = function (clientId) {
|
|
|
8593
9053
|
* @param {function} fn - The callback function to handle the storage event.
|
|
8594
9054
|
*/
|
|
8595
9055
|
var listenStorageEventOnce = function (clientId, filterFn, fn) {
|
|
8596
|
-
swarm.loggerService.log("middleware listenStorageEventOnce", {
|
|
9056
|
+
swarm$1.loggerService.log("middleware listenStorageEventOnce", {
|
|
8597
9057
|
clientId: clientId,
|
|
8598
9058
|
});
|
|
8599
9059
|
validateClientId$1(clientId);
|
|
8600
|
-
return swarm.busService.once(clientId, "storage-bus", filterFn, fn);
|
|
9060
|
+
return swarm$1.busService.once(clientId, "storage-bus", filterFn, fn);
|
|
8601
9061
|
};
|
|
8602
9062
|
|
|
8603
9063
|
var validateClientId = function (clientId) {
|
|
8604
9064
|
if (clientId === "*") {
|
|
8605
9065
|
return;
|
|
8606
9066
|
}
|
|
8607
|
-
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
9067
|
+
if (!swarm$1.sessionValidationService.hasSession(clientId)) {
|
|
8608
9068
|
throw new Error("agent-swarm listenSwarmEventOnce session not found for clientId=".concat(clientId));
|
|
8609
9069
|
}
|
|
8610
9070
|
};
|
|
@@ -8615,11 +9075,11 @@ var validateClientId = function (clientId) {
|
|
|
8615
9075
|
* @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
|
|
8616
9076
|
*/
|
|
8617
9077
|
var listenSwarmEventOnce = function (clientId, filterFn, fn) {
|
|
8618
|
-
swarm.loggerService.log("middleware listenSwarmEventOnce", {
|
|
9078
|
+
swarm$1.loggerService.log("middleware listenSwarmEventOnce", {
|
|
8619
9079
|
clientId: clientId,
|
|
8620
9080
|
});
|
|
8621
9081
|
validateClientId(clientId);
|
|
8622
|
-
return swarm.busService.once(clientId, "swarm-bus", filterFn, fn);
|
|
9082
|
+
return swarm$1.busService.once(clientId, "swarm-bus", filterFn, fn);
|
|
8623
9083
|
};
|
|
8624
9084
|
|
|
8625
9085
|
var METHOD_NAME_TAKE = "StorageUtils.take";
|
|
@@ -8646,18 +9106,18 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8646
9106
|
switch (_a.label) {
|
|
8647
9107
|
case 0:
|
|
8648
9108
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8649
|
-
swarm.loggerService.log(METHOD_NAME_TAKE, {
|
|
9109
|
+
swarm$1.loggerService.log(METHOD_NAME_TAKE, {
|
|
8650
9110
|
search: payload.search,
|
|
8651
9111
|
total: payload.total,
|
|
8652
9112
|
clientId: payload.clientId,
|
|
8653
9113
|
storageName: payload.storageName,
|
|
8654
9114
|
score: payload.score,
|
|
8655
9115
|
});
|
|
8656
|
-
swarm.storageValidationService.validate(payload.storageName, METHOD_NAME_TAKE);
|
|
8657
|
-
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
9116
|
+
swarm$1.storageValidationService.validate(payload.storageName, METHOD_NAME_TAKE);
|
|
9117
|
+
if (!swarm$1.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8658
9118
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (take)"));
|
|
8659
9119
|
}
|
|
8660
|
-
return [4 /*yield*/, swarm.storagePublicService.take(payload.search, payload.total, METHOD_NAME_TAKE, payload.clientId, payload.storageName, payload.score)];
|
|
9120
|
+
return [4 /*yield*/, swarm$1.storagePublicService.take(payload.search, payload.total, METHOD_NAME_TAKE, payload.clientId, payload.storageName, payload.score)];
|
|
8661
9121
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
8662
9122
|
}
|
|
8663
9123
|
});
|
|
@@ -8676,16 +9136,16 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8676
9136
|
switch (_a.label) {
|
|
8677
9137
|
case 0:
|
|
8678
9138
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8679
|
-
swarm.loggerService.log(METHOD_NAME_UPSERT, {
|
|
9139
|
+
swarm$1.loggerService.log(METHOD_NAME_UPSERT, {
|
|
8680
9140
|
item: payload.item,
|
|
8681
9141
|
clientId: payload.clientId,
|
|
8682
9142
|
storageName: payload.storageName,
|
|
8683
9143
|
});
|
|
8684
|
-
swarm.storageValidationService.validate(payload.storageName, METHOD_NAME_UPSERT);
|
|
8685
|
-
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
9144
|
+
swarm$1.storageValidationService.validate(payload.storageName, METHOD_NAME_UPSERT);
|
|
9145
|
+
if (!swarm$1.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8686
9146
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (upsert)"));
|
|
8687
9147
|
}
|
|
8688
|
-
return [4 /*yield*/, swarm.storagePublicService.upsert(payload.item, METHOD_NAME_UPSERT, payload.clientId, payload.storageName)];
|
|
9148
|
+
return [4 /*yield*/, swarm$1.storagePublicService.upsert(payload.item, METHOD_NAME_UPSERT, payload.clientId, payload.storageName)];
|
|
8689
9149
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8690
9150
|
}
|
|
8691
9151
|
});
|
|
@@ -8703,16 +9163,16 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8703
9163
|
switch (_a.label) {
|
|
8704
9164
|
case 0:
|
|
8705
9165
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8706
|
-
swarm.loggerService.log(METHOD_NAME_REMOVE, {
|
|
9166
|
+
swarm$1.loggerService.log(METHOD_NAME_REMOVE, {
|
|
8707
9167
|
itemId: payload.itemId,
|
|
8708
9168
|
clientId: payload.clientId,
|
|
8709
9169
|
storageName: payload.storageName,
|
|
8710
9170
|
});
|
|
8711
|
-
swarm.storageValidationService.validate(payload.storageName, METHOD_NAME_REMOVE);
|
|
8712
|
-
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
9171
|
+
swarm$1.storageValidationService.validate(payload.storageName, METHOD_NAME_REMOVE);
|
|
9172
|
+
if (!swarm$1.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8713
9173
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (remove)"));
|
|
8714
9174
|
}
|
|
8715
|
-
return [4 /*yield*/, swarm.storagePublicService.remove(payload.itemId, METHOD_NAME_REMOVE, payload.clientId, payload.storageName)];
|
|
9175
|
+
return [4 /*yield*/, swarm$1.storagePublicService.remove(payload.itemId, METHOD_NAME_REMOVE, payload.clientId, payload.storageName)];
|
|
8716
9176
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8717
9177
|
}
|
|
8718
9178
|
});
|
|
@@ -8731,16 +9191,16 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8731
9191
|
switch (_a.label) {
|
|
8732
9192
|
case 0:
|
|
8733
9193
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8734
|
-
swarm.loggerService.log(METHOD_NAME_GET$1, {
|
|
9194
|
+
swarm$1.loggerService.log(METHOD_NAME_GET$1, {
|
|
8735
9195
|
itemId: payload.itemId,
|
|
8736
9196
|
clientId: payload.clientId,
|
|
8737
9197
|
storageName: payload.storageName,
|
|
8738
9198
|
});
|
|
8739
|
-
swarm.storageValidationService.validate(payload.storageName, METHOD_NAME_GET$1);
|
|
8740
|
-
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
9199
|
+
swarm$1.storageValidationService.validate(payload.storageName, METHOD_NAME_GET$1);
|
|
9200
|
+
if (!swarm$1.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8741
9201
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (get)"));
|
|
8742
9202
|
}
|
|
8743
|
-
return [4 /*yield*/, swarm.storagePublicService.get(payload.itemId, METHOD_NAME_GET$1, payload.clientId, payload.storageName)];
|
|
9203
|
+
return [4 /*yield*/, swarm$1.storagePublicService.get(payload.itemId, METHOD_NAME_GET$1, payload.clientId, payload.storageName)];
|
|
8744
9204
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
8745
9205
|
}
|
|
8746
9206
|
});
|
|
@@ -8759,15 +9219,15 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8759
9219
|
switch (_a.label) {
|
|
8760
9220
|
case 0:
|
|
8761
9221
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8762
|
-
swarm.loggerService.log(METHOD_NAME_LIST, {
|
|
9222
|
+
swarm$1.loggerService.log(METHOD_NAME_LIST, {
|
|
8763
9223
|
clientId: payload.clientId,
|
|
8764
9224
|
storageName: payload.storageName,
|
|
8765
9225
|
});
|
|
8766
|
-
swarm.storageValidationService.validate(payload.storageName, METHOD_NAME_LIST);
|
|
8767
|
-
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
9226
|
+
swarm$1.storageValidationService.validate(payload.storageName, METHOD_NAME_LIST);
|
|
9227
|
+
if (!swarm$1.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8768
9228
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (list)"));
|
|
8769
9229
|
}
|
|
8770
|
-
return [4 /*yield*/, swarm.storagePublicService.list(METHOD_NAME_LIST, payload.clientId, payload.storageName, payload.filter)];
|
|
9230
|
+
return [4 /*yield*/, swarm$1.storagePublicService.list(METHOD_NAME_LIST, payload.clientId, payload.storageName, payload.filter)];
|
|
8771
9231
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
8772
9232
|
}
|
|
8773
9233
|
});
|
|
@@ -8784,15 +9244,15 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8784
9244
|
switch (_a.label) {
|
|
8785
9245
|
case 0:
|
|
8786
9246
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8787
|
-
swarm.loggerService.log(METHOD_NAME_CLEAR, {
|
|
9247
|
+
swarm$1.loggerService.log(METHOD_NAME_CLEAR, {
|
|
8788
9248
|
clientId: payload.clientId,
|
|
8789
9249
|
storageName: payload.storageName,
|
|
8790
9250
|
});
|
|
8791
|
-
swarm.storageValidationService.validate(payload.storageName, METHOD_NAME_CLEAR);
|
|
8792
|
-
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
9251
|
+
swarm$1.storageValidationService.validate(payload.storageName, METHOD_NAME_CLEAR);
|
|
9252
|
+
if (!swarm$1.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8793
9253
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (clear)"));
|
|
8794
9254
|
}
|
|
8795
|
-
return [4 /*yield*/, swarm.storagePublicService.clear(METHOD_NAME_CLEAR, payload.clientId, payload.storageName)];
|
|
9255
|
+
return [4 /*yield*/, swarm$1.storagePublicService.clear(METHOD_NAME_CLEAR, payload.clientId, payload.storageName)];
|
|
8796
9256
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8797
9257
|
}
|
|
8798
9258
|
});
|
|
@@ -8826,14 +9286,14 @@ var StateUtils = /** @class */ (function () {
|
|
|
8826
9286
|
switch (_a.label) {
|
|
8827
9287
|
case 0:
|
|
8828
9288
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8829
|
-
swarm.loggerService.log(METHOD_NAME_GET, {
|
|
9289
|
+
swarm$1.loggerService.log(METHOD_NAME_GET, {
|
|
8830
9290
|
clientId: payload.clientId,
|
|
8831
9291
|
stateName: payload.stateName,
|
|
8832
9292
|
});
|
|
8833
|
-
if (!swarm.agentValidationService.hasState(payload.agentName, payload.stateName)) {
|
|
9293
|
+
if (!swarm$1.agentValidationService.hasState(payload.agentName, payload.stateName)) {
|
|
8834
9294
|
throw new Error("agent-swarm StateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (getState)"));
|
|
8835
9295
|
}
|
|
8836
|
-
return [4 /*yield*/, swarm.statePublicService.getState(METHOD_NAME_GET, payload.clientId, payload.stateName)];
|
|
9296
|
+
return [4 /*yield*/, swarm$1.statePublicService.getState(METHOD_NAME_GET, payload.clientId, payload.stateName)];
|
|
8837
9297
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8838
9298
|
}
|
|
8839
9299
|
});
|
|
@@ -8855,17 +9315,17 @@ var StateUtils = /** @class */ (function () {
|
|
|
8855
9315
|
switch (_a.label) {
|
|
8856
9316
|
case 0:
|
|
8857
9317
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8858
|
-
swarm.loggerService.log(METHOD_NAME_SET, {
|
|
9318
|
+
swarm$1.loggerService.log(METHOD_NAME_SET, {
|
|
8859
9319
|
clientId: payload.clientId,
|
|
8860
9320
|
stateName: payload.stateName,
|
|
8861
9321
|
});
|
|
8862
|
-
if (!swarm.agentValidationService.hasState(payload.agentName, payload.stateName)) {
|
|
9322
|
+
if (!swarm$1.agentValidationService.hasState(payload.agentName, payload.stateName)) {
|
|
8863
9323
|
throw new Error("agent-swarm StateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (setState)"));
|
|
8864
9324
|
}
|
|
8865
9325
|
if (!(typeof dispatchFn === "function")) return [3 /*break*/, 2];
|
|
8866
|
-
return [4 /*yield*/, swarm.statePublicService.setState(dispatchFn, METHOD_NAME_SET, payload.clientId, payload.stateName)];
|
|
9326
|
+
return [4 /*yield*/, swarm$1.statePublicService.setState(dispatchFn, METHOD_NAME_SET, payload.clientId, payload.stateName)];
|
|
8867
9327
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8868
|
-
case 2: return [4 /*yield*/, swarm.statePublicService.setState(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
9328
|
+
case 2: return [4 /*yield*/, swarm$1.statePublicService.setState(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
8869
9329
|
return [2 /*return*/, dispatchFn];
|
|
8870
9330
|
}); }); }, METHOD_NAME_SET, payload.clientId, payload.stateName)];
|
|
8871
9331
|
case 3: return [2 /*return*/, _a.sent()];
|
|
@@ -8881,27 +9341,6 @@ var StateUtils = /** @class */ (function () {
|
|
|
8881
9341
|
*/
|
|
8882
9342
|
var State = new StateUtils();
|
|
8883
9343
|
|
|
8884
|
-
var METHOD_NAME_USE_LOGGER = "HistoryInstance.useLogger";
|
|
8885
|
-
var LoggerUtils = /** @class */ (function () {
|
|
8886
|
-
function LoggerUtils() {
|
|
8887
|
-
/**
|
|
8888
|
-
* Sets the provided logger to the logger service.
|
|
8889
|
-
* @param {ILogger} logger - The logger instance to be used.
|
|
8890
|
-
*/
|
|
8891
|
-
this.useLogger = function (logger) {
|
|
8892
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8893
|
-
swarm.loggerService.log(METHOD_NAME_USE_LOGGER);
|
|
8894
|
-
swarm.loggerService.setLogger(logger);
|
|
8895
|
-
};
|
|
8896
|
-
}
|
|
8897
|
-
return LoggerUtils;
|
|
8898
|
-
}());
|
|
8899
|
-
/**
|
|
8900
|
-
* Instance of LoggerUtils to be used for logging.
|
|
8901
|
-
* @type {LoggerUtils}
|
|
8902
|
-
*/
|
|
8903
|
-
var Logger = new LoggerUtils();
|
|
8904
|
-
|
|
8905
9344
|
/**
|
|
8906
9345
|
* Function that recursively flattens a nested object to array of entries.
|
|
8907
9346
|
*/
|
|
@@ -8951,7 +9390,7 @@ var SchemaUtils = /** @class */ (function () {
|
|
|
8951
9390
|
*/
|
|
8952
9391
|
this.serialize = function (data) {
|
|
8953
9392
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
8954
|
-
swarm.loggerService.log(METHOD_NAME_SERIALIZE, {
|
|
9393
|
+
swarm$1.loggerService.log(METHOD_NAME_SERIALIZE, {
|
|
8955
9394
|
data: data,
|
|
8956
9395
|
});
|
|
8957
9396
|
if (Array.isArray(data)) {
|
|
@@ -8994,6 +9433,8 @@ exports.History = History;
|
|
|
8994
9433
|
exports.HistoryAdapter = HistoryAdapter;
|
|
8995
9434
|
exports.HistoryInstance = HistoryInstance;
|
|
8996
9435
|
exports.Logger = Logger;
|
|
9436
|
+
exports.LoggerAdapter = LoggerAdapter;
|
|
9437
|
+
exports.LoggerInstance = LoggerInstance;
|
|
8997
9438
|
exports.MethodContextService = MethodContextService;
|
|
8998
9439
|
exports.Schema = Schema;
|
|
8999
9440
|
exports.State = State;
|