agent-swarm-kit 1.0.28 → 1.0.30
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 +52 -36
- package/build/index.mjs +52 -36
- package/package.json +1 -1
- package/types.d.ts +211 -193
package/build/index.cjs
CHANGED
|
@@ -438,7 +438,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
438
438
|
* @returns {Promise<void>}
|
|
439
439
|
* @private
|
|
440
440
|
*/
|
|
441
|
-
this._emitOuput = function (result) { return __awaiter(_this, void 0, void 0, function () {
|
|
441
|
+
this._emitOuput = function (mode, result) { return __awaiter(_this, void 0, void 0, function () {
|
|
442
442
|
var validation, result_1;
|
|
443
443
|
return __generator(this, function (_a) {
|
|
444
444
|
switch (_a.label) {
|
|
@@ -448,7 +448,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
448
448
|
return [4 /*yield*/, this.params.validate(result)];
|
|
449
449
|
case 1:
|
|
450
450
|
if (!(validation = _a.sent())) return [3 /*break*/, 5];
|
|
451
|
-
return [4 /*yield*/, this._resurrectModel(validation)];
|
|
451
|
+
return [4 /*yield*/, this._resurrectModel(mode, validation)];
|
|
452
452
|
case 2:
|
|
453
453
|
result_1 = _a.sent();
|
|
454
454
|
return [4 /*yield*/, this.params.validate(result_1)];
|
|
@@ -473,7 +473,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
473
473
|
* @returns {Promise<string>}
|
|
474
474
|
* @private
|
|
475
475
|
*/
|
|
476
|
-
this._resurrectModel = function (reason) { return __awaiter(_this, void 0, void 0, function () {
|
|
476
|
+
this._resurrectModel = function (mode, reason) { return __awaiter(_this, void 0, void 0, function () {
|
|
477
477
|
var message, result, validation, content;
|
|
478
478
|
return __generator(this, function (_a) {
|
|
479
479
|
switch (_a.label) {
|
|
@@ -481,6 +481,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
481
481
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " _resurrectModel"));
|
|
482
482
|
return [4 /*yield*/, this.params.history.push({
|
|
483
483
|
role: "resque",
|
|
484
|
+
mode: 'tool',
|
|
484
485
|
agentName: this.params.agentName,
|
|
485
486
|
content: reason || "Unknown error",
|
|
486
487
|
})];
|
|
@@ -488,12 +489,13 @@ var ClientAgent = /** @class */ (function () {
|
|
|
488
489
|
_a.sent();
|
|
489
490
|
return [4 /*yield*/, this.params.history.push({
|
|
490
491
|
role: "user",
|
|
492
|
+
mode: 'tool',
|
|
491
493
|
agentName: this.params.agentName,
|
|
492
494
|
content: GLOBAL_CONFIG.CC_TOOL_CALL_EXCEPTION_PROMPT,
|
|
493
495
|
})];
|
|
494
496
|
case 2:
|
|
495
497
|
_a.sent();
|
|
496
|
-
return [4 /*yield*/, this.getCompletion()];
|
|
498
|
+
return [4 /*yield*/, this.getCompletion(mode)];
|
|
497
499
|
case 3:
|
|
498
500
|
message = _a.sent();
|
|
499
501
|
result = message.content;
|
|
@@ -506,6 +508,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
506
508
|
return [4 /*yield*/, this.params.history.push({
|
|
507
509
|
agentName: this.params.agentName,
|
|
508
510
|
role: "assistant",
|
|
511
|
+
mode: 'tool',
|
|
509
512
|
content: content,
|
|
510
513
|
})];
|
|
511
514
|
case 5:
|
|
@@ -536,7 +539,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
536
539
|
* Gets the completion message from the model.
|
|
537
540
|
* @returns {Promise<IModelMessage>}
|
|
538
541
|
*/
|
|
539
|
-
this.getCompletion = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
542
|
+
this.getCompletion = function (mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
540
543
|
var messages;
|
|
541
544
|
var _a;
|
|
542
545
|
return __generator(this, function (_b) {
|
|
@@ -550,6 +553,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
550
553
|
clientId: this.params.clientId,
|
|
551
554
|
agentName: this.params.agentName,
|
|
552
555
|
messages: messages,
|
|
556
|
+
mode: mode,
|
|
553
557
|
tools: (_a = this.params.tools) === null || _a === void 0 ? void 0 : _a.map(function (t) {
|
|
554
558
|
return lodashEs.omit(t, "toolName", "call", "validate");
|
|
555
559
|
}),
|
|
@@ -571,6 +575,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
571
575
|
return [4 /*yield*/, this.params.history.push({
|
|
572
576
|
role: "user",
|
|
573
577
|
agentName: this.params.agentName,
|
|
578
|
+
mode: 'user',
|
|
574
579
|
content: message.trim(),
|
|
575
580
|
})];
|
|
576
581
|
case 1:
|
|
@@ -592,6 +597,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
592
597
|
return [4 /*yield*/, this.params.history.push({
|
|
593
598
|
role: "system",
|
|
594
599
|
agentName: this.params.agentName,
|
|
600
|
+
mode: 'tool',
|
|
595
601
|
content: message.trim(),
|
|
596
602
|
})];
|
|
597
603
|
case 1:
|
|
@@ -613,6 +619,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
613
619
|
return [4 /*yield*/, this.params.history.push({
|
|
614
620
|
role: "tool",
|
|
615
621
|
agentName: this.params.agentName,
|
|
622
|
+
mode: 'tool',
|
|
616
623
|
content: content,
|
|
617
624
|
})];
|
|
618
625
|
case 1:
|
|
@@ -629,22 +636,23 @@ var ClientAgent = /** @class */ (function () {
|
|
|
629
636
|
* @param {string} incoming - The incoming message content.
|
|
630
637
|
* @returns {Promise<void>}
|
|
631
638
|
*/
|
|
632
|
-
this.execute = functoolsKit.queued(function (incoming) { return __awaiter(_this, void 0, void 0, function () {
|
|
639
|
+
this.execute = functoolsKit.queued(function (incoming, mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
633
640
|
var message, _loop_1, this_1, _a, _b, tool, state_1, e_1_1, result, validation, result1;
|
|
634
641
|
var e_1, _c;
|
|
635
642
|
var _d;
|
|
636
643
|
return __generator(this, function (_e) {
|
|
637
644
|
switch (_e.label) {
|
|
638
645
|
case 0:
|
|
639
|
-
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute begin"), { incoming: incoming });
|
|
646
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute begin"), { incoming: incoming, mode: mode });
|
|
640
647
|
return [4 /*yield*/, this.params.history.push({
|
|
641
648
|
role: "user",
|
|
649
|
+
mode: mode,
|
|
642
650
|
agentName: this.params.agentName,
|
|
643
651
|
content: incoming.trim(),
|
|
644
652
|
})];
|
|
645
653
|
case 1:
|
|
646
654
|
_e.sent();
|
|
647
|
-
return [4 /*yield*/, this.getCompletion()];
|
|
655
|
+
return [4 /*yield*/, this.getCompletion(mode)];
|
|
648
656
|
case 2:
|
|
649
657
|
message = _e.sent();
|
|
650
658
|
if (!message.tool_calls) return [3 /*break*/, 11];
|
|
@@ -660,11 +668,11 @@ var ClientAgent = /** @class */ (function () {
|
|
|
660
668
|
_f.sent();
|
|
661
669
|
if (!!targetFn) return [3 /*break*/, 4];
|
|
662
670
|
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " functionName=").concat(tool.function.name, " tool function not found"), this_1.params.tools);
|
|
663
|
-
return [4 /*yield*/, this_1._resurrectModel("No target function for ".concat(tool.function.name))];
|
|
671
|
+
return [4 /*yield*/, this_1._resurrectModel(mode, "No target function for ".concat(tool.function.name))];
|
|
664
672
|
case 2:
|
|
665
673
|
result_2 = _f.sent();
|
|
666
674
|
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_2));
|
|
667
|
-
return [4 /*yield*/, this_1._emitOuput(result_2)];
|
|
675
|
+
return [4 /*yield*/, this_1._emitOuput(mode, result_2)];
|
|
668
676
|
case 3:
|
|
669
677
|
_f.sent();
|
|
670
678
|
return [2 /*return*/, { value: void 0 }];
|
|
@@ -672,11 +680,11 @@ var ClientAgent = /** @class */ (function () {
|
|
|
672
680
|
case 5:
|
|
673
681
|
if (!_f.sent()) return [3 /*break*/, 8];
|
|
674
682
|
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " functionName=").concat(tool.function.name, " tool validation not passed"));
|
|
675
|
-
return [4 /*yield*/, this_1._resurrectModel("Function validation failed: name=".concat(tool.function.name, " arguments=").concat(JSON.stringify(tool.function.arguments)))];
|
|
683
|
+
return [4 /*yield*/, this_1._resurrectModel(mode, "Function validation failed: name=".concat(tool.function.name, " arguments=").concat(JSON.stringify(tool.function.arguments)))];
|
|
676
684
|
case 6:
|
|
677
685
|
result_3 = _f.sent();
|
|
678
686
|
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_3));
|
|
679
|
-
return [4 /*yield*/, this_1._emitOuput(result_3)];
|
|
687
|
+
return [4 /*yield*/, this_1._emitOuput(mode, result_3)];
|
|
680
688
|
case 7:
|
|
681
689
|
_f.sent();
|
|
682
690
|
return [2 /*return*/, { value: void 0 }];
|
|
@@ -740,16 +748,16 @@ var ClientAgent = /** @class */ (function () {
|
|
|
740
748
|
case 13:
|
|
741
749
|
if (!(validation = _e.sent())) return [3 /*break*/, 16];
|
|
742
750
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute invalid tool call detected: ").concat(validation), { result: result });
|
|
743
|
-
return [4 /*yield*/, this._resurrectModel("Invalid model output: ".concat(result))];
|
|
751
|
+
return [4 /*yield*/, this._resurrectModel(mode, "Invalid model output: ".concat(result))];
|
|
744
752
|
case 14:
|
|
745
753
|
result1 = _e.sent();
|
|
746
|
-
return [4 /*yield*/, this._emitOuput(result1)];
|
|
754
|
+
return [4 /*yield*/, this._emitOuput(mode, result1)];
|
|
747
755
|
case 15:
|
|
748
756
|
_e.sent();
|
|
749
757
|
return [2 /*return*/];
|
|
750
758
|
case 16:
|
|
751
759
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute end result=").concat(result));
|
|
752
|
-
return [4 /*yield*/, this._emitOuput(result)];
|
|
760
|
+
return [4 /*yield*/, this._emitOuput(mode, result)];
|
|
753
761
|
case 17:
|
|
754
762
|
_e.sent();
|
|
755
763
|
return [2 /*return*/];
|
|
@@ -807,15 +815,16 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
807
815
|
* @param {string} input - The input command.
|
|
808
816
|
* @returns {Promise<any>} The execution result.
|
|
809
817
|
*/
|
|
810
|
-
this.execute = function (input) { return __awaiter(_this, void 0, void 0, function () {
|
|
818
|
+
this.execute = function (input, mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
811
819
|
return __generator(this, function (_a) {
|
|
812
820
|
switch (_a.label) {
|
|
813
821
|
case 0:
|
|
814
822
|
this.loggerService.log("agentConnectionService execute", {
|
|
815
823
|
input: input,
|
|
824
|
+
mode: mode,
|
|
816
825
|
context: this.contextService.context,
|
|
817
826
|
});
|
|
818
|
-
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).execute(input)];
|
|
827
|
+
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).execute(input, mode)];
|
|
819
828
|
case 1: return [2 /*return*/, _a.sent()];
|
|
820
829
|
}
|
|
821
830
|
});
|
|
@@ -1068,6 +1077,7 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1068
1077
|
{
|
|
1069
1078
|
promptMessages.push({
|
|
1070
1079
|
agentName: this.params.agentName,
|
|
1080
|
+
mode: 'tool',
|
|
1071
1081
|
content: prompt,
|
|
1072
1082
|
role: "system",
|
|
1073
1083
|
});
|
|
@@ -1075,6 +1085,7 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1075
1085
|
system.forEach(function (content) {
|
|
1076
1086
|
return promptMessages.push({
|
|
1077
1087
|
agentName: _this.params.agentName,
|
|
1088
|
+
mode: 'tool',
|
|
1078
1089
|
content: content,
|
|
1079
1090
|
role: "system",
|
|
1080
1091
|
});
|
|
@@ -1639,12 +1650,12 @@ var ClientSession = /** @class */ (function () {
|
|
|
1639
1650
|
* @param {boolean} [noEmit=false] - Whether to emit the output or not.
|
|
1640
1651
|
* @returns {Promise<string>} - The output of the execution.
|
|
1641
1652
|
*/
|
|
1642
|
-
this.execute = function (message_1) {
|
|
1653
|
+
this.execute = function (message_1, mode_1) {
|
|
1643
1654
|
var args_1 = [];
|
|
1644
|
-
for (var _i =
|
|
1645
|
-
args_1[_i -
|
|
1655
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1656
|
+
args_1[_i - 2] = arguments[_i];
|
|
1646
1657
|
}
|
|
1647
|
-
return __awaiter(_this, __spreadArray([message_1], __read(args_1), false), void 0, function (message, noEmit) {
|
|
1658
|
+
return __awaiter(_this, __spreadArray([message_1, mode_1], __read(args_1), false), void 0, function (message, mode, noEmit) {
|
|
1648
1659
|
var agent, outputAwaiter, output, _a;
|
|
1649
1660
|
if (noEmit === void 0) { noEmit = false; }
|
|
1650
1661
|
return __generator(this, function (_b) {
|
|
@@ -1652,13 +1663,14 @@ var ClientSession = /** @class */ (function () {
|
|
|
1652
1663
|
case 0:
|
|
1653
1664
|
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " execute"), {
|
|
1654
1665
|
message: message,
|
|
1666
|
+
mode: mode,
|
|
1655
1667
|
noEmit: noEmit,
|
|
1656
1668
|
});
|
|
1657
1669
|
return [4 /*yield*/, this.params.swarm.getAgent()];
|
|
1658
1670
|
case 1:
|
|
1659
1671
|
agent = _b.sent();
|
|
1660
1672
|
outputAwaiter = this.params.swarm.waitForOutput();
|
|
1661
|
-
agent.execute(message);
|
|
1673
|
+
agent.execute(message, mode);
|
|
1662
1674
|
return [4 /*yield*/, outputAwaiter];
|
|
1663
1675
|
case 2:
|
|
1664
1676
|
output = _b.sent();
|
|
@@ -1771,7 +1783,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
1771
1783
|
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " connect call"));
|
|
1772
1784
|
_a = connector;
|
|
1773
1785
|
_b = {};
|
|
1774
|
-
return [4 /*yield*/, this.execute(incoming.data, true)];
|
|
1786
|
+
return [4 /*yield*/, this.execute(incoming.data, "user", true)];
|
|
1775
1787
|
case 1:
|
|
1776
1788
|
_b.data = _c.sent();
|
|
1777
1789
|
return [4 /*yield*/, this.params.swarm.getAgentName()];
|
|
@@ -1840,14 +1852,16 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
1840
1852
|
* @param {string} content - The content to execute.
|
|
1841
1853
|
* @returns {Promise<string>} A promise that resolves with the execution result.
|
|
1842
1854
|
*/
|
|
1843
|
-
this.execute = function (content) { return __awaiter(_this, void 0, void 0, function () {
|
|
1855
|
+
this.execute = function (content, mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
1844
1856
|
return __generator(this, function (_a) {
|
|
1845
1857
|
switch (_a.label) {
|
|
1846
1858
|
case 0:
|
|
1847
1859
|
this.loggerService.log("sessionConnectionService execute", {
|
|
1848
1860
|
context: this.contextService.context,
|
|
1861
|
+
content: content,
|
|
1862
|
+
mode: mode,
|
|
1849
1863
|
});
|
|
1850
|
-
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).execute(content)];
|
|
1864
|
+
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).execute(content, mode)];
|
|
1851
1865
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1852
1866
|
}
|
|
1853
1867
|
});
|
|
@@ -1977,7 +1991,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
1977
1991
|
* @param {AgentName} agentName - The name of the agent.
|
|
1978
1992
|
* @returns {Promise<unknown>} The execution result.
|
|
1979
1993
|
*/
|
|
1980
|
-
this.execute = function (input, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
1994
|
+
this.execute = function (input, mode, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
1981
1995
|
var _this = this;
|
|
1982
1996
|
return __generator(this, function (_a) {
|
|
1983
1997
|
switch (_a.label) {
|
|
@@ -1986,11 +2000,12 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
1986
2000
|
input: input,
|
|
1987
2001
|
clientId: clientId,
|
|
1988
2002
|
agentName: agentName,
|
|
2003
|
+
mode: mode,
|
|
1989
2004
|
});
|
|
1990
2005
|
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1991
2006
|
return __generator(this, function (_a) {
|
|
1992
2007
|
switch (_a.label) {
|
|
1993
|
-
case 0: return [4 /*yield*/, this.agentConnectionService.execute(input)];
|
|
2008
|
+
case 0: return [4 /*yield*/, this.agentConnectionService.execute(input, mode)];
|
|
1994
2009
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1995
2010
|
}
|
|
1996
2011
|
});
|
|
@@ -2356,20 +2371,21 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
2356
2371
|
* @param {SwarmName} swarmName - The swarm name.
|
|
2357
2372
|
* @returns {Promise<void>}
|
|
2358
2373
|
*/
|
|
2359
|
-
this.execute = function (content, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
2374
|
+
this.execute = function (content, mode, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
2360
2375
|
var _this = this;
|
|
2361
2376
|
return __generator(this, function (_a) {
|
|
2362
2377
|
switch (_a.label) {
|
|
2363
2378
|
case 0:
|
|
2364
2379
|
this.loggerService.log("sessionPublicService execute", {
|
|
2365
2380
|
content: content,
|
|
2381
|
+
mode: mode,
|
|
2366
2382
|
clientId: clientId,
|
|
2367
2383
|
swarmName: swarmName,
|
|
2368
2384
|
});
|
|
2369
2385
|
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2370
2386
|
return __generator(this, function (_a) {
|
|
2371
2387
|
switch (_a.label) {
|
|
2372
|
-
case 0: return [4 /*yield*/, this.sessionConnectionService.execute(content)];
|
|
2388
|
+
case 0: return [4 /*yield*/, this.sessionConnectionService.execute(content, mode)];
|
|
2373
2389
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2374
2390
|
}
|
|
2375
2391
|
});
|
|
@@ -3661,7 +3677,7 @@ var createComplete = functoolsKit.ttl(function (clientId, swarmName) {
|
|
|
3661
3677
|
case 0:
|
|
3662
3678
|
swarm.swarmValidationService.validate(swarmName, "complete");
|
|
3663
3679
|
swarm.sessionValidationService.addSession(clientId, swarmName, "complete");
|
|
3664
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, clientId, swarmName)];
|
|
3680
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", clientId, swarmName)];
|
|
3665
3681
|
case 1:
|
|
3666
3682
|
result = _a.sent();
|
|
3667
3683
|
return [4 /*yield*/, disposeConnection(clientId, swarmName)];
|
|
@@ -3746,7 +3762,7 @@ var session = function (clientId, swarmName) {
|
|
|
3746
3762
|
switch (_a.label) {
|
|
3747
3763
|
case 0:
|
|
3748
3764
|
swarm.sessionValidationService.validate(clientId, "session");
|
|
3749
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, clientId, swarmName)];
|
|
3765
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", clientId, swarmName)];
|
|
3750
3766
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3751
3767
|
}
|
|
3752
3768
|
});
|
|
@@ -4028,7 +4044,7 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
|
|
|
4028
4044
|
});
|
|
4029
4045
|
return [2 /*return*/];
|
|
4030
4046
|
}
|
|
4031
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, clientId, swarmName)];
|
|
4047
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", clientId, swarmName)];
|
|
4032
4048
|
case 2: return [2 /*return*/, _a.sent()];
|
|
4033
4049
|
}
|
|
4034
4050
|
});
|
|
@@ -4096,8 +4112,8 @@ var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0,
|
|
|
4096
4112
|
case 1:
|
|
4097
4113
|
history = _a.sent();
|
|
4098
4114
|
last = history.findLast(function (_a) {
|
|
4099
|
-
var role = _a.role;
|
|
4100
|
-
return role === "user";
|
|
4115
|
+
var role = _a.role, mode = _a.mode;
|
|
4116
|
+
return role === "user" && mode === "user";
|
|
4101
4117
|
});
|
|
4102
4118
|
return [2 /*return*/, last ? last.content : null];
|
|
4103
4119
|
}
|
|
@@ -4122,8 +4138,8 @@ var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
4122
4138
|
case 1:
|
|
4123
4139
|
history = _a.sent();
|
|
4124
4140
|
return [2 /*return*/, history.filter(function (_a) {
|
|
4125
|
-
var role = _a.role;
|
|
4126
|
-
return role === "user";
|
|
4141
|
+
var role = _a.role, mode = _a.mode;
|
|
4142
|
+
return role === "user" && mode === "user";
|
|
4127
4143
|
})];
|
|
4128
4144
|
}
|
|
4129
4145
|
});
|
package/build/index.mjs
CHANGED
|
@@ -436,7 +436,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
436
436
|
* @returns {Promise<void>}
|
|
437
437
|
* @private
|
|
438
438
|
*/
|
|
439
|
-
this._emitOuput = function (result) { return __awaiter(_this, void 0, void 0, function () {
|
|
439
|
+
this._emitOuput = function (mode, result) { return __awaiter(_this, void 0, void 0, function () {
|
|
440
440
|
var validation, result_1;
|
|
441
441
|
return __generator(this, function (_a) {
|
|
442
442
|
switch (_a.label) {
|
|
@@ -446,7 +446,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
446
446
|
return [4 /*yield*/, this.params.validate(result)];
|
|
447
447
|
case 1:
|
|
448
448
|
if (!(validation = _a.sent())) return [3 /*break*/, 5];
|
|
449
|
-
return [4 /*yield*/, this._resurrectModel(validation)];
|
|
449
|
+
return [4 /*yield*/, this._resurrectModel(mode, validation)];
|
|
450
450
|
case 2:
|
|
451
451
|
result_1 = _a.sent();
|
|
452
452
|
return [4 /*yield*/, this.params.validate(result_1)];
|
|
@@ -471,7 +471,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
471
471
|
* @returns {Promise<string>}
|
|
472
472
|
* @private
|
|
473
473
|
*/
|
|
474
|
-
this._resurrectModel = function (reason) { return __awaiter(_this, void 0, void 0, function () {
|
|
474
|
+
this._resurrectModel = function (mode, reason) { return __awaiter(_this, void 0, void 0, function () {
|
|
475
475
|
var message, result, validation, content;
|
|
476
476
|
return __generator(this, function (_a) {
|
|
477
477
|
switch (_a.label) {
|
|
@@ -479,6 +479,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
479
479
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " _resurrectModel"));
|
|
480
480
|
return [4 /*yield*/, this.params.history.push({
|
|
481
481
|
role: "resque",
|
|
482
|
+
mode: 'tool',
|
|
482
483
|
agentName: this.params.agentName,
|
|
483
484
|
content: reason || "Unknown error",
|
|
484
485
|
})];
|
|
@@ -486,12 +487,13 @@ var ClientAgent = /** @class */ (function () {
|
|
|
486
487
|
_a.sent();
|
|
487
488
|
return [4 /*yield*/, this.params.history.push({
|
|
488
489
|
role: "user",
|
|
490
|
+
mode: 'tool',
|
|
489
491
|
agentName: this.params.agentName,
|
|
490
492
|
content: GLOBAL_CONFIG.CC_TOOL_CALL_EXCEPTION_PROMPT,
|
|
491
493
|
})];
|
|
492
494
|
case 2:
|
|
493
495
|
_a.sent();
|
|
494
|
-
return [4 /*yield*/, this.getCompletion()];
|
|
496
|
+
return [4 /*yield*/, this.getCompletion(mode)];
|
|
495
497
|
case 3:
|
|
496
498
|
message = _a.sent();
|
|
497
499
|
result = message.content;
|
|
@@ -504,6 +506,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
504
506
|
return [4 /*yield*/, this.params.history.push({
|
|
505
507
|
agentName: this.params.agentName,
|
|
506
508
|
role: "assistant",
|
|
509
|
+
mode: 'tool',
|
|
507
510
|
content: content,
|
|
508
511
|
})];
|
|
509
512
|
case 5:
|
|
@@ -534,7 +537,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
534
537
|
* Gets the completion message from the model.
|
|
535
538
|
* @returns {Promise<IModelMessage>}
|
|
536
539
|
*/
|
|
537
|
-
this.getCompletion = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
540
|
+
this.getCompletion = function (mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
538
541
|
var messages;
|
|
539
542
|
var _a;
|
|
540
543
|
return __generator(this, function (_b) {
|
|
@@ -548,6 +551,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
548
551
|
clientId: this.params.clientId,
|
|
549
552
|
agentName: this.params.agentName,
|
|
550
553
|
messages: messages,
|
|
554
|
+
mode: mode,
|
|
551
555
|
tools: (_a = this.params.tools) === null || _a === void 0 ? void 0 : _a.map(function (t) {
|
|
552
556
|
return omit(t, "toolName", "call", "validate");
|
|
553
557
|
}),
|
|
@@ -569,6 +573,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
569
573
|
return [4 /*yield*/, this.params.history.push({
|
|
570
574
|
role: "user",
|
|
571
575
|
agentName: this.params.agentName,
|
|
576
|
+
mode: 'user',
|
|
572
577
|
content: message.trim(),
|
|
573
578
|
})];
|
|
574
579
|
case 1:
|
|
@@ -590,6 +595,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
590
595
|
return [4 /*yield*/, this.params.history.push({
|
|
591
596
|
role: "system",
|
|
592
597
|
agentName: this.params.agentName,
|
|
598
|
+
mode: 'tool',
|
|
593
599
|
content: message.trim(),
|
|
594
600
|
})];
|
|
595
601
|
case 1:
|
|
@@ -611,6 +617,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
611
617
|
return [4 /*yield*/, this.params.history.push({
|
|
612
618
|
role: "tool",
|
|
613
619
|
agentName: this.params.agentName,
|
|
620
|
+
mode: 'tool',
|
|
614
621
|
content: content,
|
|
615
622
|
})];
|
|
616
623
|
case 1:
|
|
@@ -627,22 +634,23 @@ var ClientAgent = /** @class */ (function () {
|
|
|
627
634
|
* @param {string} incoming - The incoming message content.
|
|
628
635
|
* @returns {Promise<void>}
|
|
629
636
|
*/
|
|
630
|
-
this.execute = queued(function (incoming) { return __awaiter(_this, void 0, void 0, function () {
|
|
637
|
+
this.execute = queued(function (incoming, mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
631
638
|
var message, _loop_1, this_1, _a, _b, tool, state_1, e_1_1, result, validation, result1;
|
|
632
639
|
var e_1, _c;
|
|
633
640
|
var _d;
|
|
634
641
|
return __generator(this, function (_e) {
|
|
635
642
|
switch (_e.label) {
|
|
636
643
|
case 0:
|
|
637
|
-
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute begin"), { incoming: incoming });
|
|
644
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute begin"), { incoming: incoming, mode: mode });
|
|
638
645
|
return [4 /*yield*/, this.params.history.push({
|
|
639
646
|
role: "user",
|
|
647
|
+
mode: mode,
|
|
640
648
|
agentName: this.params.agentName,
|
|
641
649
|
content: incoming.trim(),
|
|
642
650
|
})];
|
|
643
651
|
case 1:
|
|
644
652
|
_e.sent();
|
|
645
|
-
return [4 /*yield*/, this.getCompletion()];
|
|
653
|
+
return [4 /*yield*/, this.getCompletion(mode)];
|
|
646
654
|
case 2:
|
|
647
655
|
message = _e.sent();
|
|
648
656
|
if (!message.tool_calls) return [3 /*break*/, 11];
|
|
@@ -658,11 +666,11 @@ var ClientAgent = /** @class */ (function () {
|
|
|
658
666
|
_f.sent();
|
|
659
667
|
if (!!targetFn) return [3 /*break*/, 4];
|
|
660
668
|
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " functionName=").concat(tool.function.name, " tool function not found"), this_1.params.tools);
|
|
661
|
-
return [4 /*yield*/, this_1._resurrectModel("No target function for ".concat(tool.function.name))];
|
|
669
|
+
return [4 /*yield*/, this_1._resurrectModel(mode, "No target function for ".concat(tool.function.name))];
|
|
662
670
|
case 2:
|
|
663
671
|
result_2 = _f.sent();
|
|
664
672
|
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_2));
|
|
665
|
-
return [4 /*yield*/, this_1._emitOuput(result_2)];
|
|
673
|
+
return [4 /*yield*/, this_1._emitOuput(mode, result_2)];
|
|
666
674
|
case 3:
|
|
667
675
|
_f.sent();
|
|
668
676
|
return [2 /*return*/, { value: void 0 }];
|
|
@@ -670,11 +678,11 @@ var ClientAgent = /** @class */ (function () {
|
|
|
670
678
|
case 5:
|
|
671
679
|
if (!_f.sent()) return [3 /*break*/, 8];
|
|
672
680
|
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " functionName=").concat(tool.function.name, " tool validation not passed"));
|
|
673
|
-
return [4 /*yield*/, this_1._resurrectModel("Function validation failed: name=".concat(tool.function.name, " arguments=").concat(JSON.stringify(tool.function.arguments)))];
|
|
681
|
+
return [4 /*yield*/, this_1._resurrectModel(mode, "Function validation failed: name=".concat(tool.function.name, " arguments=").concat(JSON.stringify(tool.function.arguments)))];
|
|
674
682
|
case 6:
|
|
675
683
|
result_3 = _f.sent();
|
|
676
684
|
this_1.params.logger.debug("ClientAgent agentName=".concat(this_1.params.agentName, " clientId=").concat(this_1.params.clientId, " execute end result=").concat(result_3));
|
|
677
|
-
return [4 /*yield*/, this_1._emitOuput(result_3)];
|
|
685
|
+
return [4 /*yield*/, this_1._emitOuput(mode, result_3)];
|
|
678
686
|
case 7:
|
|
679
687
|
_f.sent();
|
|
680
688
|
return [2 /*return*/, { value: void 0 }];
|
|
@@ -738,16 +746,16 @@ var ClientAgent = /** @class */ (function () {
|
|
|
738
746
|
case 13:
|
|
739
747
|
if (!(validation = _e.sent())) return [3 /*break*/, 16];
|
|
740
748
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute invalid tool call detected: ").concat(validation), { result: result });
|
|
741
|
-
return [4 /*yield*/, this._resurrectModel("Invalid model output: ".concat(result))];
|
|
749
|
+
return [4 /*yield*/, this._resurrectModel(mode, "Invalid model output: ".concat(result))];
|
|
742
750
|
case 14:
|
|
743
751
|
result1 = _e.sent();
|
|
744
|
-
return [4 /*yield*/, this._emitOuput(result1)];
|
|
752
|
+
return [4 /*yield*/, this._emitOuput(mode, result1)];
|
|
745
753
|
case 15:
|
|
746
754
|
_e.sent();
|
|
747
755
|
return [2 /*return*/];
|
|
748
756
|
case 16:
|
|
749
757
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute end result=").concat(result));
|
|
750
|
-
return [4 /*yield*/, this._emitOuput(result)];
|
|
758
|
+
return [4 /*yield*/, this._emitOuput(mode, result)];
|
|
751
759
|
case 17:
|
|
752
760
|
_e.sent();
|
|
753
761
|
return [2 /*return*/];
|
|
@@ -805,15 +813,16 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
805
813
|
* @param {string} input - The input command.
|
|
806
814
|
* @returns {Promise<any>} The execution result.
|
|
807
815
|
*/
|
|
808
|
-
this.execute = function (input) { return __awaiter(_this, void 0, void 0, function () {
|
|
816
|
+
this.execute = function (input, mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
809
817
|
return __generator(this, function (_a) {
|
|
810
818
|
switch (_a.label) {
|
|
811
819
|
case 0:
|
|
812
820
|
this.loggerService.log("agentConnectionService execute", {
|
|
813
821
|
input: input,
|
|
822
|
+
mode: mode,
|
|
814
823
|
context: this.contextService.context,
|
|
815
824
|
});
|
|
816
|
-
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).execute(input)];
|
|
825
|
+
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).execute(input, mode)];
|
|
817
826
|
case 1: return [2 /*return*/, _a.sent()];
|
|
818
827
|
}
|
|
819
828
|
});
|
|
@@ -1066,6 +1075,7 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1066
1075
|
{
|
|
1067
1076
|
promptMessages.push({
|
|
1068
1077
|
agentName: this.params.agentName,
|
|
1078
|
+
mode: 'tool',
|
|
1069
1079
|
content: prompt,
|
|
1070
1080
|
role: "system",
|
|
1071
1081
|
});
|
|
@@ -1073,6 +1083,7 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1073
1083
|
system.forEach(function (content) {
|
|
1074
1084
|
return promptMessages.push({
|
|
1075
1085
|
agentName: _this.params.agentName,
|
|
1086
|
+
mode: 'tool',
|
|
1076
1087
|
content: content,
|
|
1077
1088
|
role: "system",
|
|
1078
1089
|
});
|
|
@@ -1637,12 +1648,12 @@ var ClientSession = /** @class */ (function () {
|
|
|
1637
1648
|
* @param {boolean} [noEmit=false] - Whether to emit the output or not.
|
|
1638
1649
|
* @returns {Promise<string>} - The output of the execution.
|
|
1639
1650
|
*/
|
|
1640
|
-
this.execute = function (message_1) {
|
|
1651
|
+
this.execute = function (message_1, mode_1) {
|
|
1641
1652
|
var args_1 = [];
|
|
1642
|
-
for (var _i =
|
|
1643
|
-
args_1[_i -
|
|
1653
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1654
|
+
args_1[_i - 2] = arguments[_i];
|
|
1644
1655
|
}
|
|
1645
|
-
return __awaiter(_this, __spreadArray([message_1], __read(args_1), false), void 0, function (message, noEmit) {
|
|
1656
|
+
return __awaiter(_this, __spreadArray([message_1, mode_1], __read(args_1), false), void 0, function (message, mode, noEmit) {
|
|
1646
1657
|
var agent, outputAwaiter, output, _a;
|
|
1647
1658
|
if (noEmit === void 0) { noEmit = false; }
|
|
1648
1659
|
return __generator(this, function (_b) {
|
|
@@ -1650,13 +1661,14 @@ var ClientSession = /** @class */ (function () {
|
|
|
1650
1661
|
case 0:
|
|
1651
1662
|
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " execute"), {
|
|
1652
1663
|
message: message,
|
|
1664
|
+
mode: mode,
|
|
1653
1665
|
noEmit: noEmit,
|
|
1654
1666
|
});
|
|
1655
1667
|
return [4 /*yield*/, this.params.swarm.getAgent()];
|
|
1656
1668
|
case 1:
|
|
1657
1669
|
agent = _b.sent();
|
|
1658
1670
|
outputAwaiter = this.params.swarm.waitForOutput();
|
|
1659
|
-
agent.execute(message);
|
|
1671
|
+
agent.execute(message, mode);
|
|
1660
1672
|
return [4 /*yield*/, outputAwaiter];
|
|
1661
1673
|
case 2:
|
|
1662
1674
|
output = _b.sent();
|
|
@@ -1769,7 +1781,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
1769
1781
|
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " connect call"));
|
|
1770
1782
|
_a = connector;
|
|
1771
1783
|
_b = {};
|
|
1772
|
-
return [4 /*yield*/, this.execute(incoming.data, true)];
|
|
1784
|
+
return [4 /*yield*/, this.execute(incoming.data, "user", true)];
|
|
1773
1785
|
case 1:
|
|
1774
1786
|
_b.data = _c.sent();
|
|
1775
1787
|
return [4 /*yield*/, this.params.swarm.getAgentName()];
|
|
@@ -1838,14 +1850,16 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
1838
1850
|
* @param {string} content - The content to execute.
|
|
1839
1851
|
* @returns {Promise<string>} A promise that resolves with the execution result.
|
|
1840
1852
|
*/
|
|
1841
|
-
this.execute = function (content) { return __awaiter(_this, void 0, void 0, function () {
|
|
1853
|
+
this.execute = function (content, mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
1842
1854
|
return __generator(this, function (_a) {
|
|
1843
1855
|
switch (_a.label) {
|
|
1844
1856
|
case 0:
|
|
1845
1857
|
this.loggerService.log("sessionConnectionService execute", {
|
|
1846
1858
|
context: this.contextService.context,
|
|
1859
|
+
content: content,
|
|
1860
|
+
mode: mode,
|
|
1847
1861
|
});
|
|
1848
|
-
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).execute(content)];
|
|
1862
|
+
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).execute(content, mode)];
|
|
1849
1863
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1850
1864
|
}
|
|
1851
1865
|
});
|
|
@@ -1975,7 +1989,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
1975
1989
|
* @param {AgentName} agentName - The name of the agent.
|
|
1976
1990
|
* @returns {Promise<unknown>} The execution result.
|
|
1977
1991
|
*/
|
|
1978
|
-
this.execute = function (input, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
1992
|
+
this.execute = function (input, mode, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
1979
1993
|
var _this = this;
|
|
1980
1994
|
return __generator(this, function (_a) {
|
|
1981
1995
|
switch (_a.label) {
|
|
@@ -1984,11 +1998,12 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
1984
1998
|
input: input,
|
|
1985
1999
|
clientId: clientId,
|
|
1986
2000
|
agentName: agentName,
|
|
2001
|
+
mode: mode,
|
|
1987
2002
|
});
|
|
1988
2003
|
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1989
2004
|
return __generator(this, function (_a) {
|
|
1990
2005
|
switch (_a.label) {
|
|
1991
|
-
case 0: return [4 /*yield*/, this.agentConnectionService.execute(input)];
|
|
2006
|
+
case 0: return [4 /*yield*/, this.agentConnectionService.execute(input, mode)];
|
|
1992
2007
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1993
2008
|
}
|
|
1994
2009
|
});
|
|
@@ -2354,20 +2369,21 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
2354
2369
|
* @param {SwarmName} swarmName - The swarm name.
|
|
2355
2370
|
* @returns {Promise<void>}
|
|
2356
2371
|
*/
|
|
2357
|
-
this.execute = function (content, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
2372
|
+
this.execute = function (content, mode, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
2358
2373
|
var _this = this;
|
|
2359
2374
|
return __generator(this, function (_a) {
|
|
2360
2375
|
switch (_a.label) {
|
|
2361
2376
|
case 0:
|
|
2362
2377
|
this.loggerService.log("sessionPublicService execute", {
|
|
2363
2378
|
content: content,
|
|
2379
|
+
mode: mode,
|
|
2364
2380
|
clientId: clientId,
|
|
2365
2381
|
swarmName: swarmName,
|
|
2366
2382
|
});
|
|
2367
2383
|
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2368
2384
|
return __generator(this, function (_a) {
|
|
2369
2385
|
switch (_a.label) {
|
|
2370
|
-
case 0: return [4 /*yield*/, this.sessionConnectionService.execute(content)];
|
|
2386
|
+
case 0: return [4 /*yield*/, this.sessionConnectionService.execute(content, mode)];
|
|
2371
2387
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2372
2388
|
}
|
|
2373
2389
|
});
|
|
@@ -3659,7 +3675,7 @@ var createComplete = ttl(function (clientId, swarmName) {
|
|
|
3659
3675
|
case 0:
|
|
3660
3676
|
swarm.swarmValidationService.validate(swarmName, "complete");
|
|
3661
3677
|
swarm.sessionValidationService.addSession(clientId, swarmName, "complete");
|
|
3662
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, clientId, swarmName)];
|
|
3678
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", clientId, swarmName)];
|
|
3663
3679
|
case 1:
|
|
3664
3680
|
result = _a.sent();
|
|
3665
3681
|
return [4 /*yield*/, disposeConnection(clientId, swarmName)];
|
|
@@ -3744,7 +3760,7 @@ var session = function (clientId, swarmName) {
|
|
|
3744
3760
|
switch (_a.label) {
|
|
3745
3761
|
case 0:
|
|
3746
3762
|
swarm.sessionValidationService.validate(clientId, "session");
|
|
3747
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, clientId, swarmName)];
|
|
3763
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", clientId, swarmName)];
|
|
3748
3764
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3749
3765
|
}
|
|
3750
3766
|
});
|
|
@@ -4026,7 +4042,7 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
|
|
|
4026
4042
|
});
|
|
4027
4043
|
return [2 /*return*/];
|
|
4028
4044
|
}
|
|
4029
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, clientId, swarmName)];
|
|
4045
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", clientId, swarmName)];
|
|
4030
4046
|
case 2: return [2 /*return*/, _a.sent()];
|
|
4031
4047
|
}
|
|
4032
4048
|
});
|
|
@@ -4094,8 +4110,8 @@ var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0,
|
|
|
4094
4110
|
case 1:
|
|
4095
4111
|
history = _a.sent();
|
|
4096
4112
|
last = history.findLast(function (_a) {
|
|
4097
|
-
var role = _a.role;
|
|
4098
|
-
return role === "user";
|
|
4113
|
+
var role = _a.role, mode = _a.mode;
|
|
4114
|
+
return role === "user" && mode === "user";
|
|
4099
4115
|
});
|
|
4100
4116
|
return [2 /*return*/, last ? last.content : null];
|
|
4101
4117
|
}
|
|
@@ -4120,8 +4136,8 @@ var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
4120
4136
|
case 1:
|
|
4121
4137
|
history = _a.sent();
|
|
4122
4138
|
return [2 /*return*/, history.filter(function (_a) {
|
|
4123
|
-
var role = _a.role;
|
|
4124
|
-
return role === "user";
|
|
4139
|
+
var role = _a.role, mode = _a.mode;
|
|
4140
|
+
return role === "user" && mode === "user";
|
|
4125
4141
|
})];
|
|
4126
4142
|
}
|
|
4127
4143
|
});
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as di_scoped from 'di-scoped';
|
|
2
|
+
import { ExecutionMode as ExecutionMode$1 } from 'src/interfaces/Session.interface';
|
|
2
3
|
import * as functools_kit from 'functools-kit';
|
|
3
4
|
import { IPubsubArray, Subject } from 'functools-kit';
|
|
4
5
|
|
|
@@ -10,7 +11,7 @@ interface IModelMessage {
|
|
|
10
11
|
* The role of the message sender.
|
|
11
12
|
* @type {'assistant' | 'system' | 'tool' | 'user' | 'resque'}
|
|
12
13
|
*/
|
|
13
|
-
role:
|
|
14
|
+
role: "assistant" | "system" | "tool" | "user" | "resque";
|
|
14
15
|
/**
|
|
15
16
|
* The name of the agent sending the message.
|
|
16
17
|
* @type {string}
|
|
@@ -21,6 +22,11 @@ interface IModelMessage {
|
|
|
21
22
|
* @type {string}
|
|
22
23
|
*/
|
|
23
24
|
content: string;
|
|
25
|
+
/**
|
|
26
|
+
* The source of message: tool or user
|
|
27
|
+
* @type {ExecutionMode}
|
|
28
|
+
*/
|
|
29
|
+
mode: ExecutionMode$1;
|
|
24
30
|
/**
|
|
25
31
|
* Optional tool calls associated with the message.
|
|
26
32
|
* @type {Array<{ function: { name: string; arguments: { [key: string]: any; }; }; }>}
|
|
@@ -173,6 +179,196 @@ interface ITool {
|
|
|
173
179
|
};
|
|
174
180
|
}
|
|
175
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Interface representing an incoming message.
|
|
184
|
+
*/
|
|
185
|
+
interface IIncomingMessage {
|
|
186
|
+
/**
|
|
187
|
+
* The ID of the client sending the message.
|
|
188
|
+
*/
|
|
189
|
+
clientId: string;
|
|
190
|
+
/**
|
|
191
|
+
* The data contained in the message.
|
|
192
|
+
*/
|
|
193
|
+
data: string;
|
|
194
|
+
/**
|
|
195
|
+
* The name of the agent sending the message.
|
|
196
|
+
*/
|
|
197
|
+
agentName: AgentName;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Interface representing an outgoing message.
|
|
201
|
+
*/
|
|
202
|
+
interface IOutgoingMessage {
|
|
203
|
+
/**
|
|
204
|
+
* The ID of the client receiving the message.
|
|
205
|
+
*/
|
|
206
|
+
clientId: string;
|
|
207
|
+
/**
|
|
208
|
+
* The data contained in the message.
|
|
209
|
+
*/
|
|
210
|
+
data: string;
|
|
211
|
+
/**
|
|
212
|
+
* The name of the agent sending the message.
|
|
213
|
+
*/
|
|
214
|
+
agentName: AgentName;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Parameters for initializing a swarm.
|
|
219
|
+
* @interface
|
|
220
|
+
* @extends {Omit<ISwarmSchema, 'agentList'>}
|
|
221
|
+
*/
|
|
222
|
+
interface ISwarmParams extends Omit<ISwarmSchema, keyof {
|
|
223
|
+
agentList: never;
|
|
224
|
+
}> {
|
|
225
|
+
/** Client identifier */
|
|
226
|
+
clientId: string;
|
|
227
|
+
/** Logger instance */
|
|
228
|
+
logger: ILogger;
|
|
229
|
+
/** Map of agent names to agent instances */
|
|
230
|
+
agentMap: Record<AgentName, IAgent>;
|
|
231
|
+
/** Emit the callback on agent change */
|
|
232
|
+
onAgentChanged(clientId: string, agentName: AgentName, swarmName: SwarmName): Promise<void>;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Schema for defining a swarm.
|
|
236
|
+
* @interface
|
|
237
|
+
*/
|
|
238
|
+
interface ISwarmSchema {
|
|
239
|
+
/** Default agent name */
|
|
240
|
+
defaultAgent: AgentName;
|
|
241
|
+
/** Name of the swarm */
|
|
242
|
+
swarmName: string;
|
|
243
|
+
/** List of agent names */
|
|
244
|
+
agentList: string[];
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Interface for a swarm.
|
|
248
|
+
* @interface
|
|
249
|
+
*/
|
|
250
|
+
interface ISwarm {
|
|
251
|
+
/**
|
|
252
|
+
* Waits for the output from the swarm.
|
|
253
|
+
* @returns {Promise<string>} The output from the swarm.
|
|
254
|
+
*/
|
|
255
|
+
waitForOutput(): Promise<string>;
|
|
256
|
+
/**
|
|
257
|
+
* Gets the name of the agent.
|
|
258
|
+
* @returns {Promise<AgentName>} The name of the agent.
|
|
259
|
+
*/
|
|
260
|
+
getAgentName(): Promise<AgentName>;
|
|
261
|
+
/**
|
|
262
|
+
* Gets the agent instance.
|
|
263
|
+
* @returns {Promise<IAgent>} The agent instance.
|
|
264
|
+
*/
|
|
265
|
+
getAgent(): Promise<IAgent>;
|
|
266
|
+
/**
|
|
267
|
+
* Sets the reference to an agent.
|
|
268
|
+
* @param {AgentName} agentName - The name of the agent.
|
|
269
|
+
* @param {IAgent} agent - The agent instance.
|
|
270
|
+
* @returns {Promise<void>}
|
|
271
|
+
*/
|
|
272
|
+
setAgentRef(agentName: AgentName, agent: IAgent): Promise<void>;
|
|
273
|
+
/**
|
|
274
|
+
* Sets the name of the agent.
|
|
275
|
+
* @param {AgentName} agentName - The name of the agent.
|
|
276
|
+
* @returns {Promise<void>}
|
|
277
|
+
*/
|
|
278
|
+
setAgentName(agentName: AgentName): Promise<void>;
|
|
279
|
+
}
|
|
280
|
+
/** Type alias for swarm name */
|
|
281
|
+
type SwarmName = string;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Parameters required to create a session.
|
|
285
|
+
* @interface
|
|
286
|
+
*/
|
|
287
|
+
interface ISessionParams extends ISessionSchema {
|
|
288
|
+
clientId: string;
|
|
289
|
+
logger: ILogger;
|
|
290
|
+
swarm: ISwarm;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Schema for session data.
|
|
294
|
+
* @interface
|
|
295
|
+
*/
|
|
296
|
+
interface ISessionSchema {
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Function type for sending messages.
|
|
300
|
+
* @typedef {function} SendMessageFn
|
|
301
|
+
* @param {IOutgoingMessage} outgoing - The outgoing message.
|
|
302
|
+
* @returns {Promise<void> | void}
|
|
303
|
+
*/
|
|
304
|
+
type SendMessageFn$1 = (outgoing: IOutgoingMessage) => Promise<void> | void;
|
|
305
|
+
/**
|
|
306
|
+
* Function type for receiving messages.
|
|
307
|
+
* @typedef {function} ReceiveMessageFn
|
|
308
|
+
* @param {IIncomingMessage} incoming - The incoming message.
|
|
309
|
+
* @returns {Promise<void> | void}
|
|
310
|
+
*/
|
|
311
|
+
type ReceiveMessageFn = (incoming: IIncomingMessage) => Promise<void> | void;
|
|
312
|
+
/**
|
|
313
|
+
* Interface for a session.
|
|
314
|
+
* @interface
|
|
315
|
+
*/
|
|
316
|
+
interface ISession {
|
|
317
|
+
/**
|
|
318
|
+
* Emit a message.
|
|
319
|
+
* @param {string} message - The message to emit.
|
|
320
|
+
* @returns {Promise<void>}
|
|
321
|
+
*/
|
|
322
|
+
emit(message: string): Promise<void>;
|
|
323
|
+
/**
|
|
324
|
+
* Execute a command.
|
|
325
|
+
* @param {string} content - The content to execute.
|
|
326
|
+
* @param {string} mode - The source of execution: tool or user
|
|
327
|
+
* @returns {Promise<string>}
|
|
328
|
+
*/
|
|
329
|
+
execute(content: string, mode: ExecutionMode): Promise<string>;
|
|
330
|
+
/**
|
|
331
|
+
* Connect to a message sender.
|
|
332
|
+
* @param {SendMessageFn} connector - The function to send messages.
|
|
333
|
+
* @returns {ReceiveMessageFn}
|
|
334
|
+
*/
|
|
335
|
+
connect(connector: SendMessageFn$1): ReceiveMessageFn;
|
|
336
|
+
/**
|
|
337
|
+
* Commit tool output.
|
|
338
|
+
* @param {string} content - The content to commit.
|
|
339
|
+
* @returns {Promise<void>}
|
|
340
|
+
*/
|
|
341
|
+
commitToolOutput(content: string): Promise<void>;
|
|
342
|
+
/**
|
|
343
|
+
* Commit user message without answer
|
|
344
|
+
* @param {string} message - The message to commit.
|
|
345
|
+
* @returns {Promise<void>}
|
|
346
|
+
*/
|
|
347
|
+
commitUserMessage: (message: string) => Promise<void>;
|
|
348
|
+
/**
|
|
349
|
+
* Commit a system message.
|
|
350
|
+
* @param {string} message - The message to commit.
|
|
351
|
+
* @returns {Promise<void>}
|
|
352
|
+
*/
|
|
353
|
+
commitSystemMessage(message: string): Promise<void>;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Type for session ID.
|
|
357
|
+
* @typedef {string} SessionId
|
|
358
|
+
*/
|
|
359
|
+
type SessionId = string;
|
|
360
|
+
/**
|
|
361
|
+
* Type for session mode.
|
|
362
|
+
* @typedef {"session" | "makeConnection" | "complete"} SessionMode
|
|
363
|
+
*/
|
|
364
|
+
type SessionMode = "session" | "makeConnection" | "complete";
|
|
365
|
+
/**
|
|
366
|
+
* Tools can emit user messages to trigger user friendly responses.
|
|
367
|
+
* Should be ignored for `getUserHistory`
|
|
368
|
+
* @typedef {"tool" | "user"} ExecutionMode
|
|
369
|
+
*/
|
|
370
|
+
type ExecutionMode = "tool" | "user";
|
|
371
|
+
|
|
176
372
|
/**
|
|
177
373
|
* Interface representing a completion.
|
|
178
374
|
*/
|
|
@@ -190,6 +386,10 @@ interface ICompletionArgs {
|
|
|
190
386
|
* Name of the agent.
|
|
191
387
|
*/
|
|
192
388
|
agentName: AgentName;
|
|
389
|
+
/**
|
|
390
|
+
* The source of the last message: tool or user
|
|
391
|
+
*/
|
|
392
|
+
mode: ExecutionMode;
|
|
193
393
|
/**
|
|
194
394
|
* Array of model messages.
|
|
195
395
|
*/
|
|
@@ -296,9 +496,10 @@ interface IAgent {
|
|
|
296
496
|
/**
|
|
297
497
|
* Executes the agent with the given input.
|
|
298
498
|
* @param input - The input to execute.
|
|
499
|
+
* @param mode - The source of execution: tool or user
|
|
299
500
|
* @returns A promise that resolves when the execution is complete.
|
|
300
501
|
*/
|
|
301
|
-
execute: (input: string) => Promise<void>;
|
|
502
|
+
execute: (input: string, mode: ExecutionMode) => Promise<void>;
|
|
302
503
|
/**
|
|
303
504
|
* Waits for the output from the agent.
|
|
304
505
|
* @returns A promise that resolves to the output string.
|
|
@@ -328,72 +529,6 @@ type AgentName = string;
|
|
|
328
529
|
/** Type representing the name of a tool. */
|
|
329
530
|
type ToolName = string;
|
|
330
531
|
|
|
331
|
-
/**
|
|
332
|
-
* Parameters for initializing a swarm.
|
|
333
|
-
* @interface
|
|
334
|
-
* @extends {Omit<ISwarmSchema, 'agentList'>}
|
|
335
|
-
*/
|
|
336
|
-
interface ISwarmParams extends Omit<ISwarmSchema, keyof {
|
|
337
|
-
agentList: never;
|
|
338
|
-
}> {
|
|
339
|
-
/** Client identifier */
|
|
340
|
-
clientId: string;
|
|
341
|
-
/** Logger instance */
|
|
342
|
-
logger: ILogger;
|
|
343
|
-
/** Map of agent names to agent instances */
|
|
344
|
-
agentMap: Record<AgentName, IAgent>;
|
|
345
|
-
/** Emit the callback on agent change */
|
|
346
|
-
onAgentChanged(clientId: string, agentName: AgentName, swarmName: SwarmName): Promise<void>;
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Schema for defining a swarm.
|
|
350
|
-
* @interface
|
|
351
|
-
*/
|
|
352
|
-
interface ISwarmSchema {
|
|
353
|
-
/** Default agent name */
|
|
354
|
-
defaultAgent: AgentName;
|
|
355
|
-
/** Name of the swarm */
|
|
356
|
-
swarmName: string;
|
|
357
|
-
/** List of agent names */
|
|
358
|
-
agentList: string[];
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Interface for a swarm.
|
|
362
|
-
* @interface
|
|
363
|
-
*/
|
|
364
|
-
interface ISwarm {
|
|
365
|
-
/**
|
|
366
|
-
* Waits for the output from the swarm.
|
|
367
|
-
* @returns {Promise<string>} The output from the swarm.
|
|
368
|
-
*/
|
|
369
|
-
waitForOutput(): Promise<string>;
|
|
370
|
-
/**
|
|
371
|
-
* Gets the name of the agent.
|
|
372
|
-
* @returns {Promise<AgentName>} The name of the agent.
|
|
373
|
-
*/
|
|
374
|
-
getAgentName(): Promise<AgentName>;
|
|
375
|
-
/**
|
|
376
|
-
* Gets the agent instance.
|
|
377
|
-
* @returns {Promise<IAgent>} The agent instance.
|
|
378
|
-
*/
|
|
379
|
-
getAgent(): Promise<IAgent>;
|
|
380
|
-
/**
|
|
381
|
-
* Sets the reference to an agent.
|
|
382
|
-
* @param {AgentName} agentName - The name of the agent.
|
|
383
|
-
* @param {IAgent} agent - The agent instance.
|
|
384
|
-
* @returns {Promise<void>}
|
|
385
|
-
*/
|
|
386
|
-
setAgentRef(agentName: AgentName, agent: IAgent): Promise<void>;
|
|
387
|
-
/**
|
|
388
|
-
* Sets the name of the agent.
|
|
389
|
-
* @param {AgentName} agentName - The name of the agent.
|
|
390
|
-
* @returns {Promise<void>}
|
|
391
|
-
*/
|
|
392
|
-
setAgentName(agentName: AgentName): Promise<void>;
|
|
393
|
-
}
|
|
394
|
-
/** Type alias for swarm name */
|
|
395
|
-
type SwarmName = string;
|
|
396
|
-
|
|
397
532
|
/**
|
|
398
533
|
* Interface representing the context.
|
|
399
534
|
*/
|
|
@@ -455,14 +590,14 @@ declare class ClientAgent implements IAgent {
|
|
|
455
590
|
* @returns {Promise<void>}
|
|
456
591
|
* @private
|
|
457
592
|
*/
|
|
458
|
-
_emitOuput: (result: string) => Promise<void>;
|
|
593
|
+
_emitOuput: (mode: ExecutionMode, result: string) => Promise<void>;
|
|
459
594
|
/**
|
|
460
595
|
* Resurrects the model based on the given reason.
|
|
461
596
|
* @param {string} [reason] - The reason for resurrecting the model.
|
|
462
597
|
* @returns {Promise<string>}
|
|
463
598
|
* @private
|
|
464
599
|
*/
|
|
465
|
-
_resurrectModel: (reason?: string) => Promise<string>;
|
|
600
|
+
_resurrectModel: (mode: ExecutionMode, reason?: string) => Promise<string>;
|
|
466
601
|
/**
|
|
467
602
|
* Waits for the output to be available.
|
|
468
603
|
* @returns {Promise<string>}
|
|
@@ -472,7 +607,7 @@ declare class ClientAgent implements IAgent {
|
|
|
472
607
|
* Gets the completion message from the model.
|
|
473
608
|
* @returns {Promise<IModelMessage>}
|
|
474
609
|
*/
|
|
475
|
-
getCompletion: () => Promise<IModelMessage>;
|
|
610
|
+
getCompletion: (mode: ExecutionMode) => Promise<IModelMessage>;
|
|
476
611
|
/**
|
|
477
612
|
* Commits a user message to the history without answer.
|
|
478
613
|
* @param {string} message - The message to commit.
|
|
@@ -523,7 +658,7 @@ declare class AgentConnectionService implements IAgent {
|
|
|
523
658
|
* @param {string} input - The input command.
|
|
524
659
|
* @returns {Promise<any>} The execution result.
|
|
525
660
|
*/
|
|
526
|
-
execute: (input: string) => Promise<void>;
|
|
661
|
+
execute: (input: string, mode: ExecutionMode) => Promise<void>;
|
|
527
662
|
/**
|
|
528
663
|
* Waits for the output from the agent.
|
|
529
664
|
* @returns {Promise<any>} The output result.
|
|
@@ -804,123 +939,6 @@ declare class CompletionSchemaService {
|
|
|
804
939
|
get: (key: string) => ICompletionSchema;
|
|
805
940
|
}
|
|
806
941
|
|
|
807
|
-
/**
|
|
808
|
-
* Interface representing an incoming message.
|
|
809
|
-
*/
|
|
810
|
-
interface IIncomingMessage {
|
|
811
|
-
/**
|
|
812
|
-
* The ID of the client sending the message.
|
|
813
|
-
*/
|
|
814
|
-
clientId: string;
|
|
815
|
-
/**
|
|
816
|
-
* The data contained in the message.
|
|
817
|
-
*/
|
|
818
|
-
data: string;
|
|
819
|
-
/**
|
|
820
|
-
* The name of the agent sending the message.
|
|
821
|
-
*/
|
|
822
|
-
agentName: AgentName;
|
|
823
|
-
}
|
|
824
|
-
/**
|
|
825
|
-
* Interface representing an outgoing message.
|
|
826
|
-
*/
|
|
827
|
-
interface IOutgoingMessage {
|
|
828
|
-
/**
|
|
829
|
-
* The ID of the client receiving the message.
|
|
830
|
-
*/
|
|
831
|
-
clientId: string;
|
|
832
|
-
/**
|
|
833
|
-
* The data contained in the message.
|
|
834
|
-
*/
|
|
835
|
-
data: string;
|
|
836
|
-
/**
|
|
837
|
-
* The name of the agent sending the message.
|
|
838
|
-
*/
|
|
839
|
-
agentName: AgentName;
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
/**
|
|
843
|
-
* Parameters required to create a session.
|
|
844
|
-
* @interface
|
|
845
|
-
*/
|
|
846
|
-
interface ISessionParams extends ISessionSchema {
|
|
847
|
-
clientId: string;
|
|
848
|
-
logger: ILogger;
|
|
849
|
-
swarm: ISwarm;
|
|
850
|
-
}
|
|
851
|
-
/**
|
|
852
|
-
* Schema for session data.
|
|
853
|
-
* @interface
|
|
854
|
-
*/
|
|
855
|
-
interface ISessionSchema {
|
|
856
|
-
}
|
|
857
|
-
/**
|
|
858
|
-
* Function type for sending messages.
|
|
859
|
-
* @typedef {function} SendMessageFn
|
|
860
|
-
* @param {IOutgoingMessage} outgoing - The outgoing message.
|
|
861
|
-
* @returns {Promise<void> | void}
|
|
862
|
-
*/
|
|
863
|
-
type SendMessageFn$1 = (outgoing: IOutgoingMessage) => Promise<void> | void;
|
|
864
|
-
/**
|
|
865
|
-
* Function type for receiving messages.
|
|
866
|
-
* @typedef {function} ReceiveMessageFn
|
|
867
|
-
* @param {IIncomingMessage} incoming - The incoming message.
|
|
868
|
-
* @returns {Promise<void> | void}
|
|
869
|
-
*/
|
|
870
|
-
type ReceiveMessageFn = (incoming: IIncomingMessage) => Promise<void> | void;
|
|
871
|
-
/**
|
|
872
|
-
* Interface for a session.
|
|
873
|
-
* @interface
|
|
874
|
-
*/
|
|
875
|
-
interface ISession {
|
|
876
|
-
/**
|
|
877
|
-
* Emit a message.
|
|
878
|
-
* @param {string} message - The message to emit.
|
|
879
|
-
* @returns {Promise<void>}
|
|
880
|
-
*/
|
|
881
|
-
emit(message: string): Promise<void>;
|
|
882
|
-
/**
|
|
883
|
-
* Execute a command.
|
|
884
|
-
* @param {string} content - The content to execute.
|
|
885
|
-
* @returns {Promise<string>}
|
|
886
|
-
*/
|
|
887
|
-
execute(content: string): Promise<string>;
|
|
888
|
-
/**
|
|
889
|
-
* Connect to a message sender.
|
|
890
|
-
* @param {SendMessageFn} connector - The function to send messages.
|
|
891
|
-
* @returns {ReceiveMessageFn}
|
|
892
|
-
*/
|
|
893
|
-
connect(connector: SendMessageFn$1): ReceiveMessageFn;
|
|
894
|
-
/**
|
|
895
|
-
* Commit tool output.
|
|
896
|
-
* @param {string} content - The content to commit.
|
|
897
|
-
* @returns {Promise<void>}
|
|
898
|
-
*/
|
|
899
|
-
commitToolOutput(content: string): Promise<void>;
|
|
900
|
-
/**
|
|
901
|
-
* Commit user message without answer
|
|
902
|
-
* @param {string} message - The message to commit.
|
|
903
|
-
* @returns {Promise<void>}
|
|
904
|
-
*/
|
|
905
|
-
commitUserMessage: (message: string) => Promise<void>;
|
|
906
|
-
/**
|
|
907
|
-
* Commit a system message.
|
|
908
|
-
* @param {string} message - The message to commit.
|
|
909
|
-
* @returns {Promise<void>}
|
|
910
|
-
*/
|
|
911
|
-
commitSystemMessage(message: string): Promise<void>;
|
|
912
|
-
}
|
|
913
|
-
/**
|
|
914
|
-
* Type for session ID.
|
|
915
|
-
* @typedef {string} SessionId
|
|
916
|
-
*/
|
|
917
|
-
type SessionId = string;
|
|
918
|
-
/**
|
|
919
|
-
* Type for session mode.
|
|
920
|
-
* @typedef {"session" | "makeConnection" | "complete"} SessionMode
|
|
921
|
-
*/
|
|
922
|
-
type SessionMode = "session" | "makeConnection" | "complete";
|
|
923
|
-
|
|
924
942
|
/**
|
|
925
943
|
* ClientSession class implements the ISession interface.
|
|
926
944
|
*/
|
|
@@ -944,7 +962,7 @@ declare class ClientSession implements ISession {
|
|
|
944
962
|
* @param {boolean} [noEmit=false] - Whether to emit the output or not.
|
|
945
963
|
* @returns {Promise<string>} - The output of the execution.
|
|
946
964
|
*/
|
|
947
|
-
execute: (message: string, noEmit?: boolean) => Promise<string>;
|
|
965
|
+
execute: (message: string, mode: ExecutionMode, noEmit?: boolean) => Promise<string>;
|
|
948
966
|
/**
|
|
949
967
|
* Commits tool output.
|
|
950
968
|
* @param {string} content - The content to commit.
|
|
@@ -997,7 +1015,7 @@ declare class SessionConnectionService implements ISession {
|
|
|
997
1015
|
* @param {string} content - The content to execute.
|
|
998
1016
|
* @returns {Promise<string>} A promise that resolves with the execution result.
|
|
999
1017
|
*/
|
|
1000
|
-
execute: (content: string) => Promise<string>;
|
|
1018
|
+
execute: (content: string, mode: ExecutionMode) => Promise<string>;
|
|
1001
1019
|
/**
|
|
1002
1020
|
* Connects to the session using the provided connector.
|
|
1003
1021
|
* @param {SendMessageFn} connector - The function to send messages.
|
|
@@ -1057,7 +1075,7 @@ declare class AgentPublicService implements TAgentConnectionService {
|
|
|
1057
1075
|
* @param {AgentName} agentName - The name of the agent.
|
|
1058
1076
|
* @returns {Promise<unknown>} The execution result.
|
|
1059
1077
|
*/
|
|
1060
|
-
execute: (input: string, clientId: string, agentName: AgentName) => Promise<void>;
|
|
1078
|
+
execute: (input: string, mode: ExecutionMode, clientId: string, agentName: AgentName) => Promise<void>;
|
|
1061
1079
|
/**
|
|
1062
1080
|
* Waits for the agent's output.
|
|
1063
1081
|
* @param {string} clientId - The client ID.
|
|
@@ -1174,7 +1192,7 @@ declare class SessionPublicService implements TSessionConnectionService {
|
|
|
1174
1192
|
* @param {SwarmName} swarmName - The swarm name.
|
|
1175
1193
|
* @returns {Promise<void>}
|
|
1176
1194
|
*/
|
|
1177
|
-
execute: (content: string, clientId: string, swarmName: SwarmName) => Promise<string>;
|
|
1195
|
+
execute: (content: string, mode: ExecutionMode, clientId: string, swarmName: SwarmName) => Promise<string>;
|
|
1178
1196
|
/**
|
|
1179
1197
|
* Connects to the session.
|
|
1180
1198
|
* @param {SendMessageFn} connector - The function to send messages.
|