agent-swarm-kit 1.0.74 → 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 +680 -362
- package/build/index.mjs +673 -363
- package/package.json +2 -2
- package/types.d.ts +132 -49
package/build/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var diScoped = require('di-scoped');
|
|
4
|
-
var functoolsKit = require('functools-kit');
|
|
5
4
|
var diKit = require('di-kit');
|
|
5
|
+
var functoolsKit = require('functools-kit');
|
|
6
6
|
var lodashEs = require('lodash-es');
|
|
7
7
|
var xml2js = require('xml2js');
|
|
8
8
|
|
|
@@ -167,6 +167,50 @@ var ContextService = diScoped.scoped(/** @class */ (function () {
|
|
|
167
167
|
return class_1;
|
|
168
168
|
}()));
|
|
169
169
|
|
|
170
|
+
var _a;
|
|
171
|
+
var init = (_a = diKit.createActivator("agent-swarm"), _a.init), inject = _a.inject, provide = _a.provide;
|
|
172
|
+
|
|
173
|
+
var baseServices$1 = {
|
|
174
|
+
busService: Symbol('busService'),
|
|
175
|
+
loggerService: Symbol('loggerService'),
|
|
176
|
+
contextService: Symbol('contextService'),
|
|
177
|
+
};
|
|
178
|
+
var connectionServices$1 = {
|
|
179
|
+
agentConnectionService: Symbol('agentConnectionService'),
|
|
180
|
+
historyConnectionService: Symbol('historyConnectionService'),
|
|
181
|
+
swarmConnectionService: Symbol('swarmConnectionService'),
|
|
182
|
+
sessionConnectionService: Symbol('sessionConnectionService'),
|
|
183
|
+
storageConnectionService: Symbol('storageConnectionService'),
|
|
184
|
+
stateConnectionService: Symbol('stateConnectionService'),
|
|
185
|
+
};
|
|
186
|
+
var schemaServices$1 = {
|
|
187
|
+
completionSchemaService: Symbol('completionSchemaService'),
|
|
188
|
+
agentSchemaService: Symbol('agentSchemaService'),
|
|
189
|
+
swarmSchemaService: Symbol('swarmSchemaService'),
|
|
190
|
+
toolSchemaService: Symbol('toolSchemaService'),
|
|
191
|
+
embeddingSchemaService: Symbol('embeddingSchemaService'),
|
|
192
|
+
storageSchemaService: Symbol('storageSchemaService'),
|
|
193
|
+
stateSchemaService: Symbol('stateSchemaService'),
|
|
194
|
+
};
|
|
195
|
+
var publicServices$1 = {
|
|
196
|
+
agentPublicService: Symbol('agentPublicService'),
|
|
197
|
+
historyPublicService: Symbol('historyPublicService'),
|
|
198
|
+
sessionPublicService: Symbol('sessionPublicService'),
|
|
199
|
+
swarmPublicService: Symbol('swarmPublicService'),
|
|
200
|
+
storagePublicService: Symbol('storagePublicService'),
|
|
201
|
+
statePublicService: Symbol('statePublicService'),
|
|
202
|
+
};
|
|
203
|
+
var validationServices$1 = {
|
|
204
|
+
agentValidationService: Symbol('agentValidationService'),
|
|
205
|
+
toolValidationService: Symbol('toolValidationService'),
|
|
206
|
+
sessionValidationService: Symbol('sessionValidationService'),
|
|
207
|
+
swarmValidationService: Symbol('swarmValidationService'),
|
|
208
|
+
completionValidationService: Symbol('completionValidationService'),
|
|
209
|
+
embeddingValidationService: Symbol('embeddingValidationService'),
|
|
210
|
+
storageValidationService: Symbol('storageValidationService'),
|
|
211
|
+
};
|
|
212
|
+
var TYPES = __assign(__assign(__assign(__assign(__assign({}, baseServices$1), schemaServices$1), connectionServices$1), publicServices$1), validationServices$1);
|
|
213
|
+
|
|
170
214
|
/**
|
|
171
215
|
* LoggerService class that implements the ILogger interface.
|
|
172
216
|
* Provides methods to log and debug messages.
|
|
@@ -174,6 +218,7 @@ var ContextService = diScoped.scoped(/** @class */ (function () {
|
|
|
174
218
|
var LoggerService = /** @class */ (function () {
|
|
175
219
|
function LoggerService() {
|
|
176
220
|
var _this = this;
|
|
221
|
+
this.contextService = inject(TYPES.contextService);
|
|
177
222
|
this._logger = {
|
|
178
223
|
/**
|
|
179
224
|
* Logs messages.
|
|
@@ -193,24 +238,32 @@ var LoggerService = /** @class */ (function () {
|
|
|
193
238
|
* @param {...any} args - The messages to log.
|
|
194
239
|
*/
|
|
195
240
|
this.log = function () {
|
|
196
|
-
var _a;
|
|
241
|
+
var _a, _b;
|
|
197
242
|
var args = [];
|
|
198
243
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
199
244
|
args[_i] = arguments[_i];
|
|
200
245
|
}
|
|
201
|
-
(
|
|
246
|
+
if (ContextService.hasContext()) {
|
|
247
|
+
(_a = _this._logger).log.apply(_a, __spreadArray(__spreadArray([], __read(args), false), [_this.contextService.context], false));
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
(_b = _this._logger).log.apply(_b, __spreadArray([], __read(args), false));
|
|
202
251
|
};
|
|
203
252
|
/**
|
|
204
253
|
* Logs debug messages using the current logger.
|
|
205
254
|
* @param {...any} args - The debug messages to log.
|
|
206
255
|
*/
|
|
207
256
|
this.debug = function () {
|
|
208
|
-
var _a;
|
|
257
|
+
var _a, _b;
|
|
209
258
|
var args = [];
|
|
210
259
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
211
260
|
args[_i] = arguments[_i];
|
|
212
261
|
}
|
|
213
|
-
(
|
|
262
|
+
if (ContextService.hasContext()) {
|
|
263
|
+
(_a = _this._logger).debug.apply(_a, __spreadArray(__spreadArray([], __read(args), false), [_this.contextService.context], false));
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
(_b = _this._logger).debug.apply(_b, __spreadArray([], __read(args), false));
|
|
214
267
|
};
|
|
215
268
|
/**
|
|
216
269
|
* Sets a new logger.
|
|
@@ -223,50 +276,6 @@ var LoggerService = /** @class */ (function () {
|
|
|
223
276
|
return LoggerService;
|
|
224
277
|
}());
|
|
225
278
|
|
|
226
|
-
var _a;
|
|
227
|
-
var init = (_a = diKit.createActivator("agent-swarm"), _a.init), inject = _a.inject, provide = _a.provide;
|
|
228
|
-
|
|
229
|
-
var baseServices$1 = {
|
|
230
|
-
busService: Symbol('busService'),
|
|
231
|
-
loggerService: Symbol('loggerService'),
|
|
232
|
-
contextService: Symbol('contextService'),
|
|
233
|
-
};
|
|
234
|
-
var connectionServices$1 = {
|
|
235
|
-
agentConnectionService: Symbol('agentConnectionService'),
|
|
236
|
-
historyConnectionService: Symbol('historyConnectionService'),
|
|
237
|
-
swarmConnectionService: Symbol('swarmConnectionService'),
|
|
238
|
-
sessionConnectionService: Symbol('sessionConnectionService'),
|
|
239
|
-
storageConnectionService: Symbol('storageConnectionService'),
|
|
240
|
-
stateConnectionService: Symbol('stateConnectionService'),
|
|
241
|
-
};
|
|
242
|
-
var schemaServices$1 = {
|
|
243
|
-
completionSchemaService: Symbol('completionSchemaService'),
|
|
244
|
-
agentSchemaService: Symbol('agentSchemaService'),
|
|
245
|
-
swarmSchemaService: Symbol('swarmSchemaService'),
|
|
246
|
-
toolSchemaService: Symbol('toolSchemaService'),
|
|
247
|
-
embeddingSchemaService: Symbol('embeddingSchemaService'),
|
|
248
|
-
storageSchemaService: Symbol('storageSchemaService'),
|
|
249
|
-
stateSchemaService: Symbol('stateSchemaService'),
|
|
250
|
-
};
|
|
251
|
-
var publicServices$1 = {
|
|
252
|
-
agentPublicService: Symbol('agentPublicService'),
|
|
253
|
-
historyPublicService: Symbol('historyPublicService'),
|
|
254
|
-
sessionPublicService: Symbol('sessionPublicService'),
|
|
255
|
-
swarmPublicService: Symbol('swarmPublicService'),
|
|
256
|
-
storagePublicService: Symbol('storagePublicService'),
|
|
257
|
-
statePublicService: Symbol('statePublicService'),
|
|
258
|
-
};
|
|
259
|
-
var validationServices$1 = {
|
|
260
|
-
agentValidationService: Symbol('agentValidationService'),
|
|
261
|
-
toolValidationService: Symbol('toolValidationService'),
|
|
262
|
-
sessionValidationService: Symbol('sessionValidationService'),
|
|
263
|
-
swarmValidationService: Symbol('swarmValidationService'),
|
|
264
|
-
completionValidationService: Symbol('completionValidationService'),
|
|
265
|
-
embeddingValidationService: Symbol('embeddingValidationService'),
|
|
266
|
-
storageValidationService: Symbol('storageValidationService'),
|
|
267
|
-
};
|
|
268
|
-
var TYPES = __assign(__assign(__assign(__assign(__assign({}, baseServices$1), schemaServices$1), connectionServices$1), publicServices$1), validationServices$1);
|
|
269
|
-
|
|
270
279
|
/**
|
|
271
280
|
* Service for managing agent schemas.
|
|
272
281
|
*/
|
|
@@ -1558,7 +1567,6 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1558
1567
|
this.loggerService.log("agentConnectionService execute", {
|
|
1559
1568
|
input: input,
|
|
1560
1569
|
mode: mode,
|
|
1561
|
-
context: this.contextService.context,
|
|
1562
1570
|
});
|
|
1563
1571
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).execute(input, mode)];
|
|
1564
1572
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -1573,9 +1581,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1573
1581
|
return __generator(this, function (_a) {
|
|
1574
1582
|
switch (_a.label) {
|
|
1575
1583
|
case 0:
|
|
1576
|
-
this.loggerService.log("agentConnectionService waitForOutput"
|
|
1577
|
-
context: this.contextService.context,
|
|
1578
|
-
});
|
|
1584
|
+
this.loggerService.log("agentConnectionService waitForOutput");
|
|
1579
1585
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).waitForOutput()];
|
|
1580
1586
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1581
1587
|
}
|
|
@@ -1594,7 +1600,6 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1594
1600
|
this.loggerService.log("agentConnectionService commitToolOutput", {
|
|
1595
1601
|
content: content,
|
|
1596
1602
|
toolId: toolId,
|
|
1597
|
-
context: this.contextService.context,
|
|
1598
1603
|
});
|
|
1599
1604
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitToolOutput(toolId, content)];
|
|
1600
1605
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -1612,7 +1617,6 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1612
1617
|
case 0:
|
|
1613
1618
|
this.loggerService.log("agentConnectionService commitSystemMessage", {
|
|
1614
1619
|
message: message,
|
|
1615
|
-
context: this.contextService.context,
|
|
1616
1620
|
});
|
|
1617
1621
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitSystemMessage(message)];
|
|
1618
1622
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -1630,7 +1634,6 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1630
1634
|
case 0:
|
|
1631
1635
|
this.loggerService.log("agentConnectionService commitUserMessage", {
|
|
1632
1636
|
message: message,
|
|
1633
|
-
context: this.contextService.context,
|
|
1634
1637
|
});
|
|
1635
1638
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitUserMessage(message)];
|
|
1636
1639
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -1645,9 +1648,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1645
1648
|
return __generator(this, function (_a) {
|
|
1646
1649
|
switch (_a.label) {
|
|
1647
1650
|
case 0:
|
|
1648
|
-
this.loggerService.log("agentConnectionService commitAgentChange"
|
|
1649
|
-
context: this.contextService.context,
|
|
1650
|
-
});
|
|
1651
|
+
this.loggerService.log("agentConnectionService commitAgentChange");
|
|
1651
1652
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitAgentChange()];
|
|
1652
1653
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1653
1654
|
}
|
|
@@ -1661,9 +1662,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1661
1662
|
return __generator(this, function (_a) {
|
|
1662
1663
|
switch (_a.label) {
|
|
1663
1664
|
case 0:
|
|
1664
|
-
this.loggerService.log("agentConnectionService commitFlush"
|
|
1665
|
-
context: this.contextService.context,
|
|
1666
|
-
});
|
|
1665
|
+
this.loggerService.log("agentConnectionService commitFlush");
|
|
1667
1666
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitFlush()];
|
|
1668
1667
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1669
1668
|
}
|
|
@@ -1678,9 +1677,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1678
1677
|
return __generator(this, function (_a) {
|
|
1679
1678
|
switch (_a.label) {
|
|
1680
1679
|
case 0:
|
|
1681
|
-
this.loggerService.log("agentConnectionService dispose"
|
|
1682
|
-
context: this.contextService.context,
|
|
1683
|
-
});
|
|
1680
|
+
this.loggerService.log("agentConnectionService dispose");
|
|
1684
1681
|
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.agentName);
|
|
1685
1682
|
if (!this.getAgent.has(key)) {
|
|
1686
1683
|
return [2 /*return*/];
|
|
@@ -2001,7 +1998,7 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
2001
1998
|
switch (_a.label) {
|
|
2002
1999
|
case 0:
|
|
2003
2000
|
this.loggerService.log("historyConnectionService push", {
|
|
2004
|
-
|
|
2001
|
+
message: message,
|
|
2005
2002
|
});
|
|
2006
2003
|
return [4 /*yield*/, this.getHistory(this.contextService.context.clientId, this.contextService.context.agentName).push(message)];
|
|
2007
2004
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -2018,7 +2015,7 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
2018
2015
|
switch (_a.label) {
|
|
2019
2016
|
case 0:
|
|
2020
2017
|
this.loggerService.log("historyConnectionService toArrayForAgent", {
|
|
2021
|
-
|
|
2018
|
+
prompt: prompt,
|
|
2022
2019
|
});
|
|
2023
2020
|
return [4 /*yield*/, this.getHistory(this.contextService.context.clientId, this.contextService.context.agentName).toArrayForAgent(prompt)];
|
|
2024
2021
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -2033,9 +2030,7 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
2033
2030
|
return __generator(this, function (_a) {
|
|
2034
2031
|
switch (_a.label) {
|
|
2035
2032
|
case 0:
|
|
2036
|
-
this.loggerService.log("historyConnectionService toArrayForRaw"
|
|
2037
|
-
context: this.contextService.context,
|
|
2038
|
-
});
|
|
2033
|
+
this.loggerService.log("historyConnectionService toArrayForRaw");
|
|
2039
2034
|
return [4 /*yield*/, this.getHistory(this.contextService.context.clientId, this.contextService.context.agentName).toArrayForRaw()];
|
|
2040
2035
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2041
2036
|
}
|
|
@@ -2050,9 +2045,7 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
2050
2045
|
return __generator(this, function (_a) {
|
|
2051
2046
|
switch (_a.label) {
|
|
2052
2047
|
case 0:
|
|
2053
|
-
this.loggerService.log("historyConnectionService dispose"
|
|
2054
|
-
context: this.contextService.context,
|
|
2055
|
-
});
|
|
2048
|
+
this.loggerService.log("historyConnectionService dispose");
|
|
2056
2049
|
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.agentName);
|
|
2057
2050
|
if (!this.getHistory.has(key)) {
|
|
2058
2051
|
return [2 /*return*/];
|
|
@@ -2445,9 +2438,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2445
2438
|
return __generator(this, function (_a) {
|
|
2446
2439
|
switch (_a.label) {
|
|
2447
2440
|
case 0:
|
|
2448
|
-
this.loggerService.log("swarmConnectionService cancelOutput"
|
|
2449
|
-
context: this.contextService.context,
|
|
2450
|
-
});
|
|
2441
|
+
this.loggerService.log("swarmConnectionService cancelOutput");
|
|
2451
2442
|
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).cancelOutput()];
|
|
2452
2443
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2453
2444
|
}
|
|
@@ -2461,9 +2452,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2461
2452
|
return __generator(this, function (_a) {
|
|
2462
2453
|
switch (_a.label) {
|
|
2463
2454
|
case 0:
|
|
2464
|
-
this.loggerService.log("swarmConnectionService waitForOutput"
|
|
2465
|
-
context: this.contextService.context,
|
|
2466
|
-
});
|
|
2455
|
+
this.loggerService.log("swarmConnectionService waitForOutput");
|
|
2467
2456
|
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).waitForOutput()];
|
|
2468
2457
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2469
2458
|
}
|
|
@@ -2477,9 +2466,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2477
2466
|
return __generator(this, function (_a) {
|
|
2478
2467
|
switch (_a.label) {
|
|
2479
2468
|
case 0:
|
|
2480
|
-
this.loggerService.log("swarmConnectionService getAgentName"
|
|
2481
|
-
context: this.contextService.context,
|
|
2482
|
-
});
|
|
2469
|
+
this.loggerService.log("swarmConnectionService getAgentName");
|
|
2483
2470
|
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).getAgentName()];
|
|
2484
2471
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2485
2472
|
}
|
|
@@ -2493,9 +2480,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2493
2480
|
return __generator(this, function (_a) {
|
|
2494
2481
|
switch (_a.label) {
|
|
2495
2482
|
case 0:
|
|
2496
|
-
this.loggerService.log("swarmConnectionService getAgent"
|
|
2497
|
-
context: this.contextService.context,
|
|
2498
|
-
});
|
|
2483
|
+
this.loggerService.log("swarmConnectionService getAgent");
|
|
2499
2484
|
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).getAgent()];
|
|
2500
2485
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2501
2486
|
}
|
|
@@ -2512,7 +2497,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2512
2497
|
switch (_a.label) {
|
|
2513
2498
|
case 0:
|
|
2514
2499
|
this.loggerService.log("swarmConnectionService setAgentRef", {
|
|
2515
|
-
|
|
2500
|
+
agentName: agentName,
|
|
2516
2501
|
});
|
|
2517
2502
|
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).setAgentRef(agentName, agent)];
|
|
2518
2503
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -2530,7 +2515,6 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2530
2515
|
case 0:
|
|
2531
2516
|
this.loggerService.log("swarmConnectionService setAgentName", {
|
|
2532
2517
|
agentName: agentName,
|
|
2533
|
-
context: this.contextService.context,
|
|
2534
2518
|
});
|
|
2535
2519
|
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).setAgentName(agentName)];
|
|
2536
2520
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -2544,9 +2528,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2544
2528
|
this.dispose = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2545
2529
|
var key;
|
|
2546
2530
|
return __generator(this, function (_a) {
|
|
2547
|
-
this.loggerService.log("swarmConnectionService dispose"
|
|
2548
|
-
context: this.contextService.context,
|
|
2549
|
-
});
|
|
2531
|
+
this.loggerService.log("swarmConnectionService dispose");
|
|
2550
2532
|
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.swarmName);
|
|
2551
2533
|
if (!this.getSwarm.has(key)) {
|
|
2552
2534
|
return [2 /*return*/];
|
|
@@ -2896,17 +2878,22 @@ var ClientSession = /** @class */ (function () {
|
|
|
2896
2878
|
clientId: _this.params.clientId,
|
|
2897
2879
|
});
|
|
2898
2880
|
return function (incoming) { return __awaiter(_this, void 0, void 0, function () {
|
|
2899
|
-
var _a;
|
|
2881
|
+
var data, _a;
|
|
2900
2882
|
var _b;
|
|
2901
2883
|
return __generator(this, function (_c) {
|
|
2902
2884
|
switch (_c.label) {
|
|
2903
2885
|
case 0:
|
|
2904
2886
|
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " connect call"));
|
|
2905
|
-
_a = connector;
|
|
2906
|
-
_b = {};
|
|
2907
2887
|
return [4 /*yield*/, this.execute(incoming.data, "user")];
|
|
2908
2888
|
case 1:
|
|
2909
|
-
|
|
2889
|
+
data = _c.sent();
|
|
2890
|
+
if (!data) {
|
|
2891
|
+
return [2 /*return*/];
|
|
2892
|
+
}
|
|
2893
|
+
_a = connector;
|
|
2894
|
+
_b = {
|
|
2895
|
+
data: data
|
|
2896
|
+
};
|
|
2910
2897
|
return [4 /*yield*/, this.params.swarm.getAgentName()];
|
|
2911
2898
|
case 2: return [4 /*yield*/, _a.apply(void 0, [(_b.agentName = _c.sent(),
|
|
2912
2899
|
_b.clientId = incoming.clientId,
|
|
@@ -2973,7 +2960,7 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
2973
2960
|
switch (_a.label) {
|
|
2974
2961
|
case 0:
|
|
2975
2962
|
this.loggerService.log("sessionConnectionService emit", {
|
|
2976
|
-
|
|
2963
|
+
content: content,
|
|
2977
2964
|
});
|
|
2978
2965
|
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).emit(content)];
|
|
2979
2966
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -2990,7 +2977,6 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
2990
2977
|
switch (_a.label) {
|
|
2991
2978
|
case 0:
|
|
2992
2979
|
this.loggerService.log("sessionConnectionService execute", {
|
|
2993
|
-
context: this.contextService.context,
|
|
2994
2980
|
content: content,
|
|
2995
2981
|
mode: mode,
|
|
2996
2982
|
});
|
|
@@ -3005,9 +2991,7 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3005
2991
|
* @returns {ReceiveMessageFn} The function to receive messages.
|
|
3006
2992
|
*/
|
|
3007
2993
|
this.connect = function (connector) {
|
|
3008
|
-
_this.loggerService.log("sessionConnectionService connect"
|
|
3009
|
-
context: _this.contextService.context,
|
|
3010
|
-
});
|
|
2994
|
+
_this.loggerService.log("sessionConnectionService connect");
|
|
3011
2995
|
return _this.getSession(_this.contextService.context.clientId, _this.contextService.context.swarmName).connect(connector);
|
|
3012
2996
|
};
|
|
3013
2997
|
/**
|
|
@@ -3021,7 +3005,6 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3021
3005
|
switch (_a.label) {
|
|
3022
3006
|
case 0:
|
|
3023
3007
|
this.loggerService.log("sessionConnectionService commitToolOutput", {
|
|
3024
|
-
context: this.contextService.context,
|
|
3025
3008
|
content: content,
|
|
3026
3009
|
toolId: toolId,
|
|
3027
3010
|
});
|
|
@@ -3040,7 +3023,6 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3040
3023
|
switch (_a.label) {
|
|
3041
3024
|
case 0:
|
|
3042
3025
|
this.loggerService.log("sessionConnectionService commitSystemMessage", {
|
|
3043
|
-
context: this.contextService.context,
|
|
3044
3026
|
message: message,
|
|
3045
3027
|
});
|
|
3046
3028
|
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).commitSystemMessage(message)];
|
|
@@ -3058,7 +3040,6 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3058
3040
|
switch (_a.label) {
|
|
3059
3041
|
case 0:
|
|
3060
3042
|
this.loggerService.log("sessionConnectionService commitUserMessage", {
|
|
3061
|
-
context: this.contextService.context,
|
|
3062
3043
|
message: message,
|
|
3063
3044
|
});
|
|
3064
3045
|
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).commitUserMessage(message)];
|
|
@@ -3075,9 +3056,7 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3075
3056
|
return __generator(this, function (_a) {
|
|
3076
3057
|
switch (_a.label) {
|
|
3077
3058
|
case 0:
|
|
3078
|
-
this.loggerService.log("sessionConnectionService commitFlush"
|
|
3079
|
-
context: this.contextService.context,
|
|
3080
|
-
});
|
|
3059
|
+
this.loggerService.log("sessionConnectionService commitFlush");
|
|
3081
3060
|
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).commitFlush()];
|
|
3082
3061
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3083
3062
|
}
|
|
@@ -3092,9 +3071,7 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3092
3071
|
return __generator(this, function (_a) {
|
|
3093
3072
|
switch (_a.label) {
|
|
3094
3073
|
case 0:
|
|
3095
|
-
this.loggerService.log("sessionConnectionService dispose"
|
|
3096
|
-
context: this.contextService.context,
|
|
3097
|
-
});
|
|
3074
|
+
this.loggerService.log("sessionConnectionService dispose");
|
|
3098
3075
|
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.swarmName);
|
|
3099
3076
|
if (!this.getSession.has(key)) {
|
|
3100
3077
|
return [2 /*return*/];
|
|
@@ -3125,12 +3102,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3125
3102
|
* @param {AgentName} agentName - The name of the agent.
|
|
3126
3103
|
* @returns {Promise<unknown>} The agent reference.
|
|
3127
3104
|
*/
|
|
3128
|
-
this.createAgentRef = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3105
|
+
this.createAgentRef = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3129
3106
|
var _this = this;
|
|
3130
3107
|
return __generator(this, function (_a) {
|
|
3131
3108
|
switch (_a.label) {
|
|
3132
3109
|
case 0:
|
|
3133
3110
|
this.loggerService.log("agentPublicService createAgentRef", {
|
|
3111
|
+
requestId: requestId,
|
|
3134
3112
|
clientId: clientId,
|
|
3135
3113
|
agentName: agentName,
|
|
3136
3114
|
});
|
|
@@ -3142,6 +3120,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3142
3120
|
}
|
|
3143
3121
|
});
|
|
3144
3122
|
}); }, {
|
|
3123
|
+
requestId: requestId,
|
|
3145
3124
|
clientId: clientId,
|
|
3146
3125
|
agentName: agentName,
|
|
3147
3126
|
swarmName: "",
|
|
@@ -3159,12 +3138,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3159
3138
|
* @param {AgentName} agentName - The name of the agent.
|
|
3160
3139
|
* @returns {Promise<unknown>} The execution result.
|
|
3161
3140
|
*/
|
|
3162
|
-
this.execute = function (input, mode, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3141
|
+
this.execute = function (input, mode, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3163
3142
|
var _this = this;
|
|
3164
3143
|
return __generator(this, function (_a) {
|
|
3165
3144
|
switch (_a.label) {
|
|
3166
3145
|
case 0:
|
|
3167
3146
|
this.loggerService.log("agentPublicService execute", {
|
|
3147
|
+
requestId: requestId,
|
|
3168
3148
|
input: input,
|
|
3169
3149
|
clientId: clientId,
|
|
3170
3150
|
agentName: agentName,
|
|
@@ -3178,6 +3158,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3178
3158
|
}
|
|
3179
3159
|
});
|
|
3180
3160
|
}); }, {
|
|
3161
|
+
requestId: requestId,
|
|
3181
3162
|
clientId: clientId,
|
|
3182
3163
|
agentName: agentName,
|
|
3183
3164
|
swarmName: "",
|
|
@@ -3194,12 +3175,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3194
3175
|
* @param {AgentName} agentName - The name of the agent.
|
|
3195
3176
|
* @returns {Promise<unknown>} The output result.
|
|
3196
3177
|
*/
|
|
3197
|
-
this.waitForOutput = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3178
|
+
this.waitForOutput = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3198
3179
|
var _this = this;
|
|
3199
3180
|
return __generator(this, function (_a) {
|
|
3200
3181
|
switch (_a.label) {
|
|
3201
3182
|
case 0:
|
|
3202
3183
|
this.loggerService.log("agentPublicService waitForOutput", {
|
|
3184
|
+
requestId: requestId,
|
|
3203
3185
|
clientId: clientId,
|
|
3204
3186
|
agentName: agentName,
|
|
3205
3187
|
});
|
|
@@ -3211,6 +3193,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3211
3193
|
}
|
|
3212
3194
|
});
|
|
3213
3195
|
}); }, {
|
|
3196
|
+
requestId: requestId,
|
|
3214
3197
|
clientId: clientId,
|
|
3215
3198
|
agentName: agentName,
|
|
3216
3199
|
swarmName: "",
|
|
@@ -3229,12 +3212,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3229
3212
|
* @param {AgentName} agentName - The name of the agent.
|
|
3230
3213
|
* @returns {Promise<unknown>} The commit result.
|
|
3231
3214
|
*/
|
|
3232
|
-
this.commitToolOutput = function (toolId, content, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3215
|
+
this.commitToolOutput = function (toolId, content, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3233
3216
|
var _this = this;
|
|
3234
3217
|
return __generator(this, function (_a) {
|
|
3235
3218
|
switch (_a.label) {
|
|
3236
3219
|
case 0:
|
|
3237
3220
|
this.loggerService.log("agentPublicService commitToolOutput", {
|
|
3221
|
+
requestId: requestId,
|
|
3238
3222
|
content: content,
|
|
3239
3223
|
clientId: clientId,
|
|
3240
3224
|
toolId: toolId,
|
|
@@ -3248,6 +3232,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3248
3232
|
}
|
|
3249
3233
|
});
|
|
3250
3234
|
}); }, {
|
|
3235
|
+
requestId: requestId,
|
|
3251
3236
|
clientId: clientId,
|
|
3252
3237
|
agentName: agentName,
|
|
3253
3238
|
swarmName: "",
|
|
@@ -3265,12 +3250,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3265
3250
|
* @param {AgentName} agentName - The name of the agent.
|
|
3266
3251
|
* @returns {Promise<unknown>} The commit result.
|
|
3267
3252
|
*/
|
|
3268
|
-
this.commitSystemMessage = function (message, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3253
|
+
this.commitSystemMessage = function (message, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3269
3254
|
var _this = this;
|
|
3270
3255
|
return __generator(this, function (_a) {
|
|
3271
3256
|
switch (_a.label) {
|
|
3272
3257
|
case 0:
|
|
3273
3258
|
this.loggerService.log("agentPublicService commitSystemMessage", {
|
|
3259
|
+
requestId: requestId,
|
|
3274
3260
|
message: message,
|
|
3275
3261
|
clientId: clientId,
|
|
3276
3262
|
agentName: agentName,
|
|
@@ -3283,6 +3269,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3283
3269
|
}
|
|
3284
3270
|
});
|
|
3285
3271
|
}); }, {
|
|
3272
|
+
requestId: requestId,
|
|
3286
3273
|
clientId: clientId,
|
|
3287
3274
|
agentName: agentName,
|
|
3288
3275
|
swarmName: "",
|
|
@@ -3300,12 +3287,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3300
3287
|
* @param {AgentName} agentName - The name of the agent.
|
|
3301
3288
|
* @returns {Promise<unknown>} The commit result.
|
|
3302
3289
|
*/
|
|
3303
|
-
this.commitUserMessage = function (message, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3290
|
+
this.commitUserMessage = function (message, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3304
3291
|
var _this = this;
|
|
3305
3292
|
return __generator(this, function (_a) {
|
|
3306
3293
|
switch (_a.label) {
|
|
3307
3294
|
case 0:
|
|
3308
3295
|
this.loggerService.log("agentPublicService commitUserMessage", {
|
|
3296
|
+
requestId: requestId,
|
|
3309
3297
|
message: message,
|
|
3310
3298
|
clientId: clientId,
|
|
3311
3299
|
agentName: agentName,
|
|
@@ -3318,6 +3306,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3318
3306
|
}
|
|
3319
3307
|
});
|
|
3320
3308
|
}); }, {
|
|
3309
|
+
requestId: requestId,
|
|
3321
3310
|
clientId: clientId,
|
|
3322
3311
|
agentName: agentName,
|
|
3323
3312
|
swarmName: "",
|
|
@@ -3334,12 +3323,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3334
3323
|
* @param {AgentName} agentName - The name of the agent.
|
|
3335
3324
|
* @returns {Promise<unknown>} The commit result.
|
|
3336
3325
|
*/
|
|
3337
|
-
this.commitFlush = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3326
|
+
this.commitFlush = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3338
3327
|
var _this = this;
|
|
3339
3328
|
return __generator(this, function (_a) {
|
|
3340
3329
|
switch (_a.label) {
|
|
3341
3330
|
case 0:
|
|
3342
3331
|
this.loggerService.log("agentPublicService commitFlush", {
|
|
3332
|
+
requestId: requestId,
|
|
3343
3333
|
clientId: clientId,
|
|
3344
3334
|
agentName: agentName,
|
|
3345
3335
|
});
|
|
@@ -3351,6 +3341,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3351
3341
|
}
|
|
3352
3342
|
});
|
|
3353
3343
|
}); }, {
|
|
3344
|
+
requestId: requestId,
|
|
3354
3345
|
clientId: clientId,
|
|
3355
3346
|
agentName: agentName,
|
|
3356
3347
|
swarmName: "",
|
|
@@ -3367,12 +3358,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3367
3358
|
* @param {AgentName} agentName - The name of the agent.
|
|
3368
3359
|
* @returns {Promise<unknown>} The commit result.
|
|
3369
3360
|
*/
|
|
3370
|
-
this.commitAgentChange = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3361
|
+
this.commitAgentChange = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3371
3362
|
var _this = this;
|
|
3372
3363
|
return __generator(this, function (_a) {
|
|
3373
3364
|
switch (_a.label) {
|
|
3374
3365
|
case 0:
|
|
3375
3366
|
this.loggerService.log("agentPublicService commitAgentChange", {
|
|
3367
|
+
requestId: requestId,
|
|
3376
3368
|
clientId: clientId,
|
|
3377
3369
|
agentName: agentName,
|
|
3378
3370
|
});
|
|
@@ -3384,6 +3376,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3384
3376
|
}
|
|
3385
3377
|
});
|
|
3386
3378
|
}); }, {
|
|
3379
|
+
requestId: requestId,
|
|
3387
3380
|
clientId: clientId,
|
|
3388
3381
|
agentName: agentName,
|
|
3389
3382
|
swarmName: "",
|
|
@@ -3400,12 +3393,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3400
3393
|
* @param {AgentName} agentName - The name of the agent.
|
|
3401
3394
|
* @returns {Promise<unknown>} The dispose result.
|
|
3402
3395
|
*/
|
|
3403
|
-
this.dispose = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3396
|
+
this.dispose = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3404
3397
|
var _this = this;
|
|
3405
3398
|
return __generator(this, function (_a) {
|
|
3406
3399
|
switch (_a.label) {
|
|
3407
3400
|
case 0:
|
|
3408
3401
|
this.loggerService.log("agentPublicService dispose", {
|
|
3402
|
+
requestId: requestId,
|
|
3409
3403
|
clientId: clientId,
|
|
3410
3404
|
agentName: agentName,
|
|
3411
3405
|
});
|
|
@@ -3417,6 +3411,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3417
3411
|
}
|
|
3418
3412
|
});
|
|
3419
3413
|
}); }, {
|
|
3414
|
+
requestId: requestId,
|
|
3420
3415
|
clientId: clientId,
|
|
3421
3416
|
agentName: agentName,
|
|
3422
3417
|
swarmName: "",
|
|
@@ -3446,12 +3441,13 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3446
3441
|
* @param {AgentName} agentName - The agent name.
|
|
3447
3442
|
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
3448
3443
|
*/
|
|
3449
|
-
this.push = function (message, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3444
|
+
this.push = function (message, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3450
3445
|
var _this = this;
|
|
3451
3446
|
return __generator(this, function (_a) {
|
|
3452
3447
|
switch (_a.label) {
|
|
3453
3448
|
case 0:
|
|
3454
3449
|
this.loggerService.log("historyPublicService push", {
|
|
3450
|
+
requestId: requestId,
|
|
3455
3451
|
message: message,
|
|
3456
3452
|
clientId: clientId,
|
|
3457
3453
|
agentName: agentName,
|
|
@@ -3464,6 +3460,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3464
3460
|
}
|
|
3465
3461
|
});
|
|
3466
3462
|
}); }, {
|
|
3463
|
+
requestId: requestId,
|
|
3467
3464
|
clientId: clientId,
|
|
3468
3465
|
agentName: agentName,
|
|
3469
3466
|
swarmName: "",
|
|
@@ -3481,7 +3478,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3481
3478
|
* @param {AgentName} agentName - The agent name.
|
|
3482
3479
|
* @returns {Promise<any[]>} A promise that resolves to an array of history items.
|
|
3483
3480
|
*/
|
|
3484
|
-
this.toArrayForAgent = function (prompt, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3481
|
+
this.toArrayForAgent = function (prompt, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3485
3482
|
var _this = this;
|
|
3486
3483
|
return __generator(this, function (_a) {
|
|
3487
3484
|
switch (_a.label) {
|
|
@@ -3499,6 +3496,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3499
3496
|
}
|
|
3500
3497
|
});
|
|
3501
3498
|
}); }, {
|
|
3499
|
+
requestId: requestId,
|
|
3502
3500
|
clientId: clientId,
|
|
3503
3501
|
agentName: agentName,
|
|
3504
3502
|
swarmName: "",
|
|
@@ -3515,12 +3513,13 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3515
3513
|
* @param {AgentName} agentName - The agent name.
|
|
3516
3514
|
* @returns {Promise<any[]>} A promise that resolves to a raw array of history items.
|
|
3517
3515
|
*/
|
|
3518
|
-
this.toArrayForRaw = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3516
|
+
this.toArrayForRaw = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3519
3517
|
var _this = this;
|
|
3520
3518
|
return __generator(this, function (_a) {
|
|
3521
3519
|
switch (_a.label) {
|
|
3522
3520
|
case 0:
|
|
3523
3521
|
this.loggerService.log("historyPublicService toArrayForRaw", {
|
|
3522
|
+
requestId: requestId,
|
|
3524
3523
|
clientId: clientId,
|
|
3525
3524
|
agentName: agentName,
|
|
3526
3525
|
});
|
|
@@ -3532,6 +3531,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3532
3531
|
}
|
|
3533
3532
|
});
|
|
3534
3533
|
}); }, {
|
|
3534
|
+
requestId: requestId,
|
|
3535
3535
|
clientId: clientId,
|
|
3536
3536
|
agentName: agentName,
|
|
3537
3537
|
swarmName: "",
|
|
@@ -3548,7 +3548,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3548
3548
|
* @param {AgentName} agentName - The agent name.
|
|
3549
3549
|
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
3550
3550
|
*/
|
|
3551
|
-
this.dispose = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3551
|
+
this.dispose = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3552
3552
|
var _this = this;
|
|
3553
3553
|
return __generator(this, function (_a) {
|
|
3554
3554
|
switch (_a.label) {
|
|
@@ -3565,6 +3565,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3565
3565
|
}
|
|
3566
3566
|
});
|
|
3567
3567
|
}); }, {
|
|
3568
|
+
requestId: requestId,
|
|
3568
3569
|
clientId: clientId,
|
|
3569
3570
|
agentName: agentName,
|
|
3570
3571
|
swarmName: "",
|
|
@@ -3594,7 +3595,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3594
3595
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3595
3596
|
* @returns {Promise<void>}
|
|
3596
3597
|
*/
|
|
3597
|
-
this.emit = function (content, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3598
|
+
this.emit = function (content, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3598
3599
|
var _this = this;
|
|
3599
3600
|
return __generator(this, function (_a) {
|
|
3600
3601
|
switch (_a.label) {
|
|
@@ -3602,6 +3603,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3602
3603
|
this.loggerService.log("sessionPublicService emit", {
|
|
3603
3604
|
content: content,
|
|
3604
3605
|
clientId: clientId,
|
|
3606
|
+
requestId: requestId,
|
|
3605
3607
|
swarmName: swarmName,
|
|
3606
3608
|
});
|
|
3607
3609
|
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -3612,6 +3614,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3612
3614
|
}
|
|
3613
3615
|
});
|
|
3614
3616
|
}); }, {
|
|
3617
|
+
requestId: requestId,
|
|
3615
3618
|
clientId: clientId,
|
|
3616
3619
|
swarmName: swarmName,
|
|
3617
3620
|
agentName: "",
|
|
@@ -3629,7 +3632,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3629
3632
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3630
3633
|
* @returns {Promise<void>}
|
|
3631
3634
|
*/
|
|
3632
|
-
this.execute = function (content, mode, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3635
|
+
this.execute = function (content, mode, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3633
3636
|
var _this = this;
|
|
3634
3637
|
return __generator(this, function (_a) {
|
|
3635
3638
|
switch (_a.label) {
|
|
@@ -3648,6 +3651,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3648
3651
|
}
|
|
3649
3652
|
});
|
|
3650
3653
|
}); }, {
|
|
3654
|
+
requestId: requestId,
|
|
3651
3655
|
clientId: clientId,
|
|
3652
3656
|
swarmName: swarmName,
|
|
3653
3657
|
agentName: "",
|
|
@@ -3665,8 +3669,9 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3665
3669
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3666
3670
|
* @returns {ReceiveMessageFn}
|
|
3667
3671
|
*/
|
|
3668
|
-
this.connect = function (connector, clientId, swarmName) {
|
|
3672
|
+
this.connect = function (connector, requestId, clientId, swarmName) {
|
|
3669
3673
|
_this.loggerService.log("sessionPublicService connect", {
|
|
3674
|
+
requestId: requestId,
|
|
3670
3675
|
clientId: clientId,
|
|
3671
3676
|
swarmName: swarmName,
|
|
3672
3677
|
});
|
|
@@ -3683,6 +3688,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3683
3688
|
}
|
|
3684
3689
|
});
|
|
3685
3690
|
}); }, {
|
|
3691
|
+
requestId: requestId,
|
|
3686
3692
|
clientId: clientId,
|
|
3687
3693
|
swarmName: swarmName,
|
|
3688
3694
|
agentName: "",
|
|
@@ -3697,6 +3703,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3697
3703
|
return ContextService.runInContext(function () {
|
|
3698
3704
|
return receive(incoming);
|
|
3699
3705
|
}, {
|
|
3706
|
+
requestId: requestId,
|
|
3700
3707
|
clientId: clientId,
|
|
3701
3708
|
swarmName: swarmName,
|
|
3702
3709
|
agentName: "",
|
|
@@ -3705,6 +3712,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3705
3712
|
});
|
|
3706
3713
|
};
|
|
3707
3714
|
}, {
|
|
3715
|
+
requestId: requestId,
|
|
3708
3716
|
clientId: clientId,
|
|
3709
3717
|
swarmName: swarmName,
|
|
3710
3718
|
agentName: "",
|
|
@@ -3720,12 +3728,13 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3720
3728
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3721
3729
|
* @returns {Promise<void>}
|
|
3722
3730
|
*/
|
|
3723
|
-
this.commitToolOutput = function (toolId, content, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3731
|
+
this.commitToolOutput = function (toolId, content, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3724
3732
|
var _this = this;
|
|
3725
3733
|
return __generator(this, function (_a) {
|
|
3726
3734
|
switch (_a.label) {
|
|
3727
3735
|
case 0:
|
|
3728
3736
|
this.loggerService.log("sessionPublicService commitToolOutput", {
|
|
3737
|
+
requestId: requestId,
|
|
3729
3738
|
toolId: toolId,
|
|
3730
3739
|
content: content,
|
|
3731
3740
|
clientId: clientId,
|
|
@@ -3739,6 +3748,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3739
3748
|
}
|
|
3740
3749
|
});
|
|
3741
3750
|
}); }, {
|
|
3751
|
+
requestId: requestId,
|
|
3742
3752
|
clientId: clientId,
|
|
3743
3753
|
swarmName: swarmName,
|
|
3744
3754
|
agentName: "",
|
|
@@ -3756,12 +3766,13 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3756
3766
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3757
3767
|
* @returns {Promise<void>}
|
|
3758
3768
|
*/
|
|
3759
|
-
this.commitSystemMessage = function (message, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3769
|
+
this.commitSystemMessage = function (message, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3760
3770
|
var _this = this;
|
|
3761
3771
|
return __generator(this, function (_a) {
|
|
3762
3772
|
switch (_a.label) {
|
|
3763
3773
|
case 0:
|
|
3764
3774
|
this.loggerService.log("sessionPublicService commitSystemMessage", {
|
|
3775
|
+
requestId: requestId,
|
|
3765
3776
|
message: message,
|
|
3766
3777
|
clientId: clientId,
|
|
3767
3778
|
swarmName: swarmName,
|
|
@@ -3774,6 +3785,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3774
3785
|
}
|
|
3775
3786
|
});
|
|
3776
3787
|
}); }, {
|
|
3788
|
+
requestId: requestId,
|
|
3777
3789
|
clientId: clientId,
|
|
3778
3790
|
swarmName: swarmName,
|
|
3779
3791
|
agentName: "",
|
|
@@ -3791,12 +3803,13 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3791
3803
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3792
3804
|
* @returns {Promise<void>}
|
|
3793
3805
|
*/
|
|
3794
|
-
this.commitUserMessage = function (message, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3806
|
+
this.commitUserMessage = function (message, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3795
3807
|
var _this = this;
|
|
3796
3808
|
return __generator(this, function (_a) {
|
|
3797
3809
|
switch (_a.label) {
|
|
3798
3810
|
case 0:
|
|
3799
3811
|
this.loggerService.log("sessionPublicService commitUserMessage", {
|
|
3812
|
+
requestId: requestId,
|
|
3800
3813
|
message: message,
|
|
3801
3814
|
clientId: clientId,
|
|
3802
3815
|
swarmName: swarmName,
|
|
@@ -3809,6 +3822,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3809
3822
|
}
|
|
3810
3823
|
});
|
|
3811
3824
|
}); }, {
|
|
3825
|
+
requestId: requestId,
|
|
3812
3826
|
clientId: clientId,
|
|
3813
3827
|
swarmName: swarmName,
|
|
3814
3828
|
agentName: "",
|
|
@@ -3825,7 +3839,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3825
3839
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3826
3840
|
* @returns {Promise<void>}
|
|
3827
3841
|
*/
|
|
3828
|
-
this.commitFlush = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3842
|
+
this.commitFlush = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3829
3843
|
var _this = this;
|
|
3830
3844
|
return __generator(this, function (_a) {
|
|
3831
3845
|
switch (_a.label) {
|
|
@@ -3842,6 +3856,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3842
3856
|
}
|
|
3843
3857
|
});
|
|
3844
3858
|
}); }, {
|
|
3859
|
+
requestId: requestId,
|
|
3845
3860
|
clientId: clientId,
|
|
3846
3861
|
swarmName: swarmName,
|
|
3847
3862
|
agentName: "",
|
|
@@ -3858,12 +3873,13 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3858
3873
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3859
3874
|
* @returns {Promise<void>}
|
|
3860
3875
|
*/
|
|
3861
|
-
this.dispose = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3876
|
+
this.dispose = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3862
3877
|
var _this = this;
|
|
3863
3878
|
return __generator(this, function (_a) {
|
|
3864
3879
|
switch (_a.label) {
|
|
3865
3880
|
case 0:
|
|
3866
3881
|
this.loggerService.log("sessionPublicService dispose", {
|
|
3882
|
+
requestId: requestId,
|
|
3867
3883
|
clientId: clientId,
|
|
3868
3884
|
swarmName: swarmName,
|
|
3869
3885
|
});
|
|
@@ -3875,6 +3891,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3875
3891
|
}
|
|
3876
3892
|
});
|
|
3877
3893
|
}); }, {
|
|
3894
|
+
requestId: requestId,
|
|
3878
3895
|
clientId: clientId,
|
|
3879
3896
|
swarmName: swarmName,
|
|
3880
3897
|
agentName: "",
|
|
@@ -3903,7 +3920,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3903
3920
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3904
3921
|
* @returns {Promise<void>}
|
|
3905
3922
|
*/
|
|
3906
|
-
this.cancelOutput = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3923
|
+
this.cancelOutput = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3907
3924
|
var _this = this;
|
|
3908
3925
|
return __generator(this, function (_a) {
|
|
3909
3926
|
switch (_a.label) {
|
|
@@ -3920,6 +3937,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3920
3937
|
}
|
|
3921
3938
|
});
|
|
3922
3939
|
}); }, {
|
|
3940
|
+
requestId: requestId,
|
|
3923
3941
|
clientId: clientId,
|
|
3924
3942
|
swarmName: swarmName,
|
|
3925
3943
|
agentName: "",
|
|
@@ -3936,13 +3954,14 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3936
3954
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3937
3955
|
* @returns {Promise<void>}
|
|
3938
3956
|
*/
|
|
3939
|
-
this.waitForOutput = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3957
|
+
this.waitForOutput = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3940
3958
|
var _this = this;
|
|
3941
3959
|
return __generator(this, function (_a) {
|
|
3942
3960
|
switch (_a.label) {
|
|
3943
3961
|
case 0:
|
|
3944
3962
|
this.loggerService.log("swarmPublicService waitForOutput", {
|
|
3945
3963
|
clientId: clientId,
|
|
3964
|
+
requestId: requestId,
|
|
3946
3965
|
swarmName: swarmName,
|
|
3947
3966
|
});
|
|
3948
3967
|
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -3953,6 +3972,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3953
3972
|
}
|
|
3954
3973
|
});
|
|
3955
3974
|
}); }, {
|
|
3975
|
+
requestId: requestId,
|
|
3956
3976
|
clientId: clientId,
|
|
3957
3977
|
swarmName: swarmName,
|
|
3958
3978
|
agentName: "",
|
|
@@ -3969,7 +3989,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3969
3989
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3970
3990
|
* @returns {Promise<string>}
|
|
3971
3991
|
*/
|
|
3972
|
-
this.getAgentName = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3992
|
+
this.getAgentName = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3973
3993
|
var _this = this;
|
|
3974
3994
|
return __generator(this, function (_a) {
|
|
3975
3995
|
switch (_a.label) {
|
|
@@ -3977,6 +3997,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3977
3997
|
this.loggerService.log("swarmPublicService getAgentName", {
|
|
3978
3998
|
clientId: clientId,
|
|
3979
3999
|
swarmName: swarmName,
|
|
4000
|
+
requestId: requestId,
|
|
3980
4001
|
});
|
|
3981
4002
|
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3982
4003
|
return __generator(this, function (_a) {
|
|
@@ -3986,6 +4007,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3986
4007
|
}
|
|
3987
4008
|
});
|
|
3988
4009
|
}); }, {
|
|
4010
|
+
requestId: requestId,
|
|
3989
4011
|
clientId: clientId,
|
|
3990
4012
|
swarmName: swarmName,
|
|
3991
4013
|
agentName: "",
|
|
@@ -4002,7 +4024,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4002
4024
|
* @param {SwarmName} swarmName - The swarm name.
|
|
4003
4025
|
* @returns {Promise<IAgent>}
|
|
4004
4026
|
*/
|
|
4005
|
-
this.getAgent = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4027
|
+
this.getAgent = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4006
4028
|
var _this = this;
|
|
4007
4029
|
return __generator(this, function (_a) {
|
|
4008
4030
|
switch (_a.label) {
|
|
@@ -4019,6 +4041,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4019
4041
|
}
|
|
4020
4042
|
});
|
|
4021
4043
|
}); }, {
|
|
4044
|
+
requestId: requestId,
|
|
4022
4045
|
clientId: clientId,
|
|
4023
4046
|
swarmName: swarmName,
|
|
4024
4047
|
agentName: "",
|
|
@@ -4037,12 +4060,13 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4037
4060
|
* @param {IAgent} agent - The agent instance.
|
|
4038
4061
|
* @returns {Promise<void>}
|
|
4039
4062
|
*/
|
|
4040
|
-
this.setAgentRef = function (clientId, swarmName, agentName, agent) { return __awaiter(_this, void 0, void 0, function () {
|
|
4063
|
+
this.setAgentRef = function (requestId, clientId, swarmName, agentName, agent) { return __awaiter(_this, void 0, void 0, function () {
|
|
4041
4064
|
var _this = this;
|
|
4042
4065
|
return __generator(this, function (_a) {
|
|
4043
4066
|
switch (_a.label) {
|
|
4044
4067
|
case 0:
|
|
4045
4068
|
this.loggerService.log("swarmPublicService setAgentRef", {
|
|
4069
|
+
requestId: requestId,
|
|
4046
4070
|
agentName: agentName,
|
|
4047
4071
|
agent: agent,
|
|
4048
4072
|
clientId: clientId,
|
|
@@ -4056,6 +4080,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4056
4080
|
}
|
|
4057
4081
|
});
|
|
4058
4082
|
}); }, {
|
|
4083
|
+
requestId: requestId,
|
|
4059
4084
|
clientId: clientId,
|
|
4060
4085
|
swarmName: swarmName,
|
|
4061
4086
|
agentName: "",
|
|
@@ -4073,12 +4098,13 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4073
4098
|
* @param {SwarmName} swarmName - The swarm name.
|
|
4074
4099
|
* @returns {Promise<void>}
|
|
4075
4100
|
*/
|
|
4076
|
-
this.setAgentName = function (agentName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4101
|
+
this.setAgentName = function (agentName, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4077
4102
|
var _this = this;
|
|
4078
4103
|
return __generator(this, function (_a) {
|
|
4079
4104
|
switch (_a.label) {
|
|
4080
4105
|
case 0:
|
|
4081
4106
|
this.loggerService.log("swarmPublicService setAgentName", {
|
|
4107
|
+
requestId: requestId,
|
|
4082
4108
|
agentName: agentName,
|
|
4083
4109
|
clientId: clientId,
|
|
4084
4110
|
swarmName: swarmName,
|
|
@@ -4091,6 +4117,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4091
4117
|
}
|
|
4092
4118
|
});
|
|
4093
4119
|
}); }, {
|
|
4120
|
+
requestId: requestId,
|
|
4094
4121
|
clientId: clientId,
|
|
4095
4122
|
swarmName: swarmName,
|
|
4096
4123
|
agentName: "",
|
|
@@ -4107,12 +4134,13 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4107
4134
|
* @param {SwarmName} swarmName - The swarm name.
|
|
4108
4135
|
* @returns {Promise<void>}
|
|
4109
4136
|
*/
|
|
4110
|
-
this.dispose = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4137
|
+
this.dispose = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4111
4138
|
var _this = this;
|
|
4112
4139
|
return __generator(this, function (_a) {
|
|
4113
4140
|
switch (_a.label) {
|
|
4114
4141
|
case 0:
|
|
4115
4142
|
this.loggerService.log("swarmPublicService dispose", {
|
|
4143
|
+
requestId: requestId,
|
|
4116
4144
|
clientId: clientId,
|
|
4117
4145
|
swarmName: swarmName,
|
|
4118
4146
|
});
|
|
@@ -4124,6 +4152,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4124
4152
|
}
|
|
4125
4153
|
});
|
|
4126
4154
|
}); }, {
|
|
4155
|
+
requestId: requestId,
|
|
4127
4156
|
clientId: clientId,
|
|
4128
4157
|
swarmName: swarmName,
|
|
4129
4158
|
agentName: "",
|
|
@@ -5216,7 +5245,6 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5216
5245
|
switch (_a.label) {
|
|
5217
5246
|
case 0:
|
|
5218
5247
|
this.loggerService.log("storageConnectionService take", {
|
|
5219
|
-
context: this.contextService.context,
|
|
5220
5248
|
search: search,
|
|
5221
5249
|
total: total,
|
|
5222
5250
|
score: score,
|
|
@@ -5241,7 +5269,6 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5241
5269
|
switch (_a.label) {
|
|
5242
5270
|
case 0:
|
|
5243
5271
|
this.loggerService.log("storageConnectionService upsert", {
|
|
5244
|
-
context: this.contextService.context,
|
|
5245
5272
|
item: item,
|
|
5246
5273
|
});
|
|
5247
5274
|
storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
@@ -5264,7 +5291,6 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5264
5291
|
switch (_a.label) {
|
|
5265
5292
|
case 0:
|
|
5266
5293
|
this.loggerService.log("storageConnectionService remove", {
|
|
5267
|
-
context: this.contextService.context,
|
|
5268
5294
|
itemId: itemId,
|
|
5269
5295
|
});
|
|
5270
5296
|
storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
@@ -5287,7 +5313,6 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5287
5313
|
switch (_a.label) {
|
|
5288
5314
|
case 0:
|
|
5289
5315
|
this.loggerService.log("storageConnectionService get", {
|
|
5290
|
-
context: this.contextService.context,
|
|
5291
5316
|
itemId: itemId,
|
|
5292
5317
|
});
|
|
5293
5318
|
storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
@@ -5309,9 +5334,7 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5309
5334
|
return __generator(this, function (_a) {
|
|
5310
5335
|
switch (_a.label) {
|
|
5311
5336
|
case 0:
|
|
5312
|
-
this.loggerService.log("storageConnectionService list"
|
|
5313
|
-
context: this.contextService.context,
|
|
5314
|
-
});
|
|
5337
|
+
this.loggerService.log("storageConnectionService list");
|
|
5315
5338
|
storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
5316
5339
|
return [4 /*yield*/, storage.waitForInit()];
|
|
5317
5340
|
case 1:
|
|
@@ -5330,9 +5353,7 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5330
5353
|
return __generator(this, function (_a) {
|
|
5331
5354
|
switch (_a.label) {
|
|
5332
5355
|
case 0:
|
|
5333
|
-
this.loggerService.log("storageConnectionService clear"
|
|
5334
|
-
context: this.contextService.context,
|
|
5335
|
-
});
|
|
5356
|
+
this.loggerService.log("storageConnectionService clear");
|
|
5336
5357
|
storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
5337
5358
|
return [4 /*yield*/, storage.waitForInit()];
|
|
5338
5359
|
case 1:
|
|
@@ -5351,9 +5372,7 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5351
5372
|
return __generator(this, function (_a) {
|
|
5352
5373
|
switch (_a.label) {
|
|
5353
5374
|
case 0:
|
|
5354
|
-
this.loggerService.log("storageConnectionService dispose"
|
|
5355
|
-
context: this.contextService.context,
|
|
5356
|
-
});
|
|
5375
|
+
this.loggerService.log("storageConnectionService dispose");
|
|
5357
5376
|
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.storageName);
|
|
5358
5377
|
if (!this.getStorage.has(key)) {
|
|
5359
5378
|
return [2 /*return*/];
|
|
@@ -5392,12 +5411,13 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5392
5411
|
* @param {number} total - The total number of items to retrieve.
|
|
5393
5412
|
* @returns {Promise<IStorageData[]>} The list of storage data.
|
|
5394
5413
|
*/
|
|
5395
|
-
this.take = function (search, total, clientId, storageName, score) { return __awaiter(_this, void 0, void 0, function () {
|
|
5414
|
+
this.take = function (search, total, requestId, clientId, storageName, score) { return __awaiter(_this, void 0, void 0, function () {
|
|
5396
5415
|
var _this = this;
|
|
5397
5416
|
return __generator(this, function (_a) {
|
|
5398
5417
|
switch (_a.label) {
|
|
5399
5418
|
case 0:
|
|
5400
5419
|
this.loggerService.log("storagePublicService take", {
|
|
5420
|
+
requestId: requestId,
|
|
5401
5421
|
search: search,
|
|
5402
5422
|
total: total,
|
|
5403
5423
|
clientId: clientId,
|
|
@@ -5412,6 +5432,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5412
5432
|
}
|
|
5413
5433
|
});
|
|
5414
5434
|
}); }, {
|
|
5435
|
+
requestId: requestId,
|
|
5415
5436
|
clientId: clientId,
|
|
5416
5437
|
storageName: storageName,
|
|
5417
5438
|
agentName: "",
|
|
@@ -5427,7 +5448,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5427
5448
|
* @param {IStorageData} item - The item to upsert.
|
|
5428
5449
|
* @returns {Promise<void>}
|
|
5429
5450
|
*/
|
|
5430
|
-
this.upsert = function (item, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5451
|
+
this.upsert = function (item, requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5431
5452
|
var _this = this;
|
|
5432
5453
|
return __generator(this, function (_a) {
|
|
5433
5454
|
switch (_a.label) {
|
|
@@ -5445,6 +5466,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5445
5466
|
}
|
|
5446
5467
|
});
|
|
5447
5468
|
}); }, {
|
|
5469
|
+
requestId: requestId,
|
|
5448
5470
|
clientId: clientId,
|
|
5449
5471
|
storageName: storageName,
|
|
5450
5472
|
agentName: "",
|
|
@@ -5460,7 +5482,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5460
5482
|
* @param {IStorageData["id"]} itemId - The ID of the item to remove.
|
|
5461
5483
|
* @returns {Promise<void>}
|
|
5462
5484
|
*/
|
|
5463
|
-
this.remove = function (itemId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5485
|
+
this.remove = function (itemId, requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5464
5486
|
var _this = this;
|
|
5465
5487
|
return __generator(this, function (_a) {
|
|
5466
5488
|
switch (_a.label) {
|
|
@@ -5478,6 +5500,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5478
5500
|
}
|
|
5479
5501
|
});
|
|
5480
5502
|
}); }, {
|
|
5503
|
+
requestId: requestId,
|
|
5481
5504
|
clientId: clientId,
|
|
5482
5505
|
storageName: storageName,
|
|
5483
5506
|
agentName: "",
|
|
@@ -5493,12 +5516,13 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5493
5516
|
* @param {IStorageData["id"]} itemId - The ID of the item to retrieve.
|
|
5494
5517
|
* @returns {Promise<IStorageData>} The retrieved item.
|
|
5495
5518
|
*/
|
|
5496
|
-
this.get = function (itemId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5519
|
+
this.get = function (itemId, requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5497
5520
|
var _this = this;
|
|
5498
5521
|
return __generator(this, function (_a) {
|
|
5499
5522
|
switch (_a.label) {
|
|
5500
5523
|
case 0:
|
|
5501
5524
|
this.loggerService.log("storagePublicService get", {
|
|
5525
|
+
requestId: requestId,
|
|
5502
5526
|
itemId: itemId,
|
|
5503
5527
|
clientId: clientId,
|
|
5504
5528
|
storageName: storageName,
|
|
@@ -5511,6 +5535,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5511
5535
|
}
|
|
5512
5536
|
});
|
|
5513
5537
|
}); }, {
|
|
5538
|
+
requestId: requestId,
|
|
5514
5539
|
clientId: clientId,
|
|
5515
5540
|
storageName: storageName,
|
|
5516
5541
|
agentName: "",
|
|
@@ -5526,12 +5551,13 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5526
5551
|
* @param {function(IStorageData): boolean} [filter] - The optional filter function.
|
|
5527
5552
|
* @returns {Promise<IStorageData[]>} The list of items.
|
|
5528
5553
|
*/
|
|
5529
|
-
this.list = function (clientId, storageName, filter) { return __awaiter(_this, void 0, void 0, function () {
|
|
5554
|
+
this.list = function (requestId, clientId, storageName, filter) { return __awaiter(_this, void 0, void 0, function () {
|
|
5530
5555
|
var _this = this;
|
|
5531
5556
|
return __generator(this, function (_a) {
|
|
5532
5557
|
switch (_a.label) {
|
|
5533
5558
|
case 0:
|
|
5534
5559
|
this.loggerService.log("storagePublicService list", {
|
|
5560
|
+
requestId: requestId,
|
|
5535
5561
|
clientId: clientId,
|
|
5536
5562
|
storageName: storageName,
|
|
5537
5563
|
});
|
|
@@ -5543,6 +5569,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5543
5569
|
}
|
|
5544
5570
|
});
|
|
5545
5571
|
}); }, {
|
|
5572
|
+
requestId: requestId,
|
|
5546
5573
|
clientId: clientId,
|
|
5547
5574
|
storageName: storageName,
|
|
5548
5575
|
agentName: "",
|
|
@@ -5557,12 +5584,13 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5557
5584
|
* Clears all items from the storage.
|
|
5558
5585
|
* @returns {Promise<void>}
|
|
5559
5586
|
*/
|
|
5560
|
-
this.clear = function (clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5587
|
+
this.clear = function (requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5561
5588
|
var _this = this;
|
|
5562
5589
|
return __generator(this, function (_a) {
|
|
5563
5590
|
switch (_a.label) {
|
|
5564
5591
|
case 0:
|
|
5565
5592
|
this.loggerService.log("storagePublicService clear", {
|
|
5593
|
+
requestId: requestId,
|
|
5566
5594
|
clientId: clientId,
|
|
5567
5595
|
storageName: storageName,
|
|
5568
5596
|
});
|
|
@@ -5574,6 +5602,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5574
5602
|
}
|
|
5575
5603
|
});
|
|
5576
5604
|
}); }, {
|
|
5605
|
+
requestId: requestId,
|
|
5577
5606
|
clientId: clientId,
|
|
5578
5607
|
storageName: storageName,
|
|
5579
5608
|
agentName: "",
|
|
@@ -5590,7 +5619,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5590
5619
|
* @param {StorageName} storageName - The storage name.
|
|
5591
5620
|
* @returns {Promise<void>}
|
|
5592
5621
|
*/
|
|
5593
|
-
this.dispose = function (clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5622
|
+
this.dispose = function (requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5594
5623
|
var _this = this;
|
|
5595
5624
|
return __generator(this, function (_a) {
|
|
5596
5625
|
switch (_a.label) {
|
|
@@ -5607,6 +5636,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5607
5636
|
}
|
|
5608
5637
|
});
|
|
5609
5638
|
}); }, {
|
|
5639
|
+
requestId: requestId,
|
|
5610
5640
|
clientId: clientId,
|
|
5611
5641
|
storageName: storageName,
|
|
5612
5642
|
agentName: "",
|
|
@@ -6035,9 +6065,7 @@ var StateConnectionService = /** @class */ (function () {
|
|
|
6035
6065
|
return __generator(this, function (_a) {
|
|
6036
6066
|
switch (_a.label) {
|
|
6037
6067
|
case 0:
|
|
6038
|
-
this.loggerService.log("stateConnectionService setState"
|
|
6039
|
-
context: this.contextService.context,
|
|
6040
|
-
});
|
|
6068
|
+
this.loggerService.log("stateConnectionService setState");
|
|
6041
6069
|
state = this.getStateRef(this.contextService.context.clientId, this.contextService.context.stateName);
|
|
6042
6070
|
return [4 /*yield*/, state.waitForInit()];
|
|
6043
6071
|
case 1:
|
|
@@ -6056,9 +6084,7 @@ var StateConnectionService = /** @class */ (function () {
|
|
|
6056
6084
|
return __generator(this, function (_a) {
|
|
6057
6085
|
switch (_a.label) {
|
|
6058
6086
|
case 0:
|
|
6059
|
-
this.loggerService.log("stateConnectionService getState"
|
|
6060
|
-
context: this.contextService.context,
|
|
6061
|
-
});
|
|
6087
|
+
this.loggerService.log("stateConnectionService getState");
|
|
6062
6088
|
state = this.getStateRef(this.contextService.context.clientId, this.contextService.context.stateName);
|
|
6063
6089
|
return [4 /*yield*/, state.waitForInit()];
|
|
6064
6090
|
case 1:
|
|
@@ -6077,9 +6103,7 @@ var StateConnectionService = /** @class */ (function () {
|
|
|
6077
6103
|
return __generator(this, function (_a) {
|
|
6078
6104
|
switch (_a.label) {
|
|
6079
6105
|
case 0:
|
|
6080
|
-
this.loggerService.log("stateConnectionService dispose"
|
|
6081
|
-
context: this.contextService.context,
|
|
6082
|
-
});
|
|
6106
|
+
this.loggerService.log("stateConnectionService dispose");
|
|
6083
6107
|
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.stateName);
|
|
6084
6108
|
if (!this.getStateRef.has(key)) {
|
|
6085
6109
|
return [2 /*return*/];
|
|
@@ -6116,12 +6140,13 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6116
6140
|
* @param {StateName} stateName - The name of the state.
|
|
6117
6141
|
* @returns {Promise<T>} - The updated state.
|
|
6118
6142
|
*/
|
|
6119
|
-
this.setState = function (dispatchFn, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
6143
|
+
this.setState = function (dispatchFn, requestId, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
6120
6144
|
var _this = this;
|
|
6121
6145
|
return __generator(this, function (_a) {
|
|
6122
6146
|
switch (_a.label) {
|
|
6123
6147
|
case 0:
|
|
6124
6148
|
this.loggerService.log("statePublicService setState", {
|
|
6149
|
+
requestId: requestId,
|
|
6125
6150
|
clientId: clientId,
|
|
6126
6151
|
stateName: stateName,
|
|
6127
6152
|
});
|
|
@@ -6133,6 +6158,7 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6133
6158
|
}
|
|
6134
6159
|
});
|
|
6135
6160
|
}); }, {
|
|
6161
|
+
requestId: requestId,
|
|
6136
6162
|
clientId: clientId,
|
|
6137
6163
|
stateName: stateName,
|
|
6138
6164
|
agentName: "",
|
|
@@ -6149,7 +6175,7 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6149
6175
|
* @param {StateName} stateName - The name of the state.
|
|
6150
6176
|
* @returns {Promise<T>} - The current state.
|
|
6151
6177
|
*/
|
|
6152
|
-
this.getState = function (clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
6178
|
+
this.getState = function (requestId, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
6153
6179
|
var _this = this;
|
|
6154
6180
|
return __generator(this, function (_a) {
|
|
6155
6181
|
switch (_a.label) {
|
|
@@ -6166,6 +6192,7 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6166
6192
|
}
|
|
6167
6193
|
});
|
|
6168
6194
|
}); }, {
|
|
6195
|
+
requestId: requestId,
|
|
6169
6196
|
clientId: clientId,
|
|
6170
6197
|
stateName: stateName,
|
|
6171
6198
|
agentName: "",
|
|
@@ -6182,12 +6209,13 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6182
6209
|
* @param {StateName} stateName - The name of the state.
|
|
6183
6210
|
* @returns {Promise<void>} - A promise that resolves when the state is disposed.
|
|
6184
6211
|
*/
|
|
6185
|
-
this.dispose = function (clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
6212
|
+
this.dispose = function (requestId, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
6186
6213
|
var _this = this;
|
|
6187
6214
|
return __generator(this, function (_a) {
|
|
6188
6215
|
switch (_a.label) {
|
|
6189
6216
|
case 0:
|
|
6190
6217
|
this.loggerService.log("statePublicService dispose", {
|
|
6218
|
+
requestId: requestId,
|
|
6191
6219
|
clientId: clientId,
|
|
6192
6220
|
stateName: stateName,
|
|
6193
6221
|
});
|
|
@@ -6199,6 +6227,7 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6199
6227
|
}
|
|
6200
6228
|
});
|
|
6201
6229
|
}); }, {
|
|
6230
|
+
requestId: requestId,
|
|
6202
6231
|
clientId: clientId,
|
|
6203
6232
|
stateName: stateName,
|
|
6204
6233
|
agentName: "",
|
|
@@ -6239,7 +6268,7 @@ var BusService = /** @class */ (function () {
|
|
|
6239
6268
|
_this._eventWildcardMap.set(source, true);
|
|
6240
6269
|
}
|
|
6241
6270
|
_this._eventSourceSet.add(source);
|
|
6242
|
-
_this.getEventSubject(clientId, source).subscribe(fn);
|
|
6271
|
+
return _this.getEventSubject(clientId, source).subscribe(fn);
|
|
6243
6272
|
};
|
|
6244
6273
|
/**
|
|
6245
6274
|
* Subscribes to a single event for a specific client and source.
|
|
@@ -6536,20 +6565,22 @@ var addStorage = function (storageSchema) {
|
|
|
6536
6565
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
6537
6566
|
*/
|
|
6538
6567
|
var commitUserMessage = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6539
|
-
var swarmName, currentAgentName;
|
|
6568
|
+
var requestId, swarmName, currentAgentName;
|
|
6540
6569
|
return __generator(this, function (_a) {
|
|
6541
6570
|
switch (_a.label) {
|
|
6542
6571
|
case 0:
|
|
6572
|
+
requestId = functoolsKit.randomString();
|
|
6543
6573
|
swarm.loggerService.log('function commitSystemMessage', {
|
|
6544
6574
|
content: content,
|
|
6545
6575
|
clientId: clientId,
|
|
6546
6576
|
agentName: agentName,
|
|
6577
|
+
requestId: requestId,
|
|
6547
6578
|
});
|
|
6548
6579
|
swarm.agentValidationService.validate(agentName, "commitUserMessage");
|
|
6549
6580
|
swarm.sessionValidationService.validate(clientId, "commitUserMessage");
|
|
6550
6581
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
6551
6582
|
swarm.swarmValidationService.validate(swarmName, "commitUserMessage");
|
|
6552
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
6583
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
6553
6584
|
case 1:
|
|
6554
6585
|
currentAgentName = _a.sent();
|
|
6555
6586
|
if (currentAgentName !== agentName) {
|
|
@@ -6560,7 +6591,7 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
|
|
|
6560
6591
|
});
|
|
6561
6592
|
return [2 /*return*/];
|
|
6562
6593
|
}
|
|
6563
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, clientId, swarmName)];
|
|
6594
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, requestId, clientId, swarmName)];
|
|
6564
6595
|
case 2:
|
|
6565
6596
|
_a.sent();
|
|
6566
6597
|
return [2 /*return*/];
|
|
@@ -6576,17 +6607,19 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
|
|
|
6576
6607
|
* @throws Will throw an error if the client ID is invalid or if the swarm validation fails.
|
|
6577
6608
|
*/
|
|
6578
6609
|
var getAgentName = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6579
|
-
var swarmName;
|
|
6610
|
+
var requestId, swarmName;
|
|
6580
6611
|
return __generator(this, function (_a) {
|
|
6581
6612
|
switch (_a.label) {
|
|
6582
6613
|
case 0:
|
|
6614
|
+
requestId = functoolsKit.randomString();
|
|
6583
6615
|
swarm.loggerService.log("function getAgentName", {
|
|
6584
6616
|
clientId: clientId,
|
|
6617
|
+
requestId: requestId,
|
|
6585
6618
|
});
|
|
6586
6619
|
swarm.sessionValidationService.validate(clientId, "getAgentName");
|
|
6587
6620
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
6588
6621
|
swarm.swarmValidationService.validate(swarmName, "getAgentName");
|
|
6589
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
6622
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
6590
6623
|
case 1: return [2 /*return*/, _a.sent()];
|
|
6591
6624
|
}
|
|
6592
6625
|
});
|
|
@@ -6602,13 +6635,15 @@ var SCHEDULED_DELAY$1 = 1000;
|
|
|
6602
6635
|
* @returns {SendMessageFn} - A function to send messages to the swarm.
|
|
6603
6636
|
*/
|
|
6604
6637
|
var makeConnection = function (connector, clientId, swarmName) {
|
|
6638
|
+
var requestId = functoolsKit.randomString();
|
|
6605
6639
|
swarm.loggerService.log("function makeConnection", {
|
|
6606
6640
|
clientId: clientId,
|
|
6607
6641
|
swarmName: swarmName,
|
|
6642
|
+
requestId: requestId,
|
|
6608
6643
|
});
|
|
6609
6644
|
swarm.swarmValidationService.validate(swarmName, "makeConnection");
|
|
6610
6645
|
swarm.sessionValidationService.addSession(clientId, swarmName, "makeConnection");
|
|
6611
|
-
var send = swarm.sessionPublicService.connect(connector, clientId, swarmName);
|
|
6646
|
+
var send = swarm.sessionPublicService.connect(connector, requestId, clientId, swarmName);
|
|
6612
6647
|
return functoolsKit.queued(function (outgoing) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6613
6648
|
var _a;
|
|
6614
6649
|
var _b;
|
|
@@ -6620,7 +6655,7 @@ var makeConnection = function (connector, clientId, swarmName) {
|
|
|
6620
6655
|
_b = {
|
|
6621
6656
|
data: outgoing
|
|
6622
6657
|
};
|
|
6623
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
6658
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
6624
6659
|
case 1: return [4 /*yield*/, _a.apply(void 0, [(_b.agentName = _c.sent(),
|
|
6625
6660
|
_b.clientId = clientId,
|
|
6626
6661
|
_b)])];
|
|
@@ -6723,7 +6758,7 @@ var CHANGE_AGENT_GC = 60 * 1000;
|
|
|
6723
6758
|
* @returns {TChangeAgentRun} - The change agent function.
|
|
6724
6759
|
*/
|
|
6725
6760
|
var createChangeAgent = functoolsKit.ttl(function (clientId) {
|
|
6726
|
-
return functoolsKit.queued(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6761
|
+
return functoolsKit.queued(function (requestId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6727
6762
|
var swarmName, _a, _b, _c;
|
|
6728
6763
|
return __generator(this, function (_d) {
|
|
6729
6764
|
switch (_d.label) {
|
|
@@ -6736,7 +6771,7 @@ var createChangeAgent = functoolsKit.ttl(function (clientId) {
|
|
|
6736
6771
|
.map(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6737
6772
|
return __generator(this, function (_a) {
|
|
6738
6773
|
switch (_a.label) {
|
|
6739
|
-
case 0: return [4 /*yield*/, swarm.agentPublicService.commitAgentChange(clientId, agentName)];
|
|
6774
|
+
case 0: return [4 /*yield*/, swarm.agentPublicService.commitAgentChange(requestId, clientId, agentName)];
|
|
6740
6775
|
case 1:
|
|
6741
6776
|
_a.sent();
|
|
6742
6777
|
return [2 /*return*/];
|
|
@@ -6745,21 +6780,22 @@ var createChangeAgent = functoolsKit.ttl(function (clientId) {
|
|
|
6745
6780
|
}); }))];
|
|
6746
6781
|
case 1:
|
|
6747
6782
|
_d.sent();
|
|
6748
|
-
return [4 /*yield*/, swarm.agentPublicService.dispose(clientId, agentName)];
|
|
6783
|
+
return [4 /*yield*/, swarm.agentPublicService.dispose(requestId, clientId, agentName)];
|
|
6749
6784
|
case 2:
|
|
6750
6785
|
_d.sent();
|
|
6751
|
-
return [4 /*yield*/, swarm.historyPublicService.dispose(clientId, agentName)];
|
|
6786
|
+
return [4 /*yield*/, swarm.historyPublicService.dispose(requestId, clientId, agentName)];
|
|
6752
6787
|
case 3:
|
|
6753
6788
|
_d.sent();
|
|
6754
6789
|
_b = (_a = swarm.swarmPublicService).setAgentRef;
|
|
6755
|
-
_c = [
|
|
6790
|
+
_c = [requestId,
|
|
6791
|
+
clientId,
|
|
6756
6792
|
swarmName,
|
|
6757
6793
|
agentName];
|
|
6758
|
-
return [4 /*yield*/, swarm.agentPublicService.createAgentRef(clientId, agentName)];
|
|
6794
|
+
return [4 /*yield*/, swarm.agentPublicService.createAgentRef(requestId, clientId, agentName)];
|
|
6759
6795
|
case 4: return [4 /*yield*/, _b.apply(_a, _c.concat([_d.sent()]))];
|
|
6760
6796
|
case 5:
|
|
6761
6797
|
_d.sent();
|
|
6762
|
-
return [4 /*yield*/, swarm.swarmPublicService.setAgentName(agentName, clientId, swarmName)];
|
|
6798
|
+
return [4 /*yield*/, swarm.swarmPublicService.setAgentName(agentName, requestId, clientId, swarmName)];
|
|
6763
6799
|
case 6:
|
|
6764
6800
|
_d.sent();
|
|
6765
6801
|
return [2 /*return*/];
|
|
@@ -6793,10 +6829,11 @@ var createGc$1 = functoolsKit.singleshot(function () { return __awaiter(void 0,
|
|
|
6793
6829
|
* @returns {Promise<void>} - A promise that resolves when the agent is changed.
|
|
6794
6830
|
*/
|
|
6795
6831
|
var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6796
|
-
var run;
|
|
6832
|
+
var requestId, run;
|
|
6797
6833
|
return __generator(this, function (_a) {
|
|
6798
6834
|
switch (_a.label) {
|
|
6799
6835
|
case 0:
|
|
6836
|
+
requestId = functoolsKit.randomString();
|
|
6800
6837
|
swarm.loggerService.log("function changeAgent", {
|
|
6801
6838
|
agentName: agentName,
|
|
6802
6839
|
clientId: clientId,
|
|
@@ -6805,7 +6842,7 @@ var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void
|
|
|
6805
6842
|
case 1:
|
|
6806
6843
|
run = _a.sent();
|
|
6807
6844
|
createGc$1();
|
|
6808
|
-
return [4 /*yield*/, run(agentName)];
|
|
6845
|
+
return [4 /*yield*/, run(requestId, agentName)];
|
|
6809
6846
|
case 2: return [2 /*return*/, _a.sent()];
|
|
6810
6847
|
}
|
|
6811
6848
|
});
|
|
@@ -6818,83 +6855,91 @@ var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void
|
|
|
6818
6855
|
* @param {SwarmName} swarmName - The name of the swarm.
|
|
6819
6856
|
* @returns {Promise<void>} A promise that resolves when the connection is disposed.
|
|
6820
6857
|
*/
|
|
6821
|
-
var disposeConnection = function (
|
|
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
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6858
|
+
var disposeConnection = function (clientId_1, swarmName_1) {
|
|
6859
|
+
var args_1 = [];
|
|
6860
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
6861
|
+
args_1[_i - 2] = arguments[_i];
|
|
6862
|
+
}
|
|
6863
|
+
return __awaiter(void 0, __spreadArray([clientId_1, swarmName_1], __read(args_1), false), void 0, function (clientId, swarmName, requestId) {
|
|
6864
|
+
if (requestId === void 0) { requestId = functoolsKit.randomString(); }
|
|
6865
|
+
return __generator(this, function (_a) {
|
|
6866
|
+
switch (_a.label) {
|
|
6867
|
+
case 0:
|
|
6868
|
+
swarm.loggerService.log("function disposeConnection", {
|
|
6869
|
+
clientId: clientId,
|
|
6870
|
+
swarmName: swarmName,
|
|
6871
|
+
requestId: requestId,
|
|
6872
|
+
});
|
|
6873
|
+
swarm.swarmValidationService.validate(swarmName, "disposeConnection");
|
|
6874
|
+
swarm.sessionValidationService.removeSession(clientId);
|
|
6875
|
+
swarm.busService.dispose(clientId);
|
|
6876
|
+
return [4 /*yield*/, swarm.sessionPublicService.dispose(requestId, clientId, swarmName)];
|
|
6877
|
+
case 1:
|
|
6878
|
+
_a.sent();
|
|
6879
|
+
return [4 /*yield*/, swarm.swarmPublicService.dispose(requestId, clientId, swarmName)];
|
|
6880
|
+
case 2:
|
|
6881
|
+
_a.sent();
|
|
6882
|
+
return [4 /*yield*/, Promise.all(swarm.swarmValidationService
|
|
6883
|
+
.getAgentList(swarmName)
|
|
6884
|
+
.map(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6885
|
+
return __generator(this, function (_a) {
|
|
6886
|
+
switch (_a.label) {
|
|
6887
|
+
case 0: return [4 /*yield*/, swarm.agentPublicService.dispose(requestId, clientId, agentName)];
|
|
6888
|
+
case 1:
|
|
6889
|
+
_a.sent();
|
|
6890
|
+
return [4 /*yield*/, swarm.historyPublicService.dispose(requestId, clientId, agentName)];
|
|
6891
|
+
case 2:
|
|
6892
|
+
_a.sent();
|
|
6893
|
+
return [2 /*return*/];
|
|
6894
|
+
}
|
|
6895
|
+
});
|
|
6896
|
+
}); }))];
|
|
6897
|
+
case 3:
|
|
6898
|
+
_a.sent();
|
|
6899
|
+
return [4 /*yield*/, Promise.all(swarm.swarmValidationService
|
|
6900
|
+
.getAgentList(swarmName)
|
|
6901
|
+
.flatMap(function (agentName) {
|
|
6902
|
+
return swarm.agentValidationService.getStorageList(agentName);
|
|
6903
|
+
})
|
|
6904
|
+
.filter(function (storageName) { return !!storageName; })
|
|
6905
|
+
.map(function (storageName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6906
|
+
return __generator(this, function (_a) {
|
|
6907
|
+
switch (_a.label) {
|
|
6908
|
+
case 0: return [4 /*yield*/, swarm.storagePublicService.dispose(requestId, clientId, storageName)];
|
|
6909
|
+
case 1:
|
|
6910
|
+
_a.sent();
|
|
6911
|
+
return [2 /*return*/];
|
|
6912
|
+
}
|
|
6913
|
+
});
|
|
6914
|
+
}); }))];
|
|
6915
|
+
case 4:
|
|
6916
|
+
_a.sent();
|
|
6917
|
+
return [4 /*yield*/, Promise.all(swarm.swarmValidationService
|
|
6918
|
+
.getAgentList(swarmName)
|
|
6919
|
+
.flatMap(function (agentName) {
|
|
6920
|
+
return swarm.agentValidationService.getStateList(agentName);
|
|
6921
|
+
})
|
|
6922
|
+
.filter(function (stateName) { return !!stateName; })
|
|
6923
|
+
.map(function (stateName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6924
|
+
return __generator(this, function (_a) {
|
|
6925
|
+
switch (_a.label) {
|
|
6926
|
+
case 0: return [4 /*yield*/, swarm.statePublicService.dispose(requestId, clientId, stateName)];
|
|
6927
|
+
case 1:
|
|
6928
|
+
_a.sent();
|
|
6929
|
+
return [2 /*return*/];
|
|
6930
|
+
}
|
|
6931
|
+
});
|
|
6932
|
+
}); }))];
|
|
6933
|
+
case 5:
|
|
6934
|
+
_a.sent();
|
|
6935
|
+
return [4 /*yield*/, HistoryAdapter.dispose(clientId, null)];
|
|
6936
|
+
case 6:
|
|
6937
|
+
_a.sent();
|
|
6938
|
+
return [2 /*return*/];
|
|
6939
|
+
}
|
|
6940
|
+
});
|
|
6896
6941
|
});
|
|
6897
|
-
}
|
|
6942
|
+
};
|
|
6898
6943
|
|
|
6899
6944
|
var COMPLETE_TTL = 15 * 60 * 1000;
|
|
6900
6945
|
var COMPLETE_GC = 60 * 1000;
|
|
@@ -6905,17 +6950,17 @@ var COMPLETE_GC = 60 * 1000;
|
|
|
6905
6950
|
* @returns {TCompleteRun} The complete run function.
|
|
6906
6951
|
*/
|
|
6907
6952
|
var createComplete = functoolsKit.ttl(function (clientId, swarmName) {
|
|
6908
|
-
return functoolsKit.queued(function (content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6953
|
+
return functoolsKit.queued(function (requestId, content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6909
6954
|
var result;
|
|
6910
6955
|
return __generator(this, function (_a) {
|
|
6911
6956
|
switch (_a.label) {
|
|
6912
6957
|
case 0:
|
|
6913
6958
|
swarm.swarmValidationService.validate(swarmName, "complete");
|
|
6914
6959
|
swarm.sessionValidationService.addSession(clientId, swarmName, "complete");
|
|
6915
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", clientId, swarmName)];
|
|
6960
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", requestId, clientId, swarmName)];
|
|
6916
6961
|
case 1:
|
|
6917
6962
|
result = _a.sent();
|
|
6918
|
-
return [4 /*yield*/, disposeConnection(clientId, swarmName)];
|
|
6963
|
+
return [4 /*yield*/, disposeConnection(clientId, swarmName, requestId)];
|
|
6919
6964
|
case 2:
|
|
6920
6965
|
_a.sent();
|
|
6921
6966
|
return [2 /*return*/, result];
|
|
@@ -6949,20 +6994,22 @@ var createGc = functoolsKit.singleshot(function () { return __awaiter(void 0, vo
|
|
|
6949
6994
|
* @returns {Promise<string>} The result of the complete function.
|
|
6950
6995
|
*/
|
|
6951
6996
|
var complete = function (content, clientId, swarmName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6952
|
-
var run;
|
|
6997
|
+
var requestId, run;
|
|
6953
6998
|
return __generator(this, function (_a) {
|
|
6954
6999
|
switch (_a.label) {
|
|
6955
7000
|
case 0:
|
|
7001
|
+
requestId = functoolsKit.randomString();
|
|
6956
7002
|
swarm.loggerService.log("function complete", {
|
|
6957
7003
|
content: content,
|
|
6958
7004
|
clientId: clientId,
|
|
6959
7005
|
swarmName: swarmName,
|
|
7006
|
+
requestId: requestId,
|
|
6960
7007
|
});
|
|
6961
7008
|
return [4 /*yield*/, createComplete(clientId, swarmName)];
|
|
6962
7009
|
case 1:
|
|
6963
7010
|
run = _a.sent();
|
|
6964
7011
|
createGc();
|
|
6965
|
-
return [4 /*yield*/, run(content)];
|
|
7012
|
+
return [4 /*yield*/, run(requestId, content)];
|
|
6966
7013
|
case 2: return [2 /*return*/, _a.sent()];
|
|
6967
7014
|
}
|
|
6968
7015
|
});
|
|
@@ -6979,9 +7026,11 @@ var SCHEDULED_DELAY = 1000;
|
|
|
6979
7026
|
* @returns {Function} dispose - A function to dispose of the session.
|
|
6980
7027
|
*/
|
|
6981
7028
|
var session = function (clientId, swarmName) {
|
|
7029
|
+
var requestId = functoolsKit.randomString();
|
|
6982
7030
|
swarm.loggerService.log("function session", {
|
|
6983
7031
|
clientId: clientId,
|
|
6984
7032
|
swarmName: swarmName,
|
|
7033
|
+
requestId: requestId,
|
|
6985
7034
|
});
|
|
6986
7035
|
swarm.swarmValidationService.validate(swarmName, "session");
|
|
6987
7036
|
swarm.sessionValidationService.addSession(clientId, swarmName, "session");
|
|
@@ -6997,7 +7046,7 @@ var session = function (clientId, swarmName) {
|
|
|
6997
7046
|
switch (_a.label) {
|
|
6998
7047
|
case 0:
|
|
6999
7048
|
swarm.sessionValidationService.validate(clientId, "session");
|
|
7000
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", clientId, swarmName)];
|
|
7049
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", requestId, clientId, swarmName)];
|
|
7001
7050
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7002
7051
|
}
|
|
7003
7052
|
});
|
|
@@ -7010,7 +7059,7 @@ var session = function (clientId, swarmName) {
|
|
|
7010
7059
|
dispose: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
7011
7060
|
return __generator(this, function (_a) {
|
|
7012
7061
|
switch (_a.label) {
|
|
7013
|
-
case 0: return [4 /*yield*/, disposeConnection(clientId, swarmName)];
|
|
7062
|
+
case 0: return [4 /*yield*/, disposeConnection(clientId, swarmName, requestId)];
|
|
7014
7063
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7015
7064
|
}
|
|
7016
7065
|
});
|
|
@@ -7115,27 +7164,35 @@ session.scheduled = function (clientId, swarmName, _a) {
|
|
|
7115
7164
|
* @param {string} clientId - The ID of the client whose history is to be retrieved.
|
|
7116
7165
|
* @returns {Promise<Array>} A promise that resolves to an array containing the raw history.
|
|
7117
7166
|
*/
|
|
7118
|
-
var getRawHistory = function (
|
|
7119
|
-
var
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7167
|
+
var getRawHistory = function (clientId_1) {
|
|
7168
|
+
var args_1 = [];
|
|
7169
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7170
|
+
args_1[_i - 1] = arguments[_i];
|
|
7171
|
+
}
|
|
7172
|
+
return __awaiter(void 0, __spreadArray([clientId_1], __read(args_1), false), void 0, function (clientId, requestId) {
|
|
7173
|
+
var swarmName, agentName, history;
|
|
7174
|
+
if (requestId === void 0) { requestId = functoolsKit.randomString(); }
|
|
7175
|
+
return __generator(this, function (_a) {
|
|
7176
|
+
switch (_a.label) {
|
|
7177
|
+
case 0:
|
|
7178
|
+
swarm.loggerService.log("function getRawHistory", {
|
|
7179
|
+
clientId: clientId,
|
|
7180
|
+
requestId: requestId,
|
|
7181
|
+
});
|
|
7182
|
+
swarm.sessionValidationService.validate(clientId, "getRawHistory");
|
|
7183
|
+
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7184
|
+
swarm.swarmValidationService.validate(swarmName, "getRawHistory");
|
|
7185
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7186
|
+
case 1:
|
|
7187
|
+
agentName = _a.sent();
|
|
7188
|
+
return [4 /*yield*/, swarm.historyPublicService.toArrayForRaw(requestId, clientId, agentName)];
|
|
7189
|
+
case 2:
|
|
7190
|
+
history = _a.sent();
|
|
7191
|
+
return [2 /*return*/, __spreadArray([], __read(history), false)];
|
|
7192
|
+
}
|
|
7193
|
+
});
|
|
7137
7194
|
});
|
|
7138
|
-
}
|
|
7195
|
+
};
|
|
7139
7196
|
|
|
7140
7197
|
/**
|
|
7141
7198
|
* Retrieves the history prepared for a specific agent with resque algorithm tweaks
|
|
@@ -7145,17 +7202,19 @@ var getRawHistory = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
7145
7202
|
* @returns {Promise<Array>} - A promise that resolves to an array containing the agent's history.
|
|
7146
7203
|
*/
|
|
7147
7204
|
var getAgentHistory = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7148
|
-
var prompt, history;
|
|
7205
|
+
var requestId, prompt, history;
|
|
7149
7206
|
return __generator(this, function (_a) {
|
|
7150
7207
|
switch (_a.label) {
|
|
7151
7208
|
case 0:
|
|
7209
|
+
requestId = functoolsKit.randomString();
|
|
7152
7210
|
swarm.loggerService.log("function getAgentHistory", {
|
|
7153
7211
|
clientId: clientId,
|
|
7154
7212
|
agentName: agentName,
|
|
7213
|
+
requestId: requestId,
|
|
7155
7214
|
});
|
|
7156
7215
|
swarm.agentValidationService.validate(agentName, "getAgentHistory");
|
|
7157
7216
|
prompt = swarm.agentSchemaService.get(agentName).prompt;
|
|
7158
|
-
return [4 /*yield*/, swarm.historyPublicService.toArrayForAgent(prompt, clientId, agentName)];
|
|
7217
|
+
return [4 /*yield*/, swarm.historyPublicService.toArrayForAgent(prompt, requestId, clientId, agentName)];
|
|
7159
7218
|
case 1:
|
|
7160
7219
|
history = _a.sent();
|
|
7161
7220
|
return [2 /*return*/, __spreadArray([], __read(history), false)];
|
|
@@ -7189,21 +7248,23 @@ var getSessionMode = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
7189
7248
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
7190
7249
|
*/
|
|
7191
7250
|
var commitToolOutput = function (toolId, content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7192
|
-
var swarmName, currentAgentName;
|
|
7251
|
+
var requestId, swarmName, currentAgentName;
|
|
7193
7252
|
return __generator(this, function (_a) {
|
|
7194
7253
|
switch (_a.label) {
|
|
7195
7254
|
case 0:
|
|
7255
|
+
requestId = functoolsKit.randomString();
|
|
7196
7256
|
swarm.loggerService.log('function commitToolOutput', {
|
|
7197
7257
|
toolId: toolId,
|
|
7198
7258
|
content: content,
|
|
7199
7259
|
clientId: clientId,
|
|
7200
7260
|
agentName: agentName,
|
|
7261
|
+
requestId: requestId,
|
|
7201
7262
|
});
|
|
7202
7263
|
swarm.agentValidationService.validate(agentName, "commitSystemMessage");
|
|
7203
7264
|
swarm.sessionValidationService.validate(clientId, "commitToolOutput");
|
|
7204
7265
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7205
7266
|
swarm.swarmValidationService.validate(swarmName, "commitToolOutput");
|
|
7206
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7267
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7207
7268
|
case 1:
|
|
7208
7269
|
currentAgentName = _a.sent();
|
|
7209
7270
|
if (currentAgentName !== agentName) {
|
|
@@ -7215,7 +7276,7 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
|
|
|
7215
7276
|
});
|
|
7216
7277
|
return [2 /*return*/];
|
|
7217
7278
|
}
|
|
7218
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, clientId, swarmName)];
|
|
7279
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, requestId, clientId, swarmName)];
|
|
7219
7280
|
case 2:
|
|
7220
7281
|
_a.sent();
|
|
7221
7282
|
return [2 /*return*/];
|
|
@@ -7232,20 +7293,22 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
|
|
|
7232
7293
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7233
7294
|
*/
|
|
7234
7295
|
var commitSystemMessage = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7235
|
-
var swarmName, currentAgentName;
|
|
7296
|
+
var requestId, swarmName, currentAgentName;
|
|
7236
7297
|
return __generator(this, function (_a) {
|
|
7237
7298
|
switch (_a.label) {
|
|
7238
7299
|
case 0:
|
|
7300
|
+
requestId = functoolsKit.randomString();
|
|
7239
7301
|
swarm.loggerService.log('function commitSystemMessage', {
|
|
7240
7302
|
content: content,
|
|
7241
7303
|
clientId: clientId,
|
|
7242
7304
|
agentName: agentName,
|
|
7305
|
+
requestId: requestId,
|
|
7243
7306
|
});
|
|
7244
7307
|
swarm.agentValidationService.validate(agentName, "commitSystemMessage");
|
|
7245
7308
|
swarm.sessionValidationService.validate(clientId, "commitSystemMessage");
|
|
7246
7309
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7247
7310
|
swarm.swarmValidationService.validate(swarmName, "commitSystemMessage");
|
|
7248
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7311
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7249
7312
|
case 1:
|
|
7250
7313
|
currentAgentName = _a.sent();
|
|
7251
7314
|
if (currentAgentName !== agentName) {
|
|
@@ -7256,7 +7319,7 @@ var commitSystemMessage = function (content, clientId, agentName) { return __awa
|
|
|
7256
7319
|
});
|
|
7257
7320
|
return [2 /*return*/];
|
|
7258
7321
|
}
|
|
7259
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, clientId, swarmName)];
|
|
7322
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, requestId, clientId, swarmName)];
|
|
7260
7323
|
case 2:
|
|
7261
7324
|
_a.sent();
|
|
7262
7325
|
return [2 /*return*/];
|
|
@@ -7272,19 +7335,21 @@ var commitSystemMessage = function (content, clientId, agentName) { return __awa
|
|
|
7272
7335
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7273
7336
|
*/
|
|
7274
7337
|
var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7275
|
-
var swarmName, currentAgentName;
|
|
7338
|
+
var requestId, swarmName, currentAgentName;
|
|
7276
7339
|
return __generator(this, function (_a) {
|
|
7277
7340
|
switch (_a.label) {
|
|
7278
7341
|
case 0:
|
|
7342
|
+
requestId = functoolsKit.randomString();
|
|
7279
7343
|
swarm.loggerService.log('function commitFlush', {
|
|
7280
7344
|
clientId: clientId,
|
|
7281
7345
|
agentName: agentName,
|
|
7346
|
+
requestId: requestId,
|
|
7282
7347
|
});
|
|
7283
7348
|
swarm.agentValidationService.validate(agentName, "commitFlush");
|
|
7284
7349
|
swarm.sessionValidationService.validate(clientId, "commitFlush");
|
|
7285
7350
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7286
7351
|
swarm.swarmValidationService.validate(swarmName, "commitFlush");
|
|
7287
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7352
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7288
7353
|
case 1:
|
|
7289
7354
|
currentAgentName = _a.sent();
|
|
7290
7355
|
if (currentAgentName !== agentName) {
|
|
@@ -7295,7 +7360,7 @@ var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void
|
|
|
7295
7360
|
});
|
|
7296
7361
|
return [2 /*return*/];
|
|
7297
7362
|
}
|
|
7298
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitFlush(clientId, swarmName)];
|
|
7363
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitFlush(requestId, clientId, swarmName)];
|
|
7299
7364
|
case 2:
|
|
7300
7365
|
_a.sent();
|
|
7301
7366
|
return [2 /*return*/];
|
|
@@ -7313,20 +7378,22 @@ var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void
|
|
|
7313
7378
|
* @returns {Promise<void>} - A promise that resolves when the execution is complete.
|
|
7314
7379
|
*/
|
|
7315
7380
|
var execute = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7316
|
-
var swarmName, currentAgentName;
|
|
7381
|
+
var requestId, swarmName, currentAgentName;
|
|
7317
7382
|
return __generator(this, function (_a) {
|
|
7318
7383
|
switch (_a.label) {
|
|
7319
7384
|
case 0:
|
|
7385
|
+
requestId = functoolsKit.randomString();
|
|
7320
7386
|
swarm.loggerService.log("function execute", {
|
|
7321
7387
|
content: content,
|
|
7322
7388
|
clientId: clientId,
|
|
7323
7389
|
agentName: agentName,
|
|
7390
|
+
requestId: requestId,
|
|
7324
7391
|
});
|
|
7325
7392
|
swarm.agentValidationService.validate(agentName, "execute");
|
|
7326
7393
|
swarm.sessionValidationService.validate(clientId, "execute");
|
|
7327
7394
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7328
7395
|
swarm.swarmValidationService.validate(swarmName, "execute");
|
|
7329
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7396
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7330
7397
|
case 1:
|
|
7331
7398
|
currentAgentName = _a.sent();
|
|
7332
7399
|
if (currentAgentName !== agentName) {
|
|
@@ -7337,7 +7404,7 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
|
|
|
7337
7404
|
});
|
|
7338
7405
|
return [2 /*return*/];
|
|
7339
7406
|
}
|
|
7340
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", clientId, swarmName)];
|
|
7407
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", requestId, clientId, swarmName)];
|
|
7341
7408
|
case 2: return [2 /*return*/, _a.sent()];
|
|
7342
7409
|
}
|
|
7343
7410
|
});
|
|
@@ -7354,14 +7421,16 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
|
|
|
7354
7421
|
* @returns {Promise<void>} A promise that resolves when the content is emitted.
|
|
7355
7422
|
*/
|
|
7356
7423
|
var emit = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7357
|
-
var swarmName, currentAgentName;
|
|
7424
|
+
var requestId, swarmName, currentAgentName;
|
|
7358
7425
|
return __generator(this, function (_a) {
|
|
7359
7426
|
switch (_a.label) {
|
|
7360
7427
|
case 0:
|
|
7428
|
+
requestId = functoolsKit.randomString();
|
|
7361
7429
|
swarm.loggerService.log("function emit", {
|
|
7362
7430
|
content: content,
|
|
7363
7431
|
clientId: clientId,
|
|
7364
7432
|
agentName: agentName,
|
|
7433
|
+
requestId: requestId,
|
|
7365
7434
|
});
|
|
7366
7435
|
if (swarm.sessionValidationService.getSessionMode(clientId) !== "makeConnection") {
|
|
7367
7436
|
throw new Error("agent-swarm-kit emit session is not makeConnection clientId=".concat(clientId));
|
|
@@ -7370,7 +7439,7 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
|
|
|
7370
7439
|
swarm.sessionValidationService.validate(clientId, "emit");
|
|
7371
7440
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7372
7441
|
swarm.swarmValidationService.validate(swarmName, "emit");
|
|
7373
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7442
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7374
7443
|
case 1:
|
|
7375
7444
|
currentAgentName = _a.sent();
|
|
7376
7445
|
if (currentAgentName !== agentName) {
|
|
@@ -7381,7 +7450,7 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
|
|
|
7381
7450
|
});
|
|
7382
7451
|
return [2 /*return*/];
|
|
7383
7452
|
}
|
|
7384
|
-
return [4 /*yield*/, swarm.sessionPublicService.emit(content, clientId, swarmName)];
|
|
7453
|
+
return [4 /*yield*/, swarm.sessionPublicService.emit(content, requestId, clientId, swarmName)];
|
|
7385
7454
|
case 2: return [2 /*return*/, _a.sent()];
|
|
7386
7455
|
}
|
|
7387
7456
|
});
|
|
@@ -7395,19 +7464,21 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
|
|
|
7395
7464
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
7396
7465
|
*/
|
|
7397
7466
|
var commitToolOutputForce = function (toolId, content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7398
|
-
var swarmName;
|
|
7467
|
+
var requestId, swarmName;
|
|
7399
7468
|
return __generator(this, function (_a) {
|
|
7400
7469
|
switch (_a.label) {
|
|
7401
7470
|
case 0:
|
|
7471
|
+
requestId = functoolsKit.randomString();
|
|
7402
7472
|
swarm.loggerService.log('function commitToolOutputForce', {
|
|
7403
7473
|
toolId: toolId,
|
|
7404
7474
|
content: content,
|
|
7405
7475
|
clientId: clientId,
|
|
7476
|
+
requestId: requestId,
|
|
7406
7477
|
});
|
|
7407
7478
|
swarm.sessionValidationService.validate(clientId, "commitToolOutputForce");
|
|
7408
7479
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7409
7480
|
swarm.swarmValidationService.validate(swarmName, "commitToolOutputForce");
|
|
7410
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, clientId, swarmName)];
|
|
7481
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, requestId, clientId, swarmName)];
|
|
7411
7482
|
case 1:
|
|
7412
7483
|
_a.sent();
|
|
7413
7484
|
return [2 /*return*/];
|
|
@@ -7423,18 +7494,20 @@ var commitToolOutputForce = function (toolId, content, clientId) { return __awai
|
|
|
7423
7494
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7424
7495
|
*/
|
|
7425
7496
|
var commitSystemMessageForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7426
|
-
var swarmName;
|
|
7497
|
+
var requestId, swarmName;
|
|
7427
7498
|
return __generator(this, function (_a) {
|
|
7428
7499
|
switch (_a.label) {
|
|
7429
7500
|
case 0:
|
|
7501
|
+
requestId = functoolsKit.randomString();
|
|
7430
7502
|
swarm.loggerService.log('function commitSystemMessageForce', {
|
|
7431
7503
|
content: content,
|
|
7432
7504
|
clientId: clientId,
|
|
7505
|
+
requestId: requestId,
|
|
7433
7506
|
});
|
|
7434
7507
|
swarm.sessionValidationService.validate(clientId, "commitSystemMessageForce");
|
|
7435
7508
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7436
7509
|
swarm.swarmValidationService.validate(swarmName, "commitSystemMessageForce");
|
|
7437
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, clientId, swarmName)];
|
|
7510
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, requestId, clientId, swarmName)];
|
|
7438
7511
|
case 1:
|
|
7439
7512
|
_a.sent();
|
|
7440
7513
|
return [2 /*return*/];
|
|
@@ -7449,17 +7522,19 @@ var commitSystemMessageForce = function (content, clientId) { return __awaiter(v
|
|
|
7449
7522
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7450
7523
|
*/
|
|
7451
7524
|
var commitFlushForce = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7452
|
-
var swarmName;
|
|
7525
|
+
var requestId, swarmName;
|
|
7453
7526
|
return __generator(this, function (_a) {
|
|
7454
7527
|
switch (_a.label) {
|
|
7455
7528
|
case 0:
|
|
7529
|
+
requestId = functoolsKit.randomString();
|
|
7456
7530
|
swarm.loggerService.log('function commitFlushForce', {
|
|
7457
7531
|
clientId: clientId,
|
|
7532
|
+
requestId: requestId,
|
|
7458
7533
|
});
|
|
7459
7534
|
swarm.sessionValidationService.validate(clientId, "commitFlushForce");
|
|
7460
7535
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7461
7536
|
swarm.swarmValidationService.validate(swarmName, "commitFlushForce");
|
|
7462
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitFlush(clientId, swarmName)];
|
|
7537
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitFlush(requestId, clientId, swarmName)];
|
|
7463
7538
|
case 1:
|
|
7464
7539
|
_a.sent();
|
|
7465
7540
|
return [2 /*return*/];
|
|
@@ -7475,18 +7550,20 @@ var commitFlushForce = function (clientId) { return __awaiter(void 0, void 0, vo
|
|
|
7475
7550
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7476
7551
|
*/
|
|
7477
7552
|
var commitUserMessageForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7478
|
-
var swarmName;
|
|
7553
|
+
var requestId, swarmName;
|
|
7479
7554
|
return __generator(this, function (_a) {
|
|
7480
7555
|
switch (_a.label) {
|
|
7481
7556
|
case 0:
|
|
7557
|
+
requestId = functoolsKit.randomString();
|
|
7482
7558
|
swarm.loggerService.log('function commitSystemMessage', {
|
|
7483
7559
|
content: content,
|
|
7484
7560
|
clientId: clientId,
|
|
7561
|
+
requestId: requestId,
|
|
7485
7562
|
});
|
|
7486
7563
|
swarm.sessionValidationService.validate(clientId, "commitUserMessageForce");
|
|
7487
7564
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7488
7565
|
swarm.swarmValidationService.validate(swarmName, "commitUserMessageForce");
|
|
7489
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, clientId, swarmName)];
|
|
7566
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, requestId, clientId, swarmName)];
|
|
7490
7567
|
case 1:
|
|
7491
7568
|
_a.sent();
|
|
7492
7569
|
return [2 /*return*/];
|
|
@@ -7505,13 +7582,15 @@ var commitUserMessageForce = function (content, clientId) { return __awaiter(voi
|
|
|
7505
7582
|
* @returns {Promise<void>} A promise that resolves when the content is emitted.
|
|
7506
7583
|
*/
|
|
7507
7584
|
var emitForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7508
|
-
var swarmName;
|
|
7585
|
+
var requestId, swarmName;
|
|
7509
7586
|
return __generator(this, function (_a) {
|
|
7510
7587
|
switch (_a.label) {
|
|
7511
7588
|
case 0:
|
|
7589
|
+
requestId = functoolsKit.randomString();
|
|
7512
7590
|
swarm.loggerService.log("function emitForce", {
|
|
7513
7591
|
content: content,
|
|
7514
7592
|
clientId: clientId,
|
|
7593
|
+
requestId: requestId,
|
|
7515
7594
|
});
|
|
7516
7595
|
if (swarm.sessionValidationService.getSessionMode(clientId) !== "makeConnection") {
|
|
7517
7596
|
throw new Error("agent-swarm-kit emitForce session is not makeConnection clientId=".concat(clientId));
|
|
@@ -7519,7 +7598,7 @@ var emitForce = function (content, clientId) { return __awaiter(void 0, void 0,
|
|
|
7519
7598
|
swarm.sessionValidationService.validate(clientId, "emitForce");
|
|
7520
7599
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7521
7600
|
swarm.swarmValidationService.validate(swarmName, "emitForce");
|
|
7522
|
-
return [4 /*yield*/, swarm.sessionPublicService.emit(content, clientId, swarmName)];
|
|
7601
|
+
return [4 /*yield*/, swarm.sessionPublicService.emit(content, requestId, clientId, swarmName)];
|
|
7523
7602
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7524
7603
|
}
|
|
7525
7604
|
});
|
|
@@ -7536,24 +7615,26 @@ var emitForce = function (content, clientId) { return __awaiter(void 0, void 0,
|
|
|
7536
7615
|
* @returns {Promise<void>} - A promise that resolves when the execution is complete.
|
|
7537
7616
|
*/
|
|
7538
7617
|
var executeForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7539
|
-
var swarmName;
|
|
7618
|
+
var requestId, swarmName;
|
|
7540
7619
|
return __generator(this, function (_a) {
|
|
7541
7620
|
switch (_a.label) {
|
|
7542
7621
|
case 0:
|
|
7622
|
+
requestId = functoolsKit.randomString();
|
|
7543
7623
|
swarm.loggerService.log("function executeForce", {
|
|
7544
7624
|
content: content,
|
|
7545
7625
|
clientId: clientId,
|
|
7626
|
+
requestId: requestId,
|
|
7546
7627
|
});
|
|
7547
7628
|
swarm.sessionValidationService.validate(clientId, "executeForce");
|
|
7548
7629
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7549
7630
|
swarm.swarmValidationService.validate(swarmName, "executeForce");
|
|
7550
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", clientId, swarmName)];
|
|
7631
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", requestId, clientId, swarmName)];
|
|
7551
7632
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7552
7633
|
}
|
|
7553
7634
|
});
|
|
7554
7635
|
}); };
|
|
7555
7636
|
|
|
7556
|
-
var DISALLOWED_EVENT_SOURCE_LIST$
|
|
7637
|
+
var DISALLOWED_EVENT_SOURCE_LIST$2 = new Set([
|
|
7557
7638
|
"agent-bus",
|
|
7558
7639
|
"history-bus",
|
|
7559
7640
|
"session-bus",
|
|
@@ -7561,7 +7642,7 @@ var DISALLOWED_EVENT_SOURCE_LIST$1 = new Set([
|
|
|
7561
7642
|
"storage-bus",
|
|
7562
7643
|
"swarm-bus",
|
|
7563
7644
|
]);
|
|
7564
|
-
var validateClientId$
|
|
7645
|
+
var validateClientId$d = function (clientId) {
|
|
7565
7646
|
if (clientId === "*") {
|
|
7566
7647
|
return;
|
|
7567
7648
|
}
|
|
@@ -7580,16 +7661,56 @@ var listenEvent = function (clientId, topicName, fn) {
|
|
|
7580
7661
|
swarm.loggerService.log("function listenEvent", {
|
|
7581
7662
|
clientId: clientId,
|
|
7582
7663
|
});
|
|
7583
|
-
if (DISALLOWED_EVENT_SOURCE_LIST$
|
|
7664
|
+
if (DISALLOWED_EVENT_SOURCE_LIST$2.has(topicName)) {
|
|
7584
7665
|
throw new Error("agent-swarm listenEvent topic is reserved topicName=".concat(topicName));
|
|
7585
7666
|
}
|
|
7586
|
-
validateClientId$
|
|
7667
|
+
validateClientId$d(clientId);
|
|
7587
7668
|
return swarm.busService.subscribe(clientId, topicName, function (_a) {
|
|
7588
7669
|
var payload = _a.payload;
|
|
7589
7670
|
return fn(payload);
|
|
7590
7671
|
});
|
|
7591
7672
|
};
|
|
7592
7673
|
|
|
7674
|
+
var DISALLOWED_EVENT_SOURCE_LIST$1 = new Set([
|
|
7675
|
+
"agent-bus",
|
|
7676
|
+
"history-bus",
|
|
7677
|
+
"session-bus",
|
|
7678
|
+
"state-bus",
|
|
7679
|
+
"storage-bus",
|
|
7680
|
+
"swarm-bus",
|
|
7681
|
+
]);
|
|
7682
|
+
var validateClientId$c = function (clientId) {
|
|
7683
|
+
if (clientId === "*") {
|
|
7684
|
+
return;
|
|
7685
|
+
}
|
|
7686
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
7687
|
+
throw new Error("agent-swarm listenEventOnce session not found for clientId=".concat(clientId));
|
|
7688
|
+
}
|
|
7689
|
+
};
|
|
7690
|
+
/**
|
|
7691
|
+
* Listens for an event on the swarm bus service and executes a callback function when the event is received.
|
|
7692
|
+
*
|
|
7693
|
+
* @template T - The type of the data payload.
|
|
7694
|
+
* @param {string} clientId - The ID of the client to listen for events from.
|
|
7695
|
+
* @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.
|
|
7696
|
+
*/
|
|
7697
|
+
var listenEventOnce = function (clientId, topicName, filterFn, fn) {
|
|
7698
|
+
swarm.loggerService.log("function listenEventOnce", {
|
|
7699
|
+
clientId: clientId,
|
|
7700
|
+
});
|
|
7701
|
+
if (DISALLOWED_EVENT_SOURCE_LIST$1.has(topicName)) {
|
|
7702
|
+
throw new Error("agent-swarm listenEventOnce topic is reserved topicName=".concat(topicName));
|
|
7703
|
+
}
|
|
7704
|
+
validateClientId$c(clientId);
|
|
7705
|
+
return swarm.busService.once(clientId, topicName, function (_a) {
|
|
7706
|
+
var payload = _a.payload;
|
|
7707
|
+
return filterFn(payload);
|
|
7708
|
+
}, function (_a) {
|
|
7709
|
+
var payload = _a.payload;
|
|
7710
|
+
return fn(payload);
|
|
7711
|
+
});
|
|
7712
|
+
};
|
|
7713
|
+
|
|
7593
7714
|
/**
|
|
7594
7715
|
* Retrieves the last message sent by the user from the client's message history.
|
|
7595
7716
|
*
|
|
@@ -7597,14 +7718,16 @@ var listenEvent = function (clientId, topicName, fn) {
|
|
|
7597
7718
|
* @returns {Promise<string | null>} - The content of the last user message, or null if no user message is found.
|
|
7598
7719
|
*/
|
|
7599
7720
|
var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7600
|
-
var history, last;
|
|
7721
|
+
var requestId, history, last;
|
|
7601
7722
|
return __generator(this, function (_a) {
|
|
7602
7723
|
switch (_a.label) {
|
|
7603
7724
|
case 0:
|
|
7725
|
+
requestId = functoolsKit.randomString();
|
|
7604
7726
|
swarm.loggerService.log("function getLastUserMessage", {
|
|
7605
7727
|
clientId: clientId,
|
|
7728
|
+
requestId: requestId,
|
|
7606
7729
|
});
|
|
7607
|
-
return [4 /*yield*/, getRawHistory(clientId)];
|
|
7730
|
+
return [4 /*yield*/, getRawHistory(clientId, requestId)];
|
|
7608
7731
|
case 1:
|
|
7609
7732
|
history = _a.sent();
|
|
7610
7733
|
last = history.findLast(function (_a) {
|
|
@@ -7623,14 +7746,16 @@ var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0,
|
|
|
7623
7746
|
* @returns {Promise<Array>} A promise that resolves to an array of history objects filtered by user role.
|
|
7624
7747
|
*/
|
|
7625
7748
|
var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7626
|
-
var history;
|
|
7749
|
+
var requestId, history;
|
|
7627
7750
|
return __generator(this, function (_a) {
|
|
7628
7751
|
switch (_a.label) {
|
|
7629
7752
|
case 0:
|
|
7753
|
+
requestId = functoolsKit.randomString();
|
|
7630
7754
|
swarm.loggerService.log("function getUserHistory", {
|
|
7631
7755
|
clientId: clientId,
|
|
7756
|
+
requestId: requestId,
|
|
7632
7757
|
});
|
|
7633
|
-
return [4 /*yield*/, getRawHistory(clientId)];
|
|
7758
|
+
return [4 /*yield*/, getRawHistory(clientId, requestId)];
|
|
7634
7759
|
case 1:
|
|
7635
7760
|
history = _a.sent();
|
|
7636
7761
|
return [2 /*return*/, history.filter(function (_a) {
|
|
@@ -7648,14 +7773,16 @@ var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
7648
7773
|
* @returns {Promise<Array>} - A promise that resolves to an array of history objects where the role is "assistant".
|
|
7649
7774
|
*/
|
|
7650
7775
|
var getAssistantHistory = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7651
|
-
var history;
|
|
7776
|
+
var requestId, history;
|
|
7652
7777
|
return __generator(this, function (_a) {
|
|
7653
7778
|
switch (_a.label) {
|
|
7654
7779
|
case 0:
|
|
7780
|
+
requestId = functoolsKit.randomString();
|
|
7655
7781
|
swarm.loggerService.log("function getAssistantHistory", {
|
|
7656
7782
|
clientId: clientId,
|
|
7783
|
+
requestId: requestId,
|
|
7657
7784
|
});
|
|
7658
|
-
return [4 /*yield*/, getRawHistory(clientId)];
|
|
7785
|
+
return [4 /*yield*/, getRawHistory(clientId, requestId)];
|
|
7659
7786
|
case 1:
|
|
7660
7787
|
history = _a.sent();
|
|
7661
7788
|
return [2 /*return*/, history.filter(function (_a) {
|
|
@@ -7673,14 +7800,16 @@ var getAssistantHistory = function (clientId) { return __awaiter(void 0, void 0,
|
|
|
7673
7800
|
* @returns {Promise<string | null>} - The content of the last assistant message, or null if no user message is found.
|
|
7674
7801
|
*/
|
|
7675
7802
|
var getLastAssistantMessage = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7676
|
-
var history, last;
|
|
7803
|
+
var requestId, history, last;
|
|
7677
7804
|
return __generator(this, function (_a) {
|
|
7678
7805
|
switch (_a.label) {
|
|
7679
7806
|
case 0:
|
|
7807
|
+
requestId = functoolsKit.randomString();
|
|
7680
7808
|
swarm.loggerService.log("function getLastAssistantMessage", {
|
|
7681
7809
|
clientId: clientId,
|
|
7810
|
+
requestId: requestId,
|
|
7682
7811
|
});
|
|
7683
|
-
return [4 /*yield*/, getRawHistory(clientId)];
|
|
7812
|
+
return [4 /*yield*/, getRawHistory(clientId, requestId)];
|
|
7684
7813
|
case 1:
|
|
7685
7814
|
history = _a.sent();
|
|
7686
7815
|
last = history.findLast(function (_a) {
|
|
@@ -7699,14 +7828,16 @@ var getLastAssistantMessage = function (clientId) { return __awaiter(void 0, voi
|
|
|
7699
7828
|
* @returns {Promise<string | null>} - The content of the last system message, or null if no user message is found.
|
|
7700
7829
|
*/
|
|
7701
7830
|
var getLastSystemMessage = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7702
|
-
var history, last;
|
|
7831
|
+
var requestId, history, last;
|
|
7703
7832
|
return __generator(this, function (_a) {
|
|
7704
7833
|
switch (_a.label) {
|
|
7705
7834
|
case 0:
|
|
7835
|
+
requestId = functoolsKit.randomString();
|
|
7706
7836
|
swarm.loggerService.log("function getLastSystemMessage", {
|
|
7707
7837
|
clientId: clientId,
|
|
7838
|
+
requestId: requestId,
|
|
7708
7839
|
});
|
|
7709
|
-
return [4 /*yield*/, getRawHistory(clientId)];
|
|
7840
|
+
return [4 /*yield*/, getRawHistory(clientId, requestId)];
|
|
7710
7841
|
case 1:
|
|
7711
7842
|
history = _a.sent();
|
|
7712
7843
|
last = history.findLast(function (_a) {
|
|
@@ -7810,19 +7941,21 @@ var event = function (clientId, topicName, payload) {
|
|
|
7810
7941
|
* @returns {Promise<void>} - A promise that resolves when the output is canceled
|
|
7811
7942
|
*/
|
|
7812
7943
|
var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7813
|
-
var swarmName, currentAgentName;
|
|
7944
|
+
var requestId, swarmName, currentAgentName;
|
|
7814
7945
|
return __generator(this, function (_a) {
|
|
7815
7946
|
switch (_a.label) {
|
|
7816
7947
|
case 0:
|
|
7948
|
+
requestId = functoolsKit.randomString();
|
|
7817
7949
|
swarm.loggerService.log('function cancelOutput', {
|
|
7818
7950
|
clientId: clientId,
|
|
7819
7951
|
agentName: agentName,
|
|
7952
|
+
requestId: requestId,
|
|
7820
7953
|
});
|
|
7821
7954
|
swarm.agentValidationService.validate(agentName, "cancelOutput");
|
|
7822
7955
|
swarm.sessionValidationService.validate(clientId, "cancelOutput");
|
|
7823
7956
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7824
7957
|
swarm.swarmValidationService.validate(swarmName, "cancelOutput");
|
|
7825
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7958
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7826
7959
|
case 1:
|
|
7827
7960
|
currentAgentName = _a.sent();
|
|
7828
7961
|
if (currentAgentName !== agentName) {
|
|
@@ -7833,7 +7966,7 @@ var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, voi
|
|
|
7833
7966
|
});
|
|
7834
7967
|
return [2 /*return*/];
|
|
7835
7968
|
}
|
|
7836
|
-
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(clientId, swarmName)];
|
|
7969
|
+
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(requestId, clientId, swarmName)];
|
|
7837
7970
|
case 2:
|
|
7838
7971
|
_a.sent();
|
|
7839
7972
|
return [2 /*return*/];
|
|
@@ -7849,17 +7982,19 @@ var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, voi
|
|
|
7849
7982
|
* @returns {Promise<void>} - A promise that resolves when the output is canceled
|
|
7850
7983
|
*/
|
|
7851
7984
|
var cancelOutputForce = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7852
|
-
var swarmName;
|
|
7985
|
+
var requestId, swarmName;
|
|
7853
7986
|
return __generator(this, function (_a) {
|
|
7854
7987
|
switch (_a.label) {
|
|
7855
7988
|
case 0:
|
|
7989
|
+
requestId = functoolsKit.randomString();
|
|
7856
7990
|
swarm.loggerService.log('function cancelOutputForce', {
|
|
7857
7991
|
clientId: clientId,
|
|
7992
|
+
requestId: requestId
|
|
7858
7993
|
});
|
|
7859
7994
|
swarm.sessionValidationService.validate(clientId, "cancelOutputForce");
|
|
7860
7995
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7861
7996
|
swarm.swarmValidationService.validate(swarmName, "cancelOutputForce");
|
|
7862
|
-
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(clientId, swarmName)];
|
|
7997
|
+
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(requestId, clientId, swarmName)];
|
|
7863
7998
|
case 1:
|
|
7864
7999
|
_a.sent();
|
|
7865
8000
|
return [2 /*return*/];
|
|
@@ -7867,7 +8002,7 @@ var cancelOutputForce = function (clientId) { return __awaiter(void 0, void 0, v
|
|
|
7867
8002
|
});
|
|
7868
8003
|
}); };
|
|
7869
8004
|
|
|
7870
|
-
var validateClientId$
|
|
8005
|
+
var validateClientId$b = function (clientId) {
|
|
7871
8006
|
if (clientId === "*") {
|
|
7872
8007
|
return;
|
|
7873
8008
|
}
|
|
@@ -7885,11 +8020,11 @@ var listenAgentEvent = function (clientId, fn) {
|
|
|
7885
8020
|
swarm.loggerService.log("middleware listenAgentEvent", {
|
|
7886
8021
|
clientId: clientId,
|
|
7887
8022
|
});
|
|
7888
|
-
validateClientId$
|
|
7889
|
-
swarm.busService.subscribe(clientId, "agent-bus", fn);
|
|
8023
|
+
validateClientId$b(clientId);
|
|
8024
|
+
return swarm.busService.subscribe(clientId, "agent-bus", fn);
|
|
7890
8025
|
};
|
|
7891
8026
|
|
|
7892
|
-
var validateClientId$
|
|
8027
|
+
var validateClientId$a = function (clientId) {
|
|
7893
8028
|
if (clientId === "*") {
|
|
7894
8029
|
return;
|
|
7895
8030
|
}
|
|
@@ -7907,11 +8042,11 @@ var listenHistoryEvent = function (clientId, fn) {
|
|
|
7907
8042
|
swarm.loggerService.log("middleware listenHistoryEvent", {
|
|
7908
8043
|
clientId: clientId,
|
|
7909
8044
|
});
|
|
7910
|
-
validateClientId$
|
|
7911
|
-
swarm.busService.subscribe(clientId, "history-bus", fn);
|
|
8045
|
+
validateClientId$a(clientId);
|
|
8046
|
+
return swarm.busService.subscribe(clientId, "history-bus", fn);
|
|
7912
8047
|
};
|
|
7913
8048
|
|
|
7914
|
-
var validateClientId$
|
|
8049
|
+
var validateClientId$9 = function (clientId) {
|
|
7915
8050
|
if (clientId === "*") {
|
|
7916
8051
|
return;
|
|
7917
8052
|
}
|
|
@@ -7929,11 +8064,11 @@ var listenSessionEvent = function (clientId, fn) {
|
|
|
7929
8064
|
swarm.loggerService.log("middleware listenSessionEvent", {
|
|
7930
8065
|
clientId: clientId,
|
|
7931
8066
|
});
|
|
7932
|
-
validateClientId$
|
|
7933
|
-
swarm.busService.subscribe(clientId, "session-bus", fn);
|
|
8067
|
+
validateClientId$9(clientId);
|
|
8068
|
+
return swarm.busService.subscribe(clientId, "session-bus", fn);
|
|
7934
8069
|
};
|
|
7935
8070
|
|
|
7936
|
-
var validateClientId$
|
|
8071
|
+
var validateClientId$8 = function (clientId) {
|
|
7937
8072
|
if (clientId === "*") {
|
|
7938
8073
|
return;
|
|
7939
8074
|
}
|
|
@@ -7951,11 +8086,11 @@ var listenStateEvent = function (clientId, fn) {
|
|
|
7951
8086
|
swarm.loggerService.log("middleware listenStateEvent", {
|
|
7952
8087
|
clientId: clientId,
|
|
7953
8088
|
});
|
|
7954
|
-
validateClientId$
|
|
7955
|
-
swarm.busService.subscribe(clientId, "state-bus", fn);
|
|
8089
|
+
validateClientId$8(clientId);
|
|
8090
|
+
return swarm.busService.subscribe(clientId, "state-bus", fn);
|
|
7956
8091
|
};
|
|
7957
8092
|
|
|
7958
|
-
var validateClientId$
|
|
8093
|
+
var validateClientId$7 = function (clientId) {
|
|
7959
8094
|
if (clientId === "*") {
|
|
7960
8095
|
return;
|
|
7961
8096
|
}
|
|
@@ -7973,11 +8108,11 @@ var listenStorageEvent = function (clientId, fn) {
|
|
|
7973
8108
|
swarm.loggerService.log("middleware listenStorageEvent", {
|
|
7974
8109
|
clientId: clientId,
|
|
7975
8110
|
});
|
|
7976
|
-
validateClientId$
|
|
7977
|
-
swarm.busService.subscribe(clientId, "storage-bus", fn);
|
|
8111
|
+
validateClientId$7(clientId);
|
|
8112
|
+
return swarm.busService.subscribe(clientId, "storage-bus", fn);
|
|
7978
8113
|
};
|
|
7979
8114
|
|
|
7980
|
-
var validateClientId = function (clientId) {
|
|
8115
|
+
var validateClientId$6 = function (clientId) {
|
|
7981
8116
|
if (clientId === "*") {
|
|
7982
8117
|
return;
|
|
7983
8118
|
}
|
|
@@ -7995,8 +8130,140 @@ var listenSwarmEvent = function (clientId, fn) {
|
|
|
7995
8130
|
swarm.loggerService.log("middleware listenSwarmEvent", {
|
|
7996
8131
|
clientId: clientId,
|
|
7997
8132
|
});
|
|
8133
|
+
validateClientId$6(clientId);
|
|
8134
|
+
return swarm.busService.subscribe(clientId, "swarm-bus", fn);
|
|
8135
|
+
};
|
|
8136
|
+
|
|
8137
|
+
var validateClientId$5 = function (clientId) {
|
|
8138
|
+
if (clientId === "*") {
|
|
8139
|
+
return;
|
|
8140
|
+
}
|
|
8141
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8142
|
+
throw new Error("agent-swarm listenAgentEventOnce session not found for clientId=".concat(clientId));
|
|
8143
|
+
}
|
|
8144
|
+
};
|
|
8145
|
+
/**
|
|
8146
|
+
* Hook to subscribe to agent events for a specific client.
|
|
8147
|
+
*
|
|
8148
|
+
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
8149
|
+
* @param {function} fn - The callback function to handle the event.
|
|
8150
|
+
*/
|
|
8151
|
+
var listenAgentEventOnce = function (clientId, filterFn, fn) {
|
|
8152
|
+
swarm.loggerService.log("middleware listenAgentEventOnce", {
|
|
8153
|
+
clientId: clientId,
|
|
8154
|
+
});
|
|
8155
|
+
validateClientId$5(clientId);
|
|
8156
|
+
return swarm.busService.once(clientId, "agent-bus", filterFn, fn);
|
|
8157
|
+
};
|
|
8158
|
+
|
|
8159
|
+
var validateClientId$4 = function (clientId) {
|
|
8160
|
+
if (clientId === "*") {
|
|
8161
|
+
return;
|
|
8162
|
+
}
|
|
8163
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8164
|
+
throw new Error("agent-swarm listenHistoryEventOnce session not found for clientId=".concat(clientId));
|
|
8165
|
+
}
|
|
8166
|
+
};
|
|
8167
|
+
/**
|
|
8168
|
+
* Hook to subscribe to history events for a specific client.
|
|
8169
|
+
*
|
|
8170
|
+
* @param {string} clientId - The ID of the client to subscribe to.
|
|
8171
|
+
* @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
|
|
8172
|
+
*/
|
|
8173
|
+
var listenHistoryEventOnce = function (clientId, filterFn, fn) {
|
|
8174
|
+
swarm.loggerService.log("middleware listenHistoryEventOnce", {
|
|
8175
|
+
clientId: clientId,
|
|
8176
|
+
});
|
|
8177
|
+
validateClientId$4(clientId);
|
|
8178
|
+
return swarm.busService.once(clientId, "history-bus", filterFn, fn);
|
|
8179
|
+
};
|
|
8180
|
+
|
|
8181
|
+
var validateClientId$3 = function (clientId) {
|
|
8182
|
+
if (clientId === "*") {
|
|
8183
|
+
return;
|
|
8184
|
+
}
|
|
8185
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8186
|
+
throw new Error("agent-swarm listenSessionEventOnce session not found for clientId=".concat(clientId));
|
|
8187
|
+
}
|
|
8188
|
+
};
|
|
8189
|
+
/**
|
|
8190
|
+
* Hook to subscribe to session events for a specific client.
|
|
8191
|
+
*
|
|
8192
|
+
* @param {string} clientId - The ID of the client to subscribe to session events for.
|
|
8193
|
+
* @param {function} fn - The callback function to handle the session events.
|
|
8194
|
+
*/
|
|
8195
|
+
var listenSessionEventOnce = function (clientId, filterFn, fn) {
|
|
8196
|
+
swarm.loggerService.log("middleware listenSessionEventOnce", {
|
|
8197
|
+
clientId: clientId,
|
|
8198
|
+
});
|
|
8199
|
+
validateClientId$3(clientId);
|
|
8200
|
+
return swarm.busService.once(clientId, "session-bus", filterFn, fn);
|
|
8201
|
+
};
|
|
8202
|
+
|
|
8203
|
+
var validateClientId$2 = function (clientId) {
|
|
8204
|
+
if (clientId === "*") {
|
|
8205
|
+
return;
|
|
8206
|
+
}
|
|
8207
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8208
|
+
throw new Error("agent-swarm listenStateEventOnce session not found for clientId=".concat(clientId));
|
|
8209
|
+
}
|
|
8210
|
+
};
|
|
8211
|
+
/**
|
|
8212
|
+
* Hook to subscribe to state events for a specific client.
|
|
8213
|
+
*
|
|
8214
|
+
* @param {string} clientId - The ID of the client to subscribe to.
|
|
8215
|
+
* @param {function} fn - The callback function to handle the event.
|
|
8216
|
+
*/
|
|
8217
|
+
var listenStateEventOnce = function (clientId, filterFn, fn) {
|
|
8218
|
+
swarm.loggerService.log("middleware listenStateEventOnce", {
|
|
8219
|
+
clientId: clientId,
|
|
8220
|
+
});
|
|
8221
|
+
validateClientId$2(clientId);
|
|
8222
|
+
return swarm.busService.once(clientId, "state-bus", filterFn, fn);
|
|
8223
|
+
};
|
|
8224
|
+
|
|
8225
|
+
var validateClientId$1 = function (clientId) {
|
|
8226
|
+
if (clientId === "*") {
|
|
8227
|
+
return;
|
|
8228
|
+
}
|
|
8229
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8230
|
+
throw new Error("agent-swarm listenStorageEventOnce session not found for clientId=".concat(clientId));
|
|
8231
|
+
}
|
|
8232
|
+
};
|
|
8233
|
+
/**
|
|
8234
|
+
* Hook to subscribe to storage events for a specific client.
|
|
8235
|
+
*
|
|
8236
|
+
* @param {string} clientId - The ID of the client to subscribe to storage events for.
|
|
8237
|
+
* @param {function} fn - The callback function to handle the storage event.
|
|
8238
|
+
*/
|
|
8239
|
+
var listenStorageEventOnce = function (clientId, filterFn, fn) {
|
|
8240
|
+
swarm.loggerService.log("middleware listenStorageEventOnce", {
|
|
8241
|
+
clientId: clientId,
|
|
8242
|
+
});
|
|
8243
|
+
validateClientId$1(clientId);
|
|
8244
|
+
return swarm.busService.once(clientId, "storage-bus", filterFn, fn);
|
|
8245
|
+
};
|
|
8246
|
+
|
|
8247
|
+
var validateClientId = function (clientId) {
|
|
8248
|
+
if (clientId === "*") {
|
|
8249
|
+
return;
|
|
8250
|
+
}
|
|
8251
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8252
|
+
throw new Error("agent-swarm listenSwarmEventOnce session not found for clientId=".concat(clientId));
|
|
8253
|
+
}
|
|
8254
|
+
};
|
|
8255
|
+
/**
|
|
8256
|
+
* Hook to subscribe to swarm events for a specific client.
|
|
8257
|
+
*
|
|
8258
|
+
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
8259
|
+
* @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
|
|
8260
|
+
*/
|
|
8261
|
+
var listenSwarmEventOnce = function (clientId, filterFn, fn) {
|
|
8262
|
+
swarm.loggerService.log("middleware listenSwarmEventOnce", {
|
|
8263
|
+
clientId: clientId,
|
|
8264
|
+
});
|
|
7998
8265
|
validateClientId(clientId);
|
|
7999
|
-
swarm.busService.
|
|
8266
|
+
return swarm.busService.once(clientId, "swarm-bus", filterFn, fn);
|
|
8000
8267
|
};
|
|
8001
8268
|
|
|
8002
8269
|
var StorageUtils = /** @class */ (function () {
|
|
@@ -8013,21 +8280,24 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8013
8280
|
* @template T
|
|
8014
8281
|
*/
|
|
8015
8282
|
this.take = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8283
|
+
var requestId;
|
|
8016
8284
|
return __generator(this, function (_a) {
|
|
8017
8285
|
switch (_a.label) {
|
|
8018
8286
|
case 0:
|
|
8287
|
+
requestId = functoolsKit.randomString();
|
|
8019
8288
|
swarm.loggerService.log("StorageUtils take", {
|
|
8020
8289
|
search: payload.search,
|
|
8021
8290
|
total: payload.total,
|
|
8022
8291
|
clientId: payload.clientId,
|
|
8023
8292
|
storageName: payload.storageName,
|
|
8024
8293
|
score: payload.score,
|
|
8294
|
+
requestId: requestId,
|
|
8025
8295
|
});
|
|
8026
8296
|
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
8027
8297
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8028
8298
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (take)"));
|
|
8029
8299
|
}
|
|
8030
|
-
return [4 /*yield*/, swarm.storagePublicService.take(payload.search, payload.total, payload.clientId, payload.storageName, payload.score)];
|
|
8300
|
+
return [4 /*yield*/, swarm.storagePublicService.take(payload.search, payload.total, requestId, payload.clientId, payload.storageName, payload.score)];
|
|
8031
8301
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
8032
8302
|
}
|
|
8033
8303
|
});
|
|
@@ -8042,19 +8312,22 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8042
8312
|
* @template T
|
|
8043
8313
|
*/
|
|
8044
8314
|
this.upsert = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8315
|
+
var requestId;
|
|
8045
8316
|
return __generator(this, function (_a) {
|
|
8046
8317
|
switch (_a.label) {
|
|
8047
8318
|
case 0:
|
|
8319
|
+
requestId = functoolsKit.randomString();
|
|
8048
8320
|
swarm.loggerService.log("StorageUtils upsert", {
|
|
8049
8321
|
item: payload.item,
|
|
8050
8322
|
clientId: payload.clientId,
|
|
8051
8323
|
storageName: payload.storageName,
|
|
8324
|
+
requestId: requestId,
|
|
8052
8325
|
});
|
|
8053
8326
|
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
8054
8327
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8055
8328
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (upsert)"));
|
|
8056
8329
|
}
|
|
8057
|
-
return [4 /*yield*/, swarm.storagePublicService.upsert(payload.item, payload.clientId, payload.storageName)];
|
|
8330
|
+
return [4 /*yield*/, swarm.storagePublicService.upsert(payload.item, requestId, payload.clientId, payload.storageName)];
|
|
8058
8331
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8059
8332
|
}
|
|
8060
8333
|
});
|
|
@@ -8068,19 +8341,22 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8068
8341
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
8069
8342
|
*/
|
|
8070
8343
|
this.remove = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8344
|
+
var requestId;
|
|
8071
8345
|
return __generator(this, function (_a) {
|
|
8072
8346
|
switch (_a.label) {
|
|
8073
8347
|
case 0:
|
|
8348
|
+
requestId = functoolsKit.randomString();
|
|
8074
8349
|
swarm.loggerService.log("StorageUtils remove", {
|
|
8075
8350
|
itemId: payload.itemId,
|
|
8076
8351
|
clientId: payload.clientId,
|
|
8077
8352
|
storageName: payload.storageName,
|
|
8353
|
+
requestId: requestId,
|
|
8078
8354
|
});
|
|
8079
8355
|
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
8080
8356
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8081
8357
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (remove)"));
|
|
8082
8358
|
}
|
|
8083
|
-
return [4 /*yield*/, swarm.storagePublicService.remove(payload.itemId, payload.clientId, payload.storageName)];
|
|
8359
|
+
return [4 /*yield*/, swarm.storagePublicService.remove(payload.itemId, requestId, payload.clientId, payload.storageName)];
|
|
8084
8360
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8085
8361
|
}
|
|
8086
8362
|
});
|
|
@@ -8095,19 +8371,22 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8095
8371
|
* @template T
|
|
8096
8372
|
*/
|
|
8097
8373
|
this.get = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8374
|
+
var requestId;
|
|
8098
8375
|
return __generator(this, function (_a) {
|
|
8099
8376
|
switch (_a.label) {
|
|
8100
8377
|
case 0:
|
|
8378
|
+
requestId = functoolsKit.randomString();
|
|
8101
8379
|
swarm.loggerService.log("StorageUtils get", {
|
|
8102
8380
|
itemId: payload.itemId,
|
|
8103
8381
|
clientId: payload.clientId,
|
|
8104
8382
|
storageName: payload.storageName,
|
|
8383
|
+
requestId: requestId,
|
|
8105
8384
|
});
|
|
8106
8385
|
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
8107
8386
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8108
8387
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (get)"));
|
|
8109
8388
|
}
|
|
8110
|
-
return [4 /*yield*/, swarm.storagePublicService.get(payload.itemId, payload.clientId, payload.storageName)];
|
|
8389
|
+
return [4 /*yield*/, swarm.storagePublicService.get(payload.itemId, requestId, payload.clientId, payload.storageName)];
|
|
8111
8390
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
8112
8391
|
}
|
|
8113
8392
|
});
|
|
@@ -8122,18 +8401,21 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8122
8401
|
* @template T
|
|
8123
8402
|
*/
|
|
8124
8403
|
this.list = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8404
|
+
var requestId;
|
|
8125
8405
|
return __generator(this, function (_a) {
|
|
8126
8406
|
switch (_a.label) {
|
|
8127
8407
|
case 0:
|
|
8408
|
+
requestId = functoolsKit.randomString();
|
|
8128
8409
|
swarm.loggerService.log("StorageUtils list", {
|
|
8129
8410
|
clientId: payload.clientId,
|
|
8130
8411
|
storageName: payload.storageName,
|
|
8412
|
+
requestId: requestId,
|
|
8131
8413
|
});
|
|
8132
8414
|
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
8133
8415
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8134
8416
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (list)"));
|
|
8135
8417
|
}
|
|
8136
|
-
return [4 /*yield*/, swarm.storagePublicService.list(payload.clientId, payload.storageName, payload.filter)];
|
|
8418
|
+
return [4 /*yield*/, swarm.storagePublicService.list(requestId, payload.clientId, payload.storageName, payload.filter)];
|
|
8137
8419
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
8138
8420
|
}
|
|
8139
8421
|
});
|
|
@@ -8146,18 +8428,21 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8146
8428
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
8147
8429
|
*/
|
|
8148
8430
|
this.clear = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8431
|
+
var requestId;
|
|
8149
8432
|
return __generator(this, function (_a) {
|
|
8150
8433
|
switch (_a.label) {
|
|
8151
8434
|
case 0:
|
|
8435
|
+
requestId = functoolsKit.randomString();
|
|
8152
8436
|
swarm.loggerService.log("StorageUtils clear", {
|
|
8153
8437
|
clientId: payload.clientId,
|
|
8154
8438
|
storageName: payload.storageName,
|
|
8439
|
+
requestId: requestId,
|
|
8155
8440
|
});
|
|
8156
8441
|
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
8157
8442
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8158
8443
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (clear)"));
|
|
8159
8444
|
}
|
|
8160
|
-
return [4 /*yield*/, swarm.storagePublicService.clear(payload.clientId, payload.storageName)];
|
|
8445
|
+
return [4 /*yield*/, swarm.storagePublicService.clear(requestId, payload.clientId, payload.storageName)];
|
|
8161
8446
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8162
8447
|
}
|
|
8163
8448
|
});
|
|
@@ -8185,17 +8470,20 @@ var StateUtils = /** @class */ (function () {
|
|
|
8185
8470
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
8186
8471
|
*/
|
|
8187
8472
|
this.getState = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8473
|
+
var requestId;
|
|
8188
8474
|
return __generator(this, function (_a) {
|
|
8189
8475
|
switch (_a.label) {
|
|
8190
8476
|
case 0:
|
|
8477
|
+
requestId = functoolsKit.randomString();
|
|
8191
8478
|
swarm.loggerService.log("StateUtils getState", {
|
|
8192
8479
|
clientId: payload.clientId,
|
|
8193
8480
|
stateName: payload.stateName,
|
|
8481
|
+
requestId: requestId,
|
|
8194
8482
|
});
|
|
8195
8483
|
if (!swarm.agentValidationService.hasState(payload.agentName, payload.stateName)) {
|
|
8196
8484
|
throw new Error("agent-swarm StateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (getState)"));
|
|
8197
8485
|
}
|
|
8198
|
-
return [4 /*yield*/, swarm.statePublicService.getState(payload.clientId, payload.stateName)];
|
|
8486
|
+
return [4 /*yield*/, swarm.statePublicService.getState(requestId, payload.clientId, payload.stateName)];
|
|
8199
8487
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8200
8488
|
}
|
|
8201
8489
|
});
|
|
@@ -8212,23 +8500,26 @@ var StateUtils = /** @class */ (function () {
|
|
|
8212
8500
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
8213
8501
|
*/
|
|
8214
8502
|
this.setState = function (dispatchFn, payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8503
|
+
var requestId;
|
|
8215
8504
|
var _this = this;
|
|
8216
8505
|
return __generator(this, function (_a) {
|
|
8217
8506
|
switch (_a.label) {
|
|
8218
8507
|
case 0:
|
|
8508
|
+
requestId = functoolsKit.randomString();
|
|
8219
8509
|
swarm.loggerService.log("StateUtils setState", {
|
|
8220
8510
|
clientId: payload.clientId,
|
|
8221
8511
|
stateName: payload.stateName,
|
|
8512
|
+
requestId: requestId,
|
|
8222
8513
|
});
|
|
8223
8514
|
if (!swarm.agentValidationService.hasState(payload.agentName, payload.stateName)) {
|
|
8224
8515
|
throw new Error("agent-swarm StateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (setState)"));
|
|
8225
8516
|
}
|
|
8226
8517
|
if (!(typeof dispatchFn === "function")) return [3 /*break*/, 2];
|
|
8227
|
-
return [4 /*yield*/, swarm.statePublicService.setState(dispatchFn, payload.clientId, payload.stateName)];
|
|
8518
|
+
return [4 /*yield*/, swarm.statePublicService.setState(dispatchFn, requestId, payload.clientId, payload.stateName)];
|
|
8228
8519
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8229
8520
|
case 2: return [4 /*yield*/, swarm.statePublicService.setState(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
8230
8521
|
return [2 /*return*/, dispatchFn];
|
|
8231
|
-
}); }); }, payload.clientId, payload.stateName)];
|
|
8522
|
+
}); }); }, requestId, payload.clientId, payload.stateName)];
|
|
8232
8523
|
case 3: return [2 /*return*/, _a.sent()];
|
|
8233
8524
|
}
|
|
8234
8525
|
});
|
|
@@ -8242,10 +8533,30 @@ var StateUtils = /** @class */ (function () {
|
|
|
8242
8533
|
*/
|
|
8243
8534
|
var State = new StateUtils();
|
|
8244
8535
|
|
|
8536
|
+
var LoggerUtils = /** @class */ (function () {
|
|
8537
|
+
function LoggerUtils() {
|
|
8538
|
+
/**
|
|
8539
|
+
* Sets the provided logger to the logger service.
|
|
8540
|
+
* @param {ILogger} logger - The logger instance to be used.
|
|
8541
|
+
*/
|
|
8542
|
+
this.useLogger = function (logger) {
|
|
8543
|
+
swarm.loggerService.log("HistoryInstance useLogger");
|
|
8544
|
+
swarm.loggerService.setLogger(logger);
|
|
8545
|
+
};
|
|
8546
|
+
}
|
|
8547
|
+
return LoggerUtils;
|
|
8548
|
+
}());
|
|
8549
|
+
/**
|
|
8550
|
+
* Instance of LoggerUtils to be used for logging.
|
|
8551
|
+
* @type {LoggerUtils}
|
|
8552
|
+
*/
|
|
8553
|
+
var Logger = new LoggerUtils();
|
|
8554
|
+
|
|
8245
8555
|
exports.ContextService = ContextService;
|
|
8246
8556
|
exports.History = History;
|
|
8247
8557
|
exports.HistoryAdapter = HistoryAdapter;
|
|
8248
8558
|
exports.HistoryInstance = HistoryInstance;
|
|
8559
|
+
exports.Logger = Logger;
|
|
8249
8560
|
exports.State = State;
|
|
8250
8561
|
exports.Storage = Storage;
|
|
8251
8562
|
exports.addAgent = addAgent;
|
|
@@ -8283,12 +8594,19 @@ exports.getRawHistory = getRawHistory;
|
|
|
8283
8594
|
exports.getSessionMode = getSessionMode;
|
|
8284
8595
|
exports.getUserHistory = getUserHistory;
|
|
8285
8596
|
exports.listenAgentEvent = listenAgentEvent;
|
|
8597
|
+
exports.listenAgentEventOnce = listenAgentEventOnce;
|
|
8286
8598
|
exports.listenEvent = listenEvent;
|
|
8599
|
+
exports.listenEventOnce = listenEventOnce;
|
|
8287
8600
|
exports.listenHistoryEvent = listenHistoryEvent;
|
|
8601
|
+
exports.listenHistoryEventOnce = listenHistoryEventOnce;
|
|
8288
8602
|
exports.listenSessionEvent = listenSessionEvent;
|
|
8603
|
+
exports.listenSessionEventOnce = listenSessionEventOnce;
|
|
8289
8604
|
exports.listenStateEvent = listenStateEvent;
|
|
8605
|
+
exports.listenStateEventOnce = listenStateEventOnce;
|
|
8290
8606
|
exports.listenStorageEvent = listenStorageEvent;
|
|
8607
|
+
exports.listenStorageEventOnce = listenStorageEventOnce;
|
|
8291
8608
|
exports.listenSwarmEvent = listenSwarmEvent;
|
|
8609
|
+
exports.listenSwarmEventOnce = listenSwarmEventOnce;
|
|
8292
8610
|
exports.makeAutoDispose = makeAutoDispose;
|
|
8293
8611
|
exports.makeConnection = makeConnection;
|
|
8294
8612
|
exports.session = session;
|