agent-swarm-kit 1.0.73 → 1.0.75
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 +721 -403
- package/build/index.mjs +714 -404
- package/package.json +2 -2
- package/types.d.ts +143 -50
package/build/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { scoped } from 'di-scoped';
|
|
2
|
-
import { ToolRegistry, trycatch, singleshot, memoize, sleep, Subject, queued, getErrorMessage, errorData, not, randomString, createAwaiter, cancelable, CANCELED_PROMISE_SYMBOL, execpool, SortedArray, schedule, ttl, Source } from 'functools-kit';
|
|
3
2
|
import { createActivator } from 'di-kit';
|
|
3
|
+
import { ToolRegistry, trycatch, singleshot, memoize, sleep, Subject, queued, getErrorMessage, errorData, not, randomString, createAwaiter, cancelable, CANCELED_PROMISE_SYMBOL, execpool, SortedArray, schedule, ttl, Source } from 'functools-kit';
|
|
4
4
|
import { omit } from 'lodash-es';
|
|
5
5
|
import xml2js from 'xml2js';
|
|
6
6
|
|
|
@@ -165,6 +165,50 @@ var ContextService = scoped(/** @class */ (function () {
|
|
|
165
165
|
return class_1;
|
|
166
166
|
}()));
|
|
167
167
|
|
|
168
|
+
var _a;
|
|
169
|
+
var init = (_a = createActivator("agent-swarm"), _a.init), inject = _a.inject, provide = _a.provide;
|
|
170
|
+
|
|
171
|
+
var baseServices$1 = {
|
|
172
|
+
busService: Symbol('busService'),
|
|
173
|
+
loggerService: Symbol('loggerService'),
|
|
174
|
+
contextService: Symbol('contextService'),
|
|
175
|
+
};
|
|
176
|
+
var connectionServices$1 = {
|
|
177
|
+
agentConnectionService: Symbol('agentConnectionService'),
|
|
178
|
+
historyConnectionService: Symbol('historyConnectionService'),
|
|
179
|
+
swarmConnectionService: Symbol('swarmConnectionService'),
|
|
180
|
+
sessionConnectionService: Symbol('sessionConnectionService'),
|
|
181
|
+
storageConnectionService: Symbol('storageConnectionService'),
|
|
182
|
+
stateConnectionService: Symbol('stateConnectionService'),
|
|
183
|
+
};
|
|
184
|
+
var schemaServices$1 = {
|
|
185
|
+
completionSchemaService: Symbol('completionSchemaService'),
|
|
186
|
+
agentSchemaService: Symbol('agentSchemaService'),
|
|
187
|
+
swarmSchemaService: Symbol('swarmSchemaService'),
|
|
188
|
+
toolSchemaService: Symbol('toolSchemaService'),
|
|
189
|
+
embeddingSchemaService: Symbol('embeddingSchemaService'),
|
|
190
|
+
storageSchemaService: Symbol('storageSchemaService'),
|
|
191
|
+
stateSchemaService: Symbol('stateSchemaService'),
|
|
192
|
+
};
|
|
193
|
+
var publicServices$1 = {
|
|
194
|
+
agentPublicService: Symbol('agentPublicService'),
|
|
195
|
+
historyPublicService: Symbol('historyPublicService'),
|
|
196
|
+
sessionPublicService: Symbol('sessionPublicService'),
|
|
197
|
+
swarmPublicService: Symbol('swarmPublicService'),
|
|
198
|
+
storagePublicService: Symbol('storagePublicService'),
|
|
199
|
+
statePublicService: Symbol('statePublicService'),
|
|
200
|
+
};
|
|
201
|
+
var validationServices$1 = {
|
|
202
|
+
agentValidationService: Symbol('agentValidationService'),
|
|
203
|
+
toolValidationService: Symbol('toolValidationService'),
|
|
204
|
+
sessionValidationService: Symbol('sessionValidationService'),
|
|
205
|
+
swarmValidationService: Symbol('swarmValidationService'),
|
|
206
|
+
completionValidationService: Symbol('completionValidationService'),
|
|
207
|
+
embeddingValidationService: Symbol('embeddingValidationService'),
|
|
208
|
+
storageValidationService: Symbol('storageValidationService'),
|
|
209
|
+
};
|
|
210
|
+
var TYPES = __assign(__assign(__assign(__assign(__assign({}, baseServices$1), schemaServices$1), connectionServices$1), publicServices$1), validationServices$1);
|
|
211
|
+
|
|
168
212
|
/**
|
|
169
213
|
* LoggerService class that implements the ILogger interface.
|
|
170
214
|
* Provides methods to log and debug messages.
|
|
@@ -172,6 +216,7 @@ var ContextService = scoped(/** @class */ (function () {
|
|
|
172
216
|
var LoggerService = /** @class */ (function () {
|
|
173
217
|
function LoggerService() {
|
|
174
218
|
var _this = this;
|
|
219
|
+
this.contextService = inject(TYPES.contextService);
|
|
175
220
|
this._logger = {
|
|
176
221
|
/**
|
|
177
222
|
* Logs messages.
|
|
@@ -191,24 +236,32 @@ var LoggerService = /** @class */ (function () {
|
|
|
191
236
|
* @param {...any} args - The messages to log.
|
|
192
237
|
*/
|
|
193
238
|
this.log = function () {
|
|
194
|
-
var _a;
|
|
239
|
+
var _a, _b;
|
|
195
240
|
var args = [];
|
|
196
241
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
197
242
|
args[_i] = arguments[_i];
|
|
198
243
|
}
|
|
199
|
-
(
|
|
244
|
+
if (ContextService.hasContext()) {
|
|
245
|
+
(_a = _this._logger).log.apply(_a, __spreadArray(__spreadArray([], __read(args), false), [_this.contextService.context], false));
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
(_b = _this._logger).log.apply(_b, __spreadArray([], __read(args), false));
|
|
200
249
|
};
|
|
201
250
|
/**
|
|
202
251
|
* Logs debug messages using the current logger.
|
|
203
252
|
* @param {...any} args - The debug messages to log.
|
|
204
253
|
*/
|
|
205
254
|
this.debug = function () {
|
|
206
|
-
var _a;
|
|
255
|
+
var _a, _b;
|
|
207
256
|
var args = [];
|
|
208
257
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
209
258
|
args[_i] = arguments[_i];
|
|
210
259
|
}
|
|
211
|
-
(
|
|
260
|
+
if (ContextService.hasContext()) {
|
|
261
|
+
(_a = _this._logger).debug.apply(_a, __spreadArray(__spreadArray([], __read(args), false), [_this.contextService.context], false));
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
(_b = _this._logger).debug.apply(_b, __spreadArray([], __read(args), false));
|
|
212
265
|
};
|
|
213
266
|
/**
|
|
214
267
|
* Sets a new logger.
|
|
@@ -221,50 +274,6 @@ var LoggerService = /** @class */ (function () {
|
|
|
221
274
|
return LoggerService;
|
|
222
275
|
}());
|
|
223
276
|
|
|
224
|
-
var _a;
|
|
225
|
-
var init = (_a = createActivator("agent-swarm"), _a.init), inject = _a.inject, provide = _a.provide;
|
|
226
|
-
|
|
227
|
-
var baseServices$1 = {
|
|
228
|
-
busService: Symbol('busService'),
|
|
229
|
-
loggerService: Symbol('loggerService'),
|
|
230
|
-
contextService: Symbol('contextService'),
|
|
231
|
-
};
|
|
232
|
-
var connectionServices$1 = {
|
|
233
|
-
agentConnectionService: Symbol('agentConnectionService'),
|
|
234
|
-
historyConnectionService: Symbol('historyConnectionService'),
|
|
235
|
-
swarmConnectionService: Symbol('swarmConnectionService'),
|
|
236
|
-
sessionConnectionService: Symbol('sessionConnectionService'),
|
|
237
|
-
storageConnectionService: Symbol('storageConnectionService'),
|
|
238
|
-
stateConnectionService: Symbol('stateConnectionService'),
|
|
239
|
-
};
|
|
240
|
-
var schemaServices$1 = {
|
|
241
|
-
completionSchemaService: Symbol('completionSchemaService'),
|
|
242
|
-
agentSchemaService: Symbol('agentSchemaService'),
|
|
243
|
-
swarmSchemaService: Symbol('swarmSchemaService'),
|
|
244
|
-
toolSchemaService: Symbol('toolSchemaService'),
|
|
245
|
-
embeddingSchemaService: Symbol('embeddingSchemaService'),
|
|
246
|
-
storageSchemaService: Symbol('storageSchemaService'),
|
|
247
|
-
stateSchemaService: Symbol('stateSchemaService'),
|
|
248
|
-
};
|
|
249
|
-
var publicServices$1 = {
|
|
250
|
-
agentPublicService: Symbol('agentPublicService'),
|
|
251
|
-
historyPublicService: Symbol('historyPublicService'),
|
|
252
|
-
sessionPublicService: Symbol('sessionPublicService'),
|
|
253
|
-
swarmPublicService: Symbol('swarmPublicService'),
|
|
254
|
-
storagePublicService: Symbol('storagePublicService'),
|
|
255
|
-
statePublicService: Symbol('statePublicService'),
|
|
256
|
-
};
|
|
257
|
-
var validationServices$1 = {
|
|
258
|
-
agentValidationService: Symbol('agentValidationService'),
|
|
259
|
-
toolValidationService: Symbol('toolValidationService'),
|
|
260
|
-
sessionValidationService: Symbol('sessionValidationService'),
|
|
261
|
-
swarmValidationService: Symbol('swarmValidationService'),
|
|
262
|
-
completionValidationService: Symbol('completionValidationService'),
|
|
263
|
-
embeddingValidationService: Symbol('embeddingValidationService'),
|
|
264
|
-
storageValidationService: Symbol('storageValidationService'),
|
|
265
|
-
};
|
|
266
|
-
var TYPES = __assign(__assign(__assign(__assign(__assign({}, baseServices$1), schemaServices$1), connectionServices$1), publicServices$1), validationServices$1);
|
|
267
|
-
|
|
268
277
|
/**
|
|
269
278
|
* Service for managing agent schemas.
|
|
270
279
|
*/
|
|
@@ -971,7 +980,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
971
980
|
_a.sent();
|
|
972
981
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
973
982
|
type: "emit-output",
|
|
974
|
-
source: "agent",
|
|
983
|
+
source: "agent-bus",
|
|
975
984
|
input: {
|
|
976
985
|
mode: mode,
|
|
977
986
|
rawResult: rawResult_1,
|
|
@@ -995,7 +1004,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
995
1004
|
_a.sent();
|
|
996
1005
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
997
1006
|
type: "emit-output",
|
|
998
|
-
source: "agent",
|
|
1007
|
+
source: "agent-bus",
|
|
999
1008
|
input: {
|
|
1000
1009
|
mode: mode,
|
|
1001
1010
|
rawResult: rawResult,
|
|
@@ -1143,7 +1152,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1143
1152
|
_a.sent();
|
|
1144
1153
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
1145
1154
|
type: "commit-user-message",
|
|
1146
|
-
source: "agent",
|
|
1155
|
+
source: "agent-bus",
|
|
1147
1156
|
input: {
|
|
1148
1157
|
message: message,
|
|
1149
1158
|
},
|
|
@@ -1180,7 +1189,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1180
1189
|
_a.sent();
|
|
1181
1190
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
1182
1191
|
type: "commit-flush",
|
|
1183
|
-
source: "agent",
|
|
1192
|
+
source: "agent-bus",
|
|
1184
1193
|
input: {},
|
|
1185
1194
|
output: {},
|
|
1186
1195
|
context: {
|
|
@@ -1208,7 +1217,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1208
1217
|
_a.sent();
|
|
1209
1218
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
1210
1219
|
type: "commit-agent-change",
|
|
1211
|
-
source: "agent",
|
|
1220
|
+
source: "agent-bus",
|
|
1212
1221
|
input: {},
|
|
1213
1222
|
output: {},
|
|
1214
1223
|
context: {
|
|
@@ -1244,7 +1253,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1244
1253
|
_a.sent();
|
|
1245
1254
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
1246
1255
|
type: "commit-system-message",
|
|
1247
|
-
source: "agent",
|
|
1256
|
+
source: "agent-bus",
|
|
1248
1257
|
input: {
|
|
1249
1258
|
message: message,
|
|
1250
1259
|
},
|
|
@@ -1286,7 +1295,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1286
1295
|
_a.sent();
|
|
1287
1296
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
1288
1297
|
type: "commit-tool-output",
|
|
1289
|
-
source: "agent",
|
|
1298
|
+
source: "agent-bus",
|
|
1290
1299
|
input: {
|
|
1291
1300
|
toolId: toolId,
|
|
1292
1301
|
content: content,
|
|
@@ -1556,7 +1565,6 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1556
1565
|
this.loggerService.log("agentConnectionService execute", {
|
|
1557
1566
|
input: input,
|
|
1558
1567
|
mode: mode,
|
|
1559
|
-
context: this.contextService.context,
|
|
1560
1568
|
});
|
|
1561
1569
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).execute(input, mode)];
|
|
1562
1570
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -1571,9 +1579,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1571
1579
|
return __generator(this, function (_a) {
|
|
1572
1580
|
switch (_a.label) {
|
|
1573
1581
|
case 0:
|
|
1574
|
-
this.loggerService.log("agentConnectionService waitForOutput"
|
|
1575
|
-
context: this.contextService.context,
|
|
1576
|
-
});
|
|
1582
|
+
this.loggerService.log("agentConnectionService waitForOutput");
|
|
1577
1583
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).waitForOutput()];
|
|
1578
1584
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1579
1585
|
}
|
|
@@ -1592,7 +1598,6 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1592
1598
|
this.loggerService.log("agentConnectionService commitToolOutput", {
|
|
1593
1599
|
content: content,
|
|
1594
1600
|
toolId: toolId,
|
|
1595
|
-
context: this.contextService.context,
|
|
1596
1601
|
});
|
|
1597
1602
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitToolOutput(toolId, content)];
|
|
1598
1603
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -1610,7 +1615,6 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1610
1615
|
case 0:
|
|
1611
1616
|
this.loggerService.log("agentConnectionService commitSystemMessage", {
|
|
1612
1617
|
message: message,
|
|
1613
|
-
context: this.contextService.context,
|
|
1614
1618
|
});
|
|
1615
1619
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitSystemMessage(message)];
|
|
1616
1620
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -1628,7 +1632,6 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1628
1632
|
case 0:
|
|
1629
1633
|
this.loggerService.log("agentConnectionService commitUserMessage", {
|
|
1630
1634
|
message: message,
|
|
1631
|
-
context: this.contextService.context,
|
|
1632
1635
|
});
|
|
1633
1636
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitUserMessage(message)];
|
|
1634
1637
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -1643,9 +1646,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1643
1646
|
return __generator(this, function (_a) {
|
|
1644
1647
|
switch (_a.label) {
|
|
1645
1648
|
case 0:
|
|
1646
|
-
this.loggerService.log("agentConnectionService commitAgentChange"
|
|
1647
|
-
context: this.contextService.context,
|
|
1648
|
-
});
|
|
1649
|
+
this.loggerService.log("agentConnectionService commitAgentChange");
|
|
1649
1650
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitAgentChange()];
|
|
1650
1651
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1651
1652
|
}
|
|
@@ -1659,9 +1660,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1659
1660
|
return __generator(this, function (_a) {
|
|
1660
1661
|
switch (_a.label) {
|
|
1661
1662
|
case 0:
|
|
1662
|
-
this.loggerService.log("agentConnectionService commitFlush"
|
|
1663
|
-
context: this.contextService.context,
|
|
1664
|
-
});
|
|
1663
|
+
this.loggerService.log("agentConnectionService commitFlush");
|
|
1665
1664
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitFlush()];
|
|
1666
1665
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1667
1666
|
}
|
|
@@ -1676,9 +1675,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1676
1675
|
return __generator(this, function (_a) {
|
|
1677
1676
|
switch (_a.label) {
|
|
1678
1677
|
case 0:
|
|
1679
|
-
this.loggerService.log("agentConnectionService dispose"
|
|
1680
|
-
context: this.contextService.context,
|
|
1681
|
-
});
|
|
1678
|
+
this.loggerService.log("agentConnectionService dispose");
|
|
1682
1679
|
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.agentName);
|
|
1683
1680
|
if (!this.getAgent.has(key)) {
|
|
1684
1681
|
return [2 /*return*/];
|
|
@@ -1723,7 +1720,7 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1723
1720
|
_a.sent();
|
|
1724
1721
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
1725
1722
|
type: "push",
|
|
1726
|
-
source: "history",
|
|
1723
|
+
source: "history-bus",
|
|
1727
1724
|
input: {
|
|
1728
1725
|
message: message
|
|
1729
1726
|
},
|
|
@@ -1999,7 +1996,7 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
1999
1996
|
switch (_a.label) {
|
|
2000
1997
|
case 0:
|
|
2001
1998
|
this.loggerService.log("historyConnectionService push", {
|
|
2002
|
-
|
|
1999
|
+
message: message,
|
|
2003
2000
|
});
|
|
2004
2001
|
return [4 /*yield*/, this.getHistory(this.contextService.context.clientId, this.contextService.context.agentName).push(message)];
|
|
2005
2002
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -2016,7 +2013,7 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
2016
2013
|
switch (_a.label) {
|
|
2017
2014
|
case 0:
|
|
2018
2015
|
this.loggerService.log("historyConnectionService toArrayForAgent", {
|
|
2019
|
-
|
|
2016
|
+
prompt: prompt,
|
|
2020
2017
|
});
|
|
2021
2018
|
return [4 /*yield*/, this.getHistory(this.contextService.context.clientId, this.contextService.context.agentName).toArrayForAgent(prompt)];
|
|
2022
2019
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -2031,9 +2028,7 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
2031
2028
|
return __generator(this, function (_a) {
|
|
2032
2029
|
switch (_a.label) {
|
|
2033
2030
|
case 0:
|
|
2034
|
-
this.loggerService.log("historyConnectionService toArrayForRaw"
|
|
2035
|
-
context: this.contextService.context,
|
|
2036
|
-
});
|
|
2031
|
+
this.loggerService.log("historyConnectionService toArrayForRaw");
|
|
2037
2032
|
return [4 /*yield*/, this.getHistory(this.contextService.context.clientId, this.contextService.context.agentName).toArrayForRaw()];
|
|
2038
2033
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2039
2034
|
}
|
|
@@ -2048,9 +2043,7 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
2048
2043
|
return __generator(this, function (_a) {
|
|
2049
2044
|
switch (_a.label) {
|
|
2050
2045
|
case 0:
|
|
2051
|
-
this.loggerService.log("historyConnectionService dispose"
|
|
2052
|
-
context: this.contextService.context,
|
|
2053
|
-
});
|
|
2046
|
+
this.loggerService.log("historyConnectionService dispose");
|
|
2054
2047
|
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.agentName);
|
|
2055
2048
|
if (!this.getHistory.has(key)) {
|
|
2056
2049
|
return [2 /*return*/];
|
|
@@ -2134,7 +2127,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2134
2127
|
_d.sent();
|
|
2135
2128
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2136
2129
|
type: "cancel-output",
|
|
2137
|
-
source: "swarm",
|
|
2130
|
+
source: "swarm-bus",
|
|
2138
2131
|
input: {},
|
|
2139
2132
|
output: {},
|
|
2140
2133
|
context: {
|
|
@@ -2207,7 +2200,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2207
2200
|
this.params.logger.debug("ClientSwarm swarmName=".concat(this.params.swarmName, " clientId=").concat(this.params.clientId, " waitForAgent agent miss"), { agentName: agentName, expectAgent: expectAgent });
|
|
2208
2201
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2209
2202
|
type: "wait-for-output",
|
|
2210
|
-
source: "swarm",
|
|
2203
|
+
source: "swarm-bus",
|
|
2211
2204
|
input: {},
|
|
2212
2205
|
output: {
|
|
2213
2206
|
result: output,
|
|
@@ -2241,7 +2234,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2241
2234
|
_b.label = 2;
|
|
2242
2235
|
case 2: return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2243
2236
|
type: "get-agent-name",
|
|
2244
|
-
source: "swarm",
|
|
2237
|
+
source: "swarm-bus",
|
|
2245
2238
|
input: {},
|
|
2246
2239
|
output: {
|
|
2247
2240
|
activeAgent: this._activeAgent,
|
|
@@ -2273,7 +2266,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2273
2266
|
result = this.params.agentMap[agent];
|
|
2274
2267
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2275
2268
|
type: "get-agent",
|
|
2276
|
-
source: "swarm",
|
|
2269
|
+
source: "swarm-bus",
|
|
2277
2270
|
input: {
|
|
2278
2271
|
result: result,
|
|
2279
2272
|
},
|
|
@@ -2306,7 +2299,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2306
2299
|
this.params.agentMap[agentName] = agent;
|
|
2307
2300
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2308
2301
|
type: "set-agent-ref",
|
|
2309
|
-
source: "swarm",
|
|
2302
|
+
source: "swarm-bus",
|
|
2310
2303
|
input: {
|
|
2311
2304
|
agentName: agentName,
|
|
2312
2305
|
agent: agent,
|
|
@@ -2341,7 +2334,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2341
2334
|
_a.sent();
|
|
2342
2335
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2343
2336
|
type: "set-agent-name",
|
|
2344
|
-
source: "swarm",
|
|
2337
|
+
source: "swarm-bus",
|
|
2345
2338
|
input: {
|
|
2346
2339
|
agentName: agentName,
|
|
2347
2340
|
},
|
|
@@ -2443,9 +2436,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2443
2436
|
return __generator(this, function (_a) {
|
|
2444
2437
|
switch (_a.label) {
|
|
2445
2438
|
case 0:
|
|
2446
|
-
this.loggerService.log("swarmConnectionService cancelOutput"
|
|
2447
|
-
context: this.contextService.context,
|
|
2448
|
-
});
|
|
2439
|
+
this.loggerService.log("swarmConnectionService cancelOutput");
|
|
2449
2440
|
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).cancelOutput()];
|
|
2450
2441
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2451
2442
|
}
|
|
@@ -2459,9 +2450,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2459
2450
|
return __generator(this, function (_a) {
|
|
2460
2451
|
switch (_a.label) {
|
|
2461
2452
|
case 0:
|
|
2462
|
-
this.loggerService.log("swarmConnectionService waitForOutput"
|
|
2463
|
-
context: this.contextService.context,
|
|
2464
|
-
});
|
|
2453
|
+
this.loggerService.log("swarmConnectionService waitForOutput");
|
|
2465
2454
|
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).waitForOutput()];
|
|
2466
2455
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2467
2456
|
}
|
|
@@ -2475,9 +2464,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2475
2464
|
return __generator(this, function (_a) {
|
|
2476
2465
|
switch (_a.label) {
|
|
2477
2466
|
case 0:
|
|
2478
|
-
this.loggerService.log("swarmConnectionService getAgentName"
|
|
2479
|
-
context: this.contextService.context,
|
|
2480
|
-
});
|
|
2467
|
+
this.loggerService.log("swarmConnectionService getAgentName");
|
|
2481
2468
|
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).getAgentName()];
|
|
2482
2469
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2483
2470
|
}
|
|
@@ -2491,9 +2478,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2491
2478
|
return __generator(this, function (_a) {
|
|
2492
2479
|
switch (_a.label) {
|
|
2493
2480
|
case 0:
|
|
2494
|
-
this.loggerService.log("swarmConnectionService getAgent"
|
|
2495
|
-
context: this.contextService.context,
|
|
2496
|
-
});
|
|
2481
|
+
this.loggerService.log("swarmConnectionService getAgent");
|
|
2497
2482
|
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).getAgent()];
|
|
2498
2483
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2499
2484
|
}
|
|
@@ -2510,7 +2495,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2510
2495
|
switch (_a.label) {
|
|
2511
2496
|
case 0:
|
|
2512
2497
|
this.loggerService.log("swarmConnectionService setAgentRef", {
|
|
2513
|
-
|
|
2498
|
+
agentName: agentName,
|
|
2514
2499
|
});
|
|
2515
2500
|
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).setAgentRef(agentName, agent)];
|
|
2516
2501
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -2528,7 +2513,6 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2528
2513
|
case 0:
|
|
2529
2514
|
this.loggerService.log("swarmConnectionService setAgentName", {
|
|
2530
2515
|
agentName: agentName,
|
|
2531
|
-
context: this.contextService.context,
|
|
2532
2516
|
});
|
|
2533
2517
|
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).setAgentName(agentName)];
|
|
2534
2518
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -2542,9 +2526,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2542
2526
|
this.dispose = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2543
2527
|
var key;
|
|
2544
2528
|
return __generator(this, function (_a) {
|
|
2545
|
-
this.loggerService.log("swarmConnectionService dispose"
|
|
2546
|
-
context: this.contextService.context,
|
|
2547
|
-
});
|
|
2529
|
+
this.loggerService.log("swarmConnectionService dispose");
|
|
2548
2530
|
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.swarmName);
|
|
2549
2531
|
if (!this.getSwarm.has(key)) {
|
|
2550
2532
|
return [2 /*return*/];
|
|
@@ -2648,7 +2630,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
2648
2630
|
_a.sent();
|
|
2649
2631
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2650
2632
|
type: "emit",
|
|
2651
|
-
source: "session",
|
|
2633
|
+
source: "session-bus",
|
|
2652
2634
|
input: {
|
|
2653
2635
|
message: message
|
|
2654
2636
|
},
|
|
@@ -2691,7 +2673,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
2691
2673
|
output = _a.sent();
|
|
2692
2674
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2693
2675
|
type: "execute",
|
|
2694
|
-
source: "session",
|
|
2676
|
+
source: "session-bus",
|
|
2695
2677
|
input: {
|
|
2696
2678
|
message: message,
|
|
2697
2679
|
mode: mode,
|
|
@@ -2733,7 +2715,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
2733
2715
|
result = _a.sent();
|
|
2734
2716
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2735
2717
|
type: "commit-tool-output",
|
|
2736
|
-
source: "session",
|
|
2718
|
+
source: "session-bus",
|
|
2737
2719
|
input: {
|
|
2738
2720
|
toolId: toolId,
|
|
2739
2721
|
content: content,
|
|
@@ -2771,7 +2753,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
2771
2753
|
result = _a.sent();
|
|
2772
2754
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2773
2755
|
type: "commit-user-message",
|
|
2774
|
-
source: "session",
|
|
2756
|
+
source: "session-bus",
|
|
2775
2757
|
input: {
|
|
2776
2758
|
message: message,
|
|
2777
2759
|
},
|
|
@@ -2805,7 +2787,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
2805
2787
|
result = _a.sent();
|
|
2806
2788
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2807
2789
|
type: "commit-flush",
|
|
2808
|
-
source: "session",
|
|
2790
|
+
source: "session-bus",
|
|
2809
2791
|
input: {},
|
|
2810
2792
|
output: {},
|
|
2811
2793
|
context: {
|
|
@@ -2840,7 +2822,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
2840
2822
|
result = _a.sent();
|
|
2841
2823
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2842
2824
|
type: "commit-system-message",
|
|
2843
|
-
source: "session",
|
|
2825
|
+
source: "session-bus",
|
|
2844
2826
|
input: {
|
|
2845
2827
|
message: message
|
|
2846
2828
|
},
|
|
@@ -2885,7 +2867,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
2885
2867
|
}); });
|
|
2886
2868
|
_this.params.bus.emit(_this.params.clientId, {
|
|
2887
2869
|
type: "connect",
|
|
2888
|
-
source: "session",
|
|
2870
|
+
source: "session-bus",
|
|
2889
2871
|
input: {},
|
|
2890
2872
|
output: {},
|
|
2891
2873
|
context: {
|
|
@@ -2894,17 +2876,22 @@ var ClientSession = /** @class */ (function () {
|
|
|
2894
2876
|
clientId: _this.params.clientId,
|
|
2895
2877
|
});
|
|
2896
2878
|
return function (incoming) { return __awaiter(_this, void 0, void 0, function () {
|
|
2897
|
-
var _a;
|
|
2879
|
+
var data, _a;
|
|
2898
2880
|
var _b;
|
|
2899
2881
|
return __generator(this, function (_c) {
|
|
2900
2882
|
switch (_c.label) {
|
|
2901
2883
|
case 0:
|
|
2902
2884
|
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " connect call"));
|
|
2903
|
-
_a = connector;
|
|
2904
|
-
_b = {};
|
|
2905
2885
|
return [4 /*yield*/, this.execute(incoming.data, "user")];
|
|
2906
2886
|
case 1:
|
|
2907
|
-
|
|
2887
|
+
data = _c.sent();
|
|
2888
|
+
if (!data) {
|
|
2889
|
+
return [2 /*return*/];
|
|
2890
|
+
}
|
|
2891
|
+
_a = connector;
|
|
2892
|
+
_b = {
|
|
2893
|
+
data: data
|
|
2894
|
+
};
|
|
2908
2895
|
return [4 /*yield*/, this.params.swarm.getAgentName()];
|
|
2909
2896
|
case 2: return [4 /*yield*/, _a.apply(void 0, [(_b.agentName = _c.sent(),
|
|
2910
2897
|
_b.clientId = incoming.clientId,
|
|
@@ -2971,7 +2958,7 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
2971
2958
|
switch (_a.label) {
|
|
2972
2959
|
case 0:
|
|
2973
2960
|
this.loggerService.log("sessionConnectionService emit", {
|
|
2974
|
-
|
|
2961
|
+
content: content,
|
|
2975
2962
|
});
|
|
2976
2963
|
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).emit(content)];
|
|
2977
2964
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -2988,7 +2975,6 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
2988
2975
|
switch (_a.label) {
|
|
2989
2976
|
case 0:
|
|
2990
2977
|
this.loggerService.log("sessionConnectionService execute", {
|
|
2991
|
-
context: this.contextService.context,
|
|
2992
2978
|
content: content,
|
|
2993
2979
|
mode: mode,
|
|
2994
2980
|
});
|
|
@@ -3003,9 +2989,7 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3003
2989
|
* @returns {ReceiveMessageFn} The function to receive messages.
|
|
3004
2990
|
*/
|
|
3005
2991
|
this.connect = function (connector) {
|
|
3006
|
-
_this.loggerService.log("sessionConnectionService connect"
|
|
3007
|
-
context: _this.contextService.context,
|
|
3008
|
-
});
|
|
2992
|
+
_this.loggerService.log("sessionConnectionService connect");
|
|
3009
2993
|
return _this.getSession(_this.contextService.context.clientId, _this.contextService.context.swarmName).connect(connector);
|
|
3010
2994
|
};
|
|
3011
2995
|
/**
|
|
@@ -3019,7 +3003,6 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3019
3003
|
switch (_a.label) {
|
|
3020
3004
|
case 0:
|
|
3021
3005
|
this.loggerService.log("sessionConnectionService commitToolOutput", {
|
|
3022
|
-
context: this.contextService.context,
|
|
3023
3006
|
content: content,
|
|
3024
3007
|
toolId: toolId,
|
|
3025
3008
|
});
|
|
@@ -3038,7 +3021,6 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3038
3021
|
switch (_a.label) {
|
|
3039
3022
|
case 0:
|
|
3040
3023
|
this.loggerService.log("sessionConnectionService commitSystemMessage", {
|
|
3041
|
-
context: this.contextService.context,
|
|
3042
3024
|
message: message,
|
|
3043
3025
|
});
|
|
3044
3026
|
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).commitSystemMessage(message)];
|
|
@@ -3056,7 +3038,6 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3056
3038
|
switch (_a.label) {
|
|
3057
3039
|
case 0:
|
|
3058
3040
|
this.loggerService.log("sessionConnectionService commitUserMessage", {
|
|
3059
|
-
context: this.contextService.context,
|
|
3060
3041
|
message: message,
|
|
3061
3042
|
});
|
|
3062
3043
|
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).commitUserMessage(message)];
|
|
@@ -3073,9 +3054,7 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3073
3054
|
return __generator(this, function (_a) {
|
|
3074
3055
|
switch (_a.label) {
|
|
3075
3056
|
case 0:
|
|
3076
|
-
this.loggerService.log("sessionConnectionService commitFlush"
|
|
3077
|
-
context: this.contextService.context,
|
|
3078
|
-
});
|
|
3057
|
+
this.loggerService.log("sessionConnectionService commitFlush");
|
|
3079
3058
|
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).commitFlush()];
|
|
3080
3059
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3081
3060
|
}
|
|
@@ -3090,9 +3069,7 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3090
3069
|
return __generator(this, function (_a) {
|
|
3091
3070
|
switch (_a.label) {
|
|
3092
3071
|
case 0:
|
|
3093
|
-
this.loggerService.log("sessionConnectionService dispose"
|
|
3094
|
-
context: this.contextService.context,
|
|
3095
|
-
});
|
|
3072
|
+
this.loggerService.log("sessionConnectionService dispose");
|
|
3096
3073
|
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.swarmName);
|
|
3097
3074
|
if (!this.getSession.has(key)) {
|
|
3098
3075
|
return [2 /*return*/];
|
|
@@ -3123,12 +3100,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3123
3100
|
* @param {AgentName} agentName - The name of the agent.
|
|
3124
3101
|
* @returns {Promise<unknown>} The agent reference.
|
|
3125
3102
|
*/
|
|
3126
|
-
this.createAgentRef = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3103
|
+
this.createAgentRef = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3127
3104
|
var _this = this;
|
|
3128
3105
|
return __generator(this, function (_a) {
|
|
3129
3106
|
switch (_a.label) {
|
|
3130
3107
|
case 0:
|
|
3131
3108
|
this.loggerService.log("agentPublicService createAgentRef", {
|
|
3109
|
+
requestId: requestId,
|
|
3132
3110
|
clientId: clientId,
|
|
3133
3111
|
agentName: agentName,
|
|
3134
3112
|
});
|
|
@@ -3140,6 +3118,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3140
3118
|
}
|
|
3141
3119
|
});
|
|
3142
3120
|
}); }, {
|
|
3121
|
+
requestId: requestId,
|
|
3143
3122
|
clientId: clientId,
|
|
3144
3123
|
agentName: agentName,
|
|
3145
3124
|
swarmName: "",
|
|
@@ -3157,12 +3136,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3157
3136
|
* @param {AgentName} agentName - The name of the agent.
|
|
3158
3137
|
* @returns {Promise<unknown>} The execution result.
|
|
3159
3138
|
*/
|
|
3160
|
-
this.execute = function (input, mode, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3139
|
+
this.execute = function (input, mode, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3161
3140
|
var _this = this;
|
|
3162
3141
|
return __generator(this, function (_a) {
|
|
3163
3142
|
switch (_a.label) {
|
|
3164
3143
|
case 0:
|
|
3165
3144
|
this.loggerService.log("agentPublicService execute", {
|
|
3145
|
+
requestId: requestId,
|
|
3166
3146
|
input: input,
|
|
3167
3147
|
clientId: clientId,
|
|
3168
3148
|
agentName: agentName,
|
|
@@ -3176,6 +3156,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3176
3156
|
}
|
|
3177
3157
|
});
|
|
3178
3158
|
}); }, {
|
|
3159
|
+
requestId: requestId,
|
|
3179
3160
|
clientId: clientId,
|
|
3180
3161
|
agentName: agentName,
|
|
3181
3162
|
swarmName: "",
|
|
@@ -3192,12 +3173,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3192
3173
|
* @param {AgentName} agentName - The name of the agent.
|
|
3193
3174
|
* @returns {Promise<unknown>} The output result.
|
|
3194
3175
|
*/
|
|
3195
|
-
this.waitForOutput = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3176
|
+
this.waitForOutput = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3196
3177
|
var _this = this;
|
|
3197
3178
|
return __generator(this, function (_a) {
|
|
3198
3179
|
switch (_a.label) {
|
|
3199
3180
|
case 0:
|
|
3200
3181
|
this.loggerService.log("agentPublicService waitForOutput", {
|
|
3182
|
+
requestId: requestId,
|
|
3201
3183
|
clientId: clientId,
|
|
3202
3184
|
agentName: agentName,
|
|
3203
3185
|
});
|
|
@@ -3209,6 +3191,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3209
3191
|
}
|
|
3210
3192
|
});
|
|
3211
3193
|
}); }, {
|
|
3194
|
+
requestId: requestId,
|
|
3212
3195
|
clientId: clientId,
|
|
3213
3196
|
agentName: agentName,
|
|
3214
3197
|
swarmName: "",
|
|
@@ -3227,12 +3210,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3227
3210
|
* @param {AgentName} agentName - The name of the agent.
|
|
3228
3211
|
* @returns {Promise<unknown>} The commit result.
|
|
3229
3212
|
*/
|
|
3230
|
-
this.commitToolOutput = function (toolId, content, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3213
|
+
this.commitToolOutput = function (toolId, content, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3231
3214
|
var _this = this;
|
|
3232
3215
|
return __generator(this, function (_a) {
|
|
3233
3216
|
switch (_a.label) {
|
|
3234
3217
|
case 0:
|
|
3235
3218
|
this.loggerService.log("agentPublicService commitToolOutput", {
|
|
3219
|
+
requestId: requestId,
|
|
3236
3220
|
content: content,
|
|
3237
3221
|
clientId: clientId,
|
|
3238
3222
|
toolId: toolId,
|
|
@@ -3246,6 +3230,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3246
3230
|
}
|
|
3247
3231
|
});
|
|
3248
3232
|
}); }, {
|
|
3233
|
+
requestId: requestId,
|
|
3249
3234
|
clientId: clientId,
|
|
3250
3235
|
agentName: agentName,
|
|
3251
3236
|
swarmName: "",
|
|
@@ -3263,12 +3248,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3263
3248
|
* @param {AgentName} agentName - The name of the agent.
|
|
3264
3249
|
* @returns {Promise<unknown>} The commit result.
|
|
3265
3250
|
*/
|
|
3266
|
-
this.commitSystemMessage = function (message, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3251
|
+
this.commitSystemMessage = function (message, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3267
3252
|
var _this = this;
|
|
3268
3253
|
return __generator(this, function (_a) {
|
|
3269
3254
|
switch (_a.label) {
|
|
3270
3255
|
case 0:
|
|
3271
3256
|
this.loggerService.log("agentPublicService commitSystemMessage", {
|
|
3257
|
+
requestId: requestId,
|
|
3272
3258
|
message: message,
|
|
3273
3259
|
clientId: clientId,
|
|
3274
3260
|
agentName: agentName,
|
|
@@ -3281,6 +3267,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3281
3267
|
}
|
|
3282
3268
|
});
|
|
3283
3269
|
}); }, {
|
|
3270
|
+
requestId: requestId,
|
|
3284
3271
|
clientId: clientId,
|
|
3285
3272
|
agentName: agentName,
|
|
3286
3273
|
swarmName: "",
|
|
@@ -3298,12 +3285,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3298
3285
|
* @param {AgentName} agentName - The name of the agent.
|
|
3299
3286
|
* @returns {Promise<unknown>} The commit result.
|
|
3300
3287
|
*/
|
|
3301
|
-
this.commitUserMessage = function (message, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3288
|
+
this.commitUserMessage = function (message, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3302
3289
|
var _this = this;
|
|
3303
3290
|
return __generator(this, function (_a) {
|
|
3304
3291
|
switch (_a.label) {
|
|
3305
3292
|
case 0:
|
|
3306
3293
|
this.loggerService.log("agentPublicService commitUserMessage", {
|
|
3294
|
+
requestId: requestId,
|
|
3307
3295
|
message: message,
|
|
3308
3296
|
clientId: clientId,
|
|
3309
3297
|
agentName: agentName,
|
|
@@ -3316,6 +3304,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3316
3304
|
}
|
|
3317
3305
|
});
|
|
3318
3306
|
}); }, {
|
|
3307
|
+
requestId: requestId,
|
|
3319
3308
|
clientId: clientId,
|
|
3320
3309
|
agentName: agentName,
|
|
3321
3310
|
swarmName: "",
|
|
@@ -3332,12 +3321,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3332
3321
|
* @param {AgentName} agentName - The name of the agent.
|
|
3333
3322
|
* @returns {Promise<unknown>} The commit result.
|
|
3334
3323
|
*/
|
|
3335
|
-
this.commitFlush = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3324
|
+
this.commitFlush = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3336
3325
|
var _this = this;
|
|
3337
3326
|
return __generator(this, function (_a) {
|
|
3338
3327
|
switch (_a.label) {
|
|
3339
3328
|
case 0:
|
|
3340
3329
|
this.loggerService.log("agentPublicService commitFlush", {
|
|
3330
|
+
requestId: requestId,
|
|
3341
3331
|
clientId: clientId,
|
|
3342
3332
|
agentName: agentName,
|
|
3343
3333
|
});
|
|
@@ -3349,6 +3339,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3349
3339
|
}
|
|
3350
3340
|
});
|
|
3351
3341
|
}); }, {
|
|
3342
|
+
requestId: requestId,
|
|
3352
3343
|
clientId: clientId,
|
|
3353
3344
|
agentName: agentName,
|
|
3354
3345
|
swarmName: "",
|
|
@@ -3365,12 +3356,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3365
3356
|
* @param {AgentName} agentName - The name of the agent.
|
|
3366
3357
|
* @returns {Promise<unknown>} The commit result.
|
|
3367
3358
|
*/
|
|
3368
|
-
this.commitAgentChange = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3359
|
+
this.commitAgentChange = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3369
3360
|
var _this = this;
|
|
3370
3361
|
return __generator(this, function (_a) {
|
|
3371
3362
|
switch (_a.label) {
|
|
3372
3363
|
case 0:
|
|
3373
3364
|
this.loggerService.log("agentPublicService commitAgentChange", {
|
|
3365
|
+
requestId: requestId,
|
|
3374
3366
|
clientId: clientId,
|
|
3375
3367
|
agentName: agentName,
|
|
3376
3368
|
});
|
|
@@ -3382,6 +3374,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3382
3374
|
}
|
|
3383
3375
|
});
|
|
3384
3376
|
}); }, {
|
|
3377
|
+
requestId: requestId,
|
|
3385
3378
|
clientId: clientId,
|
|
3386
3379
|
agentName: agentName,
|
|
3387
3380
|
swarmName: "",
|
|
@@ -3398,12 +3391,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3398
3391
|
* @param {AgentName} agentName - The name of the agent.
|
|
3399
3392
|
* @returns {Promise<unknown>} The dispose result.
|
|
3400
3393
|
*/
|
|
3401
|
-
this.dispose = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3394
|
+
this.dispose = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3402
3395
|
var _this = this;
|
|
3403
3396
|
return __generator(this, function (_a) {
|
|
3404
3397
|
switch (_a.label) {
|
|
3405
3398
|
case 0:
|
|
3406
3399
|
this.loggerService.log("agentPublicService dispose", {
|
|
3400
|
+
requestId: requestId,
|
|
3407
3401
|
clientId: clientId,
|
|
3408
3402
|
agentName: agentName,
|
|
3409
3403
|
});
|
|
@@ -3415,6 +3409,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3415
3409
|
}
|
|
3416
3410
|
});
|
|
3417
3411
|
}); }, {
|
|
3412
|
+
requestId: requestId,
|
|
3418
3413
|
clientId: clientId,
|
|
3419
3414
|
agentName: agentName,
|
|
3420
3415
|
swarmName: "",
|
|
@@ -3444,12 +3439,13 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3444
3439
|
* @param {AgentName} agentName - The agent name.
|
|
3445
3440
|
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
3446
3441
|
*/
|
|
3447
|
-
this.push = function (message, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3442
|
+
this.push = function (message, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3448
3443
|
var _this = this;
|
|
3449
3444
|
return __generator(this, function (_a) {
|
|
3450
3445
|
switch (_a.label) {
|
|
3451
3446
|
case 0:
|
|
3452
3447
|
this.loggerService.log("historyPublicService push", {
|
|
3448
|
+
requestId: requestId,
|
|
3453
3449
|
message: message,
|
|
3454
3450
|
clientId: clientId,
|
|
3455
3451
|
agentName: agentName,
|
|
@@ -3462,6 +3458,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3462
3458
|
}
|
|
3463
3459
|
});
|
|
3464
3460
|
}); }, {
|
|
3461
|
+
requestId: requestId,
|
|
3465
3462
|
clientId: clientId,
|
|
3466
3463
|
agentName: agentName,
|
|
3467
3464
|
swarmName: "",
|
|
@@ -3479,7 +3476,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3479
3476
|
* @param {AgentName} agentName - The agent name.
|
|
3480
3477
|
* @returns {Promise<any[]>} A promise that resolves to an array of history items.
|
|
3481
3478
|
*/
|
|
3482
|
-
this.toArrayForAgent = function (prompt, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3479
|
+
this.toArrayForAgent = function (prompt, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3483
3480
|
var _this = this;
|
|
3484
3481
|
return __generator(this, function (_a) {
|
|
3485
3482
|
switch (_a.label) {
|
|
@@ -3497,6 +3494,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3497
3494
|
}
|
|
3498
3495
|
});
|
|
3499
3496
|
}); }, {
|
|
3497
|
+
requestId: requestId,
|
|
3500
3498
|
clientId: clientId,
|
|
3501
3499
|
agentName: agentName,
|
|
3502
3500
|
swarmName: "",
|
|
@@ -3513,12 +3511,13 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3513
3511
|
* @param {AgentName} agentName - The agent name.
|
|
3514
3512
|
* @returns {Promise<any[]>} A promise that resolves to a raw array of history items.
|
|
3515
3513
|
*/
|
|
3516
|
-
this.toArrayForRaw = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3514
|
+
this.toArrayForRaw = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3517
3515
|
var _this = this;
|
|
3518
3516
|
return __generator(this, function (_a) {
|
|
3519
3517
|
switch (_a.label) {
|
|
3520
3518
|
case 0:
|
|
3521
3519
|
this.loggerService.log("historyPublicService toArrayForRaw", {
|
|
3520
|
+
requestId: requestId,
|
|
3522
3521
|
clientId: clientId,
|
|
3523
3522
|
agentName: agentName,
|
|
3524
3523
|
});
|
|
@@ -3530,6 +3529,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3530
3529
|
}
|
|
3531
3530
|
});
|
|
3532
3531
|
}); }, {
|
|
3532
|
+
requestId: requestId,
|
|
3533
3533
|
clientId: clientId,
|
|
3534
3534
|
agentName: agentName,
|
|
3535
3535
|
swarmName: "",
|
|
@@ -3546,7 +3546,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3546
3546
|
* @param {AgentName} agentName - The agent name.
|
|
3547
3547
|
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
3548
3548
|
*/
|
|
3549
|
-
this.dispose = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3549
|
+
this.dispose = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3550
3550
|
var _this = this;
|
|
3551
3551
|
return __generator(this, function (_a) {
|
|
3552
3552
|
switch (_a.label) {
|
|
@@ -3563,6 +3563,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3563
3563
|
}
|
|
3564
3564
|
});
|
|
3565
3565
|
}); }, {
|
|
3566
|
+
requestId: requestId,
|
|
3566
3567
|
clientId: clientId,
|
|
3567
3568
|
agentName: agentName,
|
|
3568
3569
|
swarmName: "",
|
|
@@ -3592,7 +3593,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3592
3593
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3593
3594
|
* @returns {Promise<void>}
|
|
3594
3595
|
*/
|
|
3595
|
-
this.emit = function (content, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3596
|
+
this.emit = function (content, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3596
3597
|
var _this = this;
|
|
3597
3598
|
return __generator(this, function (_a) {
|
|
3598
3599
|
switch (_a.label) {
|
|
@@ -3600,6 +3601,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3600
3601
|
this.loggerService.log("sessionPublicService emit", {
|
|
3601
3602
|
content: content,
|
|
3602
3603
|
clientId: clientId,
|
|
3604
|
+
requestId: requestId,
|
|
3603
3605
|
swarmName: swarmName,
|
|
3604
3606
|
});
|
|
3605
3607
|
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -3610,6 +3612,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3610
3612
|
}
|
|
3611
3613
|
});
|
|
3612
3614
|
}); }, {
|
|
3615
|
+
requestId: requestId,
|
|
3613
3616
|
clientId: clientId,
|
|
3614
3617
|
swarmName: swarmName,
|
|
3615
3618
|
agentName: "",
|
|
@@ -3627,7 +3630,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3627
3630
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3628
3631
|
* @returns {Promise<void>}
|
|
3629
3632
|
*/
|
|
3630
|
-
this.execute = function (content, mode, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3633
|
+
this.execute = function (content, mode, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3631
3634
|
var _this = this;
|
|
3632
3635
|
return __generator(this, function (_a) {
|
|
3633
3636
|
switch (_a.label) {
|
|
@@ -3646,6 +3649,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3646
3649
|
}
|
|
3647
3650
|
});
|
|
3648
3651
|
}); }, {
|
|
3652
|
+
requestId: requestId,
|
|
3649
3653
|
clientId: clientId,
|
|
3650
3654
|
swarmName: swarmName,
|
|
3651
3655
|
agentName: "",
|
|
@@ -3663,8 +3667,9 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3663
3667
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3664
3668
|
* @returns {ReceiveMessageFn}
|
|
3665
3669
|
*/
|
|
3666
|
-
this.connect = function (connector, clientId, swarmName) {
|
|
3670
|
+
this.connect = function (connector, requestId, clientId, swarmName) {
|
|
3667
3671
|
_this.loggerService.log("sessionPublicService connect", {
|
|
3672
|
+
requestId: requestId,
|
|
3668
3673
|
clientId: clientId,
|
|
3669
3674
|
swarmName: swarmName,
|
|
3670
3675
|
});
|
|
@@ -3681,6 +3686,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3681
3686
|
}
|
|
3682
3687
|
});
|
|
3683
3688
|
}); }, {
|
|
3689
|
+
requestId: requestId,
|
|
3684
3690
|
clientId: clientId,
|
|
3685
3691
|
swarmName: swarmName,
|
|
3686
3692
|
agentName: "",
|
|
@@ -3695,6 +3701,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3695
3701
|
return ContextService.runInContext(function () {
|
|
3696
3702
|
return receive(incoming);
|
|
3697
3703
|
}, {
|
|
3704
|
+
requestId: requestId,
|
|
3698
3705
|
clientId: clientId,
|
|
3699
3706
|
swarmName: swarmName,
|
|
3700
3707
|
agentName: "",
|
|
@@ -3703,6 +3710,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3703
3710
|
});
|
|
3704
3711
|
};
|
|
3705
3712
|
}, {
|
|
3713
|
+
requestId: requestId,
|
|
3706
3714
|
clientId: clientId,
|
|
3707
3715
|
swarmName: swarmName,
|
|
3708
3716
|
agentName: "",
|
|
@@ -3718,12 +3726,13 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3718
3726
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3719
3727
|
* @returns {Promise<void>}
|
|
3720
3728
|
*/
|
|
3721
|
-
this.commitToolOutput = function (toolId, content, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3729
|
+
this.commitToolOutput = function (toolId, content, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3722
3730
|
var _this = this;
|
|
3723
3731
|
return __generator(this, function (_a) {
|
|
3724
3732
|
switch (_a.label) {
|
|
3725
3733
|
case 0:
|
|
3726
3734
|
this.loggerService.log("sessionPublicService commitToolOutput", {
|
|
3735
|
+
requestId: requestId,
|
|
3727
3736
|
toolId: toolId,
|
|
3728
3737
|
content: content,
|
|
3729
3738
|
clientId: clientId,
|
|
@@ -3737,6 +3746,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3737
3746
|
}
|
|
3738
3747
|
});
|
|
3739
3748
|
}); }, {
|
|
3749
|
+
requestId: requestId,
|
|
3740
3750
|
clientId: clientId,
|
|
3741
3751
|
swarmName: swarmName,
|
|
3742
3752
|
agentName: "",
|
|
@@ -3754,12 +3764,13 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3754
3764
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3755
3765
|
* @returns {Promise<void>}
|
|
3756
3766
|
*/
|
|
3757
|
-
this.commitSystemMessage = function (message, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3767
|
+
this.commitSystemMessage = function (message, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3758
3768
|
var _this = this;
|
|
3759
3769
|
return __generator(this, function (_a) {
|
|
3760
3770
|
switch (_a.label) {
|
|
3761
3771
|
case 0:
|
|
3762
3772
|
this.loggerService.log("sessionPublicService commitSystemMessage", {
|
|
3773
|
+
requestId: requestId,
|
|
3763
3774
|
message: message,
|
|
3764
3775
|
clientId: clientId,
|
|
3765
3776
|
swarmName: swarmName,
|
|
@@ -3772,6 +3783,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3772
3783
|
}
|
|
3773
3784
|
});
|
|
3774
3785
|
}); }, {
|
|
3786
|
+
requestId: requestId,
|
|
3775
3787
|
clientId: clientId,
|
|
3776
3788
|
swarmName: swarmName,
|
|
3777
3789
|
agentName: "",
|
|
@@ -3789,12 +3801,13 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3789
3801
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3790
3802
|
* @returns {Promise<void>}
|
|
3791
3803
|
*/
|
|
3792
|
-
this.commitUserMessage = function (message, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3804
|
+
this.commitUserMessage = function (message, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3793
3805
|
var _this = this;
|
|
3794
3806
|
return __generator(this, function (_a) {
|
|
3795
3807
|
switch (_a.label) {
|
|
3796
3808
|
case 0:
|
|
3797
3809
|
this.loggerService.log("sessionPublicService commitUserMessage", {
|
|
3810
|
+
requestId: requestId,
|
|
3798
3811
|
message: message,
|
|
3799
3812
|
clientId: clientId,
|
|
3800
3813
|
swarmName: swarmName,
|
|
@@ -3807,6 +3820,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3807
3820
|
}
|
|
3808
3821
|
});
|
|
3809
3822
|
}); }, {
|
|
3823
|
+
requestId: requestId,
|
|
3810
3824
|
clientId: clientId,
|
|
3811
3825
|
swarmName: swarmName,
|
|
3812
3826
|
agentName: "",
|
|
@@ -3823,7 +3837,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3823
3837
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3824
3838
|
* @returns {Promise<void>}
|
|
3825
3839
|
*/
|
|
3826
|
-
this.commitFlush = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3840
|
+
this.commitFlush = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3827
3841
|
var _this = this;
|
|
3828
3842
|
return __generator(this, function (_a) {
|
|
3829
3843
|
switch (_a.label) {
|
|
@@ -3840,6 +3854,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3840
3854
|
}
|
|
3841
3855
|
});
|
|
3842
3856
|
}); }, {
|
|
3857
|
+
requestId: requestId,
|
|
3843
3858
|
clientId: clientId,
|
|
3844
3859
|
swarmName: swarmName,
|
|
3845
3860
|
agentName: "",
|
|
@@ -3856,12 +3871,13 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3856
3871
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3857
3872
|
* @returns {Promise<void>}
|
|
3858
3873
|
*/
|
|
3859
|
-
this.dispose = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3874
|
+
this.dispose = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3860
3875
|
var _this = this;
|
|
3861
3876
|
return __generator(this, function (_a) {
|
|
3862
3877
|
switch (_a.label) {
|
|
3863
3878
|
case 0:
|
|
3864
3879
|
this.loggerService.log("sessionPublicService dispose", {
|
|
3880
|
+
requestId: requestId,
|
|
3865
3881
|
clientId: clientId,
|
|
3866
3882
|
swarmName: swarmName,
|
|
3867
3883
|
});
|
|
@@ -3873,6 +3889,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3873
3889
|
}
|
|
3874
3890
|
});
|
|
3875
3891
|
}); }, {
|
|
3892
|
+
requestId: requestId,
|
|
3876
3893
|
clientId: clientId,
|
|
3877
3894
|
swarmName: swarmName,
|
|
3878
3895
|
agentName: "",
|
|
@@ -3901,7 +3918,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3901
3918
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3902
3919
|
* @returns {Promise<void>}
|
|
3903
3920
|
*/
|
|
3904
|
-
this.cancelOutput = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3921
|
+
this.cancelOutput = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3905
3922
|
var _this = this;
|
|
3906
3923
|
return __generator(this, function (_a) {
|
|
3907
3924
|
switch (_a.label) {
|
|
@@ -3918,6 +3935,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3918
3935
|
}
|
|
3919
3936
|
});
|
|
3920
3937
|
}); }, {
|
|
3938
|
+
requestId: requestId,
|
|
3921
3939
|
clientId: clientId,
|
|
3922
3940
|
swarmName: swarmName,
|
|
3923
3941
|
agentName: "",
|
|
@@ -3934,13 +3952,14 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3934
3952
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3935
3953
|
* @returns {Promise<void>}
|
|
3936
3954
|
*/
|
|
3937
|
-
this.waitForOutput = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3955
|
+
this.waitForOutput = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3938
3956
|
var _this = this;
|
|
3939
3957
|
return __generator(this, function (_a) {
|
|
3940
3958
|
switch (_a.label) {
|
|
3941
3959
|
case 0:
|
|
3942
3960
|
this.loggerService.log("swarmPublicService waitForOutput", {
|
|
3943
3961
|
clientId: clientId,
|
|
3962
|
+
requestId: requestId,
|
|
3944
3963
|
swarmName: swarmName,
|
|
3945
3964
|
});
|
|
3946
3965
|
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -3951,6 +3970,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3951
3970
|
}
|
|
3952
3971
|
});
|
|
3953
3972
|
}); }, {
|
|
3973
|
+
requestId: requestId,
|
|
3954
3974
|
clientId: clientId,
|
|
3955
3975
|
swarmName: swarmName,
|
|
3956
3976
|
agentName: "",
|
|
@@ -3967,7 +3987,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3967
3987
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3968
3988
|
* @returns {Promise<string>}
|
|
3969
3989
|
*/
|
|
3970
|
-
this.getAgentName = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3990
|
+
this.getAgentName = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3971
3991
|
var _this = this;
|
|
3972
3992
|
return __generator(this, function (_a) {
|
|
3973
3993
|
switch (_a.label) {
|
|
@@ -3975,6 +3995,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3975
3995
|
this.loggerService.log("swarmPublicService getAgentName", {
|
|
3976
3996
|
clientId: clientId,
|
|
3977
3997
|
swarmName: swarmName,
|
|
3998
|
+
requestId: requestId,
|
|
3978
3999
|
});
|
|
3979
4000
|
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3980
4001
|
return __generator(this, function (_a) {
|
|
@@ -3984,6 +4005,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3984
4005
|
}
|
|
3985
4006
|
});
|
|
3986
4007
|
}); }, {
|
|
4008
|
+
requestId: requestId,
|
|
3987
4009
|
clientId: clientId,
|
|
3988
4010
|
swarmName: swarmName,
|
|
3989
4011
|
agentName: "",
|
|
@@ -4000,7 +4022,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4000
4022
|
* @param {SwarmName} swarmName - The swarm name.
|
|
4001
4023
|
* @returns {Promise<IAgent>}
|
|
4002
4024
|
*/
|
|
4003
|
-
this.getAgent = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4025
|
+
this.getAgent = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4004
4026
|
var _this = this;
|
|
4005
4027
|
return __generator(this, function (_a) {
|
|
4006
4028
|
switch (_a.label) {
|
|
@@ -4017,6 +4039,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4017
4039
|
}
|
|
4018
4040
|
});
|
|
4019
4041
|
}); }, {
|
|
4042
|
+
requestId: requestId,
|
|
4020
4043
|
clientId: clientId,
|
|
4021
4044
|
swarmName: swarmName,
|
|
4022
4045
|
agentName: "",
|
|
@@ -4035,12 +4058,13 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4035
4058
|
* @param {IAgent} agent - The agent instance.
|
|
4036
4059
|
* @returns {Promise<void>}
|
|
4037
4060
|
*/
|
|
4038
|
-
this.setAgentRef = function (clientId, swarmName, agentName, agent) { return __awaiter(_this, void 0, void 0, function () {
|
|
4061
|
+
this.setAgentRef = function (requestId, clientId, swarmName, agentName, agent) { return __awaiter(_this, void 0, void 0, function () {
|
|
4039
4062
|
var _this = this;
|
|
4040
4063
|
return __generator(this, function (_a) {
|
|
4041
4064
|
switch (_a.label) {
|
|
4042
4065
|
case 0:
|
|
4043
4066
|
this.loggerService.log("swarmPublicService setAgentRef", {
|
|
4067
|
+
requestId: requestId,
|
|
4044
4068
|
agentName: agentName,
|
|
4045
4069
|
agent: agent,
|
|
4046
4070
|
clientId: clientId,
|
|
@@ -4054,6 +4078,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4054
4078
|
}
|
|
4055
4079
|
});
|
|
4056
4080
|
}); }, {
|
|
4081
|
+
requestId: requestId,
|
|
4057
4082
|
clientId: clientId,
|
|
4058
4083
|
swarmName: swarmName,
|
|
4059
4084
|
agentName: "",
|
|
@@ -4071,12 +4096,13 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4071
4096
|
* @param {SwarmName} swarmName - The swarm name.
|
|
4072
4097
|
* @returns {Promise<void>}
|
|
4073
4098
|
*/
|
|
4074
|
-
this.setAgentName = function (agentName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4099
|
+
this.setAgentName = function (agentName, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4075
4100
|
var _this = this;
|
|
4076
4101
|
return __generator(this, function (_a) {
|
|
4077
4102
|
switch (_a.label) {
|
|
4078
4103
|
case 0:
|
|
4079
4104
|
this.loggerService.log("swarmPublicService setAgentName", {
|
|
4105
|
+
requestId: requestId,
|
|
4080
4106
|
agentName: agentName,
|
|
4081
4107
|
clientId: clientId,
|
|
4082
4108
|
swarmName: swarmName,
|
|
@@ -4089,6 +4115,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4089
4115
|
}
|
|
4090
4116
|
});
|
|
4091
4117
|
}); }, {
|
|
4118
|
+
requestId: requestId,
|
|
4092
4119
|
clientId: clientId,
|
|
4093
4120
|
swarmName: swarmName,
|
|
4094
4121
|
agentName: "",
|
|
@@ -4105,12 +4132,13 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4105
4132
|
* @param {SwarmName} swarmName - The swarm name.
|
|
4106
4133
|
* @returns {Promise<void>}
|
|
4107
4134
|
*/
|
|
4108
|
-
this.dispose = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4135
|
+
this.dispose = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4109
4136
|
var _this = this;
|
|
4110
4137
|
return __generator(this, function (_a) {
|
|
4111
4138
|
switch (_a.label) {
|
|
4112
4139
|
case 0:
|
|
4113
4140
|
this.loggerService.log("swarmPublicService dispose", {
|
|
4141
|
+
requestId: requestId,
|
|
4114
4142
|
clientId: clientId,
|
|
4115
4143
|
swarmName: swarmName,
|
|
4116
4144
|
});
|
|
@@ -4122,6 +4150,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4122
4150
|
}
|
|
4123
4151
|
});
|
|
4124
4152
|
}); }, {
|
|
4153
|
+
requestId: requestId,
|
|
4125
4154
|
clientId: clientId,
|
|
4126
4155
|
swarmName: swarmName,
|
|
4127
4156
|
agentName: "",
|
|
@@ -4923,7 +4952,7 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4923
4952
|
}
|
|
4924
4953
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
4925
4954
|
type: "take",
|
|
4926
|
-
source: "storage",
|
|
4955
|
+
source: "storage-bus",
|
|
4927
4956
|
input: {
|
|
4928
4957
|
search: search,
|
|
4929
4958
|
total: total,
|
|
@@ -4967,7 +4996,7 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4967
4996
|
}
|
|
4968
4997
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
4969
4998
|
type: "upsert",
|
|
4970
|
-
source: "storage",
|
|
4999
|
+
source: "storage-bus",
|
|
4971
5000
|
input: {
|
|
4972
5001
|
item: item,
|
|
4973
5002
|
},
|
|
@@ -5003,7 +5032,7 @@ var ClientStorage = /** @class */ (function () {
|
|
|
5003
5032
|
}
|
|
5004
5033
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
5005
5034
|
type: "remove",
|
|
5006
|
-
source: "storage",
|
|
5035
|
+
source: "storage-bus",
|
|
5007
5036
|
input: {
|
|
5008
5037
|
itemId: itemId,
|
|
5009
5038
|
},
|
|
@@ -5032,7 +5061,7 @@ var ClientStorage = /** @class */ (function () {
|
|
|
5032
5061
|
this._createEmbedding.clear();
|
|
5033
5062
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
5034
5063
|
type: "clear",
|
|
5035
|
-
source: "storage",
|
|
5064
|
+
source: "storage-bus",
|
|
5036
5065
|
input: {},
|
|
5037
5066
|
output: {},
|
|
5038
5067
|
context: {
|
|
@@ -5063,7 +5092,7 @@ var ClientStorage = /** @class */ (function () {
|
|
|
5063
5092
|
result = (_a = this._itemMap.get(itemId)) !== null && _a !== void 0 ? _a : null;
|
|
5064
5093
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
5065
5094
|
type: "get",
|
|
5066
|
-
source: "storage",
|
|
5095
|
+
source: "storage-bus",
|
|
5067
5096
|
input: {
|
|
5068
5097
|
itemId: itemId,
|
|
5069
5098
|
},
|
|
@@ -5114,7 +5143,7 @@ var ClientStorage = /** @class */ (function () {
|
|
|
5114
5143
|
}
|
|
5115
5144
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
5116
5145
|
type: "list",
|
|
5117
|
-
source: "storage",
|
|
5146
|
+
source: "storage-bus",
|
|
5118
5147
|
input: {},
|
|
5119
5148
|
output: {
|
|
5120
5149
|
result: result,
|
|
@@ -5214,7 +5243,6 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5214
5243
|
switch (_a.label) {
|
|
5215
5244
|
case 0:
|
|
5216
5245
|
this.loggerService.log("storageConnectionService take", {
|
|
5217
|
-
context: this.contextService.context,
|
|
5218
5246
|
search: search,
|
|
5219
5247
|
total: total,
|
|
5220
5248
|
score: score,
|
|
@@ -5239,7 +5267,6 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5239
5267
|
switch (_a.label) {
|
|
5240
5268
|
case 0:
|
|
5241
5269
|
this.loggerService.log("storageConnectionService upsert", {
|
|
5242
|
-
context: this.contextService.context,
|
|
5243
5270
|
item: item,
|
|
5244
5271
|
});
|
|
5245
5272
|
storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
@@ -5262,7 +5289,6 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5262
5289
|
switch (_a.label) {
|
|
5263
5290
|
case 0:
|
|
5264
5291
|
this.loggerService.log("storageConnectionService remove", {
|
|
5265
|
-
context: this.contextService.context,
|
|
5266
5292
|
itemId: itemId,
|
|
5267
5293
|
});
|
|
5268
5294
|
storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
@@ -5285,7 +5311,6 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5285
5311
|
switch (_a.label) {
|
|
5286
5312
|
case 0:
|
|
5287
5313
|
this.loggerService.log("storageConnectionService get", {
|
|
5288
|
-
context: this.contextService.context,
|
|
5289
5314
|
itemId: itemId,
|
|
5290
5315
|
});
|
|
5291
5316
|
storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
@@ -5307,9 +5332,7 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5307
5332
|
return __generator(this, function (_a) {
|
|
5308
5333
|
switch (_a.label) {
|
|
5309
5334
|
case 0:
|
|
5310
|
-
this.loggerService.log("storageConnectionService list"
|
|
5311
|
-
context: this.contextService.context,
|
|
5312
|
-
});
|
|
5335
|
+
this.loggerService.log("storageConnectionService list");
|
|
5313
5336
|
storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
5314
5337
|
return [4 /*yield*/, storage.waitForInit()];
|
|
5315
5338
|
case 1:
|
|
@@ -5328,9 +5351,7 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5328
5351
|
return __generator(this, function (_a) {
|
|
5329
5352
|
switch (_a.label) {
|
|
5330
5353
|
case 0:
|
|
5331
|
-
this.loggerService.log("storageConnectionService clear"
|
|
5332
|
-
context: this.contextService.context,
|
|
5333
|
-
});
|
|
5354
|
+
this.loggerService.log("storageConnectionService clear");
|
|
5334
5355
|
storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
5335
5356
|
return [4 /*yield*/, storage.waitForInit()];
|
|
5336
5357
|
case 1:
|
|
@@ -5349,9 +5370,7 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5349
5370
|
return __generator(this, function (_a) {
|
|
5350
5371
|
switch (_a.label) {
|
|
5351
5372
|
case 0:
|
|
5352
|
-
this.loggerService.log("storageConnectionService dispose"
|
|
5353
|
-
context: this.contextService.context,
|
|
5354
|
-
});
|
|
5373
|
+
this.loggerService.log("storageConnectionService dispose");
|
|
5355
5374
|
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.storageName);
|
|
5356
5375
|
if (!this.getStorage.has(key)) {
|
|
5357
5376
|
return [2 /*return*/];
|
|
@@ -5390,12 +5409,13 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5390
5409
|
* @param {number} total - The total number of items to retrieve.
|
|
5391
5410
|
* @returns {Promise<IStorageData[]>} The list of storage data.
|
|
5392
5411
|
*/
|
|
5393
|
-
this.take = function (search, total, clientId, storageName, score) { return __awaiter(_this, void 0, void 0, function () {
|
|
5412
|
+
this.take = function (search, total, requestId, clientId, storageName, score) { return __awaiter(_this, void 0, void 0, function () {
|
|
5394
5413
|
var _this = this;
|
|
5395
5414
|
return __generator(this, function (_a) {
|
|
5396
5415
|
switch (_a.label) {
|
|
5397
5416
|
case 0:
|
|
5398
5417
|
this.loggerService.log("storagePublicService take", {
|
|
5418
|
+
requestId: requestId,
|
|
5399
5419
|
search: search,
|
|
5400
5420
|
total: total,
|
|
5401
5421
|
clientId: clientId,
|
|
@@ -5410,6 +5430,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5410
5430
|
}
|
|
5411
5431
|
});
|
|
5412
5432
|
}); }, {
|
|
5433
|
+
requestId: requestId,
|
|
5413
5434
|
clientId: clientId,
|
|
5414
5435
|
storageName: storageName,
|
|
5415
5436
|
agentName: "",
|
|
@@ -5425,7 +5446,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5425
5446
|
* @param {IStorageData} item - The item to upsert.
|
|
5426
5447
|
* @returns {Promise<void>}
|
|
5427
5448
|
*/
|
|
5428
|
-
this.upsert = function (item, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5449
|
+
this.upsert = function (item, requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5429
5450
|
var _this = this;
|
|
5430
5451
|
return __generator(this, function (_a) {
|
|
5431
5452
|
switch (_a.label) {
|
|
@@ -5443,6 +5464,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5443
5464
|
}
|
|
5444
5465
|
});
|
|
5445
5466
|
}); }, {
|
|
5467
|
+
requestId: requestId,
|
|
5446
5468
|
clientId: clientId,
|
|
5447
5469
|
storageName: storageName,
|
|
5448
5470
|
agentName: "",
|
|
@@ -5458,7 +5480,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5458
5480
|
* @param {IStorageData["id"]} itemId - The ID of the item to remove.
|
|
5459
5481
|
* @returns {Promise<void>}
|
|
5460
5482
|
*/
|
|
5461
|
-
this.remove = function (itemId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5483
|
+
this.remove = function (itemId, requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5462
5484
|
var _this = this;
|
|
5463
5485
|
return __generator(this, function (_a) {
|
|
5464
5486
|
switch (_a.label) {
|
|
@@ -5476,6 +5498,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5476
5498
|
}
|
|
5477
5499
|
});
|
|
5478
5500
|
}); }, {
|
|
5501
|
+
requestId: requestId,
|
|
5479
5502
|
clientId: clientId,
|
|
5480
5503
|
storageName: storageName,
|
|
5481
5504
|
agentName: "",
|
|
@@ -5491,12 +5514,13 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5491
5514
|
* @param {IStorageData["id"]} itemId - The ID of the item to retrieve.
|
|
5492
5515
|
* @returns {Promise<IStorageData>} The retrieved item.
|
|
5493
5516
|
*/
|
|
5494
|
-
this.get = function (itemId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5517
|
+
this.get = function (itemId, requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5495
5518
|
var _this = this;
|
|
5496
5519
|
return __generator(this, function (_a) {
|
|
5497
5520
|
switch (_a.label) {
|
|
5498
5521
|
case 0:
|
|
5499
5522
|
this.loggerService.log("storagePublicService get", {
|
|
5523
|
+
requestId: requestId,
|
|
5500
5524
|
itemId: itemId,
|
|
5501
5525
|
clientId: clientId,
|
|
5502
5526
|
storageName: storageName,
|
|
@@ -5509,6 +5533,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5509
5533
|
}
|
|
5510
5534
|
});
|
|
5511
5535
|
}); }, {
|
|
5536
|
+
requestId: requestId,
|
|
5512
5537
|
clientId: clientId,
|
|
5513
5538
|
storageName: storageName,
|
|
5514
5539
|
agentName: "",
|
|
@@ -5524,12 +5549,13 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5524
5549
|
* @param {function(IStorageData): boolean} [filter] - The optional filter function.
|
|
5525
5550
|
* @returns {Promise<IStorageData[]>} The list of items.
|
|
5526
5551
|
*/
|
|
5527
|
-
this.list = function (clientId, storageName, filter) { return __awaiter(_this, void 0, void 0, function () {
|
|
5552
|
+
this.list = function (requestId, clientId, storageName, filter) { return __awaiter(_this, void 0, void 0, function () {
|
|
5528
5553
|
var _this = this;
|
|
5529
5554
|
return __generator(this, function (_a) {
|
|
5530
5555
|
switch (_a.label) {
|
|
5531
5556
|
case 0:
|
|
5532
5557
|
this.loggerService.log("storagePublicService list", {
|
|
5558
|
+
requestId: requestId,
|
|
5533
5559
|
clientId: clientId,
|
|
5534
5560
|
storageName: storageName,
|
|
5535
5561
|
});
|
|
@@ -5541,6 +5567,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5541
5567
|
}
|
|
5542
5568
|
});
|
|
5543
5569
|
}); }, {
|
|
5570
|
+
requestId: requestId,
|
|
5544
5571
|
clientId: clientId,
|
|
5545
5572
|
storageName: storageName,
|
|
5546
5573
|
agentName: "",
|
|
@@ -5555,12 +5582,13 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5555
5582
|
* Clears all items from the storage.
|
|
5556
5583
|
* @returns {Promise<void>}
|
|
5557
5584
|
*/
|
|
5558
|
-
this.clear = function (clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5585
|
+
this.clear = function (requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5559
5586
|
var _this = this;
|
|
5560
5587
|
return __generator(this, function (_a) {
|
|
5561
5588
|
switch (_a.label) {
|
|
5562
5589
|
case 0:
|
|
5563
5590
|
this.loggerService.log("storagePublicService clear", {
|
|
5591
|
+
requestId: requestId,
|
|
5564
5592
|
clientId: clientId,
|
|
5565
5593
|
storageName: storageName,
|
|
5566
5594
|
});
|
|
@@ -5572,6 +5600,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5572
5600
|
}
|
|
5573
5601
|
});
|
|
5574
5602
|
}); }, {
|
|
5603
|
+
requestId: requestId,
|
|
5575
5604
|
clientId: clientId,
|
|
5576
5605
|
storageName: storageName,
|
|
5577
5606
|
agentName: "",
|
|
@@ -5588,7 +5617,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5588
5617
|
* @param {StorageName} storageName - The storage name.
|
|
5589
5618
|
* @returns {Promise<void>}
|
|
5590
5619
|
*/
|
|
5591
|
-
this.dispose = function (clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5620
|
+
this.dispose = function (requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5592
5621
|
var _this = this;
|
|
5593
5622
|
return __generator(this, function (_a) {
|
|
5594
5623
|
switch (_a.label) {
|
|
@@ -5605,6 +5634,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5605
5634
|
}
|
|
5606
5635
|
});
|
|
5607
5636
|
}); }, {
|
|
5637
|
+
requestId: requestId,
|
|
5608
5638
|
clientId: clientId,
|
|
5609
5639
|
storageName: storageName,
|
|
5610
5640
|
agentName: "",
|
|
@@ -5858,7 +5888,7 @@ var ClientState = /** @class */ (function () {
|
|
|
5858
5888
|
}
|
|
5859
5889
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
5860
5890
|
type: "set-state",
|
|
5861
|
-
source: "state",
|
|
5891
|
+
source: "state-bus",
|
|
5862
5892
|
input: {},
|
|
5863
5893
|
output: {
|
|
5864
5894
|
state: this._state,
|
|
@@ -5892,7 +5922,7 @@ var ClientState = /** @class */ (function () {
|
|
|
5892
5922
|
}
|
|
5893
5923
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
5894
5924
|
type: "get-state",
|
|
5895
|
-
source: "state",
|
|
5925
|
+
source: "state-bus",
|
|
5896
5926
|
input: {},
|
|
5897
5927
|
output: {
|
|
5898
5928
|
state: this._state,
|
|
@@ -6033,9 +6063,7 @@ var StateConnectionService = /** @class */ (function () {
|
|
|
6033
6063
|
return __generator(this, function (_a) {
|
|
6034
6064
|
switch (_a.label) {
|
|
6035
6065
|
case 0:
|
|
6036
|
-
this.loggerService.log("stateConnectionService setState"
|
|
6037
|
-
context: this.contextService.context,
|
|
6038
|
-
});
|
|
6066
|
+
this.loggerService.log("stateConnectionService setState");
|
|
6039
6067
|
state = this.getStateRef(this.contextService.context.clientId, this.contextService.context.stateName);
|
|
6040
6068
|
return [4 /*yield*/, state.waitForInit()];
|
|
6041
6069
|
case 1:
|
|
@@ -6054,9 +6082,7 @@ var StateConnectionService = /** @class */ (function () {
|
|
|
6054
6082
|
return __generator(this, function (_a) {
|
|
6055
6083
|
switch (_a.label) {
|
|
6056
6084
|
case 0:
|
|
6057
|
-
this.loggerService.log("stateConnectionService getState"
|
|
6058
|
-
context: this.contextService.context,
|
|
6059
|
-
});
|
|
6085
|
+
this.loggerService.log("stateConnectionService getState");
|
|
6060
6086
|
state = this.getStateRef(this.contextService.context.clientId, this.contextService.context.stateName);
|
|
6061
6087
|
return [4 /*yield*/, state.waitForInit()];
|
|
6062
6088
|
case 1:
|
|
@@ -6075,9 +6101,7 @@ var StateConnectionService = /** @class */ (function () {
|
|
|
6075
6101
|
return __generator(this, function (_a) {
|
|
6076
6102
|
switch (_a.label) {
|
|
6077
6103
|
case 0:
|
|
6078
|
-
this.loggerService.log("stateConnectionService dispose"
|
|
6079
|
-
context: this.contextService.context,
|
|
6080
|
-
});
|
|
6104
|
+
this.loggerService.log("stateConnectionService dispose");
|
|
6081
6105
|
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.stateName);
|
|
6082
6106
|
if (!this.getStateRef.has(key)) {
|
|
6083
6107
|
return [2 /*return*/];
|
|
@@ -6114,12 +6138,13 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6114
6138
|
* @param {StateName} stateName - The name of the state.
|
|
6115
6139
|
* @returns {Promise<T>} - The updated state.
|
|
6116
6140
|
*/
|
|
6117
|
-
this.setState = function (dispatchFn, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
6141
|
+
this.setState = function (dispatchFn, requestId, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
6118
6142
|
var _this = this;
|
|
6119
6143
|
return __generator(this, function (_a) {
|
|
6120
6144
|
switch (_a.label) {
|
|
6121
6145
|
case 0:
|
|
6122
6146
|
this.loggerService.log("statePublicService setState", {
|
|
6147
|
+
requestId: requestId,
|
|
6123
6148
|
clientId: clientId,
|
|
6124
6149
|
stateName: stateName,
|
|
6125
6150
|
});
|
|
@@ -6131,6 +6156,7 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6131
6156
|
}
|
|
6132
6157
|
});
|
|
6133
6158
|
}); }, {
|
|
6159
|
+
requestId: requestId,
|
|
6134
6160
|
clientId: clientId,
|
|
6135
6161
|
stateName: stateName,
|
|
6136
6162
|
agentName: "",
|
|
@@ -6147,7 +6173,7 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6147
6173
|
* @param {StateName} stateName - The name of the state.
|
|
6148
6174
|
* @returns {Promise<T>} - The current state.
|
|
6149
6175
|
*/
|
|
6150
|
-
this.getState = function (clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
6176
|
+
this.getState = function (requestId, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
6151
6177
|
var _this = this;
|
|
6152
6178
|
return __generator(this, function (_a) {
|
|
6153
6179
|
switch (_a.label) {
|
|
@@ -6164,6 +6190,7 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6164
6190
|
}
|
|
6165
6191
|
});
|
|
6166
6192
|
}); }, {
|
|
6193
|
+
requestId: requestId,
|
|
6167
6194
|
clientId: clientId,
|
|
6168
6195
|
stateName: stateName,
|
|
6169
6196
|
agentName: "",
|
|
@@ -6180,12 +6207,13 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6180
6207
|
* @param {StateName} stateName - The name of the state.
|
|
6181
6208
|
* @returns {Promise<void>} - A promise that resolves when the state is disposed.
|
|
6182
6209
|
*/
|
|
6183
|
-
this.dispose = function (clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
6210
|
+
this.dispose = function (requestId, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
6184
6211
|
var _this = this;
|
|
6185
6212
|
return __generator(this, function (_a) {
|
|
6186
6213
|
switch (_a.label) {
|
|
6187
6214
|
case 0:
|
|
6188
6215
|
this.loggerService.log("statePublicService dispose", {
|
|
6216
|
+
requestId: requestId,
|
|
6189
6217
|
clientId: clientId,
|
|
6190
6218
|
stateName: stateName,
|
|
6191
6219
|
});
|
|
@@ -6197,6 +6225,7 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6197
6225
|
}
|
|
6198
6226
|
});
|
|
6199
6227
|
}); }, {
|
|
6228
|
+
requestId: requestId,
|
|
6200
6229
|
clientId: clientId,
|
|
6201
6230
|
stateName: stateName,
|
|
6202
6231
|
agentName: "",
|
|
@@ -6237,7 +6266,7 @@ var BusService = /** @class */ (function () {
|
|
|
6237
6266
|
_this._eventWildcardMap.set(source, true);
|
|
6238
6267
|
}
|
|
6239
6268
|
_this._eventSourceSet.add(source);
|
|
6240
|
-
_this.getEventSubject(clientId, source).subscribe(fn);
|
|
6269
|
+
return _this.getEventSubject(clientId, source).subscribe(fn);
|
|
6241
6270
|
};
|
|
6242
6271
|
/**
|
|
6243
6272
|
* Subscribes to a single event for a specific client and source.
|
|
@@ -6534,20 +6563,22 @@ var addStorage = function (storageSchema) {
|
|
|
6534
6563
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
6535
6564
|
*/
|
|
6536
6565
|
var commitUserMessage = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6537
|
-
var swarmName, currentAgentName;
|
|
6566
|
+
var requestId, swarmName, currentAgentName;
|
|
6538
6567
|
return __generator(this, function (_a) {
|
|
6539
6568
|
switch (_a.label) {
|
|
6540
6569
|
case 0:
|
|
6570
|
+
requestId = randomString();
|
|
6541
6571
|
swarm.loggerService.log('function commitSystemMessage', {
|
|
6542
6572
|
content: content,
|
|
6543
6573
|
clientId: clientId,
|
|
6544
6574
|
agentName: agentName,
|
|
6575
|
+
requestId: requestId,
|
|
6545
6576
|
});
|
|
6546
6577
|
swarm.agentValidationService.validate(agentName, "commitUserMessage");
|
|
6547
6578
|
swarm.sessionValidationService.validate(clientId, "commitUserMessage");
|
|
6548
6579
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
6549
6580
|
swarm.swarmValidationService.validate(swarmName, "commitUserMessage");
|
|
6550
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
6581
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
6551
6582
|
case 1:
|
|
6552
6583
|
currentAgentName = _a.sent();
|
|
6553
6584
|
if (currentAgentName !== agentName) {
|
|
@@ -6558,7 +6589,7 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
|
|
|
6558
6589
|
});
|
|
6559
6590
|
return [2 /*return*/];
|
|
6560
6591
|
}
|
|
6561
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, clientId, swarmName)];
|
|
6592
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, requestId, clientId, swarmName)];
|
|
6562
6593
|
case 2:
|
|
6563
6594
|
_a.sent();
|
|
6564
6595
|
return [2 /*return*/];
|
|
@@ -6574,17 +6605,19 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
|
|
|
6574
6605
|
* @throws Will throw an error if the client ID is invalid or if the swarm validation fails.
|
|
6575
6606
|
*/
|
|
6576
6607
|
var getAgentName = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6577
|
-
var swarmName;
|
|
6608
|
+
var requestId, swarmName;
|
|
6578
6609
|
return __generator(this, function (_a) {
|
|
6579
6610
|
switch (_a.label) {
|
|
6580
6611
|
case 0:
|
|
6612
|
+
requestId = randomString();
|
|
6581
6613
|
swarm.loggerService.log("function getAgentName", {
|
|
6582
6614
|
clientId: clientId,
|
|
6615
|
+
requestId: requestId,
|
|
6583
6616
|
});
|
|
6584
6617
|
swarm.sessionValidationService.validate(clientId, "getAgentName");
|
|
6585
6618
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
6586
6619
|
swarm.swarmValidationService.validate(swarmName, "getAgentName");
|
|
6587
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
6620
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
6588
6621
|
case 1: return [2 /*return*/, _a.sent()];
|
|
6589
6622
|
}
|
|
6590
6623
|
});
|
|
@@ -6600,13 +6633,15 @@ var SCHEDULED_DELAY$1 = 1000;
|
|
|
6600
6633
|
* @returns {SendMessageFn} - A function to send messages to the swarm.
|
|
6601
6634
|
*/
|
|
6602
6635
|
var makeConnection = function (connector, clientId, swarmName) {
|
|
6636
|
+
var requestId = randomString();
|
|
6603
6637
|
swarm.loggerService.log("function makeConnection", {
|
|
6604
6638
|
clientId: clientId,
|
|
6605
6639
|
swarmName: swarmName,
|
|
6640
|
+
requestId: requestId,
|
|
6606
6641
|
});
|
|
6607
6642
|
swarm.swarmValidationService.validate(swarmName, "makeConnection");
|
|
6608
6643
|
swarm.sessionValidationService.addSession(clientId, swarmName, "makeConnection");
|
|
6609
|
-
var send = swarm.sessionPublicService.connect(connector, clientId, swarmName);
|
|
6644
|
+
var send = swarm.sessionPublicService.connect(connector, requestId, clientId, swarmName);
|
|
6610
6645
|
return queued(function (outgoing) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6611
6646
|
var _a;
|
|
6612
6647
|
var _b;
|
|
@@ -6618,7 +6653,7 @@ var makeConnection = function (connector, clientId, swarmName) {
|
|
|
6618
6653
|
_b = {
|
|
6619
6654
|
data: outgoing
|
|
6620
6655
|
};
|
|
6621
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
6656
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
6622
6657
|
case 1: return [4 /*yield*/, _a.apply(void 0, [(_b.agentName = _c.sent(),
|
|
6623
6658
|
_b.clientId = clientId,
|
|
6624
6659
|
_b)])];
|
|
@@ -6721,7 +6756,7 @@ var CHANGE_AGENT_GC = 60 * 1000;
|
|
|
6721
6756
|
* @returns {TChangeAgentRun} - The change agent function.
|
|
6722
6757
|
*/
|
|
6723
6758
|
var createChangeAgent = ttl(function (clientId) {
|
|
6724
|
-
return queued(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6759
|
+
return queued(function (requestId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6725
6760
|
var swarmName, _a, _b, _c;
|
|
6726
6761
|
return __generator(this, function (_d) {
|
|
6727
6762
|
switch (_d.label) {
|
|
@@ -6734,7 +6769,7 @@ var createChangeAgent = ttl(function (clientId) {
|
|
|
6734
6769
|
.map(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6735
6770
|
return __generator(this, function (_a) {
|
|
6736
6771
|
switch (_a.label) {
|
|
6737
|
-
case 0: return [4 /*yield*/, swarm.agentPublicService.commitAgentChange(clientId, agentName)];
|
|
6772
|
+
case 0: return [4 /*yield*/, swarm.agentPublicService.commitAgentChange(requestId, clientId, agentName)];
|
|
6738
6773
|
case 1:
|
|
6739
6774
|
_a.sent();
|
|
6740
6775
|
return [2 /*return*/];
|
|
@@ -6743,21 +6778,22 @@ var createChangeAgent = ttl(function (clientId) {
|
|
|
6743
6778
|
}); }))];
|
|
6744
6779
|
case 1:
|
|
6745
6780
|
_d.sent();
|
|
6746
|
-
return [4 /*yield*/, swarm.agentPublicService.dispose(clientId, agentName)];
|
|
6781
|
+
return [4 /*yield*/, swarm.agentPublicService.dispose(requestId, clientId, agentName)];
|
|
6747
6782
|
case 2:
|
|
6748
6783
|
_d.sent();
|
|
6749
|
-
return [4 /*yield*/, swarm.historyPublicService.dispose(clientId, agentName)];
|
|
6784
|
+
return [4 /*yield*/, swarm.historyPublicService.dispose(requestId, clientId, agentName)];
|
|
6750
6785
|
case 3:
|
|
6751
6786
|
_d.sent();
|
|
6752
6787
|
_b = (_a = swarm.swarmPublicService).setAgentRef;
|
|
6753
|
-
_c = [
|
|
6788
|
+
_c = [requestId,
|
|
6789
|
+
clientId,
|
|
6754
6790
|
swarmName,
|
|
6755
6791
|
agentName];
|
|
6756
|
-
return [4 /*yield*/, swarm.agentPublicService.createAgentRef(clientId, agentName)];
|
|
6792
|
+
return [4 /*yield*/, swarm.agentPublicService.createAgentRef(requestId, clientId, agentName)];
|
|
6757
6793
|
case 4: return [4 /*yield*/, _b.apply(_a, _c.concat([_d.sent()]))];
|
|
6758
6794
|
case 5:
|
|
6759
6795
|
_d.sent();
|
|
6760
|
-
return [4 /*yield*/, swarm.swarmPublicService.setAgentName(agentName, clientId, swarmName)];
|
|
6796
|
+
return [4 /*yield*/, swarm.swarmPublicService.setAgentName(agentName, requestId, clientId, swarmName)];
|
|
6761
6797
|
case 6:
|
|
6762
6798
|
_d.sent();
|
|
6763
6799
|
return [2 /*return*/];
|
|
@@ -6791,10 +6827,11 @@ var createGc$1 = singleshot(function () { return __awaiter(void 0, void 0, void
|
|
|
6791
6827
|
* @returns {Promise<void>} - A promise that resolves when the agent is changed.
|
|
6792
6828
|
*/
|
|
6793
6829
|
var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6794
|
-
var run;
|
|
6830
|
+
var requestId, run;
|
|
6795
6831
|
return __generator(this, function (_a) {
|
|
6796
6832
|
switch (_a.label) {
|
|
6797
6833
|
case 0:
|
|
6834
|
+
requestId = randomString();
|
|
6798
6835
|
swarm.loggerService.log("function changeAgent", {
|
|
6799
6836
|
agentName: agentName,
|
|
6800
6837
|
clientId: clientId,
|
|
@@ -6803,7 +6840,7 @@ var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void
|
|
|
6803
6840
|
case 1:
|
|
6804
6841
|
run = _a.sent();
|
|
6805
6842
|
createGc$1();
|
|
6806
|
-
return [4 /*yield*/, run(agentName)];
|
|
6843
|
+
return [4 /*yield*/, run(requestId, agentName)];
|
|
6807
6844
|
case 2: return [2 /*return*/, _a.sent()];
|
|
6808
6845
|
}
|
|
6809
6846
|
});
|
|
@@ -6816,83 +6853,91 @@ var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void
|
|
|
6816
6853
|
* @param {SwarmName} swarmName - The name of the swarm.
|
|
6817
6854
|
* @returns {Promise<void>} A promise that resolves when the connection is disposed.
|
|
6818
6855
|
*/
|
|
6819
|
-
var disposeConnection = function (
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
6856
|
+
var disposeConnection = function (clientId_1, swarmName_1) {
|
|
6857
|
+
var args_1 = [];
|
|
6858
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
6859
|
+
args_1[_i - 2] = arguments[_i];
|
|
6860
|
+
}
|
|
6861
|
+
return __awaiter(void 0, __spreadArray([clientId_1, swarmName_1], __read(args_1), false), void 0, function (clientId, swarmName, requestId) {
|
|
6862
|
+
if (requestId === void 0) { requestId = randomString(); }
|
|
6863
|
+
return __generator(this, function (_a) {
|
|
6864
|
+
switch (_a.label) {
|
|
6865
|
+
case 0:
|
|
6866
|
+
swarm.loggerService.log("function disposeConnection", {
|
|
6867
|
+
clientId: clientId,
|
|
6868
|
+
swarmName: swarmName,
|
|
6869
|
+
requestId: requestId,
|
|
6870
|
+
});
|
|
6871
|
+
swarm.swarmValidationService.validate(swarmName, "disposeConnection");
|
|
6872
|
+
swarm.sessionValidationService.removeSession(clientId);
|
|
6873
|
+
swarm.busService.dispose(clientId);
|
|
6874
|
+
return [4 /*yield*/, swarm.sessionPublicService.dispose(requestId, clientId, swarmName)];
|
|
6875
|
+
case 1:
|
|
6876
|
+
_a.sent();
|
|
6877
|
+
return [4 /*yield*/, swarm.swarmPublicService.dispose(requestId, clientId, swarmName)];
|
|
6878
|
+
case 2:
|
|
6879
|
+
_a.sent();
|
|
6880
|
+
return [4 /*yield*/, Promise.all(swarm.swarmValidationService
|
|
6881
|
+
.getAgentList(swarmName)
|
|
6882
|
+
.map(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6883
|
+
return __generator(this, function (_a) {
|
|
6884
|
+
switch (_a.label) {
|
|
6885
|
+
case 0: return [4 /*yield*/, swarm.agentPublicService.dispose(requestId, clientId, agentName)];
|
|
6886
|
+
case 1:
|
|
6887
|
+
_a.sent();
|
|
6888
|
+
return [4 /*yield*/, swarm.historyPublicService.dispose(requestId, clientId, agentName)];
|
|
6889
|
+
case 2:
|
|
6890
|
+
_a.sent();
|
|
6891
|
+
return [2 /*return*/];
|
|
6892
|
+
}
|
|
6893
|
+
});
|
|
6894
|
+
}); }))];
|
|
6895
|
+
case 3:
|
|
6896
|
+
_a.sent();
|
|
6897
|
+
return [4 /*yield*/, Promise.all(swarm.swarmValidationService
|
|
6898
|
+
.getAgentList(swarmName)
|
|
6899
|
+
.flatMap(function (agentName) {
|
|
6900
|
+
return swarm.agentValidationService.getStorageList(agentName);
|
|
6901
|
+
})
|
|
6902
|
+
.filter(function (storageName) { return !!storageName; })
|
|
6903
|
+
.map(function (storageName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6904
|
+
return __generator(this, function (_a) {
|
|
6905
|
+
switch (_a.label) {
|
|
6906
|
+
case 0: return [4 /*yield*/, swarm.storagePublicService.dispose(requestId, clientId, storageName)];
|
|
6907
|
+
case 1:
|
|
6908
|
+
_a.sent();
|
|
6909
|
+
return [2 /*return*/];
|
|
6910
|
+
}
|
|
6911
|
+
});
|
|
6912
|
+
}); }))];
|
|
6913
|
+
case 4:
|
|
6914
|
+
_a.sent();
|
|
6915
|
+
return [4 /*yield*/, Promise.all(swarm.swarmValidationService
|
|
6916
|
+
.getAgentList(swarmName)
|
|
6917
|
+
.flatMap(function (agentName) {
|
|
6918
|
+
return swarm.agentValidationService.getStateList(agentName);
|
|
6919
|
+
})
|
|
6920
|
+
.filter(function (stateName) { return !!stateName; })
|
|
6921
|
+
.map(function (stateName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6922
|
+
return __generator(this, function (_a) {
|
|
6923
|
+
switch (_a.label) {
|
|
6924
|
+
case 0: return [4 /*yield*/, swarm.statePublicService.dispose(requestId, clientId, stateName)];
|
|
6925
|
+
case 1:
|
|
6926
|
+
_a.sent();
|
|
6927
|
+
return [2 /*return*/];
|
|
6928
|
+
}
|
|
6929
|
+
});
|
|
6930
|
+
}); }))];
|
|
6931
|
+
case 5:
|
|
6932
|
+
_a.sent();
|
|
6933
|
+
return [4 /*yield*/, HistoryAdapter.dispose(clientId, null)];
|
|
6934
|
+
case 6:
|
|
6935
|
+
_a.sent();
|
|
6936
|
+
return [2 /*return*/];
|
|
6937
|
+
}
|
|
6938
|
+
});
|
|
6894
6939
|
});
|
|
6895
|
-
}
|
|
6940
|
+
};
|
|
6896
6941
|
|
|
6897
6942
|
var COMPLETE_TTL = 15 * 60 * 1000;
|
|
6898
6943
|
var COMPLETE_GC = 60 * 1000;
|
|
@@ -6903,17 +6948,17 @@ var COMPLETE_GC = 60 * 1000;
|
|
|
6903
6948
|
* @returns {TCompleteRun} The complete run function.
|
|
6904
6949
|
*/
|
|
6905
6950
|
var createComplete = ttl(function (clientId, swarmName) {
|
|
6906
|
-
return queued(function (content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6951
|
+
return queued(function (requestId, content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6907
6952
|
var result;
|
|
6908
6953
|
return __generator(this, function (_a) {
|
|
6909
6954
|
switch (_a.label) {
|
|
6910
6955
|
case 0:
|
|
6911
6956
|
swarm.swarmValidationService.validate(swarmName, "complete");
|
|
6912
6957
|
swarm.sessionValidationService.addSession(clientId, swarmName, "complete");
|
|
6913
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", clientId, swarmName)];
|
|
6958
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", requestId, clientId, swarmName)];
|
|
6914
6959
|
case 1:
|
|
6915
6960
|
result = _a.sent();
|
|
6916
|
-
return [4 /*yield*/, disposeConnection(clientId, swarmName)];
|
|
6961
|
+
return [4 /*yield*/, disposeConnection(clientId, swarmName, requestId)];
|
|
6917
6962
|
case 2:
|
|
6918
6963
|
_a.sent();
|
|
6919
6964
|
return [2 /*return*/, result];
|
|
@@ -6947,20 +6992,22 @@ var createGc = singleshot(function () { return __awaiter(void 0, void 0, void 0,
|
|
|
6947
6992
|
* @returns {Promise<string>} The result of the complete function.
|
|
6948
6993
|
*/
|
|
6949
6994
|
var complete = function (content, clientId, swarmName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6950
|
-
var run;
|
|
6995
|
+
var requestId, run;
|
|
6951
6996
|
return __generator(this, function (_a) {
|
|
6952
6997
|
switch (_a.label) {
|
|
6953
6998
|
case 0:
|
|
6999
|
+
requestId = randomString();
|
|
6954
7000
|
swarm.loggerService.log("function complete", {
|
|
6955
7001
|
content: content,
|
|
6956
7002
|
clientId: clientId,
|
|
6957
7003
|
swarmName: swarmName,
|
|
7004
|
+
requestId: requestId,
|
|
6958
7005
|
});
|
|
6959
7006
|
return [4 /*yield*/, createComplete(clientId, swarmName)];
|
|
6960
7007
|
case 1:
|
|
6961
7008
|
run = _a.sent();
|
|
6962
7009
|
createGc();
|
|
6963
|
-
return [4 /*yield*/, run(content)];
|
|
7010
|
+
return [4 /*yield*/, run(requestId, content)];
|
|
6964
7011
|
case 2: return [2 /*return*/, _a.sent()];
|
|
6965
7012
|
}
|
|
6966
7013
|
});
|
|
@@ -6977,9 +7024,11 @@ var SCHEDULED_DELAY = 1000;
|
|
|
6977
7024
|
* @returns {Function} dispose - A function to dispose of the session.
|
|
6978
7025
|
*/
|
|
6979
7026
|
var session = function (clientId, swarmName) {
|
|
7027
|
+
var requestId = randomString();
|
|
6980
7028
|
swarm.loggerService.log("function session", {
|
|
6981
7029
|
clientId: clientId,
|
|
6982
7030
|
swarmName: swarmName,
|
|
7031
|
+
requestId: requestId,
|
|
6983
7032
|
});
|
|
6984
7033
|
swarm.swarmValidationService.validate(swarmName, "session");
|
|
6985
7034
|
swarm.sessionValidationService.addSession(clientId, swarmName, "session");
|
|
@@ -6995,7 +7044,7 @@ var session = function (clientId, swarmName) {
|
|
|
6995
7044
|
switch (_a.label) {
|
|
6996
7045
|
case 0:
|
|
6997
7046
|
swarm.sessionValidationService.validate(clientId, "session");
|
|
6998
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", clientId, swarmName)];
|
|
7047
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", requestId, clientId, swarmName)];
|
|
6999
7048
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7000
7049
|
}
|
|
7001
7050
|
});
|
|
@@ -7008,7 +7057,7 @@ var session = function (clientId, swarmName) {
|
|
|
7008
7057
|
dispose: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
7009
7058
|
return __generator(this, function (_a) {
|
|
7010
7059
|
switch (_a.label) {
|
|
7011
|
-
case 0: return [4 /*yield*/, disposeConnection(clientId, swarmName)];
|
|
7060
|
+
case 0: return [4 /*yield*/, disposeConnection(clientId, swarmName, requestId)];
|
|
7012
7061
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7013
7062
|
}
|
|
7014
7063
|
});
|
|
@@ -7113,27 +7162,35 @@ session.scheduled = function (clientId, swarmName, _a) {
|
|
|
7113
7162
|
* @param {string} clientId - The ID of the client whose history is to be retrieved.
|
|
7114
7163
|
* @returns {Promise<Array>} A promise that resolves to an array containing the raw history.
|
|
7115
7164
|
*/
|
|
7116
|
-
var getRawHistory = function (
|
|
7117
|
-
var
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7165
|
+
var getRawHistory = function (clientId_1) {
|
|
7166
|
+
var args_1 = [];
|
|
7167
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7168
|
+
args_1[_i - 1] = arguments[_i];
|
|
7169
|
+
}
|
|
7170
|
+
return __awaiter(void 0, __spreadArray([clientId_1], __read(args_1), false), void 0, function (clientId, requestId) {
|
|
7171
|
+
var swarmName, agentName, history;
|
|
7172
|
+
if (requestId === void 0) { requestId = randomString(); }
|
|
7173
|
+
return __generator(this, function (_a) {
|
|
7174
|
+
switch (_a.label) {
|
|
7175
|
+
case 0:
|
|
7176
|
+
swarm.loggerService.log("function getRawHistory", {
|
|
7177
|
+
clientId: clientId,
|
|
7178
|
+
requestId: requestId,
|
|
7179
|
+
});
|
|
7180
|
+
swarm.sessionValidationService.validate(clientId, "getRawHistory");
|
|
7181
|
+
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7182
|
+
swarm.swarmValidationService.validate(swarmName, "getRawHistory");
|
|
7183
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7184
|
+
case 1:
|
|
7185
|
+
agentName = _a.sent();
|
|
7186
|
+
return [4 /*yield*/, swarm.historyPublicService.toArrayForRaw(requestId, clientId, agentName)];
|
|
7187
|
+
case 2:
|
|
7188
|
+
history = _a.sent();
|
|
7189
|
+
return [2 /*return*/, __spreadArray([], __read(history), false)];
|
|
7190
|
+
}
|
|
7191
|
+
});
|
|
7135
7192
|
});
|
|
7136
|
-
}
|
|
7193
|
+
};
|
|
7137
7194
|
|
|
7138
7195
|
/**
|
|
7139
7196
|
* Retrieves the history prepared for a specific agent with resque algorithm tweaks
|
|
@@ -7143,17 +7200,19 @@ var getRawHistory = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
7143
7200
|
* @returns {Promise<Array>} - A promise that resolves to an array containing the agent's history.
|
|
7144
7201
|
*/
|
|
7145
7202
|
var getAgentHistory = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7146
|
-
var prompt, history;
|
|
7203
|
+
var requestId, prompt, history;
|
|
7147
7204
|
return __generator(this, function (_a) {
|
|
7148
7205
|
switch (_a.label) {
|
|
7149
7206
|
case 0:
|
|
7207
|
+
requestId = randomString();
|
|
7150
7208
|
swarm.loggerService.log("function getAgentHistory", {
|
|
7151
7209
|
clientId: clientId,
|
|
7152
7210
|
agentName: agentName,
|
|
7211
|
+
requestId: requestId,
|
|
7153
7212
|
});
|
|
7154
7213
|
swarm.agentValidationService.validate(agentName, "getAgentHistory");
|
|
7155
7214
|
prompt = swarm.agentSchemaService.get(agentName).prompt;
|
|
7156
|
-
return [4 /*yield*/, swarm.historyPublicService.toArrayForAgent(prompt, clientId, agentName)];
|
|
7215
|
+
return [4 /*yield*/, swarm.historyPublicService.toArrayForAgent(prompt, requestId, clientId, agentName)];
|
|
7157
7216
|
case 1:
|
|
7158
7217
|
history = _a.sent();
|
|
7159
7218
|
return [2 /*return*/, __spreadArray([], __read(history), false)];
|
|
@@ -7187,21 +7246,23 @@ var getSessionMode = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
7187
7246
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
7188
7247
|
*/
|
|
7189
7248
|
var commitToolOutput = function (toolId, content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7190
|
-
var swarmName, currentAgentName;
|
|
7249
|
+
var requestId, swarmName, currentAgentName;
|
|
7191
7250
|
return __generator(this, function (_a) {
|
|
7192
7251
|
switch (_a.label) {
|
|
7193
7252
|
case 0:
|
|
7253
|
+
requestId = randomString();
|
|
7194
7254
|
swarm.loggerService.log('function commitToolOutput', {
|
|
7195
7255
|
toolId: toolId,
|
|
7196
7256
|
content: content,
|
|
7197
7257
|
clientId: clientId,
|
|
7198
7258
|
agentName: agentName,
|
|
7259
|
+
requestId: requestId,
|
|
7199
7260
|
});
|
|
7200
7261
|
swarm.agentValidationService.validate(agentName, "commitSystemMessage");
|
|
7201
7262
|
swarm.sessionValidationService.validate(clientId, "commitToolOutput");
|
|
7202
7263
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7203
7264
|
swarm.swarmValidationService.validate(swarmName, "commitToolOutput");
|
|
7204
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7265
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7205
7266
|
case 1:
|
|
7206
7267
|
currentAgentName = _a.sent();
|
|
7207
7268
|
if (currentAgentName !== agentName) {
|
|
@@ -7213,7 +7274,7 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
|
|
|
7213
7274
|
});
|
|
7214
7275
|
return [2 /*return*/];
|
|
7215
7276
|
}
|
|
7216
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, clientId, swarmName)];
|
|
7277
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, requestId, clientId, swarmName)];
|
|
7217
7278
|
case 2:
|
|
7218
7279
|
_a.sent();
|
|
7219
7280
|
return [2 /*return*/];
|
|
@@ -7230,20 +7291,22 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
|
|
|
7230
7291
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7231
7292
|
*/
|
|
7232
7293
|
var commitSystemMessage = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7233
|
-
var swarmName, currentAgentName;
|
|
7294
|
+
var requestId, swarmName, currentAgentName;
|
|
7234
7295
|
return __generator(this, function (_a) {
|
|
7235
7296
|
switch (_a.label) {
|
|
7236
7297
|
case 0:
|
|
7298
|
+
requestId = randomString();
|
|
7237
7299
|
swarm.loggerService.log('function commitSystemMessage', {
|
|
7238
7300
|
content: content,
|
|
7239
7301
|
clientId: clientId,
|
|
7240
7302
|
agentName: agentName,
|
|
7303
|
+
requestId: requestId,
|
|
7241
7304
|
});
|
|
7242
7305
|
swarm.agentValidationService.validate(agentName, "commitSystemMessage");
|
|
7243
7306
|
swarm.sessionValidationService.validate(clientId, "commitSystemMessage");
|
|
7244
7307
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7245
7308
|
swarm.swarmValidationService.validate(swarmName, "commitSystemMessage");
|
|
7246
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7309
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7247
7310
|
case 1:
|
|
7248
7311
|
currentAgentName = _a.sent();
|
|
7249
7312
|
if (currentAgentName !== agentName) {
|
|
@@ -7254,7 +7317,7 @@ var commitSystemMessage = function (content, clientId, agentName) { return __awa
|
|
|
7254
7317
|
});
|
|
7255
7318
|
return [2 /*return*/];
|
|
7256
7319
|
}
|
|
7257
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, clientId, swarmName)];
|
|
7320
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, requestId, clientId, swarmName)];
|
|
7258
7321
|
case 2:
|
|
7259
7322
|
_a.sent();
|
|
7260
7323
|
return [2 /*return*/];
|
|
@@ -7270,19 +7333,21 @@ var commitSystemMessage = function (content, clientId, agentName) { return __awa
|
|
|
7270
7333
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7271
7334
|
*/
|
|
7272
7335
|
var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7273
|
-
var swarmName, currentAgentName;
|
|
7336
|
+
var requestId, swarmName, currentAgentName;
|
|
7274
7337
|
return __generator(this, function (_a) {
|
|
7275
7338
|
switch (_a.label) {
|
|
7276
7339
|
case 0:
|
|
7340
|
+
requestId = randomString();
|
|
7277
7341
|
swarm.loggerService.log('function commitFlush', {
|
|
7278
7342
|
clientId: clientId,
|
|
7279
7343
|
agentName: agentName,
|
|
7344
|
+
requestId: requestId,
|
|
7280
7345
|
});
|
|
7281
7346
|
swarm.agentValidationService.validate(agentName, "commitFlush");
|
|
7282
7347
|
swarm.sessionValidationService.validate(clientId, "commitFlush");
|
|
7283
7348
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7284
7349
|
swarm.swarmValidationService.validate(swarmName, "commitFlush");
|
|
7285
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7350
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7286
7351
|
case 1:
|
|
7287
7352
|
currentAgentName = _a.sent();
|
|
7288
7353
|
if (currentAgentName !== agentName) {
|
|
@@ -7293,7 +7358,7 @@ var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void
|
|
|
7293
7358
|
});
|
|
7294
7359
|
return [2 /*return*/];
|
|
7295
7360
|
}
|
|
7296
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitFlush(clientId, swarmName)];
|
|
7361
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitFlush(requestId, clientId, swarmName)];
|
|
7297
7362
|
case 2:
|
|
7298
7363
|
_a.sent();
|
|
7299
7364
|
return [2 /*return*/];
|
|
@@ -7311,20 +7376,22 @@ var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void
|
|
|
7311
7376
|
* @returns {Promise<void>} - A promise that resolves when the execution is complete.
|
|
7312
7377
|
*/
|
|
7313
7378
|
var execute = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7314
|
-
var swarmName, currentAgentName;
|
|
7379
|
+
var requestId, swarmName, currentAgentName;
|
|
7315
7380
|
return __generator(this, function (_a) {
|
|
7316
7381
|
switch (_a.label) {
|
|
7317
7382
|
case 0:
|
|
7383
|
+
requestId = randomString();
|
|
7318
7384
|
swarm.loggerService.log("function execute", {
|
|
7319
7385
|
content: content,
|
|
7320
7386
|
clientId: clientId,
|
|
7321
7387
|
agentName: agentName,
|
|
7388
|
+
requestId: requestId,
|
|
7322
7389
|
});
|
|
7323
7390
|
swarm.agentValidationService.validate(agentName, "execute");
|
|
7324
7391
|
swarm.sessionValidationService.validate(clientId, "execute");
|
|
7325
7392
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7326
7393
|
swarm.swarmValidationService.validate(swarmName, "execute");
|
|
7327
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7394
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7328
7395
|
case 1:
|
|
7329
7396
|
currentAgentName = _a.sent();
|
|
7330
7397
|
if (currentAgentName !== agentName) {
|
|
@@ -7335,7 +7402,7 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
|
|
|
7335
7402
|
});
|
|
7336
7403
|
return [2 /*return*/];
|
|
7337
7404
|
}
|
|
7338
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", clientId, swarmName)];
|
|
7405
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", requestId, clientId, swarmName)];
|
|
7339
7406
|
case 2: return [2 /*return*/, _a.sent()];
|
|
7340
7407
|
}
|
|
7341
7408
|
});
|
|
@@ -7352,14 +7419,16 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
|
|
|
7352
7419
|
* @returns {Promise<void>} A promise that resolves when the content is emitted.
|
|
7353
7420
|
*/
|
|
7354
7421
|
var emit = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7355
|
-
var swarmName, currentAgentName;
|
|
7422
|
+
var requestId, swarmName, currentAgentName;
|
|
7356
7423
|
return __generator(this, function (_a) {
|
|
7357
7424
|
switch (_a.label) {
|
|
7358
7425
|
case 0:
|
|
7426
|
+
requestId = randomString();
|
|
7359
7427
|
swarm.loggerService.log("function emit", {
|
|
7360
7428
|
content: content,
|
|
7361
7429
|
clientId: clientId,
|
|
7362
7430
|
agentName: agentName,
|
|
7431
|
+
requestId: requestId,
|
|
7363
7432
|
});
|
|
7364
7433
|
if (swarm.sessionValidationService.getSessionMode(clientId) !== "makeConnection") {
|
|
7365
7434
|
throw new Error("agent-swarm-kit emit session is not makeConnection clientId=".concat(clientId));
|
|
@@ -7368,7 +7437,7 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
|
|
|
7368
7437
|
swarm.sessionValidationService.validate(clientId, "emit");
|
|
7369
7438
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7370
7439
|
swarm.swarmValidationService.validate(swarmName, "emit");
|
|
7371
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7440
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7372
7441
|
case 1:
|
|
7373
7442
|
currentAgentName = _a.sent();
|
|
7374
7443
|
if (currentAgentName !== agentName) {
|
|
@@ -7379,7 +7448,7 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
|
|
|
7379
7448
|
});
|
|
7380
7449
|
return [2 /*return*/];
|
|
7381
7450
|
}
|
|
7382
|
-
return [4 /*yield*/, swarm.sessionPublicService.emit(content, clientId, swarmName)];
|
|
7451
|
+
return [4 /*yield*/, swarm.sessionPublicService.emit(content, requestId, clientId, swarmName)];
|
|
7383
7452
|
case 2: return [2 /*return*/, _a.sent()];
|
|
7384
7453
|
}
|
|
7385
7454
|
});
|
|
@@ -7393,19 +7462,21 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
|
|
|
7393
7462
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
7394
7463
|
*/
|
|
7395
7464
|
var commitToolOutputForce = function (toolId, content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7396
|
-
var swarmName;
|
|
7465
|
+
var requestId, swarmName;
|
|
7397
7466
|
return __generator(this, function (_a) {
|
|
7398
7467
|
switch (_a.label) {
|
|
7399
7468
|
case 0:
|
|
7469
|
+
requestId = randomString();
|
|
7400
7470
|
swarm.loggerService.log('function commitToolOutputForce', {
|
|
7401
7471
|
toolId: toolId,
|
|
7402
7472
|
content: content,
|
|
7403
7473
|
clientId: clientId,
|
|
7474
|
+
requestId: requestId,
|
|
7404
7475
|
});
|
|
7405
7476
|
swarm.sessionValidationService.validate(clientId, "commitToolOutputForce");
|
|
7406
7477
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7407
7478
|
swarm.swarmValidationService.validate(swarmName, "commitToolOutputForce");
|
|
7408
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, clientId, swarmName)];
|
|
7479
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, requestId, clientId, swarmName)];
|
|
7409
7480
|
case 1:
|
|
7410
7481
|
_a.sent();
|
|
7411
7482
|
return [2 /*return*/];
|
|
@@ -7421,18 +7492,20 @@ var commitToolOutputForce = function (toolId, content, clientId) { return __awai
|
|
|
7421
7492
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7422
7493
|
*/
|
|
7423
7494
|
var commitSystemMessageForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7424
|
-
var swarmName;
|
|
7495
|
+
var requestId, swarmName;
|
|
7425
7496
|
return __generator(this, function (_a) {
|
|
7426
7497
|
switch (_a.label) {
|
|
7427
7498
|
case 0:
|
|
7499
|
+
requestId = randomString();
|
|
7428
7500
|
swarm.loggerService.log('function commitSystemMessageForce', {
|
|
7429
7501
|
content: content,
|
|
7430
7502
|
clientId: clientId,
|
|
7503
|
+
requestId: requestId,
|
|
7431
7504
|
});
|
|
7432
7505
|
swarm.sessionValidationService.validate(clientId, "commitSystemMessageForce");
|
|
7433
7506
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7434
7507
|
swarm.swarmValidationService.validate(swarmName, "commitSystemMessageForce");
|
|
7435
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, clientId, swarmName)];
|
|
7508
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, requestId, clientId, swarmName)];
|
|
7436
7509
|
case 1:
|
|
7437
7510
|
_a.sent();
|
|
7438
7511
|
return [2 /*return*/];
|
|
@@ -7447,17 +7520,19 @@ var commitSystemMessageForce = function (content, clientId) { return __awaiter(v
|
|
|
7447
7520
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7448
7521
|
*/
|
|
7449
7522
|
var commitFlushForce = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7450
|
-
var swarmName;
|
|
7523
|
+
var requestId, swarmName;
|
|
7451
7524
|
return __generator(this, function (_a) {
|
|
7452
7525
|
switch (_a.label) {
|
|
7453
7526
|
case 0:
|
|
7527
|
+
requestId = randomString();
|
|
7454
7528
|
swarm.loggerService.log('function commitFlushForce', {
|
|
7455
7529
|
clientId: clientId,
|
|
7530
|
+
requestId: requestId,
|
|
7456
7531
|
});
|
|
7457
7532
|
swarm.sessionValidationService.validate(clientId, "commitFlushForce");
|
|
7458
7533
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7459
7534
|
swarm.swarmValidationService.validate(swarmName, "commitFlushForce");
|
|
7460
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitFlush(clientId, swarmName)];
|
|
7535
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitFlush(requestId, clientId, swarmName)];
|
|
7461
7536
|
case 1:
|
|
7462
7537
|
_a.sent();
|
|
7463
7538
|
return [2 /*return*/];
|
|
@@ -7473,18 +7548,20 @@ var commitFlushForce = function (clientId) { return __awaiter(void 0, void 0, vo
|
|
|
7473
7548
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7474
7549
|
*/
|
|
7475
7550
|
var commitUserMessageForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7476
|
-
var swarmName;
|
|
7551
|
+
var requestId, swarmName;
|
|
7477
7552
|
return __generator(this, function (_a) {
|
|
7478
7553
|
switch (_a.label) {
|
|
7479
7554
|
case 0:
|
|
7555
|
+
requestId = randomString();
|
|
7480
7556
|
swarm.loggerService.log('function commitSystemMessage', {
|
|
7481
7557
|
content: content,
|
|
7482
7558
|
clientId: clientId,
|
|
7559
|
+
requestId: requestId,
|
|
7483
7560
|
});
|
|
7484
7561
|
swarm.sessionValidationService.validate(clientId, "commitUserMessageForce");
|
|
7485
7562
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7486
7563
|
swarm.swarmValidationService.validate(swarmName, "commitUserMessageForce");
|
|
7487
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, clientId, swarmName)];
|
|
7564
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, requestId, clientId, swarmName)];
|
|
7488
7565
|
case 1:
|
|
7489
7566
|
_a.sent();
|
|
7490
7567
|
return [2 /*return*/];
|
|
@@ -7503,13 +7580,15 @@ var commitUserMessageForce = function (content, clientId) { return __awaiter(voi
|
|
|
7503
7580
|
* @returns {Promise<void>} A promise that resolves when the content is emitted.
|
|
7504
7581
|
*/
|
|
7505
7582
|
var emitForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7506
|
-
var swarmName;
|
|
7583
|
+
var requestId, swarmName;
|
|
7507
7584
|
return __generator(this, function (_a) {
|
|
7508
7585
|
switch (_a.label) {
|
|
7509
7586
|
case 0:
|
|
7587
|
+
requestId = randomString();
|
|
7510
7588
|
swarm.loggerService.log("function emitForce", {
|
|
7511
7589
|
content: content,
|
|
7512
7590
|
clientId: clientId,
|
|
7591
|
+
requestId: requestId,
|
|
7513
7592
|
});
|
|
7514
7593
|
if (swarm.sessionValidationService.getSessionMode(clientId) !== "makeConnection") {
|
|
7515
7594
|
throw new Error("agent-swarm-kit emitForce session is not makeConnection clientId=".concat(clientId));
|
|
@@ -7517,7 +7596,7 @@ var emitForce = function (content, clientId) { return __awaiter(void 0, void 0,
|
|
|
7517
7596
|
swarm.sessionValidationService.validate(clientId, "emitForce");
|
|
7518
7597
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7519
7598
|
swarm.swarmValidationService.validate(swarmName, "emitForce");
|
|
7520
|
-
return [4 /*yield*/, swarm.sessionPublicService.emit(content, clientId, swarmName)];
|
|
7599
|
+
return [4 /*yield*/, swarm.sessionPublicService.emit(content, requestId, clientId, swarmName)];
|
|
7521
7600
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7522
7601
|
}
|
|
7523
7602
|
});
|
|
@@ -7534,32 +7613,34 @@ var emitForce = function (content, clientId) { return __awaiter(void 0, void 0,
|
|
|
7534
7613
|
* @returns {Promise<void>} - A promise that resolves when the execution is complete.
|
|
7535
7614
|
*/
|
|
7536
7615
|
var executeForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7537
|
-
var swarmName;
|
|
7616
|
+
var requestId, swarmName;
|
|
7538
7617
|
return __generator(this, function (_a) {
|
|
7539
7618
|
switch (_a.label) {
|
|
7540
7619
|
case 0:
|
|
7620
|
+
requestId = randomString();
|
|
7541
7621
|
swarm.loggerService.log("function executeForce", {
|
|
7542
7622
|
content: content,
|
|
7543
7623
|
clientId: clientId,
|
|
7624
|
+
requestId: requestId,
|
|
7544
7625
|
});
|
|
7545
7626
|
swarm.sessionValidationService.validate(clientId, "executeForce");
|
|
7546
7627
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7547
7628
|
swarm.swarmValidationService.validate(swarmName, "executeForce");
|
|
7548
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", clientId, swarmName)];
|
|
7629
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", requestId, clientId, swarmName)];
|
|
7549
7630
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7550
7631
|
}
|
|
7551
7632
|
});
|
|
7552
7633
|
}); };
|
|
7553
7634
|
|
|
7554
|
-
var DISALLOWED_EVENT_SOURCE_LIST$
|
|
7555
|
-
"agent",
|
|
7556
|
-
"history",
|
|
7557
|
-
"session",
|
|
7558
|
-
"state",
|
|
7559
|
-
"storage",
|
|
7560
|
-
"swarm",
|
|
7635
|
+
var DISALLOWED_EVENT_SOURCE_LIST$2 = new Set([
|
|
7636
|
+
"agent-bus",
|
|
7637
|
+
"history-bus",
|
|
7638
|
+
"session-bus",
|
|
7639
|
+
"state-bus",
|
|
7640
|
+
"storage-bus",
|
|
7641
|
+
"swarm-bus",
|
|
7561
7642
|
]);
|
|
7562
|
-
var validateClientId$
|
|
7643
|
+
var validateClientId$d = function (clientId) {
|
|
7563
7644
|
if (clientId === "*") {
|
|
7564
7645
|
return;
|
|
7565
7646
|
}
|
|
@@ -7578,16 +7659,56 @@ var listenEvent = function (clientId, topicName, fn) {
|
|
|
7578
7659
|
swarm.loggerService.log("function listenEvent", {
|
|
7579
7660
|
clientId: clientId,
|
|
7580
7661
|
});
|
|
7581
|
-
if (DISALLOWED_EVENT_SOURCE_LIST$
|
|
7662
|
+
if (DISALLOWED_EVENT_SOURCE_LIST$2.has(topicName)) {
|
|
7582
7663
|
throw new Error("agent-swarm listenEvent topic is reserved topicName=".concat(topicName));
|
|
7583
7664
|
}
|
|
7584
|
-
validateClientId$
|
|
7665
|
+
validateClientId$d(clientId);
|
|
7585
7666
|
return swarm.busService.subscribe(clientId, topicName, function (_a) {
|
|
7586
7667
|
var payload = _a.payload;
|
|
7587
7668
|
return fn(payload);
|
|
7588
7669
|
});
|
|
7589
7670
|
};
|
|
7590
7671
|
|
|
7672
|
+
var DISALLOWED_EVENT_SOURCE_LIST$1 = new Set([
|
|
7673
|
+
"agent-bus",
|
|
7674
|
+
"history-bus",
|
|
7675
|
+
"session-bus",
|
|
7676
|
+
"state-bus",
|
|
7677
|
+
"storage-bus",
|
|
7678
|
+
"swarm-bus",
|
|
7679
|
+
]);
|
|
7680
|
+
var validateClientId$c = function (clientId) {
|
|
7681
|
+
if (clientId === "*") {
|
|
7682
|
+
return;
|
|
7683
|
+
}
|
|
7684
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
7685
|
+
throw new Error("agent-swarm listenEventOnce session not found for clientId=".concat(clientId));
|
|
7686
|
+
}
|
|
7687
|
+
};
|
|
7688
|
+
/**
|
|
7689
|
+
* Listens for an event on the swarm bus service and executes a callback function when the event is received.
|
|
7690
|
+
*
|
|
7691
|
+
* @template T - The type of the data payload.
|
|
7692
|
+
* @param {string} clientId - The ID of the client to listen for events from.
|
|
7693
|
+
* @param {(data: T) => void} fn - The callback function to execute when the event is received. The data payload is passed as an argument to this function.
|
|
7694
|
+
*/
|
|
7695
|
+
var listenEventOnce = function (clientId, topicName, filterFn, fn) {
|
|
7696
|
+
swarm.loggerService.log("function listenEventOnce", {
|
|
7697
|
+
clientId: clientId,
|
|
7698
|
+
});
|
|
7699
|
+
if (DISALLOWED_EVENT_SOURCE_LIST$1.has(topicName)) {
|
|
7700
|
+
throw new Error("agent-swarm listenEventOnce topic is reserved topicName=".concat(topicName));
|
|
7701
|
+
}
|
|
7702
|
+
validateClientId$c(clientId);
|
|
7703
|
+
return swarm.busService.once(clientId, topicName, function (_a) {
|
|
7704
|
+
var payload = _a.payload;
|
|
7705
|
+
return filterFn(payload);
|
|
7706
|
+
}, function (_a) {
|
|
7707
|
+
var payload = _a.payload;
|
|
7708
|
+
return fn(payload);
|
|
7709
|
+
});
|
|
7710
|
+
};
|
|
7711
|
+
|
|
7591
7712
|
/**
|
|
7592
7713
|
* Retrieves the last message sent by the user from the client's message history.
|
|
7593
7714
|
*
|
|
@@ -7595,14 +7716,16 @@ var listenEvent = function (clientId, topicName, fn) {
|
|
|
7595
7716
|
* @returns {Promise<string | null>} - The content of the last user message, or null if no user message is found.
|
|
7596
7717
|
*/
|
|
7597
7718
|
var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7598
|
-
var history, last;
|
|
7719
|
+
var requestId, history, last;
|
|
7599
7720
|
return __generator(this, function (_a) {
|
|
7600
7721
|
switch (_a.label) {
|
|
7601
7722
|
case 0:
|
|
7723
|
+
requestId = randomString();
|
|
7602
7724
|
swarm.loggerService.log("function getLastUserMessage", {
|
|
7603
7725
|
clientId: clientId,
|
|
7726
|
+
requestId: requestId,
|
|
7604
7727
|
});
|
|
7605
|
-
return [4 /*yield*/, getRawHistory(clientId)];
|
|
7728
|
+
return [4 /*yield*/, getRawHistory(clientId, requestId)];
|
|
7606
7729
|
case 1:
|
|
7607
7730
|
history = _a.sent();
|
|
7608
7731
|
last = history.findLast(function (_a) {
|
|
@@ -7621,14 +7744,16 @@ var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0,
|
|
|
7621
7744
|
* @returns {Promise<Array>} A promise that resolves to an array of history objects filtered by user role.
|
|
7622
7745
|
*/
|
|
7623
7746
|
var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7624
|
-
var history;
|
|
7747
|
+
var requestId, history;
|
|
7625
7748
|
return __generator(this, function (_a) {
|
|
7626
7749
|
switch (_a.label) {
|
|
7627
7750
|
case 0:
|
|
7751
|
+
requestId = randomString();
|
|
7628
7752
|
swarm.loggerService.log("function getUserHistory", {
|
|
7629
7753
|
clientId: clientId,
|
|
7754
|
+
requestId: requestId,
|
|
7630
7755
|
});
|
|
7631
|
-
return [4 /*yield*/, getRawHistory(clientId)];
|
|
7756
|
+
return [4 /*yield*/, getRawHistory(clientId, requestId)];
|
|
7632
7757
|
case 1:
|
|
7633
7758
|
history = _a.sent();
|
|
7634
7759
|
return [2 /*return*/, history.filter(function (_a) {
|
|
@@ -7646,14 +7771,16 @@ var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
7646
7771
|
* @returns {Promise<Array>} - A promise that resolves to an array of history objects where the role is "assistant".
|
|
7647
7772
|
*/
|
|
7648
7773
|
var getAssistantHistory = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7649
|
-
var history;
|
|
7774
|
+
var requestId, history;
|
|
7650
7775
|
return __generator(this, function (_a) {
|
|
7651
7776
|
switch (_a.label) {
|
|
7652
7777
|
case 0:
|
|
7778
|
+
requestId = randomString();
|
|
7653
7779
|
swarm.loggerService.log("function getAssistantHistory", {
|
|
7654
7780
|
clientId: clientId,
|
|
7781
|
+
requestId: requestId,
|
|
7655
7782
|
});
|
|
7656
|
-
return [4 /*yield*/, getRawHistory(clientId)];
|
|
7783
|
+
return [4 /*yield*/, getRawHistory(clientId, requestId)];
|
|
7657
7784
|
case 1:
|
|
7658
7785
|
history = _a.sent();
|
|
7659
7786
|
return [2 /*return*/, history.filter(function (_a) {
|
|
@@ -7671,14 +7798,16 @@ var getAssistantHistory = function (clientId) { return __awaiter(void 0, void 0,
|
|
|
7671
7798
|
* @returns {Promise<string | null>} - The content of the last assistant message, or null if no user message is found.
|
|
7672
7799
|
*/
|
|
7673
7800
|
var getLastAssistantMessage = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7674
|
-
var history, last;
|
|
7801
|
+
var requestId, history, last;
|
|
7675
7802
|
return __generator(this, function (_a) {
|
|
7676
7803
|
switch (_a.label) {
|
|
7677
7804
|
case 0:
|
|
7805
|
+
requestId = randomString();
|
|
7678
7806
|
swarm.loggerService.log("function getLastAssistantMessage", {
|
|
7679
7807
|
clientId: clientId,
|
|
7808
|
+
requestId: requestId,
|
|
7680
7809
|
});
|
|
7681
|
-
return [4 /*yield*/, getRawHistory(clientId)];
|
|
7810
|
+
return [4 /*yield*/, getRawHistory(clientId, requestId)];
|
|
7682
7811
|
case 1:
|
|
7683
7812
|
history = _a.sent();
|
|
7684
7813
|
last = history.findLast(function (_a) {
|
|
@@ -7697,14 +7826,16 @@ var getLastAssistantMessage = function (clientId) { return __awaiter(void 0, voi
|
|
|
7697
7826
|
* @returns {Promise<string | null>} - The content of the last system message, or null if no user message is found.
|
|
7698
7827
|
*/
|
|
7699
7828
|
var getLastSystemMessage = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7700
|
-
var history, last;
|
|
7829
|
+
var requestId, history, last;
|
|
7701
7830
|
return __generator(this, function (_a) {
|
|
7702
7831
|
switch (_a.label) {
|
|
7703
7832
|
case 0:
|
|
7833
|
+
requestId = randomString();
|
|
7704
7834
|
swarm.loggerService.log("function getLastSystemMessage", {
|
|
7705
7835
|
clientId: clientId,
|
|
7836
|
+
requestId: requestId,
|
|
7706
7837
|
});
|
|
7707
|
-
return [4 /*yield*/, getRawHistory(clientId)];
|
|
7838
|
+
return [4 /*yield*/, getRawHistory(clientId, requestId)];
|
|
7708
7839
|
case 1:
|
|
7709
7840
|
history = _a.sent();
|
|
7710
7841
|
last = history.findLast(function (_a) {
|
|
@@ -7771,12 +7902,12 @@ var makeAutoDispose = function (clientId, swarmName, _a) {
|
|
|
7771
7902
|
};
|
|
7772
7903
|
|
|
7773
7904
|
var DISALLOWED_EVENT_SOURCE_LIST = new Set([
|
|
7774
|
-
"agent",
|
|
7775
|
-
"history",
|
|
7776
|
-
"session",
|
|
7777
|
-
"state",
|
|
7778
|
-
"storage",
|
|
7779
|
-
"swarm",
|
|
7905
|
+
"agent-bus",
|
|
7906
|
+
"history-bus",
|
|
7907
|
+
"session-bus",
|
|
7908
|
+
"state-bus",
|
|
7909
|
+
"storage-bus",
|
|
7910
|
+
"swarm-bus",
|
|
7780
7911
|
]);
|
|
7781
7912
|
/**
|
|
7782
7913
|
* Emits an event to the swarm bus service.
|
|
@@ -7808,19 +7939,21 @@ var event = function (clientId, topicName, payload) {
|
|
|
7808
7939
|
* @returns {Promise<void>} - A promise that resolves when the output is canceled
|
|
7809
7940
|
*/
|
|
7810
7941
|
var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7811
|
-
var swarmName, currentAgentName;
|
|
7942
|
+
var requestId, swarmName, currentAgentName;
|
|
7812
7943
|
return __generator(this, function (_a) {
|
|
7813
7944
|
switch (_a.label) {
|
|
7814
7945
|
case 0:
|
|
7946
|
+
requestId = randomString();
|
|
7815
7947
|
swarm.loggerService.log('function cancelOutput', {
|
|
7816
7948
|
clientId: clientId,
|
|
7817
7949
|
agentName: agentName,
|
|
7950
|
+
requestId: requestId,
|
|
7818
7951
|
});
|
|
7819
7952
|
swarm.agentValidationService.validate(agentName, "cancelOutput");
|
|
7820
7953
|
swarm.sessionValidationService.validate(clientId, "cancelOutput");
|
|
7821
7954
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7822
7955
|
swarm.swarmValidationService.validate(swarmName, "cancelOutput");
|
|
7823
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7956
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7824
7957
|
case 1:
|
|
7825
7958
|
currentAgentName = _a.sent();
|
|
7826
7959
|
if (currentAgentName !== agentName) {
|
|
@@ -7831,7 +7964,7 @@ var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, voi
|
|
|
7831
7964
|
});
|
|
7832
7965
|
return [2 /*return*/];
|
|
7833
7966
|
}
|
|
7834
|
-
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(clientId, swarmName)];
|
|
7967
|
+
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(requestId, clientId, swarmName)];
|
|
7835
7968
|
case 2:
|
|
7836
7969
|
_a.sent();
|
|
7837
7970
|
return [2 /*return*/];
|
|
@@ -7847,17 +7980,19 @@ var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, voi
|
|
|
7847
7980
|
* @returns {Promise<void>} - A promise that resolves when the output is canceled
|
|
7848
7981
|
*/
|
|
7849
7982
|
var cancelOutputForce = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7850
|
-
var swarmName;
|
|
7983
|
+
var requestId, swarmName;
|
|
7851
7984
|
return __generator(this, function (_a) {
|
|
7852
7985
|
switch (_a.label) {
|
|
7853
7986
|
case 0:
|
|
7987
|
+
requestId = randomString();
|
|
7854
7988
|
swarm.loggerService.log('function cancelOutputForce', {
|
|
7855
7989
|
clientId: clientId,
|
|
7990
|
+
requestId: requestId
|
|
7856
7991
|
});
|
|
7857
7992
|
swarm.sessionValidationService.validate(clientId, "cancelOutputForce");
|
|
7858
7993
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7859
7994
|
swarm.swarmValidationService.validate(swarmName, "cancelOutputForce");
|
|
7860
|
-
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(clientId, swarmName)];
|
|
7995
|
+
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(requestId, clientId, swarmName)];
|
|
7861
7996
|
case 1:
|
|
7862
7997
|
_a.sent();
|
|
7863
7998
|
return [2 /*return*/];
|
|
@@ -7865,7 +8000,7 @@ var cancelOutputForce = function (clientId) { return __awaiter(void 0, void 0, v
|
|
|
7865
8000
|
});
|
|
7866
8001
|
}); };
|
|
7867
8002
|
|
|
7868
|
-
var validateClientId$
|
|
8003
|
+
var validateClientId$b = function (clientId) {
|
|
7869
8004
|
if (clientId === "*") {
|
|
7870
8005
|
return;
|
|
7871
8006
|
}
|
|
@@ -7883,11 +8018,11 @@ var listenAgentEvent = function (clientId, fn) {
|
|
|
7883
8018
|
swarm.loggerService.log("middleware listenAgentEvent", {
|
|
7884
8019
|
clientId: clientId,
|
|
7885
8020
|
});
|
|
7886
|
-
validateClientId$
|
|
7887
|
-
swarm.busService.subscribe(clientId, "agent", fn);
|
|
8021
|
+
validateClientId$b(clientId);
|
|
8022
|
+
return swarm.busService.subscribe(clientId, "agent-bus", fn);
|
|
7888
8023
|
};
|
|
7889
8024
|
|
|
7890
|
-
var validateClientId$
|
|
8025
|
+
var validateClientId$a = function (clientId) {
|
|
7891
8026
|
if (clientId === "*") {
|
|
7892
8027
|
return;
|
|
7893
8028
|
}
|
|
@@ -7905,11 +8040,11 @@ var listenHistoryEvent = function (clientId, fn) {
|
|
|
7905
8040
|
swarm.loggerService.log("middleware listenHistoryEvent", {
|
|
7906
8041
|
clientId: clientId,
|
|
7907
8042
|
});
|
|
7908
|
-
validateClientId$
|
|
7909
|
-
swarm.busService.subscribe(clientId, "history", fn);
|
|
8043
|
+
validateClientId$a(clientId);
|
|
8044
|
+
return swarm.busService.subscribe(clientId, "history-bus", fn);
|
|
7910
8045
|
};
|
|
7911
8046
|
|
|
7912
|
-
var validateClientId$
|
|
8047
|
+
var validateClientId$9 = function (clientId) {
|
|
7913
8048
|
if (clientId === "*") {
|
|
7914
8049
|
return;
|
|
7915
8050
|
}
|
|
@@ -7927,11 +8062,11 @@ var listenSessionEvent = function (clientId, fn) {
|
|
|
7927
8062
|
swarm.loggerService.log("middleware listenSessionEvent", {
|
|
7928
8063
|
clientId: clientId,
|
|
7929
8064
|
});
|
|
7930
|
-
validateClientId$
|
|
7931
|
-
swarm.busService.subscribe(clientId, "session", fn);
|
|
8065
|
+
validateClientId$9(clientId);
|
|
8066
|
+
return swarm.busService.subscribe(clientId, "session-bus", fn);
|
|
7932
8067
|
};
|
|
7933
8068
|
|
|
7934
|
-
var validateClientId$
|
|
8069
|
+
var validateClientId$8 = function (clientId) {
|
|
7935
8070
|
if (clientId === "*") {
|
|
7936
8071
|
return;
|
|
7937
8072
|
}
|
|
@@ -7949,11 +8084,11 @@ var listenStateEvent = function (clientId, fn) {
|
|
|
7949
8084
|
swarm.loggerService.log("middleware listenStateEvent", {
|
|
7950
8085
|
clientId: clientId,
|
|
7951
8086
|
});
|
|
7952
|
-
validateClientId$
|
|
7953
|
-
swarm.busService.subscribe(clientId, "state", fn);
|
|
8087
|
+
validateClientId$8(clientId);
|
|
8088
|
+
return swarm.busService.subscribe(clientId, "state-bus", fn);
|
|
7954
8089
|
};
|
|
7955
8090
|
|
|
7956
|
-
var validateClientId$
|
|
8091
|
+
var validateClientId$7 = function (clientId) {
|
|
7957
8092
|
if (clientId === "*") {
|
|
7958
8093
|
return;
|
|
7959
8094
|
}
|
|
@@ -7971,11 +8106,11 @@ var listenStorageEvent = function (clientId, fn) {
|
|
|
7971
8106
|
swarm.loggerService.log("middleware listenStorageEvent", {
|
|
7972
8107
|
clientId: clientId,
|
|
7973
8108
|
});
|
|
7974
|
-
validateClientId$
|
|
7975
|
-
swarm.busService.subscribe(clientId, "storage", fn);
|
|
8109
|
+
validateClientId$7(clientId);
|
|
8110
|
+
return swarm.busService.subscribe(clientId, "storage-bus", fn);
|
|
7976
8111
|
};
|
|
7977
8112
|
|
|
7978
|
-
var validateClientId = function (clientId) {
|
|
8113
|
+
var validateClientId$6 = function (clientId) {
|
|
7979
8114
|
if (clientId === "*") {
|
|
7980
8115
|
return;
|
|
7981
8116
|
}
|
|
@@ -7993,8 +8128,140 @@ var listenSwarmEvent = function (clientId, fn) {
|
|
|
7993
8128
|
swarm.loggerService.log("middleware listenSwarmEvent", {
|
|
7994
8129
|
clientId: clientId,
|
|
7995
8130
|
});
|
|
8131
|
+
validateClientId$6(clientId);
|
|
8132
|
+
return swarm.busService.subscribe(clientId, "swarm-bus", fn);
|
|
8133
|
+
};
|
|
8134
|
+
|
|
8135
|
+
var validateClientId$5 = function (clientId) {
|
|
8136
|
+
if (clientId === "*") {
|
|
8137
|
+
return;
|
|
8138
|
+
}
|
|
8139
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8140
|
+
throw new Error("agent-swarm listenAgentEventOnce session not found for clientId=".concat(clientId));
|
|
8141
|
+
}
|
|
8142
|
+
};
|
|
8143
|
+
/**
|
|
8144
|
+
* Hook to subscribe to agent events for a specific client.
|
|
8145
|
+
*
|
|
8146
|
+
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
8147
|
+
* @param {function} fn - The callback function to handle the event.
|
|
8148
|
+
*/
|
|
8149
|
+
var listenAgentEventOnce = function (clientId, filterFn, fn) {
|
|
8150
|
+
swarm.loggerService.log("middleware listenAgentEventOnce", {
|
|
8151
|
+
clientId: clientId,
|
|
8152
|
+
});
|
|
8153
|
+
validateClientId$5(clientId);
|
|
8154
|
+
return swarm.busService.once(clientId, "agent-bus", filterFn, fn);
|
|
8155
|
+
};
|
|
8156
|
+
|
|
8157
|
+
var validateClientId$4 = function (clientId) {
|
|
8158
|
+
if (clientId === "*") {
|
|
8159
|
+
return;
|
|
8160
|
+
}
|
|
8161
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8162
|
+
throw new Error("agent-swarm listenHistoryEventOnce session not found for clientId=".concat(clientId));
|
|
8163
|
+
}
|
|
8164
|
+
};
|
|
8165
|
+
/**
|
|
8166
|
+
* Hook to subscribe to history events for a specific client.
|
|
8167
|
+
*
|
|
8168
|
+
* @param {string} clientId - The ID of the client to subscribe to.
|
|
8169
|
+
* @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
|
|
8170
|
+
*/
|
|
8171
|
+
var listenHistoryEventOnce = function (clientId, filterFn, fn) {
|
|
8172
|
+
swarm.loggerService.log("middleware listenHistoryEventOnce", {
|
|
8173
|
+
clientId: clientId,
|
|
8174
|
+
});
|
|
8175
|
+
validateClientId$4(clientId);
|
|
8176
|
+
return swarm.busService.once(clientId, "history-bus", filterFn, fn);
|
|
8177
|
+
};
|
|
8178
|
+
|
|
8179
|
+
var validateClientId$3 = function (clientId) {
|
|
8180
|
+
if (clientId === "*") {
|
|
8181
|
+
return;
|
|
8182
|
+
}
|
|
8183
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8184
|
+
throw new Error("agent-swarm listenSessionEventOnce session not found for clientId=".concat(clientId));
|
|
8185
|
+
}
|
|
8186
|
+
};
|
|
8187
|
+
/**
|
|
8188
|
+
* Hook to subscribe to session events for a specific client.
|
|
8189
|
+
*
|
|
8190
|
+
* @param {string} clientId - The ID of the client to subscribe to session events for.
|
|
8191
|
+
* @param {function} fn - The callback function to handle the session events.
|
|
8192
|
+
*/
|
|
8193
|
+
var listenSessionEventOnce = function (clientId, filterFn, fn) {
|
|
8194
|
+
swarm.loggerService.log("middleware listenSessionEventOnce", {
|
|
8195
|
+
clientId: clientId,
|
|
8196
|
+
});
|
|
8197
|
+
validateClientId$3(clientId);
|
|
8198
|
+
return swarm.busService.once(clientId, "session-bus", filterFn, fn);
|
|
8199
|
+
};
|
|
8200
|
+
|
|
8201
|
+
var validateClientId$2 = function (clientId) {
|
|
8202
|
+
if (clientId === "*") {
|
|
8203
|
+
return;
|
|
8204
|
+
}
|
|
8205
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8206
|
+
throw new Error("agent-swarm listenStateEventOnce session not found for clientId=".concat(clientId));
|
|
8207
|
+
}
|
|
8208
|
+
};
|
|
8209
|
+
/**
|
|
8210
|
+
* Hook to subscribe to state events for a specific client.
|
|
8211
|
+
*
|
|
8212
|
+
* @param {string} clientId - The ID of the client to subscribe to.
|
|
8213
|
+
* @param {function} fn - The callback function to handle the event.
|
|
8214
|
+
*/
|
|
8215
|
+
var listenStateEventOnce = function (clientId, filterFn, fn) {
|
|
8216
|
+
swarm.loggerService.log("middleware listenStateEventOnce", {
|
|
8217
|
+
clientId: clientId,
|
|
8218
|
+
});
|
|
8219
|
+
validateClientId$2(clientId);
|
|
8220
|
+
return swarm.busService.once(clientId, "state-bus", filterFn, fn);
|
|
8221
|
+
};
|
|
8222
|
+
|
|
8223
|
+
var validateClientId$1 = function (clientId) {
|
|
8224
|
+
if (clientId === "*") {
|
|
8225
|
+
return;
|
|
8226
|
+
}
|
|
8227
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8228
|
+
throw new Error("agent-swarm listenStorageEventOnce session not found for clientId=".concat(clientId));
|
|
8229
|
+
}
|
|
8230
|
+
};
|
|
8231
|
+
/**
|
|
8232
|
+
* Hook to subscribe to storage events for a specific client.
|
|
8233
|
+
*
|
|
8234
|
+
* @param {string} clientId - The ID of the client to subscribe to storage events for.
|
|
8235
|
+
* @param {function} fn - The callback function to handle the storage event.
|
|
8236
|
+
*/
|
|
8237
|
+
var listenStorageEventOnce = function (clientId, filterFn, fn) {
|
|
8238
|
+
swarm.loggerService.log("middleware listenStorageEventOnce", {
|
|
8239
|
+
clientId: clientId,
|
|
8240
|
+
});
|
|
8241
|
+
validateClientId$1(clientId);
|
|
8242
|
+
return swarm.busService.once(clientId, "storage-bus", filterFn, fn);
|
|
8243
|
+
};
|
|
8244
|
+
|
|
8245
|
+
var validateClientId = function (clientId) {
|
|
8246
|
+
if (clientId === "*") {
|
|
8247
|
+
return;
|
|
8248
|
+
}
|
|
8249
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8250
|
+
throw new Error("agent-swarm listenSwarmEventOnce session not found for clientId=".concat(clientId));
|
|
8251
|
+
}
|
|
8252
|
+
};
|
|
8253
|
+
/**
|
|
8254
|
+
* Hook to subscribe to swarm events for a specific client.
|
|
8255
|
+
*
|
|
8256
|
+
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
8257
|
+
* @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
|
|
8258
|
+
*/
|
|
8259
|
+
var listenSwarmEventOnce = function (clientId, filterFn, fn) {
|
|
8260
|
+
swarm.loggerService.log("middleware listenSwarmEventOnce", {
|
|
8261
|
+
clientId: clientId,
|
|
8262
|
+
});
|
|
7996
8263
|
validateClientId(clientId);
|
|
7997
|
-
swarm.busService.
|
|
8264
|
+
return swarm.busService.once(clientId, "swarm-bus", filterFn, fn);
|
|
7998
8265
|
};
|
|
7999
8266
|
|
|
8000
8267
|
var StorageUtils = /** @class */ (function () {
|
|
@@ -8011,21 +8278,24 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8011
8278
|
* @template T
|
|
8012
8279
|
*/
|
|
8013
8280
|
this.take = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8281
|
+
var requestId;
|
|
8014
8282
|
return __generator(this, function (_a) {
|
|
8015
8283
|
switch (_a.label) {
|
|
8016
8284
|
case 0:
|
|
8285
|
+
requestId = randomString();
|
|
8017
8286
|
swarm.loggerService.log("StorageUtils take", {
|
|
8018
8287
|
search: payload.search,
|
|
8019
8288
|
total: payload.total,
|
|
8020
8289
|
clientId: payload.clientId,
|
|
8021
8290
|
storageName: payload.storageName,
|
|
8022
8291
|
score: payload.score,
|
|
8292
|
+
requestId: requestId,
|
|
8023
8293
|
});
|
|
8024
8294
|
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
8025
8295
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8026
8296
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (take)"));
|
|
8027
8297
|
}
|
|
8028
|
-
return [4 /*yield*/, swarm.storagePublicService.take(payload.search, payload.total, payload.clientId, payload.storageName, payload.score)];
|
|
8298
|
+
return [4 /*yield*/, swarm.storagePublicService.take(payload.search, payload.total, requestId, payload.clientId, payload.storageName, payload.score)];
|
|
8029
8299
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
8030
8300
|
}
|
|
8031
8301
|
});
|
|
@@ -8040,19 +8310,22 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8040
8310
|
* @template T
|
|
8041
8311
|
*/
|
|
8042
8312
|
this.upsert = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8313
|
+
var requestId;
|
|
8043
8314
|
return __generator(this, function (_a) {
|
|
8044
8315
|
switch (_a.label) {
|
|
8045
8316
|
case 0:
|
|
8317
|
+
requestId = randomString();
|
|
8046
8318
|
swarm.loggerService.log("StorageUtils upsert", {
|
|
8047
8319
|
item: payload.item,
|
|
8048
8320
|
clientId: payload.clientId,
|
|
8049
8321
|
storageName: payload.storageName,
|
|
8322
|
+
requestId: requestId,
|
|
8050
8323
|
});
|
|
8051
8324
|
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
8052
8325
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8053
8326
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (upsert)"));
|
|
8054
8327
|
}
|
|
8055
|
-
return [4 /*yield*/, swarm.storagePublicService.upsert(payload.item, payload.clientId, payload.storageName)];
|
|
8328
|
+
return [4 /*yield*/, swarm.storagePublicService.upsert(payload.item, requestId, payload.clientId, payload.storageName)];
|
|
8056
8329
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8057
8330
|
}
|
|
8058
8331
|
});
|
|
@@ -8066,19 +8339,22 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8066
8339
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
8067
8340
|
*/
|
|
8068
8341
|
this.remove = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8342
|
+
var requestId;
|
|
8069
8343
|
return __generator(this, function (_a) {
|
|
8070
8344
|
switch (_a.label) {
|
|
8071
8345
|
case 0:
|
|
8346
|
+
requestId = randomString();
|
|
8072
8347
|
swarm.loggerService.log("StorageUtils remove", {
|
|
8073
8348
|
itemId: payload.itemId,
|
|
8074
8349
|
clientId: payload.clientId,
|
|
8075
8350
|
storageName: payload.storageName,
|
|
8351
|
+
requestId: requestId,
|
|
8076
8352
|
});
|
|
8077
8353
|
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
8078
8354
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8079
8355
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (remove)"));
|
|
8080
8356
|
}
|
|
8081
|
-
return [4 /*yield*/, swarm.storagePublicService.remove(payload.itemId, payload.clientId, payload.storageName)];
|
|
8357
|
+
return [4 /*yield*/, swarm.storagePublicService.remove(payload.itemId, requestId, payload.clientId, payload.storageName)];
|
|
8082
8358
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8083
8359
|
}
|
|
8084
8360
|
});
|
|
@@ -8093,19 +8369,22 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8093
8369
|
* @template T
|
|
8094
8370
|
*/
|
|
8095
8371
|
this.get = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8372
|
+
var requestId;
|
|
8096
8373
|
return __generator(this, function (_a) {
|
|
8097
8374
|
switch (_a.label) {
|
|
8098
8375
|
case 0:
|
|
8376
|
+
requestId = randomString();
|
|
8099
8377
|
swarm.loggerService.log("StorageUtils get", {
|
|
8100
8378
|
itemId: payload.itemId,
|
|
8101
8379
|
clientId: payload.clientId,
|
|
8102
8380
|
storageName: payload.storageName,
|
|
8381
|
+
requestId: requestId,
|
|
8103
8382
|
});
|
|
8104
8383
|
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
8105
8384
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8106
8385
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (get)"));
|
|
8107
8386
|
}
|
|
8108
|
-
return [4 /*yield*/, swarm.storagePublicService.get(payload.itemId, payload.clientId, payload.storageName)];
|
|
8387
|
+
return [4 /*yield*/, swarm.storagePublicService.get(payload.itemId, requestId, payload.clientId, payload.storageName)];
|
|
8109
8388
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
8110
8389
|
}
|
|
8111
8390
|
});
|
|
@@ -8120,18 +8399,21 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8120
8399
|
* @template T
|
|
8121
8400
|
*/
|
|
8122
8401
|
this.list = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8402
|
+
var requestId;
|
|
8123
8403
|
return __generator(this, function (_a) {
|
|
8124
8404
|
switch (_a.label) {
|
|
8125
8405
|
case 0:
|
|
8406
|
+
requestId = randomString();
|
|
8126
8407
|
swarm.loggerService.log("StorageUtils list", {
|
|
8127
8408
|
clientId: payload.clientId,
|
|
8128
8409
|
storageName: payload.storageName,
|
|
8410
|
+
requestId: requestId,
|
|
8129
8411
|
});
|
|
8130
8412
|
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
8131
8413
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8132
8414
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (list)"));
|
|
8133
8415
|
}
|
|
8134
|
-
return [4 /*yield*/, swarm.storagePublicService.list(payload.clientId, payload.storageName, payload.filter)];
|
|
8416
|
+
return [4 /*yield*/, swarm.storagePublicService.list(requestId, payload.clientId, payload.storageName, payload.filter)];
|
|
8135
8417
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
8136
8418
|
}
|
|
8137
8419
|
});
|
|
@@ -8144,18 +8426,21 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8144
8426
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
8145
8427
|
*/
|
|
8146
8428
|
this.clear = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8429
|
+
var requestId;
|
|
8147
8430
|
return __generator(this, function (_a) {
|
|
8148
8431
|
switch (_a.label) {
|
|
8149
8432
|
case 0:
|
|
8433
|
+
requestId = randomString();
|
|
8150
8434
|
swarm.loggerService.log("StorageUtils clear", {
|
|
8151
8435
|
clientId: payload.clientId,
|
|
8152
8436
|
storageName: payload.storageName,
|
|
8437
|
+
requestId: requestId,
|
|
8153
8438
|
});
|
|
8154
8439
|
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
8155
8440
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8156
8441
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (clear)"));
|
|
8157
8442
|
}
|
|
8158
|
-
return [4 /*yield*/, swarm.storagePublicService.clear(payload.clientId, payload.storageName)];
|
|
8443
|
+
return [4 /*yield*/, swarm.storagePublicService.clear(requestId, payload.clientId, payload.storageName)];
|
|
8159
8444
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8160
8445
|
}
|
|
8161
8446
|
});
|
|
@@ -8183,17 +8468,20 @@ var StateUtils = /** @class */ (function () {
|
|
|
8183
8468
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
8184
8469
|
*/
|
|
8185
8470
|
this.getState = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8471
|
+
var requestId;
|
|
8186
8472
|
return __generator(this, function (_a) {
|
|
8187
8473
|
switch (_a.label) {
|
|
8188
8474
|
case 0:
|
|
8475
|
+
requestId = randomString();
|
|
8189
8476
|
swarm.loggerService.log("StateUtils getState", {
|
|
8190
8477
|
clientId: payload.clientId,
|
|
8191
8478
|
stateName: payload.stateName,
|
|
8479
|
+
requestId: requestId,
|
|
8192
8480
|
});
|
|
8193
8481
|
if (!swarm.agentValidationService.hasState(payload.agentName, payload.stateName)) {
|
|
8194
8482
|
throw new Error("agent-swarm StateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (getState)"));
|
|
8195
8483
|
}
|
|
8196
|
-
return [4 /*yield*/, swarm.statePublicService.getState(payload.clientId, payload.stateName)];
|
|
8484
|
+
return [4 /*yield*/, swarm.statePublicService.getState(requestId, payload.clientId, payload.stateName)];
|
|
8197
8485
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8198
8486
|
}
|
|
8199
8487
|
});
|
|
@@ -8210,23 +8498,26 @@ var StateUtils = /** @class */ (function () {
|
|
|
8210
8498
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
8211
8499
|
*/
|
|
8212
8500
|
this.setState = function (dispatchFn, payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8501
|
+
var requestId;
|
|
8213
8502
|
var _this = this;
|
|
8214
8503
|
return __generator(this, function (_a) {
|
|
8215
8504
|
switch (_a.label) {
|
|
8216
8505
|
case 0:
|
|
8506
|
+
requestId = randomString();
|
|
8217
8507
|
swarm.loggerService.log("StateUtils setState", {
|
|
8218
8508
|
clientId: payload.clientId,
|
|
8219
8509
|
stateName: payload.stateName,
|
|
8510
|
+
requestId: requestId,
|
|
8220
8511
|
});
|
|
8221
8512
|
if (!swarm.agentValidationService.hasState(payload.agentName, payload.stateName)) {
|
|
8222
8513
|
throw new Error("agent-swarm StateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (setState)"));
|
|
8223
8514
|
}
|
|
8224
8515
|
if (!(typeof dispatchFn === "function")) return [3 /*break*/, 2];
|
|
8225
|
-
return [4 /*yield*/, swarm.statePublicService.setState(dispatchFn, payload.clientId, payload.stateName)];
|
|
8516
|
+
return [4 /*yield*/, swarm.statePublicService.setState(dispatchFn, requestId, payload.clientId, payload.stateName)];
|
|
8226
8517
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8227
8518
|
case 2: return [4 /*yield*/, swarm.statePublicService.setState(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
8228
8519
|
return [2 /*return*/, dispatchFn];
|
|
8229
|
-
}); }); }, payload.clientId, payload.stateName)];
|
|
8520
|
+
}); }); }, requestId, payload.clientId, payload.stateName)];
|
|
8230
8521
|
case 3: return [2 /*return*/, _a.sent()];
|
|
8231
8522
|
}
|
|
8232
8523
|
});
|
|
@@ -8240,4 +8531,23 @@ var StateUtils = /** @class */ (function () {
|
|
|
8240
8531
|
*/
|
|
8241
8532
|
var State = new StateUtils();
|
|
8242
8533
|
|
|
8243
|
-
|
|
8534
|
+
var LoggerUtils = /** @class */ (function () {
|
|
8535
|
+
function LoggerUtils() {
|
|
8536
|
+
/**
|
|
8537
|
+
* Sets the provided logger to the logger service.
|
|
8538
|
+
* @param {ILogger} logger - The logger instance to be used.
|
|
8539
|
+
*/
|
|
8540
|
+
this.useLogger = function (logger) {
|
|
8541
|
+
swarm.loggerService.log("HistoryInstance useLogger");
|
|
8542
|
+
swarm.loggerService.setLogger(logger);
|
|
8543
|
+
};
|
|
8544
|
+
}
|
|
8545
|
+
return LoggerUtils;
|
|
8546
|
+
}());
|
|
8547
|
+
/**
|
|
8548
|
+
* Instance of LoggerUtils to be used for logging.
|
|
8549
|
+
* @type {LoggerUtils}
|
|
8550
|
+
*/
|
|
8551
|
+
var Logger = new LoggerUtils();
|
|
8552
|
+
|
|
8553
|
+
export { ContextService, History, HistoryAdapter, HistoryInstance, Logger, State, Storage, addAgent, addCompletion, addEmbedding, addState, addStorage, addSwarm, addTool, cancelOutput, cancelOutputForce, changeAgent, commitFlush, commitFlushForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitUserMessage, commitUserMessageForce, complete, disposeConnection, emit, emitForce, event, execute, executeForce, getAgentHistory, getAgentName, getAssistantHistory, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getRawHistory, getSessionMode, getUserHistory, listenAgentEvent, listenAgentEventOnce, listenEvent, listenEventOnce, listenHistoryEvent, listenHistoryEventOnce, listenSessionEvent, listenSessionEventOnce, listenStateEvent, listenStateEventOnce, listenStorageEvent, listenStorageEventOnce, listenSwarmEvent, listenSwarmEventOnce, makeAutoDispose, makeConnection, session, setConfig, swarm };
|