agent-swarm-kit 1.0.28 → 1.0.29
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 +38 -23
- package/build/index.mjs +38 -23
- package/package.json +1 -1
- package/types.d.ts +204 -190
package/build/index.cjs
CHANGED
|
@@ -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,6 +489,7 @@ 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
|
})];
|
|
@@ -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:
|
|
@@ -571,6 +574,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
571
574
|
return [4 /*yield*/, this.params.history.push({
|
|
572
575
|
role: "user",
|
|
573
576
|
agentName: this.params.agentName,
|
|
577
|
+
mode: 'user',
|
|
574
578
|
content: message.trim(),
|
|
575
579
|
})];
|
|
576
580
|
case 1:
|
|
@@ -592,6 +596,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
592
596
|
return [4 /*yield*/, this.params.history.push({
|
|
593
597
|
role: "system",
|
|
594
598
|
agentName: this.params.agentName,
|
|
599
|
+
mode: 'tool',
|
|
595
600
|
content: message.trim(),
|
|
596
601
|
})];
|
|
597
602
|
case 1:
|
|
@@ -613,6 +618,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
613
618
|
return [4 /*yield*/, this.params.history.push({
|
|
614
619
|
role: "tool",
|
|
615
620
|
agentName: this.params.agentName,
|
|
621
|
+
mode: 'tool',
|
|
616
622
|
content: content,
|
|
617
623
|
})];
|
|
618
624
|
case 1:
|
|
@@ -629,16 +635,17 @@ var ClientAgent = /** @class */ (function () {
|
|
|
629
635
|
* @param {string} incoming - The incoming message content.
|
|
630
636
|
* @returns {Promise<void>}
|
|
631
637
|
*/
|
|
632
|
-
this.execute = functoolsKit.queued(function (incoming) { return __awaiter(_this, void 0, void 0, function () {
|
|
638
|
+
this.execute = functoolsKit.queued(function (incoming, mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
633
639
|
var message, _loop_1, this_1, _a, _b, tool, state_1, e_1_1, result, validation, result1;
|
|
634
640
|
var e_1, _c;
|
|
635
641
|
var _d;
|
|
636
642
|
return __generator(this, function (_e) {
|
|
637
643
|
switch (_e.label) {
|
|
638
644
|
case 0:
|
|
639
|
-
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute begin"), { incoming: incoming });
|
|
645
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute begin"), { incoming: incoming, mode: mode });
|
|
640
646
|
return [4 /*yield*/, this.params.history.push({
|
|
641
647
|
role: "user",
|
|
648
|
+
mode: mode,
|
|
642
649
|
agentName: this.params.agentName,
|
|
643
650
|
content: incoming.trim(),
|
|
644
651
|
})];
|
|
@@ -807,15 +814,16 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
807
814
|
* @param {string} input - The input command.
|
|
808
815
|
* @returns {Promise<any>} The execution result.
|
|
809
816
|
*/
|
|
810
|
-
this.execute = function (input) { return __awaiter(_this, void 0, void 0, function () {
|
|
817
|
+
this.execute = function (input, mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
811
818
|
return __generator(this, function (_a) {
|
|
812
819
|
switch (_a.label) {
|
|
813
820
|
case 0:
|
|
814
821
|
this.loggerService.log("agentConnectionService execute", {
|
|
815
822
|
input: input,
|
|
823
|
+
mode: mode,
|
|
816
824
|
context: this.contextService.context,
|
|
817
825
|
});
|
|
818
|
-
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).execute(input)];
|
|
826
|
+
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).execute(input, mode)];
|
|
819
827
|
case 1: return [2 /*return*/, _a.sent()];
|
|
820
828
|
}
|
|
821
829
|
});
|
|
@@ -1068,6 +1076,7 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1068
1076
|
{
|
|
1069
1077
|
promptMessages.push({
|
|
1070
1078
|
agentName: this.params.agentName,
|
|
1079
|
+
mode: 'tool',
|
|
1071
1080
|
content: prompt,
|
|
1072
1081
|
role: "system",
|
|
1073
1082
|
});
|
|
@@ -1075,6 +1084,7 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1075
1084
|
system.forEach(function (content) {
|
|
1076
1085
|
return promptMessages.push({
|
|
1077
1086
|
agentName: _this.params.agentName,
|
|
1087
|
+
mode: 'tool',
|
|
1078
1088
|
content: content,
|
|
1079
1089
|
role: "system",
|
|
1080
1090
|
});
|
|
@@ -1639,12 +1649,12 @@ var ClientSession = /** @class */ (function () {
|
|
|
1639
1649
|
* @param {boolean} [noEmit=false] - Whether to emit the output or not.
|
|
1640
1650
|
* @returns {Promise<string>} - The output of the execution.
|
|
1641
1651
|
*/
|
|
1642
|
-
this.execute = function (message_1) {
|
|
1652
|
+
this.execute = function (message_1, mode_1) {
|
|
1643
1653
|
var args_1 = [];
|
|
1644
|
-
for (var _i =
|
|
1645
|
-
args_1[_i -
|
|
1654
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1655
|
+
args_1[_i - 2] = arguments[_i];
|
|
1646
1656
|
}
|
|
1647
|
-
return __awaiter(_this, __spreadArray([message_1], __read(args_1), false), void 0, function (message, noEmit) {
|
|
1657
|
+
return __awaiter(_this, __spreadArray([message_1, mode_1], __read(args_1), false), void 0, function (message, mode, noEmit) {
|
|
1648
1658
|
var agent, outputAwaiter, output, _a;
|
|
1649
1659
|
if (noEmit === void 0) { noEmit = false; }
|
|
1650
1660
|
return __generator(this, function (_b) {
|
|
@@ -1652,13 +1662,14 @@ var ClientSession = /** @class */ (function () {
|
|
|
1652
1662
|
case 0:
|
|
1653
1663
|
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " execute"), {
|
|
1654
1664
|
message: message,
|
|
1665
|
+
mode: mode,
|
|
1655
1666
|
noEmit: noEmit,
|
|
1656
1667
|
});
|
|
1657
1668
|
return [4 /*yield*/, this.params.swarm.getAgent()];
|
|
1658
1669
|
case 1:
|
|
1659
1670
|
agent = _b.sent();
|
|
1660
1671
|
outputAwaiter = this.params.swarm.waitForOutput();
|
|
1661
|
-
agent.execute(message);
|
|
1672
|
+
agent.execute(message, mode);
|
|
1662
1673
|
return [4 /*yield*/, outputAwaiter];
|
|
1663
1674
|
case 2:
|
|
1664
1675
|
output = _b.sent();
|
|
@@ -1771,7 +1782,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
1771
1782
|
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " connect call"));
|
|
1772
1783
|
_a = connector;
|
|
1773
1784
|
_b = {};
|
|
1774
|
-
return [4 /*yield*/, this.execute(incoming.data, true)];
|
|
1785
|
+
return [4 /*yield*/, this.execute(incoming.data, "user", true)];
|
|
1775
1786
|
case 1:
|
|
1776
1787
|
_b.data = _c.sent();
|
|
1777
1788
|
return [4 /*yield*/, this.params.swarm.getAgentName()];
|
|
@@ -1840,14 +1851,16 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
1840
1851
|
* @param {string} content - The content to execute.
|
|
1841
1852
|
* @returns {Promise<string>} A promise that resolves with the execution result.
|
|
1842
1853
|
*/
|
|
1843
|
-
this.execute = function (content) { return __awaiter(_this, void 0, void 0, function () {
|
|
1854
|
+
this.execute = function (content, mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
1844
1855
|
return __generator(this, function (_a) {
|
|
1845
1856
|
switch (_a.label) {
|
|
1846
1857
|
case 0:
|
|
1847
1858
|
this.loggerService.log("sessionConnectionService execute", {
|
|
1848
1859
|
context: this.contextService.context,
|
|
1860
|
+
content: content,
|
|
1861
|
+
mode: mode,
|
|
1849
1862
|
});
|
|
1850
|
-
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).execute(content)];
|
|
1863
|
+
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).execute(content, mode)];
|
|
1851
1864
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1852
1865
|
}
|
|
1853
1866
|
});
|
|
@@ -1977,7 +1990,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
1977
1990
|
* @param {AgentName} agentName - The name of the agent.
|
|
1978
1991
|
* @returns {Promise<unknown>} The execution result.
|
|
1979
1992
|
*/
|
|
1980
|
-
this.execute = function (input, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
1993
|
+
this.execute = function (input, mode, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
1981
1994
|
var _this = this;
|
|
1982
1995
|
return __generator(this, function (_a) {
|
|
1983
1996
|
switch (_a.label) {
|
|
@@ -1986,11 +1999,12 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
1986
1999
|
input: input,
|
|
1987
2000
|
clientId: clientId,
|
|
1988
2001
|
agentName: agentName,
|
|
2002
|
+
mode: mode,
|
|
1989
2003
|
});
|
|
1990
2004
|
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1991
2005
|
return __generator(this, function (_a) {
|
|
1992
2006
|
switch (_a.label) {
|
|
1993
|
-
case 0: return [4 /*yield*/, this.agentConnectionService.execute(input)];
|
|
2007
|
+
case 0: return [4 /*yield*/, this.agentConnectionService.execute(input, mode)];
|
|
1994
2008
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1995
2009
|
}
|
|
1996
2010
|
});
|
|
@@ -2356,20 +2370,21 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
2356
2370
|
* @param {SwarmName} swarmName - The swarm name.
|
|
2357
2371
|
* @returns {Promise<void>}
|
|
2358
2372
|
*/
|
|
2359
|
-
this.execute = function (content, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
2373
|
+
this.execute = function (content, mode, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
2360
2374
|
var _this = this;
|
|
2361
2375
|
return __generator(this, function (_a) {
|
|
2362
2376
|
switch (_a.label) {
|
|
2363
2377
|
case 0:
|
|
2364
2378
|
this.loggerService.log("sessionPublicService execute", {
|
|
2365
2379
|
content: content,
|
|
2380
|
+
mode: mode,
|
|
2366
2381
|
clientId: clientId,
|
|
2367
2382
|
swarmName: swarmName,
|
|
2368
2383
|
});
|
|
2369
2384
|
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2370
2385
|
return __generator(this, function (_a) {
|
|
2371
2386
|
switch (_a.label) {
|
|
2372
|
-
case 0: return [4 /*yield*/, this.sessionConnectionService.execute(content)];
|
|
2387
|
+
case 0: return [4 /*yield*/, this.sessionConnectionService.execute(content, mode)];
|
|
2373
2388
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2374
2389
|
}
|
|
2375
2390
|
});
|
|
@@ -3661,7 +3676,7 @@ var createComplete = functoolsKit.ttl(function (clientId, swarmName) {
|
|
|
3661
3676
|
case 0:
|
|
3662
3677
|
swarm.swarmValidationService.validate(swarmName, "complete");
|
|
3663
3678
|
swarm.sessionValidationService.addSession(clientId, swarmName, "complete");
|
|
3664
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, clientId, swarmName)];
|
|
3679
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", clientId, swarmName)];
|
|
3665
3680
|
case 1:
|
|
3666
3681
|
result = _a.sent();
|
|
3667
3682
|
return [4 /*yield*/, disposeConnection(clientId, swarmName)];
|
|
@@ -3746,7 +3761,7 @@ var session = function (clientId, swarmName) {
|
|
|
3746
3761
|
switch (_a.label) {
|
|
3747
3762
|
case 0:
|
|
3748
3763
|
swarm.sessionValidationService.validate(clientId, "session");
|
|
3749
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, clientId, swarmName)];
|
|
3764
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", clientId, swarmName)];
|
|
3750
3765
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3751
3766
|
}
|
|
3752
3767
|
});
|
|
@@ -4028,7 +4043,7 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
|
|
|
4028
4043
|
});
|
|
4029
4044
|
return [2 /*return*/];
|
|
4030
4045
|
}
|
|
4031
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, clientId, swarmName)];
|
|
4046
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", clientId, swarmName)];
|
|
4032
4047
|
case 2: return [2 /*return*/, _a.sent()];
|
|
4033
4048
|
}
|
|
4034
4049
|
});
|
|
@@ -4096,8 +4111,8 @@ var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0,
|
|
|
4096
4111
|
case 1:
|
|
4097
4112
|
history = _a.sent();
|
|
4098
4113
|
last = history.findLast(function (_a) {
|
|
4099
|
-
var role = _a.role;
|
|
4100
|
-
return role === "user";
|
|
4114
|
+
var role = _a.role, mode = _a.mode;
|
|
4115
|
+
return role === "user" && mode === "user";
|
|
4101
4116
|
});
|
|
4102
4117
|
return [2 /*return*/, last ? last.content : null];
|
|
4103
4118
|
}
|
|
@@ -4122,8 +4137,8 @@ var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
4122
4137
|
case 1:
|
|
4123
4138
|
history = _a.sent();
|
|
4124
4139
|
return [2 /*return*/, history.filter(function (_a) {
|
|
4125
|
-
var role = _a.role;
|
|
4126
|
-
return role === "user";
|
|
4140
|
+
var role = _a.role, mode = _a.mode;
|
|
4141
|
+
return role === "user" && mode === "user";
|
|
4127
4142
|
})];
|
|
4128
4143
|
}
|
|
4129
4144
|
});
|
package/build/index.mjs
CHANGED
|
@@ -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,6 +487,7 @@ 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
|
})];
|
|
@@ -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:
|
|
@@ -569,6 +572,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
569
572
|
return [4 /*yield*/, this.params.history.push({
|
|
570
573
|
role: "user",
|
|
571
574
|
agentName: this.params.agentName,
|
|
575
|
+
mode: 'user',
|
|
572
576
|
content: message.trim(),
|
|
573
577
|
})];
|
|
574
578
|
case 1:
|
|
@@ -590,6 +594,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
590
594
|
return [4 /*yield*/, this.params.history.push({
|
|
591
595
|
role: "system",
|
|
592
596
|
agentName: this.params.agentName,
|
|
597
|
+
mode: 'tool',
|
|
593
598
|
content: message.trim(),
|
|
594
599
|
})];
|
|
595
600
|
case 1:
|
|
@@ -611,6 +616,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
611
616
|
return [4 /*yield*/, this.params.history.push({
|
|
612
617
|
role: "tool",
|
|
613
618
|
agentName: this.params.agentName,
|
|
619
|
+
mode: 'tool',
|
|
614
620
|
content: content,
|
|
615
621
|
})];
|
|
616
622
|
case 1:
|
|
@@ -627,16 +633,17 @@ var ClientAgent = /** @class */ (function () {
|
|
|
627
633
|
* @param {string} incoming - The incoming message content.
|
|
628
634
|
* @returns {Promise<void>}
|
|
629
635
|
*/
|
|
630
|
-
this.execute = queued(function (incoming) { return __awaiter(_this, void 0, void 0, function () {
|
|
636
|
+
this.execute = queued(function (incoming, mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
631
637
|
var message, _loop_1, this_1, _a, _b, tool, state_1, e_1_1, result, validation, result1;
|
|
632
638
|
var e_1, _c;
|
|
633
639
|
var _d;
|
|
634
640
|
return __generator(this, function (_e) {
|
|
635
641
|
switch (_e.label) {
|
|
636
642
|
case 0:
|
|
637
|
-
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute begin"), { incoming: incoming });
|
|
643
|
+
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " execute begin"), { incoming: incoming, mode: mode });
|
|
638
644
|
return [4 /*yield*/, this.params.history.push({
|
|
639
645
|
role: "user",
|
|
646
|
+
mode: mode,
|
|
640
647
|
agentName: this.params.agentName,
|
|
641
648
|
content: incoming.trim(),
|
|
642
649
|
})];
|
|
@@ -805,15 +812,16 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
805
812
|
* @param {string} input - The input command.
|
|
806
813
|
* @returns {Promise<any>} The execution result.
|
|
807
814
|
*/
|
|
808
|
-
this.execute = function (input) { return __awaiter(_this, void 0, void 0, function () {
|
|
815
|
+
this.execute = function (input, mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
809
816
|
return __generator(this, function (_a) {
|
|
810
817
|
switch (_a.label) {
|
|
811
818
|
case 0:
|
|
812
819
|
this.loggerService.log("agentConnectionService execute", {
|
|
813
820
|
input: input,
|
|
821
|
+
mode: mode,
|
|
814
822
|
context: this.contextService.context,
|
|
815
823
|
});
|
|
816
|
-
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).execute(input)];
|
|
824
|
+
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).execute(input, mode)];
|
|
817
825
|
case 1: return [2 /*return*/, _a.sent()];
|
|
818
826
|
}
|
|
819
827
|
});
|
|
@@ -1066,6 +1074,7 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1066
1074
|
{
|
|
1067
1075
|
promptMessages.push({
|
|
1068
1076
|
agentName: this.params.agentName,
|
|
1077
|
+
mode: 'tool',
|
|
1069
1078
|
content: prompt,
|
|
1070
1079
|
role: "system",
|
|
1071
1080
|
});
|
|
@@ -1073,6 +1082,7 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1073
1082
|
system.forEach(function (content) {
|
|
1074
1083
|
return promptMessages.push({
|
|
1075
1084
|
agentName: _this.params.agentName,
|
|
1085
|
+
mode: 'tool',
|
|
1076
1086
|
content: content,
|
|
1077
1087
|
role: "system",
|
|
1078
1088
|
});
|
|
@@ -1637,12 +1647,12 @@ var ClientSession = /** @class */ (function () {
|
|
|
1637
1647
|
* @param {boolean} [noEmit=false] - Whether to emit the output or not.
|
|
1638
1648
|
* @returns {Promise<string>} - The output of the execution.
|
|
1639
1649
|
*/
|
|
1640
|
-
this.execute = function (message_1) {
|
|
1650
|
+
this.execute = function (message_1, mode_1) {
|
|
1641
1651
|
var args_1 = [];
|
|
1642
|
-
for (var _i =
|
|
1643
|
-
args_1[_i -
|
|
1652
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1653
|
+
args_1[_i - 2] = arguments[_i];
|
|
1644
1654
|
}
|
|
1645
|
-
return __awaiter(_this, __spreadArray([message_1], __read(args_1), false), void 0, function (message, noEmit) {
|
|
1655
|
+
return __awaiter(_this, __spreadArray([message_1, mode_1], __read(args_1), false), void 0, function (message, mode, noEmit) {
|
|
1646
1656
|
var agent, outputAwaiter, output, _a;
|
|
1647
1657
|
if (noEmit === void 0) { noEmit = false; }
|
|
1648
1658
|
return __generator(this, function (_b) {
|
|
@@ -1650,13 +1660,14 @@ var ClientSession = /** @class */ (function () {
|
|
|
1650
1660
|
case 0:
|
|
1651
1661
|
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " execute"), {
|
|
1652
1662
|
message: message,
|
|
1663
|
+
mode: mode,
|
|
1653
1664
|
noEmit: noEmit,
|
|
1654
1665
|
});
|
|
1655
1666
|
return [4 /*yield*/, this.params.swarm.getAgent()];
|
|
1656
1667
|
case 1:
|
|
1657
1668
|
agent = _b.sent();
|
|
1658
1669
|
outputAwaiter = this.params.swarm.waitForOutput();
|
|
1659
|
-
agent.execute(message);
|
|
1670
|
+
agent.execute(message, mode);
|
|
1660
1671
|
return [4 /*yield*/, outputAwaiter];
|
|
1661
1672
|
case 2:
|
|
1662
1673
|
output = _b.sent();
|
|
@@ -1769,7 +1780,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
1769
1780
|
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " connect call"));
|
|
1770
1781
|
_a = connector;
|
|
1771
1782
|
_b = {};
|
|
1772
|
-
return [4 /*yield*/, this.execute(incoming.data, true)];
|
|
1783
|
+
return [4 /*yield*/, this.execute(incoming.data, "user", true)];
|
|
1773
1784
|
case 1:
|
|
1774
1785
|
_b.data = _c.sent();
|
|
1775
1786
|
return [4 /*yield*/, this.params.swarm.getAgentName()];
|
|
@@ -1838,14 +1849,16 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
1838
1849
|
* @param {string} content - The content to execute.
|
|
1839
1850
|
* @returns {Promise<string>} A promise that resolves with the execution result.
|
|
1840
1851
|
*/
|
|
1841
|
-
this.execute = function (content) { return __awaiter(_this, void 0, void 0, function () {
|
|
1852
|
+
this.execute = function (content, mode) { return __awaiter(_this, void 0, void 0, function () {
|
|
1842
1853
|
return __generator(this, function (_a) {
|
|
1843
1854
|
switch (_a.label) {
|
|
1844
1855
|
case 0:
|
|
1845
1856
|
this.loggerService.log("sessionConnectionService execute", {
|
|
1846
1857
|
context: this.contextService.context,
|
|
1858
|
+
content: content,
|
|
1859
|
+
mode: mode,
|
|
1847
1860
|
});
|
|
1848
|
-
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).execute(content)];
|
|
1861
|
+
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).execute(content, mode)];
|
|
1849
1862
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1850
1863
|
}
|
|
1851
1864
|
});
|
|
@@ -1975,7 +1988,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
1975
1988
|
* @param {AgentName} agentName - The name of the agent.
|
|
1976
1989
|
* @returns {Promise<unknown>} The execution result.
|
|
1977
1990
|
*/
|
|
1978
|
-
this.execute = function (input, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
1991
|
+
this.execute = function (input, mode, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
1979
1992
|
var _this = this;
|
|
1980
1993
|
return __generator(this, function (_a) {
|
|
1981
1994
|
switch (_a.label) {
|
|
@@ -1984,11 +1997,12 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
1984
1997
|
input: input,
|
|
1985
1998
|
clientId: clientId,
|
|
1986
1999
|
agentName: agentName,
|
|
2000
|
+
mode: mode,
|
|
1987
2001
|
});
|
|
1988
2002
|
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1989
2003
|
return __generator(this, function (_a) {
|
|
1990
2004
|
switch (_a.label) {
|
|
1991
|
-
case 0: return [4 /*yield*/, this.agentConnectionService.execute(input)];
|
|
2005
|
+
case 0: return [4 /*yield*/, this.agentConnectionService.execute(input, mode)];
|
|
1992
2006
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1993
2007
|
}
|
|
1994
2008
|
});
|
|
@@ -2354,20 +2368,21 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
2354
2368
|
* @param {SwarmName} swarmName - The swarm name.
|
|
2355
2369
|
* @returns {Promise<void>}
|
|
2356
2370
|
*/
|
|
2357
|
-
this.execute = function (content, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
2371
|
+
this.execute = function (content, mode, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
2358
2372
|
var _this = this;
|
|
2359
2373
|
return __generator(this, function (_a) {
|
|
2360
2374
|
switch (_a.label) {
|
|
2361
2375
|
case 0:
|
|
2362
2376
|
this.loggerService.log("sessionPublicService execute", {
|
|
2363
2377
|
content: content,
|
|
2378
|
+
mode: mode,
|
|
2364
2379
|
clientId: clientId,
|
|
2365
2380
|
swarmName: swarmName,
|
|
2366
2381
|
});
|
|
2367
2382
|
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2368
2383
|
return __generator(this, function (_a) {
|
|
2369
2384
|
switch (_a.label) {
|
|
2370
|
-
case 0: return [4 /*yield*/, this.sessionConnectionService.execute(content)];
|
|
2385
|
+
case 0: return [4 /*yield*/, this.sessionConnectionService.execute(content, mode)];
|
|
2371
2386
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2372
2387
|
}
|
|
2373
2388
|
});
|
|
@@ -3659,7 +3674,7 @@ var createComplete = ttl(function (clientId, swarmName) {
|
|
|
3659
3674
|
case 0:
|
|
3660
3675
|
swarm.swarmValidationService.validate(swarmName, "complete");
|
|
3661
3676
|
swarm.sessionValidationService.addSession(clientId, swarmName, "complete");
|
|
3662
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, clientId, swarmName)];
|
|
3677
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", clientId, swarmName)];
|
|
3663
3678
|
case 1:
|
|
3664
3679
|
result = _a.sent();
|
|
3665
3680
|
return [4 /*yield*/, disposeConnection(clientId, swarmName)];
|
|
@@ -3744,7 +3759,7 @@ var session = function (clientId, swarmName) {
|
|
|
3744
3759
|
switch (_a.label) {
|
|
3745
3760
|
case 0:
|
|
3746
3761
|
swarm.sessionValidationService.validate(clientId, "session");
|
|
3747
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, clientId, swarmName)];
|
|
3762
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", clientId, swarmName)];
|
|
3748
3763
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3749
3764
|
}
|
|
3750
3765
|
});
|
|
@@ -4026,7 +4041,7 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
|
|
|
4026
4041
|
});
|
|
4027
4042
|
return [2 /*return*/];
|
|
4028
4043
|
}
|
|
4029
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, clientId, swarmName)];
|
|
4044
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", clientId, swarmName)];
|
|
4030
4045
|
case 2: return [2 /*return*/, _a.sent()];
|
|
4031
4046
|
}
|
|
4032
4047
|
});
|
|
@@ -4094,8 +4109,8 @@ var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0,
|
|
|
4094
4109
|
case 1:
|
|
4095
4110
|
history = _a.sent();
|
|
4096
4111
|
last = history.findLast(function (_a) {
|
|
4097
|
-
var role = _a.role;
|
|
4098
|
-
return role === "user";
|
|
4112
|
+
var role = _a.role, mode = _a.mode;
|
|
4113
|
+
return role === "user" && mode === "user";
|
|
4099
4114
|
});
|
|
4100
4115
|
return [2 /*return*/, last ? last.content : null];
|
|
4101
4116
|
}
|
|
@@ -4120,8 +4135,8 @@ var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
4120
4135
|
case 1:
|
|
4121
4136
|
history = _a.sent();
|
|
4122
4137
|
return [2 /*return*/, history.filter(function (_a) {
|
|
4123
|
-
var role = _a.role;
|
|
4124
|
-
return role === "user";
|
|
4138
|
+
var role = _a.role, mode = _a.mode;
|
|
4139
|
+
return role === "user" && mode === "user";
|
|
4125
4140
|
})];
|
|
4126
4141
|
}
|
|
4127
4142
|
});
|
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; }; }; }>}
|
|
@@ -219,6 +225,196 @@ interface ICompletionSchema {
|
|
|
219
225
|
*/
|
|
220
226
|
type CompletionName = string;
|
|
221
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Interface representing an incoming message.
|
|
230
|
+
*/
|
|
231
|
+
interface IIncomingMessage {
|
|
232
|
+
/**
|
|
233
|
+
* The ID of the client sending the message.
|
|
234
|
+
*/
|
|
235
|
+
clientId: string;
|
|
236
|
+
/**
|
|
237
|
+
* The data contained in the message.
|
|
238
|
+
*/
|
|
239
|
+
data: string;
|
|
240
|
+
/**
|
|
241
|
+
* The name of the agent sending the message.
|
|
242
|
+
*/
|
|
243
|
+
agentName: AgentName;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Interface representing an outgoing message.
|
|
247
|
+
*/
|
|
248
|
+
interface IOutgoingMessage {
|
|
249
|
+
/**
|
|
250
|
+
* The ID of the client receiving the message.
|
|
251
|
+
*/
|
|
252
|
+
clientId: string;
|
|
253
|
+
/**
|
|
254
|
+
* The data contained in the message.
|
|
255
|
+
*/
|
|
256
|
+
data: string;
|
|
257
|
+
/**
|
|
258
|
+
* The name of the agent sending the message.
|
|
259
|
+
*/
|
|
260
|
+
agentName: AgentName;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Parameters for initializing a swarm.
|
|
265
|
+
* @interface
|
|
266
|
+
* @extends {Omit<ISwarmSchema, 'agentList'>}
|
|
267
|
+
*/
|
|
268
|
+
interface ISwarmParams extends Omit<ISwarmSchema, keyof {
|
|
269
|
+
agentList: never;
|
|
270
|
+
}> {
|
|
271
|
+
/** Client identifier */
|
|
272
|
+
clientId: string;
|
|
273
|
+
/** Logger instance */
|
|
274
|
+
logger: ILogger;
|
|
275
|
+
/** Map of agent names to agent instances */
|
|
276
|
+
agentMap: Record<AgentName, IAgent>;
|
|
277
|
+
/** Emit the callback on agent change */
|
|
278
|
+
onAgentChanged(clientId: string, agentName: AgentName, swarmName: SwarmName): Promise<void>;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Schema for defining a swarm.
|
|
282
|
+
* @interface
|
|
283
|
+
*/
|
|
284
|
+
interface ISwarmSchema {
|
|
285
|
+
/** Default agent name */
|
|
286
|
+
defaultAgent: AgentName;
|
|
287
|
+
/** Name of the swarm */
|
|
288
|
+
swarmName: string;
|
|
289
|
+
/** List of agent names */
|
|
290
|
+
agentList: string[];
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Interface for a swarm.
|
|
294
|
+
* @interface
|
|
295
|
+
*/
|
|
296
|
+
interface ISwarm {
|
|
297
|
+
/**
|
|
298
|
+
* Waits for the output from the swarm.
|
|
299
|
+
* @returns {Promise<string>} The output from the swarm.
|
|
300
|
+
*/
|
|
301
|
+
waitForOutput(): Promise<string>;
|
|
302
|
+
/**
|
|
303
|
+
* Gets the name of the agent.
|
|
304
|
+
* @returns {Promise<AgentName>} The name of the agent.
|
|
305
|
+
*/
|
|
306
|
+
getAgentName(): Promise<AgentName>;
|
|
307
|
+
/**
|
|
308
|
+
* Gets the agent instance.
|
|
309
|
+
* @returns {Promise<IAgent>} The agent instance.
|
|
310
|
+
*/
|
|
311
|
+
getAgent(): Promise<IAgent>;
|
|
312
|
+
/**
|
|
313
|
+
* Sets the reference to an agent.
|
|
314
|
+
* @param {AgentName} agentName - The name of the agent.
|
|
315
|
+
* @param {IAgent} agent - The agent instance.
|
|
316
|
+
* @returns {Promise<void>}
|
|
317
|
+
*/
|
|
318
|
+
setAgentRef(agentName: AgentName, agent: IAgent): Promise<void>;
|
|
319
|
+
/**
|
|
320
|
+
* Sets the name of the agent.
|
|
321
|
+
* @param {AgentName} agentName - The name of the agent.
|
|
322
|
+
* @returns {Promise<void>}
|
|
323
|
+
*/
|
|
324
|
+
setAgentName(agentName: AgentName): Promise<void>;
|
|
325
|
+
}
|
|
326
|
+
/** Type alias for swarm name */
|
|
327
|
+
type SwarmName = string;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Parameters required to create a session.
|
|
331
|
+
* @interface
|
|
332
|
+
*/
|
|
333
|
+
interface ISessionParams extends ISessionSchema {
|
|
334
|
+
clientId: string;
|
|
335
|
+
logger: ILogger;
|
|
336
|
+
swarm: ISwarm;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Schema for session data.
|
|
340
|
+
* @interface
|
|
341
|
+
*/
|
|
342
|
+
interface ISessionSchema {
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Function type for sending messages.
|
|
346
|
+
* @typedef {function} SendMessageFn
|
|
347
|
+
* @param {IOutgoingMessage} outgoing - The outgoing message.
|
|
348
|
+
* @returns {Promise<void> | void}
|
|
349
|
+
*/
|
|
350
|
+
type SendMessageFn$1 = (outgoing: IOutgoingMessage) => Promise<void> | void;
|
|
351
|
+
/**
|
|
352
|
+
* Function type for receiving messages.
|
|
353
|
+
* @typedef {function} ReceiveMessageFn
|
|
354
|
+
* @param {IIncomingMessage} incoming - The incoming message.
|
|
355
|
+
* @returns {Promise<void> | void}
|
|
356
|
+
*/
|
|
357
|
+
type ReceiveMessageFn = (incoming: IIncomingMessage) => Promise<void> | void;
|
|
358
|
+
/**
|
|
359
|
+
* Interface for a session.
|
|
360
|
+
* @interface
|
|
361
|
+
*/
|
|
362
|
+
interface ISession {
|
|
363
|
+
/**
|
|
364
|
+
* Emit a message.
|
|
365
|
+
* @param {string} message - The message to emit.
|
|
366
|
+
* @returns {Promise<void>}
|
|
367
|
+
*/
|
|
368
|
+
emit(message: string): Promise<void>;
|
|
369
|
+
/**
|
|
370
|
+
* Execute a command.
|
|
371
|
+
* @param {string} content - The content to execute.
|
|
372
|
+
* @param {string} mode - The source of execution: tool or user
|
|
373
|
+
* @returns {Promise<string>}
|
|
374
|
+
*/
|
|
375
|
+
execute(content: string, mode: ExecutionMode): Promise<string>;
|
|
376
|
+
/**
|
|
377
|
+
* Connect to a message sender.
|
|
378
|
+
* @param {SendMessageFn} connector - The function to send messages.
|
|
379
|
+
* @returns {ReceiveMessageFn}
|
|
380
|
+
*/
|
|
381
|
+
connect(connector: SendMessageFn$1): ReceiveMessageFn;
|
|
382
|
+
/**
|
|
383
|
+
* Commit tool output.
|
|
384
|
+
* @param {string} content - The content to commit.
|
|
385
|
+
* @returns {Promise<void>}
|
|
386
|
+
*/
|
|
387
|
+
commitToolOutput(content: string): Promise<void>;
|
|
388
|
+
/**
|
|
389
|
+
* Commit user message without answer
|
|
390
|
+
* @param {string} message - The message to commit.
|
|
391
|
+
* @returns {Promise<void>}
|
|
392
|
+
*/
|
|
393
|
+
commitUserMessage: (message: string) => Promise<void>;
|
|
394
|
+
/**
|
|
395
|
+
* Commit a system message.
|
|
396
|
+
* @param {string} message - The message to commit.
|
|
397
|
+
* @returns {Promise<void>}
|
|
398
|
+
*/
|
|
399
|
+
commitSystemMessage(message: string): Promise<void>;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Type for session ID.
|
|
403
|
+
* @typedef {string} SessionId
|
|
404
|
+
*/
|
|
405
|
+
type SessionId = string;
|
|
406
|
+
/**
|
|
407
|
+
* Type for session mode.
|
|
408
|
+
* @typedef {"session" | "makeConnection" | "complete"} SessionMode
|
|
409
|
+
*/
|
|
410
|
+
type SessionMode = "session" | "makeConnection" | "complete";
|
|
411
|
+
/**
|
|
412
|
+
* Tools can emit user messages to trigger user friendly responses.
|
|
413
|
+
* Should be ignored for `getUserHistory`
|
|
414
|
+
* @typedef {"tool" | "user"} ExecutionMode
|
|
415
|
+
*/
|
|
416
|
+
type ExecutionMode = "tool" | "user";
|
|
417
|
+
|
|
222
418
|
/**
|
|
223
419
|
* Interface representing a tool used by an agent.
|
|
224
420
|
* @template T - The type of the parameters for the tool.
|
|
@@ -296,9 +492,10 @@ interface IAgent {
|
|
|
296
492
|
/**
|
|
297
493
|
* Executes the agent with the given input.
|
|
298
494
|
* @param input - The input to execute.
|
|
495
|
+
* @param mode - The source of execution: tool or user
|
|
299
496
|
* @returns A promise that resolves when the execution is complete.
|
|
300
497
|
*/
|
|
301
|
-
execute: (input: string) => Promise<void>;
|
|
498
|
+
execute: (input: string, mode: ExecutionMode) => Promise<void>;
|
|
302
499
|
/**
|
|
303
500
|
* Waits for the output from the agent.
|
|
304
501
|
* @returns A promise that resolves to the output string.
|
|
@@ -328,72 +525,6 @@ type AgentName = string;
|
|
|
328
525
|
/** Type representing the name of a tool. */
|
|
329
526
|
type ToolName = string;
|
|
330
527
|
|
|
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
528
|
/**
|
|
398
529
|
* Interface representing the context.
|
|
399
530
|
*/
|
|
@@ -523,7 +654,7 @@ declare class AgentConnectionService implements IAgent {
|
|
|
523
654
|
* @param {string} input - The input command.
|
|
524
655
|
* @returns {Promise<any>} The execution result.
|
|
525
656
|
*/
|
|
526
|
-
execute: (input: string) => Promise<void>;
|
|
657
|
+
execute: (input: string, mode: ExecutionMode) => Promise<void>;
|
|
527
658
|
/**
|
|
528
659
|
* Waits for the output from the agent.
|
|
529
660
|
* @returns {Promise<any>} The output result.
|
|
@@ -804,123 +935,6 @@ declare class CompletionSchemaService {
|
|
|
804
935
|
get: (key: string) => ICompletionSchema;
|
|
805
936
|
}
|
|
806
937
|
|
|
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
938
|
/**
|
|
925
939
|
* ClientSession class implements the ISession interface.
|
|
926
940
|
*/
|
|
@@ -944,7 +958,7 @@ declare class ClientSession implements ISession {
|
|
|
944
958
|
* @param {boolean} [noEmit=false] - Whether to emit the output or not.
|
|
945
959
|
* @returns {Promise<string>} - The output of the execution.
|
|
946
960
|
*/
|
|
947
|
-
execute: (message: string, noEmit?: boolean) => Promise<string>;
|
|
961
|
+
execute: (message: string, mode: ExecutionMode, noEmit?: boolean) => Promise<string>;
|
|
948
962
|
/**
|
|
949
963
|
* Commits tool output.
|
|
950
964
|
* @param {string} content - The content to commit.
|
|
@@ -997,7 +1011,7 @@ declare class SessionConnectionService implements ISession {
|
|
|
997
1011
|
* @param {string} content - The content to execute.
|
|
998
1012
|
* @returns {Promise<string>} A promise that resolves with the execution result.
|
|
999
1013
|
*/
|
|
1000
|
-
execute: (content: string) => Promise<string>;
|
|
1014
|
+
execute: (content: string, mode: ExecutionMode) => Promise<string>;
|
|
1001
1015
|
/**
|
|
1002
1016
|
* Connects to the session using the provided connector.
|
|
1003
1017
|
* @param {SendMessageFn} connector - The function to send messages.
|
|
@@ -1057,7 +1071,7 @@ declare class AgentPublicService implements TAgentConnectionService {
|
|
|
1057
1071
|
* @param {AgentName} agentName - The name of the agent.
|
|
1058
1072
|
* @returns {Promise<unknown>} The execution result.
|
|
1059
1073
|
*/
|
|
1060
|
-
execute: (input: string, clientId: string, agentName: AgentName) => Promise<void>;
|
|
1074
|
+
execute: (input: string, mode: ExecutionMode, clientId: string, agentName: AgentName) => Promise<void>;
|
|
1061
1075
|
/**
|
|
1062
1076
|
* Waits for the agent's output.
|
|
1063
1077
|
* @param {string} clientId - The client ID.
|
|
@@ -1174,7 +1188,7 @@ declare class SessionPublicService implements TSessionConnectionService {
|
|
|
1174
1188
|
* @param {SwarmName} swarmName - The swarm name.
|
|
1175
1189
|
* @returns {Promise<void>}
|
|
1176
1190
|
*/
|
|
1177
|
-
execute: (content: string, clientId: string, swarmName: SwarmName) => Promise<string>;
|
|
1191
|
+
execute: (content: string, mode: ExecutionMode, clientId: string, swarmName: SwarmName) => Promise<string>;
|
|
1178
1192
|
/**
|
|
1179
1193
|
* Connects to the session.
|
|
1180
1194
|
* @param {SendMessageFn} connector - The function to send messages.
|