agent-swarm-kit 1.0.74 → 1.0.76
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 -405
- package/build/index.mjs +673 -406
- package/package.json +2 -2
- package/types.d.ts +134 -51
package/build/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { scoped } from 'di-scoped';
|
|
2
|
-
import { ToolRegistry, trycatch, singleshot, memoize, sleep, Subject, queued, getErrorMessage, errorData, not, randomString, createAwaiter, cancelable, CANCELED_PROMISE_SYMBOL, execpool, SortedArray, schedule, ttl, Source } from 'functools-kit';
|
|
3
2
|
import { createActivator } from 'di-kit';
|
|
3
|
+
import { ToolRegistry, trycatch, singleshot, memoize, sleep, Subject, queued, getErrorMessage, errorData, not, randomString, createAwaiter, cancelable, CANCELED_PROMISE_SYMBOL, execpool, SortedArray, schedule, ttl, Source } from 'functools-kit';
|
|
4
4
|
import { omit } from 'lodash-es';
|
|
5
5
|
import xml2js from 'xml2js';
|
|
6
6
|
|
|
@@ -165,6 +165,50 @@ var ContextService = scoped(/** @class */ (function () {
|
|
|
165
165
|
return class_1;
|
|
166
166
|
}()));
|
|
167
167
|
|
|
168
|
+
var _a;
|
|
169
|
+
var init = (_a = createActivator("agent-swarm"), _a.init), inject = _a.inject, provide = _a.provide;
|
|
170
|
+
|
|
171
|
+
var baseServices$1 = {
|
|
172
|
+
busService: Symbol('busService'),
|
|
173
|
+
loggerService: Symbol('loggerService'),
|
|
174
|
+
contextService: Symbol('contextService'),
|
|
175
|
+
};
|
|
176
|
+
var connectionServices$1 = {
|
|
177
|
+
agentConnectionService: Symbol('agentConnectionService'),
|
|
178
|
+
historyConnectionService: Symbol('historyConnectionService'),
|
|
179
|
+
swarmConnectionService: Symbol('swarmConnectionService'),
|
|
180
|
+
sessionConnectionService: Symbol('sessionConnectionService'),
|
|
181
|
+
storageConnectionService: Symbol('storageConnectionService'),
|
|
182
|
+
stateConnectionService: Symbol('stateConnectionService'),
|
|
183
|
+
};
|
|
184
|
+
var schemaServices$1 = {
|
|
185
|
+
completionSchemaService: Symbol('completionSchemaService'),
|
|
186
|
+
agentSchemaService: Symbol('agentSchemaService'),
|
|
187
|
+
swarmSchemaService: Symbol('swarmSchemaService'),
|
|
188
|
+
toolSchemaService: Symbol('toolSchemaService'),
|
|
189
|
+
embeddingSchemaService: Symbol('embeddingSchemaService'),
|
|
190
|
+
storageSchemaService: Symbol('storageSchemaService'),
|
|
191
|
+
stateSchemaService: Symbol('stateSchemaService'),
|
|
192
|
+
};
|
|
193
|
+
var publicServices$1 = {
|
|
194
|
+
agentPublicService: Symbol('agentPublicService'),
|
|
195
|
+
historyPublicService: Symbol('historyPublicService'),
|
|
196
|
+
sessionPublicService: Symbol('sessionPublicService'),
|
|
197
|
+
swarmPublicService: Symbol('swarmPublicService'),
|
|
198
|
+
storagePublicService: Symbol('storagePublicService'),
|
|
199
|
+
statePublicService: Symbol('statePublicService'),
|
|
200
|
+
};
|
|
201
|
+
var validationServices$1 = {
|
|
202
|
+
agentValidationService: Symbol('agentValidationService'),
|
|
203
|
+
toolValidationService: Symbol('toolValidationService'),
|
|
204
|
+
sessionValidationService: Symbol('sessionValidationService'),
|
|
205
|
+
swarmValidationService: Symbol('swarmValidationService'),
|
|
206
|
+
completionValidationService: Symbol('completionValidationService'),
|
|
207
|
+
embeddingValidationService: Symbol('embeddingValidationService'),
|
|
208
|
+
storageValidationService: Symbol('storageValidationService'),
|
|
209
|
+
};
|
|
210
|
+
var TYPES = __assign(__assign(__assign(__assign(__assign({}, baseServices$1), schemaServices$1), connectionServices$1), publicServices$1), validationServices$1);
|
|
211
|
+
|
|
168
212
|
/**
|
|
169
213
|
* LoggerService class that implements the ILogger interface.
|
|
170
214
|
* Provides methods to log and debug messages.
|
|
@@ -172,6 +216,7 @@ var ContextService = scoped(/** @class */ (function () {
|
|
|
172
216
|
var LoggerService = /** @class */ (function () {
|
|
173
217
|
function LoggerService() {
|
|
174
218
|
var _this = this;
|
|
219
|
+
this.contextService = inject(TYPES.contextService);
|
|
175
220
|
this._logger = {
|
|
176
221
|
/**
|
|
177
222
|
* Logs messages.
|
|
@@ -191,24 +236,32 @@ var LoggerService = /** @class */ (function () {
|
|
|
191
236
|
* @param {...any} args - The messages to log.
|
|
192
237
|
*/
|
|
193
238
|
this.log = function () {
|
|
194
|
-
var _a;
|
|
239
|
+
var _a, _b;
|
|
195
240
|
var args = [];
|
|
196
241
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
197
242
|
args[_i] = arguments[_i];
|
|
198
243
|
}
|
|
199
|
-
(
|
|
244
|
+
if (ContextService.hasContext()) {
|
|
245
|
+
(_a = _this._logger).log.apply(_a, __spreadArray(__spreadArray([], __read(args), false), [_this.contextService.context], false));
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
(_b = _this._logger).log.apply(_b, __spreadArray([], __read(args), false));
|
|
200
249
|
};
|
|
201
250
|
/**
|
|
202
251
|
* Logs debug messages using the current logger.
|
|
203
252
|
* @param {...any} args - The debug messages to log.
|
|
204
253
|
*/
|
|
205
254
|
this.debug = function () {
|
|
206
|
-
var _a;
|
|
255
|
+
var _a, _b;
|
|
207
256
|
var args = [];
|
|
208
257
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
209
258
|
args[_i] = arguments[_i];
|
|
210
259
|
}
|
|
211
|
-
(
|
|
260
|
+
if (ContextService.hasContext()) {
|
|
261
|
+
(_a = _this._logger).debug.apply(_a, __spreadArray(__spreadArray([], __read(args), false), [_this.contextService.context], false));
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
(_b = _this._logger).debug.apply(_b, __spreadArray([], __read(args), false));
|
|
212
265
|
};
|
|
213
266
|
/**
|
|
214
267
|
* Sets a new logger.
|
|
@@ -221,50 +274,6 @@ var LoggerService = /** @class */ (function () {
|
|
|
221
274
|
return LoggerService;
|
|
222
275
|
}());
|
|
223
276
|
|
|
224
|
-
var _a;
|
|
225
|
-
var init = (_a = createActivator("agent-swarm"), _a.init), inject = _a.inject, provide = _a.provide;
|
|
226
|
-
|
|
227
|
-
var baseServices$1 = {
|
|
228
|
-
busService: Symbol('busService'),
|
|
229
|
-
loggerService: Symbol('loggerService'),
|
|
230
|
-
contextService: Symbol('contextService'),
|
|
231
|
-
};
|
|
232
|
-
var connectionServices$1 = {
|
|
233
|
-
agentConnectionService: Symbol('agentConnectionService'),
|
|
234
|
-
historyConnectionService: Symbol('historyConnectionService'),
|
|
235
|
-
swarmConnectionService: Symbol('swarmConnectionService'),
|
|
236
|
-
sessionConnectionService: Symbol('sessionConnectionService'),
|
|
237
|
-
storageConnectionService: Symbol('storageConnectionService'),
|
|
238
|
-
stateConnectionService: Symbol('stateConnectionService'),
|
|
239
|
-
};
|
|
240
|
-
var schemaServices$1 = {
|
|
241
|
-
completionSchemaService: Symbol('completionSchemaService'),
|
|
242
|
-
agentSchemaService: Symbol('agentSchemaService'),
|
|
243
|
-
swarmSchemaService: Symbol('swarmSchemaService'),
|
|
244
|
-
toolSchemaService: Symbol('toolSchemaService'),
|
|
245
|
-
embeddingSchemaService: Symbol('embeddingSchemaService'),
|
|
246
|
-
storageSchemaService: Symbol('storageSchemaService'),
|
|
247
|
-
stateSchemaService: Symbol('stateSchemaService'),
|
|
248
|
-
};
|
|
249
|
-
var publicServices$1 = {
|
|
250
|
-
agentPublicService: Symbol('agentPublicService'),
|
|
251
|
-
historyPublicService: Symbol('historyPublicService'),
|
|
252
|
-
sessionPublicService: Symbol('sessionPublicService'),
|
|
253
|
-
swarmPublicService: Symbol('swarmPublicService'),
|
|
254
|
-
storagePublicService: Symbol('storagePublicService'),
|
|
255
|
-
statePublicService: Symbol('statePublicService'),
|
|
256
|
-
};
|
|
257
|
-
var validationServices$1 = {
|
|
258
|
-
agentValidationService: Symbol('agentValidationService'),
|
|
259
|
-
toolValidationService: Symbol('toolValidationService'),
|
|
260
|
-
sessionValidationService: Symbol('sessionValidationService'),
|
|
261
|
-
swarmValidationService: Symbol('swarmValidationService'),
|
|
262
|
-
completionValidationService: Symbol('completionValidationService'),
|
|
263
|
-
embeddingValidationService: Symbol('embeddingValidationService'),
|
|
264
|
-
storageValidationService: Symbol('storageValidationService'),
|
|
265
|
-
};
|
|
266
|
-
var TYPES = __assign(__assign(__assign(__assign(__assign({}, baseServices$1), schemaServices$1), connectionServices$1), publicServices$1), validationServices$1);
|
|
267
|
-
|
|
268
277
|
/**
|
|
269
278
|
* Service for managing agent schemas.
|
|
270
279
|
*/
|
|
@@ -1556,7 +1565,6 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1556
1565
|
this.loggerService.log("agentConnectionService execute", {
|
|
1557
1566
|
input: input,
|
|
1558
1567
|
mode: mode,
|
|
1559
|
-
context: this.contextService.context,
|
|
1560
1568
|
});
|
|
1561
1569
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).execute(input, mode)];
|
|
1562
1570
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -1571,9 +1579,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1571
1579
|
return __generator(this, function (_a) {
|
|
1572
1580
|
switch (_a.label) {
|
|
1573
1581
|
case 0:
|
|
1574
|
-
this.loggerService.log("agentConnectionService waitForOutput"
|
|
1575
|
-
context: this.contextService.context,
|
|
1576
|
-
});
|
|
1582
|
+
this.loggerService.log("agentConnectionService waitForOutput");
|
|
1577
1583
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).waitForOutput()];
|
|
1578
1584
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1579
1585
|
}
|
|
@@ -1592,7 +1598,6 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1592
1598
|
this.loggerService.log("agentConnectionService commitToolOutput", {
|
|
1593
1599
|
content: content,
|
|
1594
1600
|
toolId: toolId,
|
|
1595
|
-
context: this.contextService.context,
|
|
1596
1601
|
});
|
|
1597
1602
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitToolOutput(toolId, content)];
|
|
1598
1603
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -1610,7 +1615,6 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1610
1615
|
case 0:
|
|
1611
1616
|
this.loggerService.log("agentConnectionService commitSystemMessage", {
|
|
1612
1617
|
message: message,
|
|
1613
|
-
context: this.contextService.context,
|
|
1614
1618
|
});
|
|
1615
1619
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitSystemMessage(message)];
|
|
1616
1620
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -1628,7 +1632,6 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1628
1632
|
case 0:
|
|
1629
1633
|
this.loggerService.log("agentConnectionService commitUserMessage", {
|
|
1630
1634
|
message: message,
|
|
1631
|
-
context: this.contextService.context,
|
|
1632
1635
|
});
|
|
1633
1636
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitUserMessage(message)];
|
|
1634
1637
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -1643,9 +1646,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1643
1646
|
return __generator(this, function (_a) {
|
|
1644
1647
|
switch (_a.label) {
|
|
1645
1648
|
case 0:
|
|
1646
|
-
this.loggerService.log("agentConnectionService commitAgentChange"
|
|
1647
|
-
context: this.contextService.context,
|
|
1648
|
-
});
|
|
1649
|
+
this.loggerService.log("agentConnectionService commitAgentChange");
|
|
1649
1650
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitAgentChange()];
|
|
1650
1651
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1651
1652
|
}
|
|
@@ -1659,9 +1660,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1659
1660
|
return __generator(this, function (_a) {
|
|
1660
1661
|
switch (_a.label) {
|
|
1661
1662
|
case 0:
|
|
1662
|
-
this.loggerService.log("agentConnectionService commitFlush"
|
|
1663
|
-
context: this.contextService.context,
|
|
1664
|
-
});
|
|
1663
|
+
this.loggerService.log("agentConnectionService commitFlush");
|
|
1665
1664
|
return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitFlush()];
|
|
1666
1665
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1667
1666
|
}
|
|
@@ -1676,9 +1675,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1676
1675
|
return __generator(this, function (_a) {
|
|
1677
1676
|
switch (_a.label) {
|
|
1678
1677
|
case 0:
|
|
1679
|
-
this.loggerService.log("agentConnectionService dispose"
|
|
1680
|
-
context: this.contextService.context,
|
|
1681
|
-
});
|
|
1678
|
+
this.loggerService.log("agentConnectionService dispose");
|
|
1682
1679
|
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.agentName);
|
|
1683
1680
|
if (!this.getAgent.has(key)) {
|
|
1684
1681
|
return [2 /*return*/];
|
|
@@ -1999,7 +1996,7 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
1999
1996
|
switch (_a.label) {
|
|
2000
1997
|
case 0:
|
|
2001
1998
|
this.loggerService.log("historyConnectionService push", {
|
|
2002
|
-
|
|
1999
|
+
message: message,
|
|
2003
2000
|
});
|
|
2004
2001
|
return [4 /*yield*/, this.getHistory(this.contextService.context.clientId, this.contextService.context.agentName).push(message)];
|
|
2005
2002
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -2016,7 +2013,7 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
2016
2013
|
switch (_a.label) {
|
|
2017
2014
|
case 0:
|
|
2018
2015
|
this.loggerService.log("historyConnectionService toArrayForAgent", {
|
|
2019
|
-
|
|
2016
|
+
prompt: prompt,
|
|
2020
2017
|
});
|
|
2021
2018
|
return [4 /*yield*/, this.getHistory(this.contextService.context.clientId, this.contextService.context.agentName).toArrayForAgent(prompt)];
|
|
2022
2019
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -2031,9 +2028,7 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
2031
2028
|
return __generator(this, function (_a) {
|
|
2032
2029
|
switch (_a.label) {
|
|
2033
2030
|
case 0:
|
|
2034
|
-
this.loggerService.log("historyConnectionService toArrayForRaw"
|
|
2035
|
-
context: this.contextService.context,
|
|
2036
|
-
});
|
|
2031
|
+
this.loggerService.log("historyConnectionService toArrayForRaw");
|
|
2037
2032
|
return [4 /*yield*/, this.getHistory(this.contextService.context.clientId, this.contextService.context.agentName).toArrayForRaw()];
|
|
2038
2033
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2039
2034
|
}
|
|
@@ -2048,9 +2043,7 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
2048
2043
|
return __generator(this, function (_a) {
|
|
2049
2044
|
switch (_a.label) {
|
|
2050
2045
|
case 0:
|
|
2051
|
-
this.loggerService.log("historyConnectionService dispose"
|
|
2052
|
-
context: this.contextService.context,
|
|
2053
|
-
});
|
|
2046
|
+
this.loggerService.log("historyConnectionService dispose");
|
|
2054
2047
|
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.agentName);
|
|
2055
2048
|
if (!this.getHistory.has(key)) {
|
|
2056
2049
|
return [2 /*return*/];
|
|
@@ -2443,9 +2436,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2443
2436
|
return __generator(this, function (_a) {
|
|
2444
2437
|
switch (_a.label) {
|
|
2445
2438
|
case 0:
|
|
2446
|
-
this.loggerService.log("swarmConnectionService cancelOutput"
|
|
2447
|
-
context: this.contextService.context,
|
|
2448
|
-
});
|
|
2439
|
+
this.loggerService.log("swarmConnectionService cancelOutput");
|
|
2449
2440
|
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).cancelOutput()];
|
|
2450
2441
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2451
2442
|
}
|
|
@@ -2459,9 +2450,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2459
2450
|
return __generator(this, function (_a) {
|
|
2460
2451
|
switch (_a.label) {
|
|
2461
2452
|
case 0:
|
|
2462
|
-
this.loggerService.log("swarmConnectionService waitForOutput"
|
|
2463
|
-
context: this.contextService.context,
|
|
2464
|
-
});
|
|
2453
|
+
this.loggerService.log("swarmConnectionService waitForOutput");
|
|
2465
2454
|
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).waitForOutput()];
|
|
2466
2455
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2467
2456
|
}
|
|
@@ -2475,9 +2464,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2475
2464
|
return __generator(this, function (_a) {
|
|
2476
2465
|
switch (_a.label) {
|
|
2477
2466
|
case 0:
|
|
2478
|
-
this.loggerService.log("swarmConnectionService getAgentName"
|
|
2479
|
-
context: this.contextService.context,
|
|
2480
|
-
});
|
|
2467
|
+
this.loggerService.log("swarmConnectionService getAgentName");
|
|
2481
2468
|
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).getAgentName()];
|
|
2482
2469
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2483
2470
|
}
|
|
@@ -2491,9 +2478,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2491
2478
|
return __generator(this, function (_a) {
|
|
2492
2479
|
switch (_a.label) {
|
|
2493
2480
|
case 0:
|
|
2494
|
-
this.loggerService.log("swarmConnectionService getAgent"
|
|
2495
|
-
context: this.contextService.context,
|
|
2496
|
-
});
|
|
2481
|
+
this.loggerService.log("swarmConnectionService getAgent");
|
|
2497
2482
|
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).getAgent()];
|
|
2498
2483
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2499
2484
|
}
|
|
@@ -2510,7 +2495,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2510
2495
|
switch (_a.label) {
|
|
2511
2496
|
case 0:
|
|
2512
2497
|
this.loggerService.log("swarmConnectionService setAgentRef", {
|
|
2513
|
-
|
|
2498
|
+
agentName: agentName,
|
|
2514
2499
|
});
|
|
2515
2500
|
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).setAgentRef(agentName, agent)];
|
|
2516
2501
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -2528,7 +2513,6 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2528
2513
|
case 0:
|
|
2529
2514
|
this.loggerService.log("swarmConnectionService setAgentName", {
|
|
2530
2515
|
agentName: agentName,
|
|
2531
|
-
context: this.contextService.context,
|
|
2532
2516
|
});
|
|
2533
2517
|
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).setAgentName(agentName)];
|
|
2534
2518
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -2542,9 +2526,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2542
2526
|
this.dispose = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2543
2527
|
var key;
|
|
2544
2528
|
return __generator(this, function (_a) {
|
|
2545
|
-
this.loggerService.log("swarmConnectionService dispose"
|
|
2546
|
-
context: this.contextService.context,
|
|
2547
|
-
});
|
|
2529
|
+
this.loggerService.log("swarmConnectionService dispose");
|
|
2548
2530
|
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.swarmName);
|
|
2549
2531
|
if (!this.getSwarm.has(key)) {
|
|
2550
2532
|
return [2 /*return*/];
|
|
@@ -2894,17 +2876,22 @@ var ClientSession = /** @class */ (function () {
|
|
|
2894
2876
|
clientId: _this.params.clientId,
|
|
2895
2877
|
});
|
|
2896
2878
|
return function (incoming) { return __awaiter(_this, void 0, void 0, function () {
|
|
2897
|
-
var _a;
|
|
2879
|
+
var data, _a;
|
|
2898
2880
|
var _b;
|
|
2899
2881
|
return __generator(this, function (_c) {
|
|
2900
2882
|
switch (_c.label) {
|
|
2901
2883
|
case 0:
|
|
2902
2884
|
this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " connect call"));
|
|
2903
|
-
_a = connector;
|
|
2904
|
-
_b = {};
|
|
2905
2885
|
return [4 /*yield*/, this.execute(incoming.data, "user")];
|
|
2906
2886
|
case 1:
|
|
2907
|
-
|
|
2887
|
+
data = _c.sent();
|
|
2888
|
+
if (!data) {
|
|
2889
|
+
return [2 /*return*/];
|
|
2890
|
+
}
|
|
2891
|
+
_a = connector;
|
|
2892
|
+
_b = {
|
|
2893
|
+
data: data
|
|
2894
|
+
};
|
|
2908
2895
|
return [4 /*yield*/, this.params.swarm.getAgentName()];
|
|
2909
2896
|
case 2: return [4 /*yield*/, _a.apply(void 0, [(_b.agentName = _c.sent(),
|
|
2910
2897
|
_b.clientId = incoming.clientId,
|
|
@@ -2971,7 +2958,7 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
2971
2958
|
switch (_a.label) {
|
|
2972
2959
|
case 0:
|
|
2973
2960
|
this.loggerService.log("sessionConnectionService emit", {
|
|
2974
|
-
|
|
2961
|
+
content: content,
|
|
2975
2962
|
});
|
|
2976
2963
|
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).emit(content)];
|
|
2977
2964
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -2988,7 +2975,6 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
2988
2975
|
switch (_a.label) {
|
|
2989
2976
|
case 0:
|
|
2990
2977
|
this.loggerService.log("sessionConnectionService execute", {
|
|
2991
|
-
context: this.contextService.context,
|
|
2992
2978
|
content: content,
|
|
2993
2979
|
mode: mode,
|
|
2994
2980
|
});
|
|
@@ -3002,11 +2988,9 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3002
2988
|
* @param {SendMessageFn} connector - The function to send messages.
|
|
3003
2989
|
* @returns {ReceiveMessageFn} The function to receive messages.
|
|
3004
2990
|
*/
|
|
3005
|
-
this.connect = function (connector) {
|
|
3006
|
-
_this.loggerService.log("sessionConnectionService connect"
|
|
3007
|
-
|
|
3008
|
-
});
|
|
3009
|
-
return _this.getSession(_this.contextService.context.clientId, _this.contextService.context.swarmName).connect(connector);
|
|
2991
|
+
this.connect = function (connector, clientId, swarmName) {
|
|
2992
|
+
_this.loggerService.log("sessionConnectionService connect");
|
|
2993
|
+
return _this.getSession(clientId, swarmName).connect(connector);
|
|
3010
2994
|
};
|
|
3011
2995
|
/**
|
|
3012
2996
|
* Commits tool output to the session.
|
|
@@ -3019,7 +3003,6 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3019
3003
|
switch (_a.label) {
|
|
3020
3004
|
case 0:
|
|
3021
3005
|
this.loggerService.log("sessionConnectionService commitToolOutput", {
|
|
3022
|
-
context: this.contextService.context,
|
|
3023
3006
|
content: content,
|
|
3024
3007
|
toolId: toolId,
|
|
3025
3008
|
});
|
|
@@ -3038,7 +3021,6 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3038
3021
|
switch (_a.label) {
|
|
3039
3022
|
case 0:
|
|
3040
3023
|
this.loggerService.log("sessionConnectionService commitSystemMessage", {
|
|
3041
|
-
context: this.contextService.context,
|
|
3042
3024
|
message: message,
|
|
3043
3025
|
});
|
|
3044
3026
|
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).commitSystemMessage(message)];
|
|
@@ -3056,7 +3038,6 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3056
3038
|
switch (_a.label) {
|
|
3057
3039
|
case 0:
|
|
3058
3040
|
this.loggerService.log("sessionConnectionService commitUserMessage", {
|
|
3059
|
-
context: this.contextService.context,
|
|
3060
3041
|
message: message,
|
|
3061
3042
|
});
|
|
3062
3043
|
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).commitUserMessage(message)];
|
|
@@ -3073,9 +3054,7 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3073
3054
|
return __generator(this, function (_a) {
|
|
3074
3055
|
switch (_a.label) {
|
|
3075
3056
|
case 0:
|
|
3076
|
-
this.loggerService.log("sessionConnectionService commitFlush"
|
|
3077
|
-
context: this.contextService.context,
|
|
3078
|
-
});
|
|
3057
|
+
this.loggerService.log("sessionConnectionService commitFlush");
|
|
3079
3058
|
return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).commitFlush()];
|
|
3080
3059
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3081
3060
|
}
|
|
@@ -3090,9 +3069,7 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
3090
3069
|
return __generator(this, function (_a) {
|
|
3091
3070
|
switch (_a.label) {
|
|
3092
3071
|
case 0:
|
|
3093
|
-
this.loggerService.log("sessionConnectionService dispose"
|
|
3094
|
-
context: this.contextService.context,
|
|
3095
|
-
});
|
|
3072
|
+
this.loggerService.log("sessionConnectionService dispose");
|
|
3096
3073
|
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.swarmName);
|
|
3097
3074
|
if (!this.getSession.has(key)) {
|
|
3098
3075
|
return [2 /*return*/];
|
|
@@ -3123,12 +3100,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3123
3100
|
* @param {AgentName} agentName - The name of the agent.
|
|
3124
3101
|
* @returns {Promise<unknown>} The agent reference.
|
|
3125
3102
|
*/
|
|
3126
|
-
this.createAgentRef = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3103
|
+
this.createAgentRef = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3127
3104
|
var _this = this;
|
|
3128
3105
|
return __generator(this, function (_a) {
|
|
3129
3106
|
switch (_a.label) {
|
|
3130
3107
|
case 0:
|
|
3131
3108
|
this.loggerService.log("agentPublicService createAgentRef", {
|
|
3109
|
+
requestId: requestId,
|
|
3132
3110
|
clientId: clientId,
|
|
3133
3111
|
agentName: agentName,
|
|
3134
3112
|
});
|
|
@@ -3140,6 +3118,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3140
3118
|
}
|
|
3141
3119
|
});
|
|
3142
3120
|
}); }, {
|
|
3121
|
+
requestId: requestId,
|
|
3143
3122
|
clientId: clientId,
|
|
3144
3123
|
agentName: agentName,
|
|
3145
3124
|
swarmName: "",
|
|
@@ -3157,12 +3136,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3157
3136
|
* @param {AgentName} agentName - The name of the agent.
|
|
3158
3137
|
* @returns {Promise<unknown>} The execution result.
|
|
3159
3138
|
*/
|
|
3160
|
-
this.execute = function (input, mode, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3139
|
+
this.execute = function (input, mode, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3161
3140
|
var _this = this;
|
|
3162
3141
|
return __generator(this, function (_a) {
|
|
3163
3142
|
switch (_a.label) {
|
|
3164
3143
|
case 0:
|
|
3165
3144
|
this.loggerService.log("agentPublicService execute", {
|
|
3145
|
+
requestId: requestId,
|
|
3166
3146
|
input: input,
|
|
3167
3147
|
clientId: clientId,
|
|
3168
3148
|
agentName: agentName,
|
|
@@ -3176,6 +3156,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3176
3156
|
}
|
|
3177
3157
|
});
|
|
3178
3158
|
}); }, {
|
|
3159
|
+
requestId: requestId,
|
|
3179
3160
|
clientId: clientId,
|
|
3180
3161
|
agentName: agentName,
|
|
3181
3162
|
swarmName: "",
|
|
@@ -3192,12 +3173,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3192
3173
|
* @param {AgentName} agentName - The name of the agent.
|
|
3193
3174
|
* @returns {Promise<unknown>} The output result.
|
|
3194
3175
|
*/
|
|
3195
|
-
this.waitForOutput = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3176
|
+
this.waitForOutput = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3196
3177
|
var _this = this;
|
|
3197
3178
|
return __generator(this, function (_a) {
|
|
3198
3179
|
switch (_a.label) {
|
|
3199
3180
|
case 0:
|
|
3200
3181
|
this.loggerService.log("agentPublicService waitForOutput", {
|
|
3182
|
+
requestId: requestId,
|
|
3201
3183
|
clientId: clientId,
|
|
3202
3184
|
agentName: agentName,
|
|
3203
3185
|
});
|
|
@@ -3209,6 +3191,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3209
3191
|
}
|
|
3210
3192
|
});
|
|
3211
3193
|
}); }, {
|
|
3194
|
+
requestId: requestId,
|
|
3212
3195
|
clientId: clientId,
|
|
3213
3196
|
agentName: agentName,
|
|
3214
3197
|
swarmName: "",
|
|
@@ -3227,12 +3210,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3227
3210
|
* @param {AgentName} agentName - The name of the agent.
|
|
3228
3211
|
* @returns {Promise<unknown>} The commit result.
|
|
3229
3212
|
*/
|
|
3230
|
-
this.commitToolOutput = function (toolId, content, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3213
|
+
this.commitToolOutput = function (toolId, content, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3231
3214
|
var _this = this;
|
|
3232
3215
|
return __generator(this, function (_a) {
|
|
3233
3216
|
switch (_a.label) {
|
|
3234
3217
|
case 0:
|
|
3235
3218
|
this.loggerService.log("agentPublicService commitToolOutput", {
|
|
3219
|
+
requestId: requestId,
|
|
3236
3220
|
content: content,
|
|
3237
3221
|
clientId: clientId,
|
|
3238
3222
|
toolId: toolId,
|
|
@@ -3246,6 +3230,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3246
3230
|
}
|
|
3247
3231
|
});
|
|
3248
3232
|
}); }, {
|
|
3233
|
+
requestId: requestId,
|
|
3249
3234
|
clientId: clientId,
|
|
3250
3235
|
agentName: agentName,
|
|
3251
3236
|
swarmName: "",
|
|
@@ -3263,12 +3248,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3263
3248
|
* @param {AgentName} agentName - The name of the agent.
|
|
3264
3249
|
* @returns {Promise<unknown>} The commit result.
|
|
3265
3250
|
*/
|
|
3266
|
-
this.commitSystemMessage = function (message, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3251
|
+
this.commitSystemMessage = function (message, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3267
3252
|
var _this = this;
|
|
3268
3253
|
return __generator(this, function (_a) {
|
|
3269
3254
|
switch (_a.label) {
|
|
3270
3255
|
case 0:
|
|
3271
3256
|
this.loggerService.log("agentPublicService commitSystemMessage", {
|
|
3257
|
+
requestId: requestId,
|
|
3272
3258
|
message: message,
|
|
3273
3259
|
clientId: clientId,
|
|
3274
3260
|
agentName: agentName,
|
|
@@ -3281,6 +3267,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3281
3267
|
}
|
|
3282
3268
|
});
|
|
3283
3269
|
}); }, {
|
|
3270
|
+
requestId: requestId,
|
|
3284
3271
|
clientId: clientId,
|
|
3285
3272
|
agentName: agentName,
|
|
3286
3273
|
swarmName: "",
|
|
@@ -3298,12 +3285,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3298
3285
|
* @param {AgentName} agentName - The name of the agent.
|
|
3299
3286
|
* @returns {Promise<unknown>} The commit result.
|
|
3300
3287
|
*/
|
|
3301
|
-
this.commitUserMessage = function (message, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3288
|
+
this.commitUserMessage = function (message, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3302
3289
|
var _this = this;
|
|
3303
3290
|
return __generator(this, function (_a) {
|
|
3304
3291
|
switch (_a.label) {
|
|
3305
3292
|
case 0:
|
|
3306
3293
|
this.loggerService.log("agentPublicService commitUserMessage", {
|
|
3294
|
+
requestId: requestId,
|
|
3307
3295
|
message: message,
|
|
3308
3296
|
clientId: clientId,
|
|
3309
3297
|
agentName: agentName,
|
|
@@ -3316,6 +3304,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3316
3304
|
}
|
|
3317
3305
|
});
|
|
3318
3306
|
}); }, {
|
|
3307
|
+
requestId: requestId,
|
|
3319
3308
|
clientId: clientId,
|
|
3320
3309
|
agentName: agentName,
|
|
3321
3310
|
swarmName: "",
|
|
@@ -3332,12 +3321,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3332
3321
|
* @param {AgentName} agentName - The name of the agent.
|
|
3333
3322
|
* @returns {Promise<unknown>} The commit result.
|
|
3334
3323
|
*/
|
|
3335
|
-
this.commitFlush = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3324
|
+
this.commitFlush = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3336
3325
|
var _this = this;
|
|
3337
3326
|
return __generator(this, function (_a) {
|
|
3338
3327
|
switch (_a.label) {
|
|
3339
3328
|
case 0:
|
|
3340
3329
|
this.loggerService.log("agentPublicService commitFlush", {
|
|
3330
|
+
requestId: requestId,
|
|
3341
3331
|
clientId: clientId,
|
|
3342
3332
|
agentName: agentName,
|
|
3343
3333
|
});
|
|
@@ -3349,6 +3339,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3349
3339
|
}
|
|
3350
3340
|
});
|
|
3351
3341
|
}); }, {
|
|
3342
|
+
requestId: requestId,
|
|
3352
3343
|
clientId: clientId,
|
|
3353
3344
|
agentName: agentName,
|
|
3354
3345
|
swarmName: "",
|
|
@@ -3365,12 +3356,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3365
3356
|
* @param {AgentName} agentName - The name of the agent.
|
|
3366
3357
|
* @returns {Promise<unknown>} The commit result.
|
|
3367
3358
|
*/
|
|
3368
|
-
this.commitAgentChange = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3359
|
+
this.commitAgentChange = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3369
3360
|
var _this = this;
|
|
3370
3361
|
return __generator(this, function (_a) {
|
|
3371
3362
|
switch (_a.label) {
|
|
3372
3363
|
case 0:
|
|
3373
3364
|
this.loggerService.log("agentPublicService commitAgentChange", {
|
|
3365
|
+
requestId: requestId,
|
|
3374
3366
|
clientId: clientId,
|
|
3375
3367
|
agentName: agentName,
|
|
3376
3368
|
});
|
|
@@ -3382,6 +3374,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3382
3374
|
}
|
|
3383
3375
|
});
|
|
3384
3376
|
}); }, {
|
|
3377
|
+
requestId: requestId,
|
|
3385
3378
|
clientId: clientId,
|
|
3386
3379
|
agentName: agentName,
|
|
3387
3380
|
swarmName: "",
|
|
@@ -3398,12 +3391,13 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3398
3391
|
* @param {AgentName} agentName - The name of the agent.
|
|
3399
3392
|
* @returns {Promise<unknown>} The dispose result.
|
|
3400
3393
|
*/
|
|
3401
|
-
this.dispose = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3394
|
+
this.dispose = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3402
3395
|
var _this = this;
|
|
3403
3396
|
return __generator(this, function (_a) {
|
|
3404
3397
|
switch (_a.label) {
|
|
3405
3398
|
case 0:
|
|
3406
3399
|
this.loggerService.log("agentPublicService dispose", {
|
|
3400
|
+
requestId: requestId,
|
|
3407
3401
|
clientId: clientId,
|
|
3408
3402
|
agentName: agentName,
|
|
3409
3403
|
});
|
|
@@ -3415,6 +3409,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3415
3409
|
}
|
|
3416
3410
|
});
|
|
3417
3411
|
}); }, {
|
|
3412
|
+
requestId: requestId,
|
|
3418
3413
|
clientId: clientId,
|
|
3419
3414
|
agentName: agentName,
|
|
3420
3415
|
swarmName: "",
|
|
@@ -3444,12 +3439,13 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3444
3439
|
* @param {AgentName} agentName - The agent name.
|
|
3445
3440
|
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
3446
3441
|
*/
|
|
3447
|
-
this.push = function (message, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3442
|
+
this.push = function (message, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3448
3443
|
var _this = this;
|
|
3449
3444
|
return __generator(this, function (_a) {
|
|
3450
3445
|
switch (_a.label) {
|
|
3451
3446
|
case 0:
|
|
3452
3447
|
this.loggerService.log("historyPublicService push", {
|
|
3448
|
+
requestId: requestId,
|
|
3453
3449
|
message: message,
|
|
3454
3450
|
clientId: clientId,
|
|
3455
3451
|
agentName: agentName,
|
|
@@ -3462,6 +3458,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3462
3458
|
}
|
|
3463
3459
|
});
|
|
3464
3460
|
}); }, {
|
|
3461
|
+
requestId: requestId,
|
|
3465
3462
|
clientId: clientId,
|
|
3466
3463
|
agentName: agentName,
|
|
3467
3464
|
swarmName: "",
|
|
@@ -3479,7 +3476,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3479
3476
|
* @param {AgentName} agentName - The agent name.
|
|
3480
3477
|
* @returns {Promise<any[]>} A promise that resolves to an array of history items.
|
|
3481
3478
|
*/
|
|
3482
|
-
this.toArrayForAgent = function (prompt, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3479
|
+
this.toArrayForAgent = function (prompt, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3483
3480
|
var _this = this;
|
|
3484
3481
|
return __generator(this, function (_a) {
|
|
3485
3482
|
switch (_a.label) {
|
|
@@ -3497,6 +3494,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3497
3494
|
}
|
|
3498
3495
|
});
|
|
3499
3496
|
}); }, {
|
|
3497
|
+
requestId: requestId,
|
|
3500
3498
|
clientId: clientId,
|
|
3501
3499
|
agentName: agentName,
|
|
3502
3500
|
swarmName: "",
|
|
@@ -3513,12 +3511,13 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3513
3511
|
* @param {AgentName} agentName - The agent name.
|
|
3514
3512
|
* @returns {Promise<any[]>} A promise that resolves to a raw array of history items.
|
|
3515
3513
|
*/
|
|
3516
|
-
this.toArrayForRaw = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3514
|
+
this.toArrayForRaw = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3517
3515
|
var _this = this;
|
|
3518
3516
|
return __generator(this, function (_a) {
|
|
3519
3517
|
switch (_a.label) {
|
|
3520
3518
|
case 0:
|
|
3521
3519
|
this.loggerService.log("historyPublicService toArrayForRaw", {
|
|
3520
|
+
requestId: requestId,
|
|
3522
3521
|
clientId: clientId,
|
|
3523
3522
|
agentName: agentName,
|
|
3524
3523
|
});
|
|
@@ -3530,6 +3529,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3530
3529
|
}
|
|
3531
3530
|
});
|
|
3532
3531
|
}); }, {
|
|
3532
|
+
requestId: requestId,
|
|
3533
3533
|
clientId: clientId,
|
|
3534
3534
|
agentName: agentName,
|
|
3535
3535
|
swarmName: "",
|
|
@@ -3546,7 +3546,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3546
3546
|
* @param {AgentName} agentName - The agent name.
|
|
3547
3547
|
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
3548
3548
|
*/
|
|
3549
|
-
this.dispose = function (clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3549
|
+
this.dispose = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3550
3550
|
var _this = this;
|
|
3551
3551
|
return __generator(this, function (_a) {
|
|
3552
3552
|
switch (_a.label) {
|
|
@@ -3563,6 +3563,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3563
3563
|
}
|
|
3564
3564
|
});
|
|
3565
3565
|
}); }, {
|
|
3566
|
+
requestId: requestId,
|
|
3566
3567
|
clientId: clientId,
|
|
3567
3568
|
agentName: agentName,
|
|
3568
3569
|
swarmName: "",
|
|
@@ -3592,7 +3593,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3592
3593
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3593
3594
|
* @returns {Promise<void>}
|
|
3594
3595
|
*/
|
|
3595
|
-
this.emit = function (content, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3596
|
+
this.emit = function (content, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3596
3597
|
var _this = this;
|
|
3597
3598
|
return __generator(this, function (_a) {
|
|
3598
3599
|
switch (_a.label) {
|
|
@@ -3600,6 +3601,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3600
3601
|
this.loggerService.log("sessionPublicService emit", {
|
|
3601
3602
|
content: content,
|
|
3602
3603
|
clientId: clientId,
|
|
3604
|
+
requestId: requestId,
|
|
3603
3605
|
swarmName: swarmName,
|
|
3604
3606
|
});
|
|
3605
3607
|
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -3610,6 +3612,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3610
3612
|
}
|
|
3611
3613
|
});
|
|
3612
3614
|
}); }, {
|
|
3615
|
+
requestId: requestId,
|
|
3613
3616
|
clientId: clientId,
|
|
3614
3617
|
swarmName: swarmName,
|
|
3615
3618
|
agentName: "",
|
|
@@ -3627,7 +3630,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3627
3630
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3628
3631
|
* @returns {Promise<void>}
|
|
3629
3632
|
*/
|
|
3630
|
-
this.execute = function (content, mode, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3633
|
+
this.execute = function (content, mode, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3631
3634
|
var _this = this;
|
|
3632
3635
|
return __generator(this, function (_a) {
|
|
3633
3636
|
switch (_a.label) {
|
|
@@ -3646,6 +3649,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3646
3649
|
}
|
|
3647
3650
|
});
|
|
3648
3651
|
}); }, {
|
|
3652
|
+
requestId: requestId,
|
|
3649
3653
|
clientId: clientId,
|
|
3650
3654
|
swarmName: swarmName,
|
|
3651
3655
|
agentName: "",
|
|
@@ -3663,52 +3667,13 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3663
3667
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3664
3668
|
* @returns {ReceiveMessageFn}
|
|
3665
3669
|
*/
|
|
3666
|
-
this.connect = function (connector, clientId, swarmName) {
|
|
3670
|
+
this.connect = function (connector, requestId, clientId, swarmName) {
|
|
3667
3671
|
_this.loggerService.log("sessionPublicService connect", {
|
|
3672
|
+
requestId: requestId,
|
|
3668
3673
|
clientId: clientId,
|
|
3669
3674
|
swarmName: swarmName,
|
|
3670
3675
|
});
|
|
3671
|
-
return
|
|
3672
|
-
var receive = _this.sessionConnectionService.connect(function (outgoing) { return __awaiter(_this, void 0, void 0, function () {
|
|
3673
|
-
var _this = this;
|
|
3674
|
-
return __generator(this, function (_a) {
|
|
3675
|
-
switch (_a.label) {
|
|
3676
|
-
case 0: return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3677
|
-
return __generator(this, function (_a) {
|
|
3678
|
-
switch (_a.label) {
|
|
3679
|
-
case 0: return [4 /*yield*/, connector(outgoing)];
|
|
3680
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
3681
|
-
}
|
|
3682
|
-
});
|
|
3683
|
-
}); }, {
|
|
3684
|
-
clientId: clientId,
|
|
3685
|
-
swarmName: swarmName,
|
|
3686
|
-
agentName: "",
|
|
3687
|
-
storageName: "",
|
|
3688
|
-
stateName: "",
|
|
3689
|
-
})];
|
|
3690
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
3691
|
-
}
|
|
3692
|
-
});
|
|
3693
|
-
}); });
|
|
3694
|
-
return function (incoming) {
|
|
3695
|
-
return ContextService.runInContext(function () {
|
|
3696
|
-
return receive(incoming);
|
|
3697
|
-
}, {
|
|
3698
|
-
clientId: clientId,
|
|
3699
|
-
swarmName: swarmName,
|
|
3700
|
-
agentName: "",
|
|
3701
|
-
storageName: "",
|
|
3702
|
-
stateName: "",
|
|
3703
|
-
});
|
|
3704
|
-
};
|
|
3705
|
-
}, {
|
|
3706
|
-
clientId: clientId,
|
|
3707
|
-
swarmName: swarmName,
|
|
3708
|
-
agentName: "",
|
|
3709
|
-
storageName: "",
|
|
3710
|
-
stateName: "",
|
|
3711
|
-
});
|
|
3676
|
+
return _this.sessionConnectionService.connect(connector, clientId, swarmName);
|
|
3712
3677
|
};
|
|
3713
3678
|
/**
|
|
3714
3679
|
* Commits tool output to the session.
|
|
@@ -3718,12 +3683,13 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3718
3683
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3719
3684
|
* @returns {Promise<void>}
|
|
3720
3685
|
*/
|
|
3721
|
-
this.commitToolOutput = function (toolId, content, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3686
|
+
this.commitToolOutput = function (toolId, content, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3722
3687
|
var _this = this;
|
|
3723
3688
|
return __generator(this, function (_a) {
|
|
3724
3689
|
switch (_a.label) {
|
|
3725
3690
|
case 0:
|
|
3726
3691
|
this.loggerService.log("sessionPublicService commitToolOutput", {
|
|
3692
|
+
requestId: requestId,
|
|
3727
3693
|
toolId: toolId,
|
|
3728
3694
|
content: content,
|
|
3729
3695
|
clientId: clientId,
|
|
@@ -3737,6 +3703,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3737
3703
|
}
|
|
3738
3704
|
});
|
|
3739
3705
|
}); }, {
|
|
3706
|
+
requestId: requestId,
|
|
3740
3707
|
clientId: clientId,
|
|
3741
3708
|
swarmName: swarmName,
|
|
3742
3709
|
agentName: "",
|
|
@@ -3754,12 +3721,13 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3754
3721
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3755
3722
|
* @returns {Promise<void>}
|
|
3756
3723
|
*/
|
|
3757
|
-
this.commitSystemMessage = function (message, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3724
|
+
this.commitSystemMessage = function (message, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3758
3725
|
var _this = this;
|
|
3759
3726
|
return __generator(this, function (_a) {
|
|
3760
3727
|
switch (_a.label) {
|
|
3761
3728
|
case 0:
|
|
3762
3729
|
this.loggerService.log("sessionPublicService commitSystemMessage", {
|
|
3730
|
+
requestId: requestId,
|
|
3763
3731
|
message: message,
|
|
3764
3732
|
clientId: clientId,
|
|
3765
3733
|
swarmName: swarmName,
|
|
@@ -3772,6 +3740,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3772
3740
|
}
|
|
3773
3741
|
});
|
|
3774
3742
|
}); }, {
|
|
3743
|
+
requestId: requestId,
|
|
3775
3744
|
clientId: clientId,
|
|
3776
3745
|
swarmName: swarmName,
|
|
3777
3746
|
agentName: "",
|
|
@@ -3789,12 +3758,13 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3789
3758
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3790
3759
|
* @returns {Promise<void>}
|
|
3791
3760
|
*/
|
|
3792
|
-
this.commitUserMessage = function (message, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3761
|
+
this.commitUserMessage = function (message, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3793
3762
|
var _this = this;
|
|
3794
3763
|
return __generator(this, function (_a) {
|
|
3795
3764
|
switch (_a.label) {
|
|
3796
3765
|
case 0:
|
|
3797
3766
|
this.loggerService.log("sessionPublicService commitUserMessage", {
|
|
3767
|
+
requestId: requestId,
|
|
3798
3768
|
message: message,
|
|
3799
3769
|
clientId: clientId,
|
|
3800
3770
|
swarmName: swarmName,
|
|
@@ -3807,6 +3777,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3807
3777
|
}
|
|
3808
3778
|
});
|
|
3809
3779
|
}); }, {
|
|
3780
|
+
requestId: requestId,
|
|
3810
3781
|
clientId: clientId,
|
|
3811
3782
|
swarmName: swarmName,
|
|
3812
3783
|
agentName: "",
|
|
@@ -3823,7 +3794,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3823
3794
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3824
3795
|
* @returns {Promise<void>}
|
|
3825
3796
|
*/
|
|
3826
|
-
this.commitFlush = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3797
|
+
this.commitFlush = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3827
3798
|
var _this = this;
|
|
3828
3799
|
return __generator(this, function (_a) {
|
|
3829
3800
|
switch (_a.label) {
|
|
@@ -3840,6 +3811,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3840
3811
|
}
|
|
3841
3812
|
});
|
|
3842
3813
|
}); }, {
|
|
3814
|
+
requestId: requestId,
|
|
3843
3815
|
clientId: clientId,
|
|
3844
3816
|
swarmName: swarmName,
|
|
3845
3817
|
agentName: "",
|
|
@@ -3856,12 +3828,13 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3856
3828
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3857
3829
|
* @returns {Promise<void>}
|
|
3858
3830
|
*/
|
|
3859
|
-
this.dispose = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3831
|
+
this.dispose = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3860
3832
|
var _this = this;
|
|
3861
3833
|
return __generator(this, function (_a) {
|
|
3862
3834
|
switch (_a.label) {
|
|
3863
3835
|
case 0:
|
|
3864
3836
|
this.loggerService.log("sessionPublicService dispose", {
|
|
3837
|
+
requestId: requestId,
|
|
3865
3838
|
clientId: clientId,
|
|
3866
3839
|
swarmName: swarmName,
|
|
3867
3840
|
});
|
|
@@ -3873,6 +3846,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3873
3846
|
}
|
|
3874
3847
|
});
|
|
3875
3848
|
}); }, {
|
|
3849
|
+
requestId: requestId,
|
|
3876
3850
|
clientId: clientId,
|
|
3877
3851
|
swarmName: swarmName,
|
|
3878
3852
|
agentName: "",
|
|
@@ -3901,7 +3875,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3901
3875
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3902
3876
|
* @returns {Promise<void>}
|
|
3903
3877
|
*/
|
|
3904
|
-
this.cancelOutput = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3878
|
+
this.cancelOutput = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3905
3879
|
var _this = this;
|
|
3906
3880
|
return __generator(this, function (_a) {
|
|
3907
3881
|
switch (_a.label) {
|
|
@@ -3918,6 +3892,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3918
3892
|
}
|
|
3919
3893
|
});
|
|
3920
3894
|
}); }, {
|
|
3895
|
+
requestId: requestId,
|
|
3921
3896
|
clientId: clientId,
|
|
3922
3897
|
swarmName: swarmName,
|
|
3923
3898
|
agentName: "",
|
|
@@ -3934,13 +3909,14 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3934
3909
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3935
3910
|
* @returns {Promise<void>}
|
|
3936
3911
|
*/
|
|
3937
|
-
this.waitForOutput = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3912
|
+
this.waitForOutput = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3938
3913
|
var _this = this;
|
|
3939
3914
|
return __generator(this, function (_a) {
|
|
3940
3915
|
switch (_a.label) {
|
|
3941
3916
|
case 0:
|
|
3942
3917
|
this.loggerService.log("swarmPublicService waitForOutput", {
|
|
3943
3918
|
clientId: clientId,
|
|
3919
|
+
requestId: requestId,
|
|
3944
3920
|
swarmName: swarmName,
|
|
3945
3921
|
});
|
|
3946
3922
|
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -3951,6 +3927,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3951
3927
|
}
|
|
3952
3928
|
});
|
|
3953
3929
|
}); }, {
|
|
3930
|
+
requestId: requestId,
|
|
3954
3931
|
clientId: clientId,
|
|
3955
3932
|
swarmName: swarmName,
|
|
3956
3933
|
agentName: "",
|
|
@@ -3967,7 +3944,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3967
3944
|
* @param {SwarmName} swarmName - The swarm name.
|
|
3968
3945
|
* @returns {Promise<string>}
|
|
3969
3946
|
*/
|
|
3970
|
-
this.getAgentName = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3947
|
+
this.getAgentName = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3971
3948
|
var _this = this;
|
|
3972
3949
|
return __generator(this, function (_a) {
|
|
3973
3950
|
switch (_a.label) {
|
|
@@ -3975,6 +3952,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3975
3952
|
this.loggerService.log("swarmPublicService getAgentName", {
|
|
3976
3953
|
clientId: clientId,
|
|
3977
3954
|
swarmName: swarmName,
|
|
3955
|
+
requestId: requestId,
|
|
3978
3956
|
});
|
|
3979
3957
|
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3980
3958
|
return __generator(this, function (_a) {
|
|
@@ -3984,6 +3962,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3984
3962
|
}
|
|
3985
3963
|
});
|
|
3986
3964
|
}); }, {
|
|
3965
|
+
requestId: requestId,
|
|
3987
3966
|
clientId: clientId,
|
|
3988
3967
|
swarmName: swarmName,
|
|
3989
3968
|
agentName: "",
|
|
@@ -4000,7 +3979,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4000
3979
|
* @param {SwarmName} swarmName - The swarm name.
|
|
4001
3980
|
* @returns {Promise<IAgent>}
|
|
4002
3981
|
*/
|
|
4003
|
-
this.getAgent = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3982
|
+
this.getAgent = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4004
3983
|
var _this = this;
|
|
4005
3984
|
return __generator(this, function (_a) {
|
|
4006
3985
|
switch (_a.label) {
|
|
@@ -4017,6 +3996,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4017
3996
|
}
|
|
4018
3997
|
});
|
|
4019
3998
|
}); }, {
|
|
3999
|
+
requestId: requestId,
|
|
4020
4000
|
clientId: clientId,
|
|
4021
4001
|
swarmName: swarmName,
|
|
4022
4002
|
agentName: "",
|
|
@@ -4035,12 +4015,13 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4035
4015
|
* @param {IAgent} agent - The agent instance.
|
|
4036
4016
|
* @returns {Promise<void>}
|
|
4037
4017
|
*/
|
|
4038
|
-
this.setAgentRef = function (clientId, swarmName, agentName, agent) { return __awaiter(_this, void 0, void 0, function () {
|
|
4018
|
+
this.setAgentRef = function (requestId, clientId, swarmName, agentName, agent) { return __awaiter(_this, void 0, void 0, function () {
|
|
4039
4019
|
var _this = this;
|
|
4040
4020
|
return __generator(this, function (_a) {
|
|
4041
4021
|
switch (_a.label) {
|
|
4042
4022
|
case 0:
|
|
4043
4023
|
this.loggerService.log("swarmPublicService setAgentRef", {
|
|
4024
|
+
requestId: requestId,
|
|
4044
4025
|
agentName: agentName,
|
|
4045
4026
|
agent: agent,
|
|
4046
4027
|
clientId: clientId,
|
|
@@ -4054,6 +4035,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4054
4035
|
}
|
|
4055
4036
|
});
|
|
4056
4037
|
}); }, {
|
|
4038
|
+
requestId: requestId,
|
|
4057
4039
|
clientId: clientId,
|
|
4058
4040
|
swarmName: swarmName,
|
|
4059
4041
|
agentName: "",
|
|
@@ -4071,12 +4053,13 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4071
4053
|
* @param {SwarmName} swarmName - The swarm name.
|
|
4072
4054
|
* @returns {Promise<void>}
|
|
4073
4055
|
*/
|
|
4074
|
-
this.setAgentName = function (agentName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4056
|
+
this.setAgentName = function (agentName, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4075
4057
|
var _this = this;
|
|
4076
4058
|
return __generator(this, function (_a) {
|
|
4077
4059
|
switch (_a.label) {
|
|
4078
4060
|
case 0:
|
|
4079
4061
|
this.loggerService.log("swarmPublicService setAgentName", {
|
|
4062
|
+
requestId: requestId,
|
|
4080
4063
|
agentName: agentName,
|
|
4081
4064
|
clientId: clientId,
|
|
4082
4065
|
swarmName: swarmName,
|
|
@@ -4089,6 +4072,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4089
4072
|
}
|
|
4090
4073
|
});
|
|
4091
4074
|
}); }, {
|
|
4075
|
+
requestId: requestId,
|
|
4092
4076
|
clientId: clientId,
|
|
4093
4077
|
swarmName: swarmName,
|
|
4094
4078
|
agentName: "",
|
|
@@ -4105,12 +4089,13 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4105
4089
|
* @param {SwarmName} swarmName - The swarm name.
|
|
4106
4090
|
* @returns {Promise<void>}
|
|
4107
4091
|
*/
|
|
4108
|
-
this.dispose = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4092
|
+
this.dispose = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
4109
4093
|
var _this = this;
|
|
4110
4094
|
return __generator(this, function (_a) {
|
|
4111
4095
|
switch (_a.label) {
|
|
4112
4096
|
case 0:
|
|
4113
4097
|
this.loggerService.log("swarmPublicService dispose", {
|
|
4098
|
+
requestId: requestId,
|
|
4114
4099
|
clientId: clientId,
|
|
4115
4100
|
swarmName: swarmName,
|
|
4116
4101
|
});
|
|
@@ -4122,6 +4107,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
4122
4107
|
}
|
|
4123
4108
|
});
|
|
4124
4109
|
}); }, {
|
|
4110
|
+
requestId: requestId,
|
|
4125
4111
|
clientId: clientId,
|
|
4126
4112
|
swarmName: swarmName,
|
|
4127
4113
|
agentName: "",
|
|
@@ -5214,7 +5200,6 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5214
5200
|
switch (_a.label) {
|
|
5215
5201
|
case 0:
|
|
5216
5202
|
this.loggerService.log("storageConnectionService take", {
|
|
5217
|
-
context: this.contextService.context,
|
|
5218
5203
|
search: search,
|
|
5219
5204
|
total: total,
|
|
5220
5205
|
score: score,
|
|
@@ -5239,7 +5224,6 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5239
5224
|
switch (_a.label) {
|
|
5240
5225
|
case 0:
|
|
5241
5226
|
this.loggerService.log("storageConnectionService upsert", {
|
|
5242
|
-
context: this.contextService.context,
|
|
5243
5227
|
item: item,
|
|
5244
5228
|
});
|
|
5245
5229
|
storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
@@ -5262,7 +5246,6 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5262
5246
|
switch (_a.label) {
|
|
5263
5247
|
case 0:
|
|
5264
5248
|
this.loggerService.log("storageConnectionService remove", {
|
|
5265
|
-
context: this.contextService.context,
|
|
5266
5249
|
itemId: itemId,
|
|
5267
5250
|
});
|
|
5268
5251
|
storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
@@ -5285,7 +5268,6 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5285
5268
|
switch (_a.label) {
|
|
5286
5269
|
case 0:
|
|
5287
5270
|
this.loggerService.log("storageConnectionService get", {
|
|
5288
|
-
context: this.contextService.context,
|
|
5289
5271
|
itemId: itemId,
|
|
5290
5272
|
});
|
|
5291
5273
|
storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
@@ -5307,9 +5289,7 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5307
5289
|
return __generator(this, function (_a) {
|
|
5308
5290
|
switch (_a.label) {
|
|
5309
5291
|
case 0:
|
|
5310
|
-
this.loggerService.log("storageConnectionService list"
|
|
5311
|
-
context: this.contextService.context,
|
|
5312
|
-
});
|
|
5292
|
+
this.loggerService.log("storageConnectionService list");
|
|
5313
5293
|
storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
5314
5294
|
return [4 /*yield*/, storage.waitForInit()];
|
|
5315
5295
|
case 1:
|
|
@@ -5328,9 +5308,7 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5328
5308
|
return __generator(this, function (_a) {
|
|
5329
5309
|
switch (_a.label) {
|
|
5330
5310
|
case 0:
|
|
5331
|
-
this.loggerService.log("storageConnectionService clear"
|
|
5332
|
-
context: this.contextService.context,
|
|
5333
|
-
});
|
|
5311
|
+
this.loggerService.log("storageConnectionService clear");
|
|
5334
5312
|
storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
5335
5313
|
return [4 /*yield*/, storage.waitForInit()];
|
|
5336
5314
|
case 1:
|
|
@@ -5349,9 +5327,7 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
5349
5327
|
return __generator(this, function (_a) {
|
|
5350
5328
|
switch (_a.label) {
|
|
5351
5329
|
case 0:
|
|
5352
|
-
this.loggerService.log("storageConnectionService dispose"
|
|
5353
|
-
context: this.contextService.context,
|
|
5354
|
-
});
|
|
5330
|
+
this.loggerService.log("storageConnectionService dispose");
|
|
5355
5331
|
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.storageName);
|
|
5356
5332
|
if (!this.getStorage.has(key)) {
|
|
5357
5333
|
return [2 /*return*/];
|
|
@@ -5390,12 +5366,13 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5390
5366
|
* @param {number} total - The total number of items to retrieve.
|
|
5391
5367
|
* @returns {Promise<IStorageData[]>} The list of storage data.
|
|
5392
5368
|
*/
|
|
5393
|
-
this.take = function (search, total, clientId, storageName, score) { return __awaiter(_this, void 0, void 0, function () {
|
|
5369
|
+
this.take = function (search, total, requestId, clientId, storageName, score) { return __awaiter(_this, void 0, void 0, function () {
|
|
5394
5370
|
var _this = this;
|
|
5395
5371
|
return __generator(this, function (_a) {
|
|
5396
5372
|
switch (_a.label) {
|
|
5397
5373
|
case 0:
|
|
5398
5374
|
this.loggerService.log("storagePublicService take", {
|
|
5375
|
+
requestId: requestId,
|
|
5399
5376
|
search: search,
|
|
5400
5377
|
total: total,
|
|
5401
5378
|
clientId: clientId,
|
|
@@ -5410,6 +5387,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5410
5387
|
}
|
|
5411
5388
|
});
|
|
5412
5389
|
}); }, {
|
|
5390
|
+
requestId: requestId,
|
|
5413
5391
|
clientId: clientId,
|
|
5414
5392
|
storageName: storageName,
|
|
5415
5393
|
agentName: "",
|
|
@@ -5425,7 +5403,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5425
5403
|
* @param {IStorageData} item - The item to upsert.
|
|
5426
5404
|
* @returns {Promise<void>}
|
|
5427
5405
|
*/
|
|
5428
|
-
this.upsert = function (item, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5406
|
+
this.upsert = function (item, requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5429
5407
|
var _this = this;
|
|
5430
5408
|
return __generator(this, function (_a) {
|
|
5431
5409
|
switch (_a.label) {
|
|
@@ -5443,6 +5421,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5443
5421
|
}
|
|
5444
5422
|
});
|
|
5445
5423
|
}); }, {
|
|
5424
|
+
requestId: requestId,
|
|
5446
5425
|
clientId: clientId,
|
|
5447
5426
|
storageName: storageName,
|
|
5448
5427
|
agentName: "",
|
|
@@ -5458,7 +5437,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5458
5437
|
* @param {IStorageData["id"]} itemId - The ID of the item to remove.
|
|
5459
5438
|
* @returns {Promise<void>}
|
|
5460
5439
|
*/
|
|
5461
|
-
this.remove = function (itemId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5440
|
+
this.remove = function (itemId, requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5462
5441
|
var _this = this;
|
|
5463
5442
|
return __generator(this, function (_a) {
|
|
5464
5443
|
switch (_a.label) {
|
|
@@ -5476,6 +5455,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5476
5455
|
}
|
|
5477
5456
|
});
|
|
5478
5457
|
}); }, {
|
|
5458
|
+
requestId: requestId,
|
|
5479
5459
|
clientId: clientId,
|
|
5480
5460
|
storageName: storageName,
|
|
5481
5461
|
agentName: "",
|
|
@@ -5491,12 +5471,13 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5491
5471
|
* @param {IStorageData["id"]} itemId - The ID of the item to retrieve.
|
|
5492
5472
|
* @returns {Promise<IStorageData>} The retrieved item.
|
|
5493
5473
|
*/
|
|
5494
|
-
this.get = function (itemId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5474
|
+
this.get = function (itemId, requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5495
5475
|
var _this = this;
|
|
5496
5476
|
return __generator(this, function (_a) {
|
|
5497
5477
|
switch (_a.label) {
|
|
5498
5478
|
case 0:
|
|
5499
5479
|
this.loggerService.log("storagePublicService get", {
|
|
5480
|
+
requestId: requestId,
|
|
5500
5481
|
itemId: itemId,
|
|
5501
5482
|
clientId: clientId,
|
|
5502
5483
|
storageName: storageName,
|
|
@@ -5509,6 +5490,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5509
5490
|
}
|
|
5510
5491
|
});
|
|
5511
5492
|
}); }, {
|
|
5493
|
+
requestId: requestId,
|
|
5512
5494
|
clientId: clientId,
|
|
5513
5495
|
storageName: storageName,
|
|
5514
5496
|
agentName: "",
|
|
@@ -5524,12 +5506,13 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5524
5506
|
* @param {function(IStorageData): boolean} [filter] - The optional filter function.
|
|
5525
5507
|
* @returns {Promise<IStorageData[]>} The list of items.
|
|
5526
5508
|
*/
|
|
5527
|
-
this.list = function (clientId, storageName, filter) { return __awaiter(_this, void 0, void 0, function () {
|
|
5509
|
+
this.list = function (requestId, clientId, storageName, filter) { return __awaiter(_this, void 0, void 0, function () {
|
|
5528
5510
|
var _this = this;
|
|
5529
5511
|
return __generator(this, function (_a) {
|
|
5530
5512
|
switch (_a.label) {
|
|
5531
5513
|
case 0:
|
|
5532
5514
|
this.loggerService.log("storagePublicService list", {
|
|
5515
|
+
requestId: requestId,
|
|
5533
5516
|
clientId: clientId,
|
|
5534
5517
|
storageName: storageName,
|
|
5535
5518
|
});
|
|
@@ -5541,6 +5524,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5541
5524
|
}
|
|
5542
5525
|
});
|
|
5543
5526
|
}); }, {
|
|
5527
|
+
requestId: requestId,
|
|
5544
5528
|
clientId: clientId,
|
|
5545
5529
|
storageName: storageName,
|
|
5546
5530
|
agentName: "",
|
|
@@ -5555,12 +5539,13 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5555
5539
|
* Clears all items from the storage.
|
|
5556
5540
|
* @returns {Promise<void>}
|
|
5557
5541
|
*/
|
|
5558
|
-
this.clear = function (clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5542
|
+
this.clear = function (requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5559
5543
|
var _this = this;
|
|
5560
5544
|
return __generator(this, function (_a) {
|
|
5561
5545
|
switch (_a.label) {
|
|
5562
5546
|
case 0:
|
|
5563
5547
|
this.loggerService.log("storagePublicService clear", {
|
|
5548
|
+
requestId: requestId,
|
|
5564
5549
|
clientId: clientId,
|
|
5565
5550
|
storageName: storageName,
|
|
5566
5551
|
});
|
|
@@ -5572,6 +5557,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5572
5557
|
}
|
|
5573
5558
|
});
|
|
5574
5559
|
}); }, {
|
|
5560
|
+
requestId: requestId,
|
|
5575
5561
|
clientId: clientId,
|
|
5576
5562
|
storageName: storageName,
|
|
5577
5563
|
agentName: "",
|
|
@@ -5588,7 +5574,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5588
5574
|
* @param {StorageName} storageName - The storage name.
|
|
5589
5575
|
* @returns {Promise<void>}
|
|
5590
5576
|
*/
|
|
5591
|
-
this.dispose = function (clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5577
|
+
this.dispose = function (requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5592
5578
|
var _this = this;
|
|
5593
5579
|
return __generator(this, function (_a) {
|
|
5594
5580
|
switch (_a.label) {
|
|
@@ -5605,6 +5591,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
5605
5591
|
}
|
|
5606
5592
|
});
|
|
5607
5593
|
}); }, {
|
|
5594
|
+
requestId: requestId,
|
|
5608
5595
|
clientId: clientId,
|
|
5609
5596
|
storageName: storageName,
|
|
5610
5597
|
agentName: "",
|
|
@@ -6033,9 +6020,7 @@ var StateConnectionService = /** @class */ (function () {
|
|
|
6033
6020
|
return __generator(this, function (_a) {
|
|
6034
6021
|
switch (_a.label) {
|
|
6035
6022
|
case 0:
|
|
6036
|
-
this.loggerService.log("stateConnectionService setState"
|
|
6037
|
-
context: this.contextService.context,
|
|
6038
|
-
});
|
|
6023
|
+
this.loggerService.log("stateConnectionService setState");
|
|
6039
6024
|
state = this.getStateRef(this.contextService.context.clientId, this.contextService.context.stateName);
|
|
6040
6025
|
return [4 /*yield*/, state.waitForInit()];
|
|
6041
6026
|
case 1:
|
|
@@ -6054,9 +6039,7 @@ var StateConnectionService = /** @class */ (function () {
|
|
|
6054
6039
|
return __generator(this, function (_a) {
|
|
6055
6040
|
switch (_a.label) {
|
|
6056
6041
|
case 0:
|
|
6057
|
-
this.loggerService.log("stateConnectionService getState"
|
|
6058
|
-
context: this.contextService.context,
|
|
6059
|
-
});
|
|
6042
|
+
this.loggerService.log("stateConnectionService getState");
|
|
6060
6043
|
state = this.getStateRef(this.contextService.context.clientId, this.contextService.context.stateName);
|
|
6061
6044
|
return [4 /*yield*/, state.waitForInit()];
|
|
6062
6045
|
case 1:
|
|
@@ -6075,9 +6058,7 @@ var StateConnectionService = /** @class */ (function () {
|
|
|
6075
6058
|
return __generator(this, function (_a) {
|
|
6076
6059
|
switch (_a.label) {
|
|
6077
6060
|
case 0:
|
|
6078
|
-
this.loggerService.log("stateConnectionService dispose"
|
|
6079
|
-
context: this.contextService.context,
|
|
6080
|
-
});
|
|
6061
|
+
this.loggerService.log("stateConnectionService dispose");
|
|
6081
6062
|
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.stateName);
|
|
6082
6063
|
if (!this.getStateRef.has(key)) {
|
|
6083
6064
|
return [2 /*return*/];
|
|
@@ -6114,12 +6095,13 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6114
6095
|
* @param {StateName} stateName - The name of the state.
|
|
6115
6096
|
* @returns {Promise<T>} - The updated state.
|
|
6116
6097
|
*/
|
|
6117
|
-
this.setState = function (dispatchFn, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
6098
|
+
this.setState = function (dispatchFn, requestId, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
6118
6099
|
var _this = this;
|
|
6119
6100
|
return __generator(this, function (_a) {
|
|
6120
6101
|
switch (_a.label) {
|
|
6121
6102
|
case 0:
|
|
6122
6103
|
this.loggerService.log("statePublicService setState", {
|
|
6104
|
+
requestId: requestId,
|
|
6123
6105
|
clientId: clientId,
|
|
6124
6106
|
stateName: stateName,
|
|
6125
6107
|
});
|
|
@@ -6131,6 +6113,7 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6131
6113
|
}
|
|
6132
6114
|
});
|
|
6133
6115
|
}); }, {
|
|
6116
|
+
requestId: requestId,
|
|
6134
6117
|
clientId: clientId,
|
|
6135
6118
|
stateName: stateName,
|
|
6136
6119
|
agentName: "",
|
|
@@ -6147,7 +6130,7 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6147
6130
|
* @param {StateName} stateName - The name of the state.
|
|
6148
6131
|
* @returns {Promise<T>} - The current state.
|
|
6149
6132
|
*/
|
|
6150
|
-
this.getState = function (clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
6133
|
+
this.getState = function (requestId, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
6151
6134
|
var _this = this;
|
|
6152
6135
|
return __generator(this, function (_a) {
|
|
6153
6136
|
switch (_a.label) {
|
|
@@ -6164,6 +6147,7 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6164
6147
|
}
|
|
6165
6148
|
});
|
|
6166
6149
|
}); }, {
|
|
6150
|
+
requestId: requestId,
|
|
6167
6151
|
clientId: clientId,
|
|
6168
6152
|
stateName: stateName,
|
|
6169
6153
|
agentName: "",
|
|
@@ -6180,12 +6164,13 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6180
6164
|
* @param {StateName} stateName - The name of the state.
|
|
6181
6165
|
* @returns {Promise<void>} - A promise that resolves when the state is disposed.
|
|
6182
6166
|
*/
|
|
6183
|
-
this.dispose = function (clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
6167
|
+
this.dispose = function (requestId, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
6184
6168
|
var _this = this;
|
|
6185
6169
|
return __generator(this, function (_a) {
|
|
6186
6170
|
switch (_a.label) {
|
|
6187
6171
|
case 0:
|
|
6188
6172
|
this.loggerService.log("statePublicService dispose", {
|
|
6173
|
+
requestId: requestId,
|
|
6189
6174
|
clientId: clientId,
|
|
6190
6175
|
stateName: stateName,
|
|
6191
6176
|
});
|
|
@@ -6197,6 +6182,7 @@ var StatePublicService = /** @class */ (function () {
|
|
|
6197
6182
|
}
|
|
6198
6183
|
});
|
|
6199
6184
|
}); }, {
|
|
6185
|
+
requestId: requestId,
|
|
6200
6186
|
clientId: clientId,
|
|
6201
6187
|
stateName: stateName,
|
|
6202
6188
|
agentName: "",
|
|
@@ -6237,7 +6223,7 @@ var BusService = /** @class */ (function () {
|
|
|
6237
6223
|
_this._eventWildcardMap.set(source, true);
|
|
6238
6224
|
}
|
|
6239
6225
|
_this._eventSourceSet.add(source);
|
|
6240
|
-
_this.getEventSubject(clientId, source).subscribe(fn);
|
|
6226
|
+
return _this.getEventSubject(clientId, source).subscribe(fn);
|
|
6241
6227
|
};
|
|
6242
6228
|
/**
|
|
6243
6229
|
* Subscribes to a single event for a specific client and source.
|
|
@@ -6534,20 +6520,22 @@ var addStorage = function (storageSchema) {
|
|
|
6534
6520
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
6535
6521
|
*/
|
|
6536
6522
|
var commitUserMessage = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6537
|
-
var swarmName, currentAgentName;
|
|
6523
|
+
var requestId, swarmName, currentAgentName;
|
|
6538
6524
|
return __generator(this, function (_a) {
|
|
6539
6525
|
switch (_a.label) {
|
|
6540
6526
|
case 0:
|
|
6527
|
+
requestId = randomString();
|
|
6541
6528
|
swarm.loggerService.log('function commitSystemMessage', {
|
|
6542
6529
|
content: content,
|
|
6543
6530
|
clientId: clientId,
|
|
6544
6531
|
agentName: agentName,
|
|
6532
|
+
requestId: requestId,
|
|
6545
6533
|
});
|
|
6546
6534
|
swarm.agentValidationService.validate(agentName, "commitUserMessage");
|
|
6547
6535
|
swarm.sessionValidationService.validate(clientId, "commitUserMessage");
|
|
6548
6536
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
6549
6537
|
swarm.swarmValidationService.validate(swarmName, "commitUserMessage");
|
|
6550
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
6538
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
6551
6539
|
case 1:
|
|
6552
6540
|
currentAgentName = _a.sent();
|
|
6553
6541
|
if (currentAgentName !== agentName) {
|
|
@@ -6558,7 +6546,7 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
|
|
|
6558
6546
|
});
|
|
6559
6547
|
return [2 /*return*/];
|
|
6560
6548
|
}
|
|
6561
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, clientId, swarmName)];
|
|
6549
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, requestId, clientId, swarmName)];
|
|
6562
6550
|
case 2:
|
|
6563
6551
|
_a.sent();
|
|
6564
6552
|
return [2 /*return*/];
|
|
@@ -6574,17 +6562,19 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
|
|
|
6574
6562
|
* @throws Will throw an error if the client ID is invalid or if the swarm validation fails.
|
|
6575
6563
|
*/
|
|
6576
6564
|
var getAgentName = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6577
|
-
var swarmName;
|
|
6565
|
+
var requestId, swarmName;
|
|
6578
6566
|
return __generator(this, function (_a) {
|
|
6579
6567
|
switch (_a.label) {
|
|
6580
6568
|
case 0:
|
|
6569
|
+
requestId = randomString();
|
|
6581
6570
|
swarm.loggerService.log("function getAgentName", {
|
|
6582
6571
|
clientId: clientId,
|
|
6572
|
+
requestId: requestId,
|
|
6583
6573
|
});
|
|
6584
6574
|
swarm.sessionValidationService.validate(clientId, "getAgentName");
|
|
6585
6575
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
6586
6576
|
swarm.swarmValidationService.validate(swarmName, "getAgentName");
|
|
6587
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
6577
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
6588
6578
|
case 1: return [2 /*return*/, _a.sent()];
|
|
6589
6579
|
}
|
|
6590
6580
|
});
|
|
@@ -6600,13 +6590,15 @@ var SCHEDULED_DELAY$1 = 1000;
|
|
|
6600
6590
|
* @returns {SendMessageFn} - A function to send messages to the swarm.
|
|
6601
6591
|
*/
|
|
6602
6592
|
var makeConnection = function (connector, clientId, swarmName) {
|
|
6593
|
+
var requestId = randomString();
|
|
6603
6594
|
swarm.loggerService.log("function makeConnection", {
|
|
6604
6595
|
clientId: clientId,
|
|
6605
6596
|
swarmName: swarmName,
|
|
6597
|
+
requestId: requestId,
|
|
6606
6598
|
});
|
|
6607
6599
|
swarm.swarmValidationService.validate(swarmName, "makeConnection");
|
|
6608
6600
|
swarm.sessionValidationService.addSession(clientId, swarmName, "makeConnection");
|
|
6609
|
-
var send = swarm.sessionPublicService.connect(connector, clientId, swarmName);
|
|
6601
|
+
var send = swarm.sessionPublicService.connect(connector, requestId, clientId, swarmName);
|
|
6610
6602
|
return queued(function (outgoing) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6611
6603
|
var _a;
|
|
6612
6604
|
var _b;
|
|
@@ -6618,7 +6610,7 @@ var makeConnection = function (connector, clientId, swarmName) {
|
|
|
6618
6610
|
_b = {
|
|
6619
6611
|
data: outgoing
|
|
6620
6612
|
};
|
|
6621
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
6613
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
6622
6614
|
case 1: return [4 /*yield*/, _a.apply(void 0, [(_b.agentName = _c.sent(),
|
|
6623
6615
|
_b.clientId = clientId,
|
|
6624
6616
|
_b)])];
|
|
@@ -6721,7 +6713,7 @@ var CHANGE_AGENT_GC = 60 * 1000;
|
|
|
6721
6713
|
* @returns {TChangeAgentRun} - The change agent function.
|
|
6722
6714
|
*/
|
|
6723
6715
|
var createChangeAgent = ttl(function (clientId) {
|
|
6724
|
-
return queued(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6716
|
+
return queued(function (requestId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6725
6717
|
var swarmName, _a, _b, _c;
|
|
6726
6718
|
return __generator(this, function (_d) {
|
|
6727
6719
|
switch (_d.label) {
|
|
@@ -6734,7 +6726,7 @@ var createChangeAgent = ttl(function (clientId) {
|
|
|
6734
6726
|
.map(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6735
6727
|
return __generator(this, function (_a) {
|
|
6736
6728
|
switch (_a.label) {
|
|
6737
|
-
case 0: return [4 /*yield*/, swarm.agentPublicService.commitAgentChange(clientId, agentName)];
|
|
6729
|
+
case 0: return [4 /*yield*/, swarm.agentPublicService.commitAgentChange(requestId, clientId, agentName)];
|
|
6738
6730
|
case 1:
|
|
6739
6731
|
_a.sent();
|
|
6740
6732
|
return [2 /*return*/];
|
|
@@ -6743,21 +6735,22 @@ var createChangeAgent = ttl(function (clientId) {
|
|
|
6743
6735
|
}); }))];
|
|
6744
6736
|
case 1:
|
|
6745
6737
|
_d.sent();
|
|
6746
|
-
return [4 /*yield*/, swarm.agentPublicService.dispose(clientId, agentName)];
|
|
6738
|
+
return [4 /*yield*/, swarm.agentPublicService.dispose(requestId, clientId, agentName)];
|
|
6747
6739
|
case 2:
|
|
6748
6740
|
_d.sent();
|
|
6749
|
-
return [4 /*yield*/, swarm.historyPublicService.dispose(clientId, agentName)];
|
|
6741
|
+
return [4 /*yield*/, swarm.historyPublicService.dispose(requestId, clientId, agentName)];
|
|
6750
6742
|
case 3:
|
|
6751
6743
|
_d.sent();
|
|
6752
6744
|
_b = (_a = swarm.swarmPublicService).setAgentRef;
|
|
6753
|
-
_c = [
|
|
6745
|
+
_c = [requestId,
|
|
6746
|
+
clientId,
|
|
6754
6747
|
swarmName,
|
|
6755
6748
|
agentName];
|
|
6756
|
-
return [4 /*yield*/, swarm.agentPublicService.createAgentRef(clientId, agentName)];
|
|
6749
|
+
return [4 /*yield*/, swarm.agentPublicService.createAgentRef(requestId, clientId, agentName)];
|
|
6757
6750
|
case 4: return [4 /*yield*/, _b.apply(_a, _c.concat([_d.sent()]))];
|
|
6758
6751
|
case 5:
|
|
6759
6752
|
_d.sent();
|
|
6760
|
-
return [4 /*yield*/, swarm.swarmPublicService.setAgentName(agentName, clientId, swarmName)];
|
|
6753
|
+
return [4 /*yield*/, swarm.swarmPublicService.setAgentName(agentName, requestId, clientId, swarmName)];
|
|
6761
6754
|
case 6:
|
|
6762
6755
|
_d.sent();
|
|
6763
6756
|
return [2 /*return*/];
|
|
@@ -6791,10 +6784,11 @@ var createGc$1 = singleshot(function () { return __awaiter(void 0, void 0, void
|
|
|
6791
6784
|
* @returns {Promise<void>} - A promise that resolves when the agent is changed.
|
|
6792
6785
|
*/
|
|
6793
6786
|
var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6794
|
-
var run;
|
|
6787
|
+
var requestId, run;
|
|
6795
6788
|
return __generator(this, function (_a) {
|
|
6796
6789
|
switch (_a.label) {
|
|
6797
6790
|
case 0:
|
|
6791
|
+
requestId = randomString();
|
|
6798
6792
|
swarm.loggerService.log("function changeAgent", {
|
|
6799
6793
|
agentName: agentName,
|
|
6800
6794
|
clientId: clientId,
|
|
@@ -6803,7 +6797,7 @@ var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void
|
|
|
6803
6797
|
case 1:
|
|
6804
6798
|
run = _a.sent();
|
|
6805
6799
|
createGc$1();
|
|
6806
|
-
return [4 /*yield*/, run(agentName)];
|
|
6800
|
+
return [4 /*yield*/, run(requestId, agentName)];
|
|
6807
6801
|
case 2: return [2 /*return*/, _a.sent()];
|
|
6808
6802
|
}
|
|
6809
6803
|
});
|
|
@@ -6816,83 +6810,91 @@ var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void
|
|
|
6816
6810
|
* @param {SwarmName} swarmName - The name of the swarm.
|
|
6817
6811
|
* @returns {Promise<void>} A promise that resolves when the connection is disposed.
|
|
6818
6812
|
*/
|
|
6819
|
-
var disposeConnection = function (
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
6813
|
+
var disposeConnection = function (clientId_1, swarmName_1) {
|
|
6814
|
+
var args_1 = [];
|
|
6815
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
6816
|
+
args_1[_i - 2] = arguments[_i];
|
|
6817
|
+
}
|
|
6818
|
+
return __awaiter(void 0, __spreadArray([clientId_1, swarmName_1], __read(args_1), false), void 0, function (clientId, swarmName, requestId) {
|
|
6819
|
+
if (requestId === void 0) { requestId = randomString(); }
|
|
6820
|
+
return __generator(this, function (_a) {
|
|
6821
|
+
switch (_a.label) {
|
|
6822
|
+
case 0:
|
|
6823
|
+
swarm.loggerService.log("function disposeConnection", {
|
|
6824
|
+
clientId: clientId,
|
|
6825
|
+
swarmName: swarmName,
|
|
6826
|
+
requestId: requestId,
|
|
6827
|
+
});
|
|
6828
|
+
swarm.swarmValidationService.validate(swarmName, "disposeConnection");
|
|
6829
|
+
swarm.sessionValidationService.removeSession(clientId);
|
|
6830
|
+
swarm.busService.dispose(clientId);
|
|
6831
|
+
return [4 /*yield*/, swarm.sessionPublicService.dispose(requestId, clientId, swarmName)];
|
|
6832
|
+
case 1:
|
|
6833
|
+
_a.sent();
|
|
6834
|
+
return [4 /*yield*/, swarm.swarmPublicService.dispose(requestId, clientId, swarmName)];
|
|
6835
|
+
case 2:
|
|
6836
|
+
_a.sent();
|
|
6837
|
+
return [4 /*yield*/, Promise.all(swarm.swarmValidationService
|
|
6838
|
+
.getAgentList(swarmName)
|
|
6839
|
+
.map(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6840
|
+
return __generator(this, function (_a) {
|
|
6841
|
+
switch (_a.label) {
|
|
6842
|
+
case 0: return [4 /*yield*/, swarm.agentPublicService.dispose(requestId, clientId, agentName)];
|
|
6843
|
+
case 1:
|
|
6844
|
+
_a.sent();
|
|
6845
|
+
return [4 /*yield*/, swarm.historyPublicService.dispose(requestId, clientId, agentName)];
|
|
6846
|
+
case 2:
|
|
6847
|
+
_a.sent();
|
|
6848
|
+
return [2 /*return*/];
|
|
6849
|
+
}
|
|
6850
|
+
});
|
|
6851
|
+
}); }))];
|
|
6852
|
+
case 3:
|
|
6853
|
+
_a.sent();
|
|
6854
|
+
return [4 /*yield*/, Promise.all(swarm.swarmValidationService
|
|
6855
|
+
.getAgentList(swarmName)
|
|
6856
|
+
.flatMap(function (agentName) {
|
|
6857
|
+
return swarm.agentValidationService.getStorageList(agentName);
|
|
6858
|
+
})
|
|
6859
|
+
.filter(function (storageName) { return !!storageName; })
|
|
6860
|
+
.map(function (storageName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6861
|
+
return __generator(this, function (_a) {
|
|
6862
|
+
switch (_a.label) {
|
|
6863
|
+
case 0: return [4 /*yield*/, swarm.storagePublicService.dispose(requestId, clientId, storageName)];
|
|
6864
|
+
case 1:
|
|
6865
|
+
_a.sent();
|
|
6866
|
+
return [2 /*return*/];
|
|
6867
|
+
}
|
|
6868
|
+
});
|
|
6869
|
+
}); }))];
|
|
6870
|
+
case 4:
|
|
6871
|
+
_a.sent();
|
|
6872
|
+
return [4 /*yield*/, Promise.all(swarm.swarmValidationService
|
|
6873
|
+
.getAgentList(swarmName)
|
|
6874
|
+
.flatMap(function (agentName) {
|
|
6875
|
+
return swarm.agentValidationService.getStateList(agentName);
|
|
6876
|
+
})
|
|
6877
|
+
.filter(function (stateName) { return !!stateName; })
|
|
6878
|
+
.map(function (stateName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6879
|
+
return __generator(this, function (_a) {
|
|
6880
|
+
switch (_a.label) {
|
|
6881
|
+
case 0: return [4 /*yield*/, swarm.statePublicService.dispose(requestId, clientId, stateName)];
|
|
6882
|
+
case 1:
|
|
6883
|
+
_a.sent();
|
|
6884
|
+
return [2 /*return*/];
|
|
6885
|
+
}
|
|
6886
|
+
});
|
|
6887
|
+
}); }))];
|
|
6888
|
+
case 5:
|
|
6889
|
+
_a.sent();
|
|
6890
|
+
return [4 /*yield*/, HistoryAdapter.dispose(clientId, null)];
|
|
6891
|
+
case 6:
|
|
6892
|
+
_a.sent();
|
|
6893
|
+
return [2 /*return*/];
|
|
6894
|
+
}
|
|
6895
|
+
});
|
|
6894
6896
|
});
|
|
6895
|
-
}
|
|
6897
|
+
};
|
|
6896
6898
|
|
|
6897
6899
|
var COMPLETE_TTL = 15 * 60 * 1000;
|
|
6898
6900
|
var COMPLETE_GC = 60 * 1000;
|
|
@@ -6903,17 +6905,17 @@ var COMPLETE_GC = 60 * 1000;
|
|
|
6903
6905
|
* @returns {TCompleteRun} The complete run function.
|
|
6904
6906
|
*/
|
|
6905
6907
|
var createComplete = ttl(function (clientId, swarmName) {
|
|
6906
|
-
return queued(function (content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6908
|
+
return queued(function (requestId, content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6907
6909
|
var result;
|
|
6908
6910
|
return __generator(this, function (_a) {
|
|
6909
6911
|
switch (_a.label) {
|
|
6910
6912
|
case 0:
|
|
6911
6913
|
swarm.swarmValidationService.validate(swarmName, "complete");
|
|
6912
6914
|
swarm.sessionValidationService.addSession(clientId, swarmName, "complete");
|
|
6913
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", clientId, swarmName)];
|
|
6915
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", requestId, clientId, swarmName)];
|
|
6914
6916
|
case 1:
|
|
6915
6917
|
result = _a.sent();
|
|
6916
|
-
return [4 /*yield*/, disposeConnection(clientId, swarmName)];
|
|
6918
|
+
return [4 /*yield*/, disposeConnection(clientId, swarmName, requestId)];
|
|
6917
6919
|
case 2:
|
|
6918
6920
|
_a.sent();
|
|
6919
6921
|
return [2 /*return*/, result];
|
|
@@ -6947,20 +6949,22 @@ var createGc = singleshot(function () { return __awaiter(void 0, void 0, void 0,
|
|
|
6947
6949
|
* @returns {Promise<string>} The result of the complete function.
|
|
6948
6950
|
*/
|
|
6949
6951
|
var complete = function (content, clientId, swarmName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6950
|
-
var run;
|
|
6952
|
+
var requestId, run;
|
|
6951
6953
|
return __generator(this, function (_a) {
|
|
6952
6954
|
switch (_a.label) {
|
|
6953
6955
|
case 0:
|
|
6956
|
+
requestId = randomString();
|
|
6954
6957
|
swarm.loggerService.log("function complete", {
|
|
6955
6958
|
content: content,
|
|
6956
6959
|
clientId: clientId,
|
|
6957
6960
|
swarmName: swarmName,
|
|
6961
|
+
requestId: requestId,
|
|
6958
6962
|
});
|
|
6959
6963
|
return [4 /*yield*/, createComplete(clientId, swarmName)];
|
|
6960
6964
|
case 1:
|
|
6961
6965
|
run = _a.sent();
|
|
6962
6966
|
createGc();
|
|
6963
|
-
return [4 /*yield*/, run(content)];
|
|
6967
|
+
return [4 /*yield*/, run(requestId, content)];
|
|
6964
6968
|
case 2: return [2 /*return*/, _a.sent()];
|
|
6965
6969
|
}
|
|
6966
6970
|
});
|
|
@@ -6977,9 +6981,11 @@ var SCHEDULED_DELAY = 1000;
|
|
|
6977
6981
|
* @returns {Function} dispose - A function to dispose of the session.
|
|
6978
6982
|
*/
|
|
6979
6983
|
var session = function (clientId, swarmName) {
|
|
6984
|
+
var requestId = randomString();
|
|
6980
6985
|
swarm.loggerService.log("function session", {
|
|
6981
6986
|
clientId: clientId,
|
|
6982
6987
|
swarmName: swarmName,
|
|
6988
|
+
requestId: requestId,
|
|
6983
6989
|
});
|
|
6984
6990
|
swarm.swarmValidationService.validate(swarmName, "session");
|
|
6985
6991
|
swarm.sessionValidationService.addSession(clientId, swarmName, "session");
|
|
@@ -6995,7 +7001,7 @@ var session = function (clientId, swarmName) {
|
|
|
6995
7001
|
switch (_a.label) {
|
|
6996
7002
|
case 0:
|
|
6997
7003
|
swarm.sessionValidationService.validate(clientId, "session");
|
|
6998
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", clientId, swarmName)];
|
|
7004
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", requestId, clientId, swarmName)];
|
|
6999
7005
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7000
7006
|
}
|
|
7001
7007
|
});
|
|
@@ -7008,7 +7014,7 @@ var session = function (clientId, swarmName) {
|
|
|
7008
7014
|
dispose: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
7009
7015
|
return __generator(this, function (_a) {
|
|
7010
7016
|
switch (_a.label) {
|
|
7011
|
-
case 0: return [4 /*yield*/, disposeConnection(clientId, swarmName)];
|
|
7017
|
+
case 0: return [4 /*yield*/, disposeConnection(clientId, swarmName, requestId)];
|
|
7012
7018
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7013
7019
|
}
|
|
7014
7020
|
});
|
|
@@ -7113,27 +7119,35 @@ session.scheduled = function (clientId, swarmName, _a) {
|
|
|
7113
7119
|
* @param {string} clientId - The ID of the client whose history is to be retrieved.
|
|
7114
7120
|
* @returns {Promise<Array>} A promise that resolves to an array containing the raw history.
|
|
7115
7121
|
*/
|
|
7116
|
-
var getRawHistory = function (
|
|
7117
|
-
var
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7122
|
+
var getRawHistory = function (clientId_1) {
|
|
7123
|
+
var args_1 = [];
|
|
7124
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7125
|
+
args_1[_i - 1] = arguments[_i];
|
|
7126
|
+
}
|
|
7127
|
+
return __awaiter(void 0, __spreadArray([clientId_1], __read(args_1), false), void 0, function (clientId, requestId) {
|
|
7128
|
+
var swarmName, agentName, history;
|
|
7129
|
+
if (requestId === void 0) { requestId = randomString(); }
|
|
7130
|
+
return __generator(this, function (_a) {
|
|
7131
|
+
switch (_a.label) {
|
|
7132
|
+
case 0:
|
|
7133
|
+
swarm.loggerService.log("function getRawHistory", {
|
|
7134
|
+
clientId: clientId,
|
|
7135
|
+
requestId: requestId,
|
|
7136
|
+
});
|
|
7137
|
+
swarm.sessionValidationService.validate(clientId, "getRawHistory");
|
|
7138
|
+
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7139
|
+
swarm.swarmValidationService.validate(swarmName, "getRawHistory");
|
|
7140
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7141
|
+
case 1:
|
|
7142
|
+
agentName = _a.sent();
|
|
7143
|
+
return [4 /*yield*/, swarm.historyPublicService.toArrayForRaw(requestId, clientId, agentName)];
|
|
7144
|
+
case 2:
|
|
7145
|
+
history = _a.sent();
|
|
7146
|
+
return [2 /*return*/, __spreadArray([], __read(history), false)];
|
|
7147
|
+
}
|
|
7148
|
+
});
|
|
7135
7149
|
});
|
|
7136
|
-
}
|
|
7150
|
+
};
|
|
7137
7151
|
|
|
7138
7152
|
/**
|
|
7139
7153
|
* Retrieves the history prepared for a specific agent with resque algorithm tweaks
|
|
@@ -7143,17 +7157,19 @@ var getRawHistory = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
7143
7157
|
* @returns {Promise<Array>} - A promise that resolves to an array containing the agent's history.
|
|
7144
7158
|
*/
|
|
7145
7159
|
var getAgentHistory = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7146
|
-
var prompt, history;
|
|
7160
|
+
var requestId, prompt, history;
|
|
7147
7161
|
return __generator(this, function (_a) {
|
|
7148
7162
|
switch (_a.label) {
|
|
7149
7163
|
case 0:
|
|
7164
|
+
requestId = randomString();
|
|
7150
7165
|
swarm.loggerService.log("function getAgentHistory", {
|
|
7151
7166
|
clientId: clientId,
|
|
7152
7167
|
agentName: agentName,
|
|
7168
|
+
requestId: requestId,
|
|
7153
7169
|
});
|
|
7154
7170
|
swarm.agentValidationService.validate(agentName, "getAgentHistory");
|
|
7155
7171
|
prompt = swarm.agentSchemaService.get(agentName).prompt;
|
|
7156
|
-
return [4 /*yield*/, swarm.historyPublicService.toArrayForAgent(prompt, clientId, agentName)];
|
|
7172
|
+
return [4 /*yield*/, swarm.historyPublicService.toArrayForAgent(prompt, requestId, clientId, agentName)];
|
|
7157
7173
|
case 1:
|
|
7158
7174
|
history = _a.sent();
|
|
7159
7175
|
return [2 /*return*/, __spreadArray([], __read(history), false)];
|
|
@@ -7187,21 +7203,23 @@ var getSessionMode = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
7187
7203
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
7188
7204
|
*/
|
|
7189
7205
|
var commitToolOutput = function (toolId, content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7190
|
-
var swarmName, currentAgentName;
|
|
7206
|
+
var requestId, swarmName, currentAgentName;
|
|
7191
7207
|
return __generator(this, function (_a) {
|
|
7192
7208
|
switch (_a.label) {
|
|
7193
7209
|
case 0:
|
|
7210
|
+
requestId = randomString();
|
|
7194
7211
|
swarm.loggerService.log('function commitToolOutput', {
|
|
7195
7212
|
toolId: toolId,
|
|
7196
7213
|
content: content,
|
|
7197
7214
|
clientId: clientId,
|
|
7198
7215
|
agentName: agentName,
|
|
7216
|
+
requestId: requestId,
|
|
7199
7217
|
});
|
|
7200
7218
|
swarm.agentValidationService.validate(agentName, "commitSystemMessage");
|
|
7201
7219
|
swarm.sessionValidationService.validate(clientId, "commitToolOutput");
|
|
7202
7220
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7203
7221
|
swarm.swarmValidationService.validate(swarmName, "commitToolOutput");
|
|
7204
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7222
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7205
7223
|
case 1:
|
|
7206
7224
|
currentAgentName = _a.sent();
|
|
7207
7225
|
if (currentAgentName !== agentName) {
|
|
@@ -7213,7 +7231,7 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
|
|
|
7213
7231
|
});
|
|
7214
7232
|
return [2 /*return*/];
|
|
7215
7233
|
}
|
|
7216
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, clientId, swarmName)];
|
|
7234
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, requestId, clientId, swarmName)];
|
|
7217
7235
|
case 2:
|
|
7218
7236
|
_a.sent();
|
|
7219
7237
|
return [2 /*return*/];
|
|
@@ -7230,20 +7248,22 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
|
|
|
7230
7248
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7231
7249
|
*/
|
|
7232
7250
|
var commitSystemMessage = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7233
|
-
var swarmName, currentAgentName;
|
|
7251
|
+
var requestId, swarmName, currentAgentName;
|
|
7234
7252
|
return __generator(this, function (_a) {
|
|
7235
7253
|
switch (_a.label) {
|
|
7236
7254
|
case 0:
|
|
7255
|
+
requestId = randomString();
|
|
7237
7256
|
swarm.loggerService.log('function commitSystemMessage', {
|
|
7238
7257
|
content: content,
|
|
7239
7258
|
clientId: clientId,
|
|
7240
7259
|
agentName: agentName,
|
|
7260
|
+
requestId: requestId,
|
|
7241
7261
|
});
|
|
7242
7262
|
swarm.agentValidationService.validate(agentName, "commitSystemMessage");
|
|
7243
7263
|
swarm.sessionValidationService.validate(clientId, "commitSystemMessage");
|
|
7244
7264
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7245
7265
|
swarm.swarmValidationService.validate(swarmName, "commitSystemMessage");
|
|
7246
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7266
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7247
7267
|
case 1:
|
|
7248
7268
|
currentAgentName = _a.sent();
|
|
7249
7269
|
if (currentAgentName !== agentName) {
|
|
@@ -7254,7 +7274,7 @@ var commitSystemMessage = function (content, clientId, agentName) { return __awa
|
|
|
7254
7274
|
});
|
|
7255
7275
|
return [2 /*return*/];
|
|
7256
7276
|
}
|
|
7257
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, clientId, swarmName)];
|
|
7277
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, requestId, clientId, swarmName)];
|
|
7258
7278
|
case 2:
|
|
7259
7279
|
_a.sent();
|
|
7260
7280
|
return [2 /*return*/];
|
|
@@ -7270,19 +7290,21 @@ var commitSystemMessage = function (content, clientId, agentName) { return __awa
|
|
|
7270
7290
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7271
7291
|
*/
|
|
7272
7292
|
var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7273
|
-
var swarmName, currentAgentName;
|
|
7293
|
+
var requestId, swarmName, currentAgentName;
|
|
7274
7294
|
return __generator(this, function (_a) {
|
|
7275
7295
|
switch (_a.label) {
|
|
7276
7296
|
case 0:
|
|
7297
|
+
requestId = randomString();
|
|
7277
7298
|
swarm.loggerService.log('function commitFlush', {
|
|
7278
7299
|
clientId: clientId,
|
|
7279
7300
|
agentName: agentName,
|
|
7301
|
+
requestId: requestId,
|
|
7280
7302
|
});
|
|
7281
7303
|
swarm.agentValidationService.validate(agentName, "commitFlush");
|
|
7282
7304
|
swarm.sessionValidationService.validate(clientId, "commitFlush");
|
|
7283
7305
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7284
7306
|
swarm.swarmValidationService.validate(swarmName, "commitFlush");
|
|
7285
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7307
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7286
7308
|
case 1:
|
|
7287
7309
|
currentAgentName = _a.sent();
|
|
7288
7310
|
if (currentAgentName !== agentName) {
|
|
@@ -7293,7 +7315,7 @@ var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void
|
|
|
7293
7315
|
});
|
|
7294
7316
|
return [2 /*return*/];
|
|
7295
7317
|
}
|
|
7296
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitFlush(clientId, swarmName)];
|
|
7318
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitFlush(requestId, clientId, swarmName)];
|
|
7297
7319
|
case 2:
|
|
7298
7320
|
_a.sent();
|
|
7299
7321
|
return [2 /*return*/];
|
|
@@ -7311,20 +7333,22 @@ var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void
|
|
|
7311
7333
|
* @returns {Promise<void>} - A promise that resolves when the execution is complete.
|
|
7312
7334
|
*/
|
|
7313
7335
|
var execute = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7314
|
-
var swarmName, currentAgentName;
|
|
7336
|
+
var requestId, swarmName, currentAgentName;
|
|
7315
7337
|
return __generator(this, function (_a) {
|
|
7316
7338
|
switch (_a.label) {
|
|
7317
7339
|
case 0:
|
|
7340
|
+
requestId = randomString();
|
|
7318
7341
|
swarm.loggerService.log("function execute", {
|
|
7319
7342
|
content: content,
|
|
7320
7343
|
clientId: clientId,
|
|
7321
7344
|
agentName: agentName,
|
|
7345
|
+
requestId: requestId,
|
|
7322
7346
|
});
|
|
7323
7347
|
swarm.agentValidationService.validate(agentName, "execute");
|
|
7324
7348
|
swarm.sessionValidationService.validate(clientId, "execute");
|
|
7325
7349
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7326
7350
|
swarm.swarmValidationService.validate(swarmName, "execute");
|
|
7327
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7351
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7328
7352
|
case 1:
|
|
7329
7353
|
currentAgentName = _a.sent();
|
|
7330
7354
|
if (currentAgentName !== agentName) {
|
|
@@ -7335,7 +7359,7 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
|
|
|
7335
7359
|
});
|
|
7336
7360
|
return [2 /*return*/];
|
|
7337
7361
|
}
|
|
7338
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", clientId, swarmName)];
|
|
7362
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", requestId, clientId, swarmName)];
|
|
7339
7363
|
case 2: return [2 /*return*/, _a.sent()];
|
|
7340
7364
|
}
|
|
7341
7365
|
});
|
|
@@ -7352,14 +7376,16 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
|
|
|
7352
7376
|
* @returns {Promise<void>} A promise that resolves when the content is emitted.
|
|
7353
7377
|
*/
|
|
7354
7378
|
var emit = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7355
|
-
var swarmName, currentAgentName;
|
|
7379
|
+
var requestId, swarmName, currentAgentName;
|
|
7356
7380
|
return __generator(this, function (_a) {
|
|
7357
7381
|
switch (_a.label) {
|
|
7358
7382
|
case 0:
|
|
7383
|
+
requestId = randomString();
|
|
7359
7384
|
swarm.loggerService.log("function emit", {
|
|
7360
7385
|
content: content,
|
|
7361
7386
|
clientId: clientId,
|
|
7362
7387
|
agentName: agentName,
|
|
7388
|
+
requestId: requestId,
|
|
7363
7389
|
});
|
|
7364
7390
|
if (swarm.sessionValidationService.getSessionMode(clientId) !== "makeConnection") {
|
|
7365
7391
|
throw new Error("agent-swarm-kit emit session is not makeConnection clientId=".concat(clientId));
|
|
@@ -7368,7 +7394,7 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
|
|
|
7368
7394
|
swarm.sessionValidationService.validate(clientId, "emit");
|
|
7369
7395
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7370
7396
|
swarm.swarmValidationService.validate(swarmName, "emit");
|
|
7371
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7397
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7372
7398
|
case 1:
|
|
7373
7399
|
currentAgentName = _a.sent();
|
|
7374
7400
|
if (currentAgentName !== agentName) {
|
|
@@ -7379,7 +7405,7 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
|
|
|
7379
7405
|
});
|
|
7380
7406
|
return [2 /*return*/];
|
|
7381
7407
|
}
|
|
7382
|
-
return [4 /*yield*/, swarm.sessionPublicService.emit(content, clientId, swarmName)];
|
|
7408
|
+
return [4 /*yield*/, swarm.sessionPublicService.emit(content, requestId, clientId, swarmName)];
|
|
7383
7409
|
case 2: return [2 /*return*/, _a.sent()];
|
|
7384
7410
|
}
|
|
7385
7411
|
});
|
|
@@ -7393,19 +7419,21 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
|
|
|
7393
7419
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
7394
7420
|
*/
|
|
7395
7421
|
var commitToolOutputForce = function (toolId, content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7396
|
-
var swarmName;
|
|
7422
|
+
var requestId, swarmName;
|
|
7397
7423
|
return __generator(this, function (_a) {
|
|
7398
7424
|
switch (_a.label) {
|
|
7399
7425
|
case 0:
|
|
7426
|
+
requestId = randomString();
|
|
7400
7427
|
swarm.loggerService.log('function commitToolOutputForce', {
|
|
7401
7428
|
toolId: toolId,
|
|
7402
7429
|
content: content,
|
|
7403
7430
|
clientId: clientId,
|
|
7431
|
+
requestId: requestId,
|
|
7404
7432
|
});
|
|
7405
7433
|
swarm.sessionValidationService.validate(clientId, "commitToolOutputForce");
|
|
7406
7434
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7407
7435
|
swarm.swarmValidationService.validate(swarmName, "commitToolOutputForce");
|
|
7408
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, clientId, swarmName)];
|
|
7436
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, requestId, clientId, swarmName)];
|
|
7409
7437
|
case 1:
|
|
7410
7438
|
_a.sent();
|
|
7411
7439
|
return [2 /*return*/];
|
|
@@ -7421,18 +7449,20 @@ var commitToolOutputForce = function (toolId, content, clientId) { return __awai
|
|
|
7421
7449
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7422
7450
|
*/
|
|
7423
7451
|
var commitSystemMessageForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7424
|
-
var swarmName;
|
|
7452
|
+
var requestId, swarmName;
|
|
7425
7453
|
return __generator(this, function (_a) {
|
|
7426
7454
|
switch (_a.label) {
|
|
7427
7455
|
case 0:
|
|
7456
|
+
requestId = randomString();
|
|
7428
7457
|
swarm.loggerService.log('function commitSystemMessageForce', {
|
|
7429
7458
|
content: content,
|
|
7430
7459
|
clientId: clientId,
|
|
7460
|
+
requestId: requestId,
|
|
7431
7461
|
});
|
|
7432
7462
|
swarm.sessionValidationService.validate(clientId, "commitSystemMessageForce");
|
|
7433
7463
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7434
7464
|
swarm.swarmValidationService.validate(swarmName, "commitSystemMessageForce");
|
|
7435
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, clientId, swarmName)];
|
|
7465
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, requestId, clientId, swarmName)];
|
|
7436
7466
|
case 1:
|
|
7437
7467
|
_a.sent();
|
|
7438
7468
|
return [2 /*return*/];
|
|
@@ -7447,17 +7477,19 @@ var commitSystemMessageForce = function (content, clientId) { return __awaiter(v
|
|
|
7447
7477
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7448
7478
|
*/
|
|
7449
7479
|
var commitFlushForce = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7450
|
-
var swarmName;
|
|
7480
|
+
var requestId, swarmName;
|
|
7451
7481
|
return __generator(this, function (_a) {
|
|
7452
7482
|
switch (_a.label) {
|
|
7453
7483
|
case 0:
|
|
7484
|
+
requestId = randomString();
|
|
7454
7485
|
swarm.loggerService.log('function commitFlushForce', {
|
|
7455
7486
|
clientId: clientId,
|
|
7487
|
+
requestId: requestId,
|
|
7456
7488
|
});
|
|
7457
7489
|
swarm.sessionValidationService.validate(clientId, "commitFlushForce");
|
|
7458
7490
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7459
7491
|
swarm.swarmValidationService.validate(swarmName, "commitFlushForce");
|
|
7460
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitFlush(clientId, swarmName)];
|
|
7492
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitFlush(requestId, clientId, swarmName)];
|
|
7461
7493
|
case 1:
|
|
7462
7494
|
_a.sent();
|
|
7463
7495
|
return [2 /*return*/];
|
|
@@ -7473,18 +7505,20 @@ var commitFlushForce = function (clientId) { return __awaiter(void 0, void 0, vo
|
|
|
7473
7505
|
* @returns {Promise<void>} - A promise that resolves when the message is committed.
|
|
7474
7506
|
*/
|
|
7475
7507
|
var commitUserMessageForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7476
|
-
var swarmName;
|
|
7508
|
+
var requestId, swarmName;
|
|
7477
7509
|
return __generator(this, function (_a) {
|
|
7478
7510
|
switch (_a.label) {
|
|
7479
7511
|
case 0:
|
|
7512
|
+
requestId = randomString();
|
|
7480
7513
|
swarm.loggerService.log('function commitSystemMessage', {
|
|
7481
7514
|
content: content,
|
|
7482
7515
|
clientId: clientId,
|
|
7516
|
+
requestId: requestId,
|
|
7483
7517
|
});
|
|
7484
7518
|
swarm.sessionValidationService.validate(clientId, "commitUserMessageForce");
|
|
7485
7519
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7486
7520
|
swarm.swarmValidationService.validate(swarmName, "commitUserMessageForce");
|
|
7487
|
-
return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, clientId, swarmName)];
|
|
7521
|
+
return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, requestId, clientId, swarmName)];
|
|
7488
7522
|
case 1:
|
|
7489
7523
|
_a.sent();
|
|
7490
7524
|
return [2 /*return*/];
|
|
@@ -7503,13 +7537,15 @@ var commitUserMessageForce = function (content, clientId) { return __awaiter(voi
|
|
|
7503
7537
|
* @returns {Promise<void>} A promise that resolves when the content is emitted.
|
|
7504
7538
|
*/
|
|
7505
7539
|
var emitForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7506
|
-
var swarmName;
|
|
7540
|
+
var requestId, swarmName;
|
|
7507
7541
|
return __generator(this, function (_a) {
|
|
7508
7542
|
switch (_a.label) {
|
|
7509
7543
|
case 0:
|
|
7544
|
+
requestId = randomString();
|
|
7510
7545
|
swarm.loggerService.log("function emitForce", {
|
|
7511
7546
|
content: content,
|
|
7512
7547
|
clientId: clientId,
|
|
7548
|
+
requestId: requestId,
|
|
7513
7549
|
});
|
|
7514
7550
|
if (swarm.sessionValidationService.getSessionMode(clientId) !== "makeConnection") {
|
|
7515
7551
|
throw new Error("agent-swarm-kit emitForce session is not makeConnection clientId=".concat(clientId));
|
|
@@ -7517,7 +7553,7 @@ var emitForce = function (content, clientId) { return __awaiter(void 0, void 0,
|
|
|
7517
7553
|
swarm.sessionValidationService.validate(clientId, "emitForce");
|
|
7518
7554
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7519
7555
|
swarm.swarmValidationService.validate(swarmName, "emitForce");
|
|
7520
|
-
return [4 /*yield*/, swarm.sessionPublicService.emit(content, clientId, swarmName)];
|
|
7556
|
+
return [4 /*yield*/, swarm.sessionPublicService.emit(content, requestId, clientId, swarmName)];
|
|
7521
7557
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7522
7558
|
}
|
|
7523
7559
|
});
|
|
@@ -7534,24 +7570,26 @@ var emitForce = function (content, clientId) { return __awaiter(void 0, void 0,
|
|
|
7534
7570
|
* @returns {Promise<void>} - A promise that resolves when the execution is complete.
|
|
7535
7571
|
*/
|
|
7536
7572
|
var executeForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7537
|
-
var swarmName;
|
|
7573
|
+
var requestId, swarmName;
|
|
7538
7574
|
return __generator(this, function (_a) {
|
|
7539
7575
|
switch (_a.label) {
|
|
7540
7576
|
case 0:
|
|
7577
|
+
requestId = randomString();
|
|
7541
7578
|
swarm.loggerService.log("function executeForce", {
|
|
7542
7579
|
content: content,
|
|
7543
7580
|
clientId: clientId,
|
|
7581
|
+
requestId: requestId,
|
|
7544
7582
|
});
|
|
7545
7583
|
swarm.sessionValidationService.validate(clientId, "executeForce");
|
|
7546
7584
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7547
7585
|
swarm.swarmValidationService.validate(swarmName, "executeForce");
|
|
7548
|
-
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", clientId, swarmName)];
|
|
7586
|
+
return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", requestId, clientId, swarmName)];
|
|
7549
7587
|
case 1: return [2 /*return*/, _a.sent()];
|
|
7550
7588
|
}
|
|
7551
7589
|
});
|
|
7552
7590
|
}); };
|
|
7553
7591
|
|
|
7554
|
-
var DISALLOWED_EVENT_SOURCE_LIST$
|
|
7592
|
+
var DISALLOWED_EVENT_SOURCE_LIST$2 = new Set([
|
|
7555
7593
|
"agent-bus",
|
|
7556
7594
|
"history-bus",
|
|
7557
7595
|
"session-bus",
|
|
@@ -7559,7 +7597,7 @@ var DISALLOWED_EVENT_SOURCE_LIST$1 = new Set([
|
|
|
7559
7597
|
"storage-bus",
|
|
7560
7598
|
"swarm-bus",
|
|
7561
7599
|
]);
|
|
7562
|
-
var validateClientId$
|
|
7600
|
+
var validateClientId$d = function (clientId) {
|
|
7563
7601
|
if (clientId === "*") {
|
|
7564
7602
|
return;
|
|
7565
7603
|
}
|
|
@@ -7578,16 +7616,56 @@ var listenEvent = function (clientId, topicName, fn) {
|
|
|
7578
7616
|
swarm.loggerService.log("function listenEvent", {
|
|
7579
7617
|
clientId: clientId,
|
|
7580
7618
|
});
|
|
7581
|
-
if (DISALLOWED_EVENT_SOURCE_LIST$
|
|
7619
|
+
if (DISALLOWED_EVENT_SOURCE_LIST$2.has(topicName)) {
|
|
7582
7620
|
throw new Error("agent-swarm listenEvent topic is reserved topicName=".concat(topicName));
|
|
7583
7621
|
}
|
|
7584
|
-
validateClientId$
|
|
7622
|
+
validateClientId$d(clientId);
|
|
7585
7623
|
return swarm.busService.subscribe(clientId, topicName, function (_a) {
|
|
7586
7624
|
var payload = _a.payload;
|
|
7587
7625
|
return fn(payload);
|
|
7588
7626
|
});
|
|
7589
7627
|
};
|
|
7590
7628
|
|
|
7629
|
+
var DISALLOWED_EVENT_SOURCE_LIST$1 = new Set([
|
|
7630
|
+
"agent-bus",
|
|
7631
|
+
"history-bus",
|
|
7632
|
+
"session-bus",
|
|
7633
|
+
"state-bus",
|
|
7634
|
+
"storage-bus",
|
|
7635
|
+
"swarm-bus",
|
|
7636
|
+
]);
|
|
7637
|
+
var validateClientId$c = function (clientId) {
|
|
7638
|
+
if (clientId === "*") {
|
|
7639
|
+
return;
|
|
7640
|
+
}
|
|
7641
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
7642
|
+
throw new Error("agent-swarm listenEventOnce session not found for clientId=".concat(clientId));
|
|
7643
|
+
}
|
|
7644
|
+
};
|
|
7645
|
+
/**
|
|
7646
|
+
* Listens for an event on the swarm bus service and executes a callback function when the event is received.
|
|
7647
|
+
*
|
|
7648
|
+
* @template T - The type of the data payload.
|
|
7649
|
+
* @param {string} clientId - The ID of the client to listen for events from.
|
|
7650
|
+
* @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.
|
|
7651
|
+
*/
|
|
7652
|
+
var listenEventOnce = function (clientId, topicName, filterFn, fn) {
|
|
7653
|
+
swarm.loggerService.log("function listenEventOnce", {
|
|
7654
|
+
clientId: clientId,
|
|
7655
|
+
});
|
|
7656
|
+
if (DISALLOWED_EVENT_SOURCE_LIST$1.has(topicName)) {
|
|
7657
|
+
throw new Error("agent-swarm listenEventOnce topic is reserved topicName=".concat(topicName));
|
|
7658
|
+
}
|
|
7659
|
+
validateClientId$c(clientId);
|
|
7660
|
+
return swarm.busService.once(clientId, topicName, function (_a) {
|
|
7661
|
+
var payload = _a.payload;
|
|
7662
|
+
return filterFn(payload);
|
|
7663
|
+
}, function (_a) {
|
|
7664
|
+
var payload = _a.payload;
|
|
7665
|
+
return fn(payload);
|
|
7666
|
+
});
|
|
7667
|
+
};
|
|
7668
|
+
|
|
7591
7669
|
/**
|
|
7592
7670
|
* Retrieves the last message sent by the user from the client's message history.
|
|
7593
7671
|
*
|
|
@@ -7595,14 +7673,16 @@ var listenEvent = function (clientId, topicName, fn) {
|
|
|
7595
7673
|
* @returns {Promise<string | null>} - The content of the last user message, or null if no user message is found.
|
|
7596
7674
|
*/
|
|
7597
7675
|
var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7598
|
-
var history, last;
|
|
7676
|
+
var requestId, history, last;
|
|
7599
7677
|
return __generator(this, function (_a) {
|
|
7600
7678
|
switch (_a.label) {
|
|
7601
7679
|
case 0:
|
|
7680
|
+
requestId = randomString();
|
|
7602
7681
|
swarm.loggerService.log("function getLastUserMessage", {
|
|
7603
7682
|
clientId: clientId,
|
|
7683
|
+
requestId: requestId,
|
|
7604
7684
|
});
|
|
7605
|
-
return [4 /*yield*/, getRawHistory(clientId)];
|
|
7685
|
+
return [4 /*yield*/, getRawHistory(clientId, requestId)];
|
|
7606
7686
|
case 1:
|
|
7607
7687
|
history = _a.sent();
|
|
7608
7688
|
last = history.findLast(function (_a) {
|
|
@@ -7621,14 +7701,16 @@ var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0,
|
|
|
7621
7701
|
* @returns {Promise<Array>} A promise that resolves to an array of history objects filtered by user role.
|
|
7622
7702
|
*/
|
|
7623
7703
|
var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7624
|
-
var history;
|
|
7704
|
+
var requestId, history;
|
|
7625
7705
|
return __generator(this, function (_a) {
|
|
7626
7706
|
switch (_a.label) {
|
|
7627
7707
|
case 0:
|
|
7708
|
+
requestId = randomString();
|
|
7628
7709
|
swarm.loggerService.log("function getUserHistory", {
|
|
7629
7710
|
clientId: clientId,
|
|
7711
|
+
requestId: requestId,
|
|
7630
7712
|
});
|
|
7631
|
-
return [4 /*yield*/, getRawHistory(clientId)];
|
|
7713
|
+
return [4 /*yield*/, getRawHistory(clientId, requestId)];
|
|
7632
7714
|
case 1:
|
|
7633
7715
|
history = _a.sent();
|
|
7634
7716
|
return [2 /*return*/, history.filter(function (_a) {
|
|
@@ -7646,14 +7728,16 @@ var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void
|
|
|
7646
7728
|
* @returns {Promise<Array>} - A promise that resolves to an array of history objects where the role is "assistant".
|
|
7647
7729
|
*/
|
|
7648
7730
|
var getAssistantHistory = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7649
|
-
var history;
|
|
7731
|
+
var requestId, history;
|
|
7650
7732
|
return __generator(this, function (_a) {
|
|
7651
7733
|
switch (_a.label) {
|
|
7652
7734
|
case 0:
|
|
7735
|
+
requestId = randomString();
|
|
7653
7736
|
swarm.loggerService.log("function getAssistantHistory", {
|
|
7654
7737
|
clientId: clientId,
|
|
7738
|
+
requestId: requestId,
|
|
7655
7739
|
});
|
|
7656
|
-
return [4 /*yield*/, getRawHistory(clientId)];
|
|
7740
|
+
return [4 /*yield*/, getRawHistory(clientId, requestId)];
|
|
7657
7741
|
case 1:
|
|
7658
7742
|
history = _a.sent();
|
|
7659
7743
|
return [2 /*return*/, history.filter(function (_a) {
|
|
@@ -7671,14 +7755,16 @@ var getAssistantHistory = function (clientId) { return __awaiter(void 0, void 0,
|
|
|
7671
7755
|
* @returns {Promise<string | null>} - The content of the last assistant message, or null if no user message is found.
|
|
7672
7756
|
*/
|
|
7673
7757
|
var getLastAssistantMessage = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7674
|
-
var history, last;
|
|
7758
|
+
var requestId, history, last;
|
|
7675
7759
|
return __generator(this, function (_a) {
|
|
7676
7760
|
switch (_a.label) {
|
|
7677
7761
|
case 0:
|
|
7762
|
+
requestId = randomString();
|
|
7678
7763
|
swarm.loggerService.log("function getLastAssistantMessage", {
|
|
7679
7764
|
clientId: clientId,
|
|
7765
|
+
requestId: requestId,
|
|
7680
7766
|
});
|
|
7681
|
-
return [4 /*yield*/, getRawHistory(clientId)];
|
|
7767
|
+
return [4 /*yield*/, getRawHistory(clientId, requestId)];
|
|
7682
7768
|
case 1:
|
|
7683
7769
|
history = _a.sent();
|
|
7684
7770
|
last = history.findLast(function (_a) {
|
|
@@ -7697,14 +7783,16 @@ var getLastAssistantMessage = function (clientId) { return __awaiter(void 0, voi
|
|
|
7697
7783
|
* @returns {Promise<string | null>} - The content of the last system message, or null if no user message is found.
|
|
7698
7784
|
*/
|
|
7699
7785
|
var getLastSystemMessage = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7700
|
-
var history, last;
|
|
7786
|
+
var requestId, history, last;
|
|
7701
7787
|
return __generator(this, function (_a) {
|
|
7702
7788
|
switch (_a.label) {
|
|
7703
7789
|
case 0:
|
|
7790
|
+
requestId = randomString();
|
|
7704
7791
|
swarm.loggerService.log("function getLastSystemMessage", {
|
|
7705
7792
|
clientId: clientId,
|
|
7793
|
+
requestId: requestId,
|
|
7706
7794
|
});
|
|
7707
|
-
return [4 /*yield*/, getRawHistory(clientId)];
|
|
7795
|
+
return [4 /*yield*/, getRawHistory(clientId, requestId)];
|
|
7708
7796
|
case 1:
|
|
7709
7797
|
history = _a.sent();
|
|
7710
7798
|
last = history.findLast(function (_a) {
|
|
@@ -7808,19 +7896,21 @@ var event = function (clientId, topicName, payload) {
|
|
|
7808
7896
|
* @returns {Promise<void>} - A promise that resolves when the output is canceled
|
|
7809
7897
|
*/
|
|
7810
7898
|
var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7811
|
-
var swarmName, currentAgentName;
|
|
7899
|
+
var requestId, swarmName, currentAgentName;
|
|
7812
7900
|
return __generator(this, function (_a) {
|
|
7813
7901
|
switch (_a.label) {
|
|
7814
7902
|
case 0:
|
|
7903
|
+
requestId = randomString();
|
|
7815
7904
|
swarm.loggerService.log('function cancelOutput', {
|
|
7816
7905
|
clientId: clientId,
|
|
7817
7906
|
agentName: agentName,
|
|
7907
|
+
requestId: requestId,
|
|
7818
7908
|
});
|
|
7819
7909
|
swarm.agentValidationService.validate(agentName, "cancelOutput");
|
|
7820
7910
|
swarm.sessionValidationService.validate(clientId, "cancelOutput");
|
|
7821
7911
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7822
7912
|
swarm.swarmValidationService.validate(swarmName, "cancelOutput");
|
|
7823
|
-
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7913
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
|
|
7824
7914
|
case 1:
|
|
7825
7915
|
currentAgentName = _a.sent();
|
|
7826
7916
|
if (currentAgentName !== agentName) {
|
|
@@ -7831,7 +7921,7 @@ var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, voi
|
|
|
7831
7921
|
});
|
|
7832
7922
|
return [2 /*return*/];
|
|
7833
7923
|
}
|
|
7834
|
-
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(clientId, swarmName)];
|
|
7924
|
+
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(requestId, clientId, swarmName)];
|
|
7835
7925
|
case 2:
|
|
7836
7926
|
_a.sent();
|
|
7837
7927
|
return [2 /*return*/];
|
|
@@ -7847,17 +7937,19 @@ var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, voi
|
|
|
7847
7937
|
* @returns {Promise<void>} - A promise that resolves when the output is canceled
|
|
7848
7938
|
*/
|
|
7849
7939
|
var cancelOutputForce = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7850
|
-
var swarmName;
|
|
7940
|
+
var requestId, swarmName;
|
|
7851
7941
|
return __generator(this, function (_a) {
|
|
7852
7942
|
switch (_a.label) {
|
|
7853
7943
|
case 0:
|
|
7944
|
+
requestId = randomString();
|
|
7854
7945
|
swarm.loggerService.log('function cancelOutputForce', {
|
|
7855
7946
|
clientId: clientId,
|
|
7947
|
+
requestId: requestId
|
|
7856
7948
|
});
|
|
7857
7949
|
swarm.sessionValidationService.validate(clientId, "cancelOutputForce");
|
|
7858
7950
|
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7859
7951
|
swarm.swarmValidationService.validate(swarmName, "cancelOutputForce");
|
|
7860
|
-
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(clientId, swarmName)];
|
|
7952
|
+
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(requestId, clientId, swarmName)];
|
|
7861
7953
|
case 1:
|
|
7862
7954
|
_a.sent();
|
|
7863
7955
|
return [2 /*return*/];
|
|
@@ -7865,7 +7957,7 @@ var cancelOutputForce = function (clientId) { return __awaiter(void 0, void 0, v
|
|
|
7865
7957
|
});
|
|
7866
7958
|
}); };
|
|
7867
7959
|
|
|
7868
|
-
var validateClientId$
|
|
7960
|
+
var validateClientId$b = function (clientId) {
|
|
7869
7961
|
if (clientId === "*") {
|
|
7870
7962
|
return;
|
|
7871
7963
|
}
|
|
@@ -7883,11 +7975,11 @@ var listenAgentEvent = function (clientId, fn) {
|
|
|
7883
7975
|
swarm.loggerService.log("middleware listenAgentEvent", {
|
|
7884
7976
|
clientId: clientId,
|
|
7885
7977
|
});
|
|
7886
|
-
validateClientId$
|
|
7887
|
-
swarm.busService.subscribe(clientId, "agent-bus", fn);
|
|
7978
|
+
validateClientId$b(clientId);
|
|
7979
|
+
return swarm.busService.subscribe(clientId, "agent-bus", fn);
|
|
7888
7980
|
};
|
|
7889
7981
|
|
|
7890
|
-
var validateClientId$
|
|
7982
|
+
var validateClientId$a = function (clientId) {
|
|
7891
7983
|
if (clientId === "*") {
|
|
7892
7984
|
return;
|
|
7893
7985
|
}
|
|
@@ -7905,11 +7997,11 @@ var listenHistoryEvent = function (clientId, fn) {
|
|
|
7905
7997
|
swarm.loggerService.log("middleware listenHistoryEvent", {
|
|
7906
7998
|
clientId: clientId,
|
|
7907
7999
|
});
|
|
7908
|
-
validateClientId$
|
|
7909
|
-
swarm.busService.subscribe(clientId, "history-bus", fn);
|
|
8000
|
+
validateClientId$a(clientId);
|
|
8001
|
+
return swarm.busService.subscribe(clientId, "history-bus", fn);
|
|
7910
8002
|
};
|
|
7911
8003
|
|
|
7912
|
-
var validateClientId$
|
|
8004
|
+
var validateClientId$9 = function (clientId) {
|
|
7913
8005
|
if (clientId === "*") {
|
|
7914
8006
|
return;
|
|
7915
8007
|
}
|
|
@@ -7927,11 +8019,11 @@ var listenSessionEvent = function (clientId, fn) {
|
|
|
7927
8019
|
swarm.loggerService.log("middleware listenSessionEvent", {
|
|
7928
8020
|
clientId: clientId,
|
|
7929
8021
|
});
|
|
7930
|
-
validateClientId$
|
|
7931
|
-
swarm.busService.subscribe(clientId, "session-bus", fn);
|
|
8022
|
+
validateClientId$9(clientId);
|
|
8023
|
+
return swarm.busService.subscribe(clientId, "session-bus", fn);
|
|
7932
8024
|
};
|
|
7933
8025
|
|
|
7934
|
-
var validateClientId$
|
|
8026
|
+
var validateClientId$8 = function (clientId) {
|
|
7935
8027
|
if (clientId === "*") {
|
|
7936
8028
|
return;
|
|
7937
8029
|
}
|
|
@@ -7949,11 +8041,11 @@ var listenStateEvent = function (clientId, fn) {
|
|
|
7949
8041
|
swarm.loggerService.log("middleware listenStateEvent", {
|
|
7950
8042
|
clientId: clientId,
|
|
7951
8043
|
});
|
|
7952
|
-
validateClientId$
|
|
7953
|
-
swarm.busService.subscribe(clientId, "state-bus", fn);
|
|
8044
|
+
validateClientId$8(clientId);
|
|
8045
|
+
return swarm.busService.subscribe(clientId, "state-bus", fn);
|
|
7954
8046
|
};
|
|
7955
8047
|
|
|
7956
|
-
var validateClientId$
|
|
8048
|
+
var validateClientId$7 = function (clientId) {
|
|
7957
8049
|
if (clientId === "*") {
|
|
7958
8050
|
return;
|
|
7959
8051
|
}
|
|
@@ -7971,11 +8063,11 @@ var listenStorageEvent = function (clientId, fn) {
|
|
|
7971
8063
|
swarm.loggerService.log("middleware listenStorageEvent", {
|
|
7972
8064
|
clientId: clientId,
|
|
7973
8065
|
});
|
|
7974
|
-
validateClientId$
|
|
7975
|
-
swarm.busService.subscribe(clientId, "storage-bus", fn);
|
|
8066
|
+
validateClientId$7(clientId);
|
|
8067
|
+
return swarm.busService.subscribe(clientId, "storage-bus", fn);
|
|
7976
8068
|
};
|
|
7977
8069
|
|
|
7978
|
-
var validateClientId = function (clientId) {
|
|
8070
|
+
var validateClientId$6 = function (clientId) {
|
|
7979
8071
|
if (clientId === "*") {
|
|
7980
8072
|
return;
|
|
7981
8073
|
}
|
|
@@ -7993,8 +8085,140 @@ var listenSwarmEvent = function (clientId, fn) {
|
|
|
7993
8085
|
swarm.loggerService.log("middleware listenSwarmEvent", {
|
|
7994
8086
|
clientId: clientId,
|
|
7995
8087
|
});
|
|
8088
|
+
validateClientId$6(clientId);
|
|
8089
|
+
return swarm.busService.subscribe(clientId, "swarm-bus", fn);
|
|
8090
|
+
};
|
|
8091
|
+
|
|
8092
|
+
var validateClientId$5 = function (clientId) {
|
|
8093
|
+
if (clientId === "*") {
|
|
8094
|
+
return;
|
|
8095
|
+
}
|
|
8096
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8097
|
+
throw new Error("agent-swarm listenAgentEventOnce session not found for clientId=".concat(clientId));
|
|
8098
|
+
}
|
|
8099
|
+
};
|
|
8100
|
+
/**
|
|
8101
|
+
* Hook to subscribe to agent events for a specific client.
|
|
8102
|
+
*
|
|
8103
|
+
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
8104
|
+
* @param {function} fn - The callback function to handle the event.
|
|
8105
|
+
*/
|
|
8106
|
+
var listenAgentEventOnce = function (clientId, filterFn, fn) {
|
|
8107
|
+
swarm.loggerService.log("middleware listenAgentEventOnce", {
|
|
8108
|
+
clientId: clientId,
|
|
8109
|
+
});
|
|
8110
|
+
validateClientId$5(clientId);
|
|
8111
|
+
return swarm.busService.once(clientId, "agent-bus", filterFn, fn);
|
|
8112
|
+
};
|
|
8113
|
+
|
|
8114
|
+
var validateClientId$4 = function (clientId) {
|
|
8115
|
+
if (clientId === "*") {
|
|
8116
|
+
return;
|
|
8117
|
+
}
|
|
8118
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8119
|
+
throw new Error("agent-swarm listenHistoryEventOnce session not found for clientId=".concat(clientId));
|
|
8120
|
+
}
|
|
8121
|
+
};
|
|
8122
|
+
/**
|
|
8123
|
+
* Hook to subscribe to history events for a specific client.
|
|
8124
|
+
*
|
|
8125
|
+
* @param {string} clientId - The ID of the client to subscribe to.
|
|
8126
|
+
* @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
|
|
8127
|
+
*/
|
|
8128
|
+
var listenHistoryEventOnce = function (clientId, filterFn, fn) {
|
|
8129
|
+
swarm.loggerService.log("middleware listenHistoryEventOnce", {
|
|
8130
|
+
clientId: clientId,
|
|
8131
|
+
});
|
|
8132
|
+
validateClientId$4(clientId);
|
|
8133
|
+
return swarm.busService.once(clientId, "history-bus", filterFn, fn);
|
|
8134
|
+
};
|
|
8135
|
+
|
|
8136
|
+
var validateClientId$3 = function (clientId) {
|
|
8137
|
+
if (clientId === "*") {
|
|
8138
|
+
return;
|
|
8139
|
+
}
|
|
8140
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8141
|
+
throw new Error("agent-swarm listenSessionEventOnce session not found for clientId=".concat(clientId));
|
|
8142
|
+
}
|
|
8143
|
+
};
|
|
8144
|
+
/**
|
|
8145
|
+
* Hook to subscribe to session events for a specific client.
|
|
8146
|
+
*
|
|
8147
|
+
* @param {string} clientId - The ID of the client to subscribe to session events for.
|
|
8148
|
+
* @param {function} fn - The callback function to handle the session events.
|
|
8149
|
+
*/
|
|
8150
|
+
var listenSessionEventOnce = function (clientId, filterFn, fn) {
|
|
8151
|
+
swarm.loggerService.log("middleware listenSessionEventOnce", {
|
|
8152
|
+
clientId: clientId,
|
|
8153
|
+
});
|
|
8154
|
+
validateClientId$3(clientId);
|
|
8155
|
+
return swarm.busService.once(clientId, "session-bus", filterFn, fn);
|
|
8156
|
+
};
|
|
8157
|
+
|
|
8158
|
+
var validateClientId$2 = function (clientId) {
|
|
8159
|
+
if (clientId === "*") {
|
|
8160
|
+
return;
|
|
8161
|
+
}
|
|
8162
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8163
|
+
throw new Error("agent-swarm listenStateEventOnce session not found for clientId=".concat(clientId));
|
|
8164
|
+
}
|
|
8165
|
+
};
|
|
8166
|
+
/**
|
|
8167
|
+
* Hook to subscribe to state events for a specific client.
|
|
8168
|
+
*
|
|
8169
|
+
* @param {string} clientId - The ID of the client to subscribe to.
|
|
8170
|
+
* @param {function} fn - The callback function to handle the event.
|
|
8171
|
+
*/
|
|
8172
|
+
var listenStateEventOnce = function (clientId, filterFn, fn) {
|
|
8173
|
+
swarm.loggerService.log("middleware listenStateEventOnce", {
|
|
8174
|
+
clientId: clientId,
|
|
8175
|
+
});
|
|
8176
|
+
validateClientId$2(clientId);
|
|
8177
|
+
return swarm.busService.once(clientId, "state-bus", filterFn, fn);
|
|
8178
|
+
};
|
|
8179
|
+
|
|
8180
|
+
var validateClientId$1 = function (clientId) {
|
|
8181
|
+
if (clientId === "*") {
|
|
8182
|
+
return;
|
|
8183
|
+
}
|
|
8184
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8185
|
+
throw new Error("agent-swarm listenStorageEventOnce session not found for clientId=".concat(clientId));
|
|
8186
|
+
}
|
|
8187
|
+
};
|
|
8188
|
+
/**
|
|
8189
|
+
* Hook to subscribe to storage events for a specific client.
|
|
8190
|
+
*
|
|
8191
|
+
* @param {string} clientId - The ID of the client to subscribe to storage events for.
|
|
8192
|
+
* @param {function} fn - The callback function to handle the storage event.
|
|
8193
|
+
*/
|
|
8194
|
+
var listenStorageEventOnce = function (clientId, filterFn, fn) {
|
|
8195
|
+
swarm.loggerService.log("middleware listenStorageEventOnce", {
|
|
8196
|
+
clientId: clientId,
|
|
8197
|
+
});
|
|
8198
|
+
validateClientId$1(clientId);
|
|
8199
|
+
return swarm.busService.once(clientId, "storage-bus", filterFn, fn);
|
|
8200
|
+
};
|
|
8201
|
+
|
|
8202
|
+
var validateClientId = function (clientId) {
|
|
8203
|
+
if (clientId === "*") {
|
|
8204
|
+
return;
|
|
8205
|
+
}
|
|
8206
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
8207
|
+
throw new Error("agent-swarm listenSwarmEventOnce session not found for clientId=".concat(clientId));
|
|
8208
|
+
}
|
|
8209
|
+
};
|
|
8210
|
+
/**
|
|
8211
|
+
* Hook to subscribe to swarm events for a specific client.
|
|
8212
|
+
*
|
|
8213
|
+
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
8214
|
+
* @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
|
|
8215
|
+
*/
|
|
8216
|
+
var listenSwarmEventOnce = function (clientId, filterFn, fn) {
|
|
8217
|
+
swarm.loggerService.log("middleware listenSwarmEventOnce", {
|
|
8218
|
+
clientId: clientId,
|
|
8219
|
+
});
|
|
7996
8220
|
validateClientId(clientId);
|
|
7997
|
-
swarm.busService.
|
|
8221
|
+
return swarm.busService.once(clientId, "swarm-bus", filterFn, fn);
|
|
7998
8222
|
};
|
|
7999
8223
|
|
|
8000
8224
|
var StorageUtils = /** @class */ (function () {
|
|
@@ -8011,21 +8235,24 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8011
8235
|
* @template T
|
|
8012
8236
|
*/
|
|
8013
8237
|
this.take = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8238
|
+
var requestId;
|
|
8014
8239
|
return __generator(this, function (_a) {
|
|
8015
8240
|
switch (_a.label) {
|
|
8016
8241
|
case 0:
|
|
8242
|
+
requestId = randomString();
|
|
8017
8243
|
swarm.loggerService.log("StorageUtils take", {
|
|
8018
8244
|
search: payload.search,
|
|
8019
8245
|
total: payload.total,
|
|
8020
8246
|
clientId: payload.clientId,
|
|
8021
8247
|
storageName: payload.storageName,
|
|
8022
8248
|
score: payload.score,
|
|
8249
|
+
requestId: requestId,
|
|
8023
8250
|
});
|
|
8024
8251
|
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
8025
8252
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8026
8253
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (take)"));
|
|
8027
8254
|
}
|
|
8028
|
-
return [4 /*yield*/, swarm.storagePublicService.take(payload.search, payload.total, payload.clientId, payload.storageName, payload.score)];
|
|
8255
|
+
return [4 /*yield*/, swarm.storagePublicService.take(payload.search, payload.total, requestId, payload.clientId, payload.storageName, payload.score)];
|
|
8029
8256
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
8030
8257
|
}
|
|
8031
8258
|
});
|
|
@@ -8040,19 +8267,22 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8040
8267
|
* @template T
|
|
8041
8268
|
*/
|
|
8042
8269
|
this.upsert = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8270
|
+
var requestId;
|
|
8043
8271
|
return __generator(this, function (_a) {
|
|
8044
8272
|
switch (_a.label) {
|
|
8045
8273
|
case 0:
|
|
8274
|
+
requestId = randomString();
|
|
8046
8275
|
swarm.loggerService.log("StorageUtils upsert", {
|
|
8047
8276
|
item: payload.item,
|
|
8048
8277
|
clientId: payload.clientId,
|
|
8049
8278
|
storageName: payload.storageName,
|
|
8279
|
+
requestId: requestId,
|
|
8050
8280
|
});
|
|
8051
8281
|
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
8052
8282
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8053
8283
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (upsert)"));
|
|
8054
8284
|
}
|
|
8055
|
-
return [4 /*yield*/, swarm.storagePublicService.upsert(payload.item, payload.clientId, payload.storageName)];
|
|
8285
|
+
return [4 /*yield*/, swarm.storagePublicService.upsert(payload.item, requestId, payload.clientId, payload.storageName)];
|
|
8056
8286
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8057
8287
|
}
|
|
8058
8288
|
});
|
|
@@ -8066,19 +8296,22 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8066
8296
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
8067
8297
|
*/
|
|
8068
8298
|
this.remove = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8299
|
+
var requestId;
|
|
8069
8300
|
return __generator(this, function (_a) {
|
|
8070
8301
|
switch (_a.label) {
|
|
8071
8302
|
case 0:
|
|
8303
|
+
requestId = randomString();
|
|
8072
8304
|
swarm.loggerService.log("StorageUtils remove", {
|
|
8073
8305
|
itemId: payload.itemId,
|
|
8074
8306
|
clientId: payload.clientId,
|
|
8075
8307
|
storageName: payload.storageName,
|
|
8308
|
+
requestId: requestId,
|
|
8076
8309
|
});
|
|
8077
8310
|
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
8078
8311
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8079
8312
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (remove)"));
|
|
8080
8313
|
}
|
|
8081
|
-
return [4 /*yield*/, swarm.storagePublicService.remove(payload.itemId, payload.clientId, payload.storageName)];
|
|
8314
|
+
return [4 /*yield*/, swarm.storagePublicService.remove(payload.itemId, requestId, payload.clientId, payload.storageName)];
|
|
8082
8315
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8083
8316
|
}
|
|
8084
8317
|
});
|
|
@@ -8093,19 +8326,22 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8093
8326
|
* @template T
|
|
8094
8327
|
*/
|
|
8095
8328
|
this.get = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8329
|
+
var requestId;
|
|
8096
8330
|
return __generator(this, function (_a) {
|
|
8097
8331
|
switch (_a.label) {
|
|
8098
8332
|
case 0:
|
|
8333
|
+
requestId = randomString();
|
|
8099
8334
|
swarm.loggerService.log("StorageUtils get", {
|
|
8100
8335
|
itemId: payload.itemId,
|
|
8101
8336
|
clientId: payload.clientId,
|
|
8102
8337
|
storageName: payload.storageName,
|
|
8338
|
+
requestId: requestId,
|
|
8103
8339
|
});
|
|
8104
8340
|
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
8105
8341
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8106
8342
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (get)"));
|
|
8107
8343
|
}
|
|
8108
|
-
return [4 /*yield*/, swarm.storagePublicService.get(payload.itemId, payload.clientId, payload.storageName)];
|
|
8344
|
+
return [4 /*yield*/, swarm.storagePublicService.get(payload.itemId, requestId, payload.clientId, payload.storageName)];
|
|
8109
8345
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
8110
8346
|
}
|
|
8111
8347
|
});
|
|
@@ -8120,18 +8356,21 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8120
8356
|
* @template T
|
|
8121
8357
|
*/
|
|
8122
8358
|
this.list = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8359
|
+
var requestId;
|
|
8123
8360
|
return __generator(this, function (_a) {
|
|
8124
8361
|
switch (_a.label) {
|
|
8125
8362
|
case 0:
|
|
8363
|
+
requestId = randomString();
|
|
8126
8364
|
swarm.loggerService.log("StorageUtils list", {
|
|
8127
8365
|
clientId: payload.clientId,
|
|
8128
8366
|
storageName: payload.storageName,
|
|
8367
|
+
requestId: requestId,
|
|
8129
8368
|
});
|
|
8130
8369
|
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
8131
8370
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8132
8371
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (list)"));
|
|
8133
8372
|
}
|
|
8134
|
-
return [4 /*yield*/, swarm.storagePublicService.list(payload.clientId, payload.storageName, payload.filter)];
|
|
8373
|
+
return [4 /*yield*/, swarm.storagePublicService.list(requestId, payload.clientId, payload.storageName, payload.filter)];
|
|
8135
8374
|
case 1: return [2 /*return*/, (_a.sent())];
|
|
8136
8375
|
}
|
|
8137
8376
|
});
|
|
@@ -8144,18 +8383,21 @@ var StorageUtils = /** @class */ (function () {
|
|
|
8144
8383
|
* @returns {Promise<void>} - A promise that resolves when the operation is complete.
|
|
8145
8384
|
*/
|
|
8146
8385
|
this.clear = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8386
|
+
var requestId;
|
|
8147
8387
|
return __generator(this, function (_a) {
|
|
8148
8388
|
switch (_a.label) {
|
|
8149
8389
|
case 0:
|
|
8390
|
+
requestId = randomString();
|
|
8150
8391
|
swarm.loggerService.log("StorageUtils clear", {
|
|
8151
8392
|
clientId: payload.clientId,
|
|
8152
8393
|
storageName: payload.storageName,
|
|
8394
|
+
requestId: requestId,
|
|
8153
8395
|
});
|
|
8154
8396
|
swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
|
|
8155
8397
|
if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
|
|
8156
8398
|
throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (clear)"));
|
|
8157
8399
|
}
|
|
8158
|
-
return [4 /*yield*/, swarm.storagePublicService.clear(payload.clientId, payload.storageName)];
|
|
8400
|
+
return [4 /*yield*/, swarm.storagePublicService.clear(requestId, payload.clientId, payload.storageName)];
|
|
8159
8401
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8160
8402
|
}
|
|
8161
8403
|
});
|
|
@@ -8183,17 +8425,20 @@ var StateUtils = /** @class */ (function () {
|
|
|
8183
8425
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
8184
8426
|
*/
|
|
8185
8427
|
this.getState = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8428
|
+
var requestId;
|
|
8186
8429
|
return __generator(this, function (_a) {
|
|
8187
8430
|
switch (_a.label) {
|
|
8188
8431
|
case 0:
|
|
8432
|
+
requestId = randomString();
|
|
8189
8433
|
swarm.loggerService.log("StateUtils getState", {
|
|
8190
8434
|
clientId: payload.clientId,
|
|
8191
8435
|
stateName: payload.stateName,
|
|
8436
|
+
requestId: requestId,
|
|
8192
8437
|
});
|
|
8193
8438
|
if (!swarm.agentValidationService.hasState(payload.agentName, payload.stateName)) {
|
|
8194
8439
|
throw new Error("agent-swarm StateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (getState)"));
|
|
8195
8440
|
}
|
|
8196
|
-
return [4 /*yield*/, swarm.statePublicService.getState(payload.clientId, payload.stateName)];
|
|
8441
|
+
return [4 /*yield*/, swarm.statePublicService.getState(requestId, payload.clientId, payload.stateName)];
|
|
8197
8442
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8198
8443
|
}
|
|
8199
8444
|
});
|
|
@@ -8210,23 +8455,26 @@ var StateUtils = /** @class */ (function () {
|
|
|
8210
8455
|
* @throws Will throw an error if the state is not registered in the agent.
|
|
8211
8456
|
*/
|
|
8212
8457
|
this.setState = function (dispatchFn, payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
8458
|
+
var requestId;
|
|
8213
8459
|
var _this = this;
|
|
8214
8460
|
return __generator(this, function (_a) {
|
|
8215
8461
|
switch (_a.label) {
|
|
8216
8462
|
case 0:
|
|
8463
|
+
requestId = randomString();
|
|
8217
8464
|
swarm.loggerService.log("StateUtils setState", {
|
|
8218
8465
|
clientId: payload.clientId,
|
|
8219
8466
|
stateName: payload.stateName,
|
|
8467
|
+
requestId: requestId,
|
|
8220
8468
|
});
|
|
8221
8469
|
if (!swarm.agentValidationService.hasState(payload.agentName, payload.stateName)) {
|
|
8222
8470
|
throw new Error("agent-swarm StateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (setState)"));
|
|
8223
8471
|
}
|
|
8224
8472
|
if (!(typeof dispatchFn === "function")) return [3 /*break*/, 2];
|
|
8225
|
-
return [4 /*yield*/, swarm.statePublicService.setState(dispatchFn, payload.clientId, payload.stateName)];
|
|
8473
|
+
return [4 /*yield*/, swarm.statePublicService.setState(dispatchFn, requestId, payload.clientId, payload.stateName)];
|
|
8226
8474
|
case 1: return [2 /*return*/, _a.sent()];
|
|
8227
8475
|
case 2: return [4 /*yield*/, swarm.statePublicService.setState(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
8228
8476
|
return [2 /*return*/, dispatchFn];
|
|
8229
|
-
}); }); }, payload.clientId, payload.stateName)];
|
|
8477
|
+
}); }); }, requestId, payload.clientId, payload.stateName)];
|
|
8230
8478
|
case 3: return [2 /*return*/, _a.sent()];
|
|
8231
8479
|
}
|
|
8232
8480
|
});
|
|
@@ -8240,4 +8488,23 @@ var StateUtils = /** @class */ (function () {
|
|
|
8240
8488
|
*/
|
|
8241
8489
|
var State = new StateUtils();
|
|
8242
8490
|
|
|
8243
|
-
|
|
8491
|
+
var LoggerUtils = /** @class */ (function () {
|
|
8492
|
+
function LoggerUtils() {
|
|
8493
|
+
/**
|
|
8494
|
+
* Sets the provided logger to the logger service.
|
|
8495
|
+
* @param {ILogger} logger - The logger instance to be used.
|
|
8496
|
+
*/
|
|
8497
|
+
this.useLogger = function (logger) {
|
|
8498
|
+
swarm.loggerService.log("HistoryInstance useLogger");
|
|
8499
|
+
swarm.loggerService.setLogger(logger);
|
|
8500
|
+
};
|
|
8501
|
+
}
|
|
8502
|
+
return LoggerUtils;
|
|
8503
|
+
}());
|
|
8504
|
+
/**
|
|
8505
|
+
* Instance of LoggerUtils to be used for logging.
|
|
8506
|
+
* @type {LoggerUtils}
|
|
8507
|
+
*/
|
|
8508
|
+
var Logger = new LoggerUtils();
|
|
8509
|
+
|
|
8510
|
+
export { ContextService, History, HistoryAdapter, HistoryInstance, Logger, State, Storage, addAgent, addCompletion, addEmbedding, addState, addStorage, addSwarm, addTool, cancelOutput, cancelOutputForce, changeAgent, commitFlush, commitFlushForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitUserMessage, commitUserMessageForce, complete, disposeConnection, emit, emitForce, event, execute, executeForce, getAgentHistory, getAgentName, getAssistantHistory, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getRawHistory, getSessionMode, getUserHistory, listenAgentEvent, listenAgentEventOnce, listenEvent, listenEventOnce, listenHistoryEvent, listenHistoryEventOnce, listenSessionEvent, listenSessionEventOnce, listenStateEvent, listenStateEventOnce, listenStorageEvent, listenStorageEventOnce, listenSwarmEvent, listenSwarmEventOnce, makeAutoDispose, makeConnection, session, setConfig, swarm };
|