agent-swarm-kit 1.0.69 → 1.0.71
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 +1016 -131
- package/build/index.mjs +1007 -132
- package/package.json +1 -1
- package/types.d.ts +921 -686
package/build/index.mjs
CHANGED
|
@@ -225,6 +225,7 @@ var _a;
|
|
|
225
225
|
var init = (_a = createActivator("agent-swarm"), _a.init), inject = _a.inject, provide = _a.provide;
|
|
226
226
|
|
|
227
227
|
var baseServices$1 = {
|
|
228
|
+
busService: Symbol('busService'),
|
|
228
229
|
loggerService: Symbol('loggerService'),
|
|
229
230
|
contextService: Symbol('contextService'),
|
|
230
231
|
};
|
|
@@ -951,7 +952,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
951
952
|
validation = null;
|
|
952
953
|
return [4 /*yield*/, this.params.validate(result)];
|
|
953
954
|
case 2:
|
|
954
|
-
if (!(validation = _a.sent())) return [3 /*break*/,
|
|
955
|
+
if (!(validation = _a.sent())) return [3 /*break*/, 8];
|
|
955
956
|
return [4 /*yield*/, this._resurrectModel(mode, validation)];
|
|
956
957
|
case 3:
|
|
957
958
|
rawResult_1 = _a.sent();
|
|
@@ -968,12 +969,44 @@ var ClientAgent = /** @class */ (function () {
|
|
|
968
969
|
return [4 /*yield*/, this._outputSubject.next(result_1)];
|
|
969
970
|
case 6:
|
|
970
971
|
_a.sent();
|
|
971
|
-
return [
|
|
972
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
973
|
+
type: "emit-output",
|
|
974
|
+
source: "agent",
|
|
975
|
+
input: {
|
|
976
|
+
mode: mode,
|
|
977
|
+
rawResult: rawResult_1,
|
|
978
|
+
},
|
|
979
|
+
output: {
|
|
980
|
+
result: result_1,
|
|
981
|
+
},
|
|
982
|
+
context: {
|
|
983
|
+
agentName: this.params.agentName,
|
|
984
|
+
}
|
|
985
|
+
})];
|
|
972
986
|
case 7:
|
|
987
|
+
_a.sent();
|
|
988
|
+
return [2 /*return*/];
|
|
989
|
+
case 8:
|
|
973
990
|
this.params.onOutput &&
|
|
974
991
|
this.params.onOutput(this.params.clientId, this.params.agentName, result);
|
|
975
992
|
return [4 /*yield*/, this._outputSubject.next(result)];
|
|
976
|
-
case
|
|
993
|
+
case 9:
|
|
994
|
+
_a.sent();
|
|
995
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
996
|
+
type: "emit-output",
|
|
997
|
+
source: "agent",
|
|
998
|
+
input: {
|
|
999
|
+
mode: mode,
|
|
1000
|
+
rawResult: rawResult,
|
|
1001
|
+
},
|
|
1002
|
+
output: {
|
|
1003
|
+
result: result,
|
|
1004
|
+
},
|
|
1005
|
+
context: {
|
|
1006
|
+
agentName: this.params.agentName,
|
|
1007
|
+
}
|
|
1008
|
+
})];
|
|
1009
|
+
case 10:
|
|
977
1010
|
_a.sent();
|
|
978
1011
|
return [2 /*return*/];
|
|
979
1012
|
}
|
|
@@ -1105,6 +1138,19 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1105
1138
|
content: message.trim(),
|
|
1106
1139
|
})];
|
|
1107
1140
|
case 1:
|
|
1141
|
+
_a.sent();
|
|
1142
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
1143
|
+
type: "commit-user-message",
|
|
1144
|
+
source: "agent",
|
|
1145
|
+
input: {
|
|
1146
|
+
message: message,
|
|
1147
|
+
},
|
|
1148
|
+
output: {},
|
|
1149
|
+
context: {
|
|
1150
|
+
agentName: this.params.agentName,
|
|
1151
|
+
}
|
|
1152
|
+
})];
|
|
1153
|
+
case 2:
|
|
1108
1154
|
_a.sent();
|
|
1109
1155
|
return [2 /*return*/];
|
|
1110
1156
|
}
|
|
@@ -1128,6 +1174,17 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1128
1174
|
content: "",
|
|
1129
1175
|
})];
|
|
1130
1176
|
case 1:
|
|
1177
|
+
_a.sent();
|
|
1178
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
1179
|
+
type: "commit-flush",
|
|
1180
|
+
source: "agent",
|
|
1181
|
+
input: {},
|
|
1182
|
+
output: {},
|
|
1183
|
+
context: {
|
|
1184
|
+
agentName: this.params.agentName,
|
|
1185
|
+
}
|
|
1186
|
+
})];
|
|
1187
|
+
case 2:
|
|
1131
1188
|
_a.sent();
|
|
1132
1189
|
return [2 /*return*/];
|
|
1133
1190
|
}
|
|
@@ -1144,6 +1201,17 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1144
1201
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " commitAgentChange"));
|
|
1145
1202
|
return [4 /*yield*/, this._agentChangeSubject.next(AGENT_CHANGE_SYMBOL)];
|
|
1146
1203
|
case 1:
|
|
1204
|
+
_a.sent();
|
|
1205
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
1206
|
+
type: "commit-agent-change",
|
|
1207
|
+
source: "agent",
|
|
1208
|
+
input: {},
|
|
1209
|
+
output: {},
|
|
1210
|
+
context: {
|
|
1211
|
+
agentName: this.params.agentName,
|
|
1212
|
+
}
|
|
1213
|
+
})];
|
|
1214
|
+
case 2:
|
|
1147
1215
|
_a.sent();
|
|
1148
1216
|
return [2 /*return*/];
|
|
1149
1217
|
}
|
|
@@ -1168,6 +1236,19 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1168
1236
|
content: message.trim(),
|
|
1169
1237
|
})];
|
|
1170
1238
|
case 1:
|
|
1239
|
+
_a.sent();
|
|
1240
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
1241
|
+
type: "commit-system-message",
|
|
1242
|
+
source: "agent",
|
|
1243
|
+
input: {
|
|
1244
|
+
message: message,
|
|
1245
|
+
},
|
|
1246
|
+
output: {},
|
|
1247
|
+
context: {
|
|
1248
|
+
agentName: this.params.agentName,
|
|
1249
|
+
}
|
|
1250
|
+
})];
|
|
1251
|
+
case 2:
|
|
1171
1252
|
_a.sent();
|
|
1172
1253
|
return [2 /*return*/];
|
|
1173
1254
|
}
|
|
@@ -1196,6 +1277,20 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1196
1277
|
_a.sent();
|
|
1197
1278
|
return [4 /*yield*/, this._toolCommitSubject.next()];
|
|
1198
1279
|
case 2:
|
|
1280
|
+
_a.sent();
|
|
1281
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
1282
|
+
type: "commit-tool-output",
|
|
1283
|
+
source: "agent",
|
|
1284
|
+
input: {
|
|
1285
|
+
toolId: toolId,
|
|
1286
|
+
content: content,
|
|
1287
|
+
},
|
|
1288
|
+
output: {},
|
|
1289
|
+
context: {
|
|
1290
|
+
agentName: this.params.agentName,
|
|
1291
|
+
}
|
|
1292
|
+
})];
|
|
1293
|
+
case 3:
|
|
1199
1294
|
_a.sent();
|
|
1200
1295
|
return [2 /*return*/];
|
|
1201
1296
|
}
|
|
@@ -1409,6 +1504,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1409
1504
|
function AgentConnectionService() {
|
|
1410
1505
|
var _this = this;
|
|
1411
1506
|
this.loggerService = inject(TYPES.loggerService);
|
|
1507
|
+
this.busService = inject(TYPES.busService);
|
|
1412
1508
|
this.contextService = inject(TYPES.contextService);
|
|
1413
1509
|
this.sessionValidationService = inject(TYPES.sessionValidationService);
|
|
1414
1510
|
this.historyConnectionService = inject(TYPES.historyConnectionService);
|
|
@@ -1439,7 +1535,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1439
1535
|
.getStorage(clientId, storageName)
|
|
1440
1536
|
.waitForInit();
|
|
1441
1537
|
});
|
|
1442
|
-
return new ClientAgent(__assign({ clientId: clientId, agentName: agentName, validate: validate, logger: _this.loggerService, history: _this.historyConnectionService.getHistory(clientId, agentName), prompt: prompt, system: system, transform: transform, map: map, tools: tools === null || tools === void 0 ? void 0 : tools.map(_this.toolSchemaService.get), completion: completion }, callbacks));
|
|
1538
|
+
return new ClientAgent(__assign({ clientId: clientId, agentName: agentName, validate: validate, logger: _this.loggerService, bus: _this.busService, history: _this.historyConnectionService.getHistory(clientId, agentName), prompt: prompt, system: system, transform: transform, map: map, tools: tools === null || tools === void 0 ? void 0 : tools.map(_this.toolSchemaService.get), completion: completion }, callbacks));
|
|
1443
1539
|
});
|
|
1444
1540
|
/**
|
|
1445
1541
|
* Executes an input command.
|
|
@@ -1617,6 +1713,19 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1617
1713
|
this.params.logger.debug("ClientHistory agentName=".concat(this.params.agentName, " push"), { message: message });
|
|
1618
1714
|
return [4 /*yield*/, this.params.items.push(message, this.params.clientId, this.params.agentName)];
|
|
1619
1715
|
case 1:
|
|
1716
|
+
_a.sent();
|
|
1717
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
1718
|
+
type: "push",
|
|
1719
|
+
source: "history",
|
|
1720
|
+
input: {
|
|
1721
|
+
message: message
|
|
1722
|
+
},
|
|
1723
|
+
output: {},
|
|
1724
|
+
context: {
|
|
1725
|
+
agentName: this.params.agentName,
|
|
1726
|
+
}
|
|
1727
|
+
})];
|
|
1728
|
+
case 2:
|
|
1620
1729
|
_a.sent();
|
|
1621
1730
|
return [2 /*return*/];
|
|
1622
1731
|
}
|
|
@@ -1850,6 +1959,7 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
1850
1959
|
function HistoryConnectionService() {
|
|
1851
1960
|
var _this = this;
|
|
1852
1961
|
this.loggerService = inject(TYPES.loggerService);
|
|
1962
|
+
this.busService = inject(TYPES.busService);
|
|
1853
1963
|
this.contextService = inject(TYPES.contextService);
|
|
1854
1964
|
this.sessionValidationService = inject(TYPES.sessionValidationService);
|
|
1855
1965
|
/**
|
|
@@ -1866,6 +1976,7 @@ var HistoryConnectionService = /** @class */ (function () {
|
|
|
1866
1976
|
return new ClientHistory({
|
|
1867
1977
|
clientId: clientId,
|
|
1868
1978
|
agentName: agentName,
|
|
1979
|
+
bus: _this.busService,
|
|
1869
1980
|
items: GLOBAL_CONFIG.CC_GET_AGENT_HISTORY_ADAPTER(clientId, agentName),
|
|
1870
1981
|
logger: _this.loggerService,
|
|
1871
1982
|
});
|
|
@@ -1993,10 +2104,44 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
1993
2104
|
this.params = params;
|
|
1994
2105
|
this._agentChangedSubject = new Subject();
|
|
1995
2106
|
this._activeAgent = AGENT_NEED_FETCH;
|
|
2107
|
+
this._cancelOutputSubject = new Subject();
|
|
2108
|
+
/**
|
|
2109
|
+
* Cancel the await of output by emit of empty string
|
|
2110
|
+
* @returns {Promise<string>} - The output from the active agent.
|
|
2111
|
+
*/
|
|
2112
|
+
this.cancelOutput = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2113
|
+
var _a, _b;
|
|
2114
|
+
var _c;
|
|
2115
|
+
return __generator(this, function (_d) {
|
|
2116
|
+
switch (_d.label) {
|
|
2117
|
+
case 0:
|
|
2118
|
+
this.params.logger.debug("ClientSwarm swarmName=".concat(this.params.swarmName, " clientId=").concat(this.params.clientId, " cancelOutput"));
|
|
2119
|
+
_b = (_a = this._cancelOutputSubject).next;
|
|
2120
|
+
_c = {};
|
|
2121
|
+
return [4 /*yield*/, this.getAgentName()];
|
|
2122
|
+
case 1: return [4 /*yield*/, _b.apply(_a, [(_c.agentName = _d.sent(),
|
|
2123
|
+
_c.output = "",
|
|
2124
|
+
_c)])];
|
|
2125
|
+
case 2:
|
|
2126
|
+
_d.sent();
|
|
2127
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2128
|
+
type: "cancel-output",
|
|
2129
|
+
source: "swarm",
|
|
2130
|
+
input: {},
|
|
2131
|
+
output: {},
|
|
2132
|
+
context: {
|
|
2133
|
+
swarmName: this.params.swarmName,
|
|
2134
|
+
},
|
|
2135
|
+
})];
|
|
2136
|
+
case 3:
|
|
2137
|
+
_d.sent();
|
|
2138
|
+
return [2 /*return*/];
|
|
2139
|
+
}
|
|
2140
|
+
});
|
|
2141
|
+
}); };
|
|
1996
2142
|
/**
|
|
1997
2143
|
* Waits for output from the active agent.
|
|
1998
2144
|
* @returns {Promise<string>} - The output from the active agent.
|
|
1999
|
-
* @throws {Error} - If the timeout is reached.
|
|
2000
2145
|
*/
|
|
2001
2146
|
this.waitForOutput = queued(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2002
2147
|
var _a, awaiter, resolve, getOutput, handleOutput, un, _b, agentName, output, expectAgent;
|
|
@@ -2010,18 +2155,23 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2010
2155
|
var _this = this;
|
|
2011
2156
|
return __generator(this, function (_a) {
|
|
2012
2157
|
switch (_a.label) {
|
|
2013
|
-
case 0: return [4 /*yield*/, Promise.race(this._agentList
|
|
2158
|
+
case 0: return [4 /*yield*/, Promise.race(this._agentList
|
|
2159
|
+
.map(function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
2014
2160
|
var _c;
|
|
2015
2161
|
var _d = __read(_b, 2), agentName = _d[0], agent = _d[1];
|
|
2016
2162
|
return __generator(this, function (_e) {
|
|
2017
2163
|
switch (_e.label) {
|
|
2018
2164
|
case 0:
|
|
2019
|
-
_c = {
|
|
2165
|
+
_c = {
|
|
2166
|
+
agentName: agentName
|
|
2167
|
+
};
|
|
2020
2168
|
return [4 /*yield*/, agent.waitForOutput()];
|
|
2021
|
-
case 1: return [2 /*return*/, (_c.output = _e.sent(),
|
|
2169
|
+
case 1: return [2 /*return*/, (_c.output = _e.sent(),
|
|
2170
|
+
_c)];
|
|
2022
2171
|
}
|
|
2023
2172
|
});
|
|
2024
|
-
}); })
|
|
2173
|
+
}); })
|
|
2174
|
+
.concat(this._cancelOutputSubject.toPromise()))];
|
|
2025
2175
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2026
2176
|
}
|
|
2027
2177
|
});
|
|
@@ -2044,7 +2194,21 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2044
2194
|
return [4 /*yield*/, this.getAgentName()];
|
|
2045
2195
|
case 2:
|
|
2046
2196
|
expectAgent = _c.sent();
|
|
2047
|
-
agentName !== expectAgent &&
|
|
2197
|
+
agentName !== expectAgent &&
|
|
2198
|
+
this.params.logger.debug("ClientSwarm swarmName=".concat(this.params.swarmName, " clientId=").concat(this.params.clientId, " waitForAgent agent miss"), { agentName: agentName, expectAgent: expectAgent });
|
|
2199
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2200
|
+
type: "wait-for-output",
|
|
2201
|
+
source: "swarm",
|
|
2202
|
+
input: {},
|
|
2203
|
+
output: {
|
|
2204
|
+
result: output,
|
|
2205
|
+
},
|
|
2206
|
+
context: {
|
|
2207
|
+
swarmName: this.params.swarmName,
|
|
2208
|
+
},
|
|
2209
|
+
})];
|
|
2210
|
+
case 3:
|
|
2211
|
+
_c.sent();
|
|
2048
2212
|
return [2 /*return*/, output];
|
|
2049
2213
|
}
|
|
2050
2214
|
});
|
|
@@ -2065,7 +2229,20 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2065
2229
|
case 1:
|
|
2066
2230
|
_a._activeAgent = _b.sent();
|
|
2067
2231
|
_b.label = 2;
|
|
2068
|
-
case 2: return [
|
|
2232
|
+
case 2: return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2233
|
+
type: "get-agent-name",
|
|
2234
|
+
source: "swarm",
|
|
2235
|
+
input: {},
|
|
2236
|
+
output: {
|
|
2237
|
+
activeAgent: this._activeAgent,
|
|
2238
|
+
},
|
|
2239
|
+
context: {
|
|
2240
|
+
swarmName: this.params.swarmName,
|
|
2241
|
+
},
|
|
2242
|
+
})];
|
|
2243
|
+
case 3:
|
|
2244
|
+
_b.sent();
|
|
2245
|
+
return [2 /*return*/, this._activeAgent];
|
|
2069
2246
|
}
|
|
2070
2247
|
});
|
|
2071
2248
|
}); };
|
|
@@ -2074,7 +2251,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2074
2251
|
* @returns {Promise<IAgent>} - The active agent.
|
|
2075
2252
|
*/
|
|
2076
2253
|
this.getAgent = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2077
|
-
var agent;
|
|
2254
|
+
var agent, result;
|
|
2078
2255
|
return __generator(this, function (_a) {
|
|
2079
2256
|
switch (_a.label) {
|
|
2080
2257
|
case 0:
|
|
@@ -2082,7 +2259,21 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2082
2259
|
return [4 /*yield*/, this.getAgentName()];
|
|
2083
2260
|
case 1:
|
|
2084
2261
|
agent = _a.sent();
|
|
2085
|
-
|
|
2262
|
+
result = this.params.agentMap[agent];
|
|
2263
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2264
|
+
type: "get-agent",
|
|
2265
|
+
source: "swarm",
|
|
2266
|
+
input: {
|
|
2267
|
+
result: result,
|
|
2268
|
+
},
|
|
2269
|
+
output: {},
|
|
2270
|
+
context: {
|
|
2271
|
+
swarmName: this.params.swarmName,
|
|
2272
|
+
},
|
|
2273
|
+
})];
|
|
2274
|
+
case 2:
|
|
2275
|
+
_a.sent();
|
|
2276
|
+
return [2 /*return*/, result];
|
|
2086
2277
|
}
|
|
2087
2278
|
});
|
|
2088
2279
|
}); };
|
|
@@ -2101,8 +2292,22 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2101
2292
|
throw new Error("agent-swarm agent ".concat(agentName, " not in the swarm"));
|
|
2102
2293
|
}
|
|
2103
2294
|
this.params.agentMap[agentName] = agent;
|
|
2104
|
-
return [4 /*yield*/, this.
|
|
2295
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2296
|
+
type: "set-agent-ref",
|
|
2297
|
+
source: "swarm",
|
|
2298
|
+
input: {
|
|
2299
|
+
agentName: agentName,
|
|
2300
|
+
agent: agent,
|
|
2301
|
+
},
|
|
2302
|
+
output: {},
|
|
2303
|
+
context: {
|
|
2304
|
+
swarmName: this.params.swarmName,
|
|
2305
|
+
},
|
|
2306
|
+
})];
|
|
2105
2307
|
case 1:
|
|
2308
|
+
_a.sent();
|
|
2309
|
+
return [4 /*yield*/, this._agentChangedSubject.next([agentName, agent])];
|
|
2310
|
+
case 2:
|
|
2106
2311
|
_a.sent();
|
|
2107
2312
|
return [2 /*return*/];
|
|
2108
2313
|
}
|
|
@@ -2120,6 +2325,19 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2120
2325
|
this._activeAgent = agentName;
|
|
2121
2326
|
return [4 /*yield*/, this.params.onAgentChanged(this.params.clientId, agentName, this.params.swarmName)];
|
|
2122
2327
|
case 1:
|
|
2328
|
+
_a.sent();
|
|
2329
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2330
|
+
type: "set-agent-name",
|
|
2331
|
+
source: "swarm",
|
|
2332
|
+
input: {
|
|
2333
|
+
agentName: agentName,
|
|
2334
|
+
},
|
|
2335
|
+
output: {},
|
|
2336
|
+
context: {
|
|
2337
|
+
swarmName: this.params.swarmName,
|
|
2338
|
+
},
|
|
2339
|
+
})];
|
|
2340
|
+
case 2:
|
|
2123
2341
|
_a.sent();
|
|
2124
2342
|
return [2 /*return*/];
|
|
2125
2343
|
}
|
|
@@ -2147,6 +2365,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2147
2365
|
function SwarmConnectionService() {
|
|
2148
2366
|
var _this = this;
|
|
2149
2367
|
this.loggerService = inject(TYPES.loggerService);
|
|
2368
|
+
this.busService = inject(TYPES.busService);
|
|
2150
2369
|
this.contextService = inject(TYPES.contextService);
|
|
2151
2370
|
this.agentConnectionService = inject(TYPES.agentConnectionService);
|
|
2152
2371
|
this.swarmSchemaService = inject(TYPES.swarmSchemaService);
|
|
@@ -2182,6 +2401,7 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2182
2401
|
defaultAgent: defaultAgent,
|
|
2183
2402
|
swarmName: swarmName,
|
|
2184
2403
|
logger: _this.loggerService,
|
|
2404
|
+
bus: _this.busService,
|
|
2185
2405
|
onAgentChanged: function (clientId, agentName, swarmName) {
|
|
2186
2406
|
return __awaiter(this, void 0, void 0, function () {
|
|
2187
2407
|
return __generator(this, function (_a) {
|
|
@@ -2201,6 +2421,22 @@ var SwarmConnectionService = /** @class */ (function () {
|
|
|
2201
2421
|
callbacks: callbacks,
|
|
2202
2422
|
});
|
|
2203
2423
|
});
|
|
2424
|
+
/**
|
|
2425
|
+
* Cancel the await of output by emit of empty string
|
|
2426
|
+
* @returns {Promise<void>}
|
|
2427
|
+
*/
|
|
2428
|
+
this.cancelOutput = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2429
|
+
return __generator(this, function (_a) {
|
|
2430
|
+
switch (_a.label) {
|
|
2431
|
+
case 0:
|
|
2432
|
+
this.loggerService.log("swarmConnectionService cancelOutput", {
|
|
2433
|
+
context: this.contextService.context,
|
|
2434
|
+
});
|
|
2435
|
+
return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).cancelOutput()];
|
|
2436
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
2437
|
+
}
|
|
2438
|
+
});
|
|
2439
|
+
}); };
|
|
2204
2440
|
/**
|
|
2205
2441
|
* Waits for the output from the swarm.
|
|
2206
2442
|
* @returns {Promise<any>} The output from the swarm.
|
|
@@ -2395,6 +2631,19 @@ var ClientSession = /** @class */ (function () {
|
|
|
2395
2631
|
this.params.onEmit(this.params.clientId, this.params.swarmName, message);
|
|
2396
2632
|
return [4 /*yield*/, this._emitSubject.next(message)];
|
|
2397
2633
|
case 1:
|
|
2634
|
+
_a.sent();
|
|
2635
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2636
|
+
type: "emit",
|
|
2637
|
+
source: "session",
|
|
2638
|
+
input: {
|
|
2639
|
+
message: message
|
|
2640
|
+
},
|
|
2641
|
+
output: {},
|
|
2642
|
+
context: {
|
|
2643
|
+
swarmName: this.params.swarmName,
|
|
2644
|
+
}
|
|
2645
|
+
})];
|
|
2646
|
+
case 2:
|
|
2398
2647
|
_a.sent();
|
|
2399
2648
|
return [2 /*return*/];
|
|
2400
2649
|
}
|
|
@@ -2425,6 +2674,22 @@ var ClientSession = /** @class */ (function () {
|
|
|
2425
2674
|
return [4 /*yield*/, outputAwaiter];
|
|
2426
2675
|
case 2:
|
|
2427
2676
|
output = _a.sent();
|
|
2677
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2678
|
+
type: "execute",
|
|
2679
|
+
source: "session",
|
|
2680
|
+
input: {
|
|
2681
|
+
message: message,
|
|
2682
|
+
mode: mode,
|
|
2683
|
+
},
|
|
2684
|
+
output: {
|
|
2685
|
+
result: output,
|
|
2686
|
+
},
|
|
2687
|
+
context: {
|
|
2688
|
+
swarmName: this.params.swarmName,
|
|
2689
|
+
}
|
|
2690
|
+
})];
|
|
2691
|
+
case 3:
|
|
2692
|
+
_a.sent();
|
|
2428
2693
|
return [2 /*return*/, output];
|
|
2429
2694
|
}
|
|
2430
2695
|
});
|
|
@@ -2436,7 +2701,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
2436
2701
|
* @returns {Promise<void>}
|
|
2437
2702
|
*/
|
|
2438
2703
|
this.commitToolOutput = function (toolId, content) { return __awaiter(_this, void 0, void 0, function () {
|
|
2439
|
-
var agent;
|
|
2704
|
+
var agent, result;
|
|
2440
2705
|
return __generator(this, function (_a) {
|
|
2441
2706
|
switch (_a.label) {
|
|
2442
2707
|
case 0:
|
|
@@ -2448,7 +2713,23 @@ var ClientSession = /** @class */ (function () {
|
|
|
2448
2713
|
case 1:
|
|
2449
2714
|
agent = _a.sent();
|
|
2450
2715
|
return [4 /*yield*/, agent.commitToolOutput(toolId, content)];
|
|
2451
|
-
case 2:
|
|
2716
|
+
case 2:
|
|
2717
|
+
result = _a.sent();
|
|
2718
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2719
|
+
type: "commit-tool-output",
|
|
2720
|
+
source: "session",
|
|
2721
|
+
input: {
|
|
2722
|
+
toolId: toolId,
|
|
2723
|
+
content: content,
|
|
2724
|
+
},
|
|
2725
|
+
output: {},
|
|
2726
|
+
context: {
|
|
2727
|
+
swarmName: this.params.swarmName,
|
|
2728
|
+
}
|
|
2729
|
+
})];
|
|
2730
|
+
case 3:
|
|
2731
|
+
_a.sent();
|
|
2732
|
+
return [2 /*return*/, result];
|
|
2452
2733
|
}
|
|
2453
2734
|
});
|
|
2454
2735
|
}); };
|
|
@@ -2458,7 +2739,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
2458
2739
|
* @returns {Promise<void>}
|
|
2459
2740
|
*/
|
|
2460
2741
|
this.commitUserMessage = function (message) { return __awaiter(_this, void 0, void 0, function () {
|
|
2461
|
-
var agent;
|
|
2742
|
+
var agent, result;
|
|
2462
2743
|
return __generator(this, function (_a) {
|
|
2463
2744
|
switch (_a.label) {
|
|
2464
2745
|
case 0:
|
|
@@ -2469,7 +2750,22 @@ var ClientSession = /** @class */ (function () {
|
|
|
2469
2750
|
case 1:
|
|
2470
2751
|
agent = _a.sent();
|
|
2471
2752
|
return [4 /*yield*/, agent.commitUserMessage(message)];
|
|
2472
|
-
case 2:
|
|
2753
|
+
case 2:
|
|
2754
|
+
result = _a.sent();
|
|
2755
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2756
|
+
type: "commit-user-message",
|
|
2757
|
+
source: "session",
|
|
2758
|
+
input: {
|
|
2759
|
+
message: message,
|
|
2760
|
+
},
|
|
2761
|
+
output: {},
|
|
2762
|
+
context: {
|
|
2763
|
+
swarmName: this.params.swarmName,
|
|
2764
|
+
}
|
|
2765
|
+
})];
|
|
2766
|
+
case 3:
|
|
2767
|
+
_a.sent();
|
|
2768
|
+
return [2 /*return*/, result];
|
|
2473
2769
|
}
|
|
2474
2770
|
});
|
|
2475
2771
|
}); };
|
|
@@ -2478,7 +2774,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
2478
2774
|
* @returns {Promise<void>}
|
|
2479
2775
|
*/
|
|
2480
2776
|
this.commitFlush = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2481
|
-
var agent;
|
|
2777
|
+
var agent, result;
|
|
2482
2778
|
return __generator(this, function (_a) {
|
|
2483
2779
|
switch (_a.label) {
|
|
2484
2780
|
case 0:
|
|
@@ -2487,7 +2783,20 @@ var ClientSession = /** @class */ (function () {
|
|
|
2487
2783
|
case 1:
|
|
2488
2784
|
agent = _a.sent();
|
|
2489
2785
|
return [4 /*yield*/, agent.commitFlush()];
|
|
2490
|
-
case 2:
|
|
2786
|
+
case 2:
|
|
2787
|
+
result = _a.sent();
|
|
2788
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2789
|
+
type: "commit-flush",
|
|
2790
|
+
source: "session",
|
|
2791
|
+
input: {},
|
|
2792
|
+
output: {},
|
|
2793
|
+
context: {
|
|
2794
|
+
swarmName: this.params.swarmName,
|
|
2795
|
+
}
|
|
2796
|
+
})];
|
|
2797
|
+
case 3:
|
|
2798
|
+
_a.sent();
|
|
2799
|
+
return [2 /*return*/, result];
|
|
2491
2800
|
}
|
|
2492
2801
|
});
|
|
2493
2802
|
}); };
|
|
@@ -2497,7 +2806,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
2497
2806
|
* @returns {Promise<void>}
|
|
2498
2807
|
*/
|
|
2499
2808
|
this.commitSystemMessage = function (message) { return __awaiter(_this, void 0, void 0, function () {
|
|
2500
|
-
var agent;
|
|
2809
|
+
var agent, result;
|
|
2501
2810
|
return __generator(this, function (_a) {
|
|
2502
2811
|
switch (_a.label) {
|
|
2503
2812
|
case 0:
|
|
@@ -2508,7 +2817,22 @@ var ClientSession = /** @class */ (function () {
|
|
|
2508
2817
|
case 1:
|
|
2509
2818
|
agent = _a.sent();
|
|
2510
2819
|
return [4 /*yield*/, agent.commitSystemMessage(message)];
|
|
2511
|
-
case 2:
|
|
2820
|
+
case 2:
|
|
2821
|
+
result = _a.sent();
|
|
2822
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2823
|
+
type: "commit-system-message",
|
|
2824
|
+
source: "session",
|
|
2825
|
+
input: {
|
|
2826
|
+
message: message
|
|
2827
|
+
},
|
|
2828
|
+
output: {},
|
|
2829
|
+
context: {
|
|
2830
|
+
swarmName: this.params.swarmName,
|
|
2831
|
+
}
|
|
2832
|
+
})];
|
|
2833
|
+
case 3:
|
|
2834
|
+
_a.sent();
|
|
2835
|
+
return [2 /*return*/, result];
|
|
2512
2836
|
}
|
|
2513
2837
|
});
|
|
2514
2838
|
}); };
|
|
@@ -2539,6 +2863,15 @@ var ClientSession = /** @class */ (function () {
|
|
|
2539
2863
|
}
|
|
2540
2864
|
});
|
|
2541
2865
|
}); });
|
|
2866
|
+
_this.params.bus.emit(_this.params.clientId, {
|
|
2867
|
+
type: "connect",
|
|
2868
|
+
source: "session",
|
|
2869
|
+
input: {},
|
|
2870
|
+
output: {},
|
|
2871
|
+
context: {
|
|
2872
|
+
swarmName: _this.params.swarmName,
|
|
2873
|
+
}
|
|
2874
|
+
});
|
|
2542
2875
|
return function (incoming) { return __awaiter(_this, void 0, void 0, function () {
|
|
2543
2876
|
var _a;
|
|
2544
2877
|
var _b;
|
|
@@ -2590,6 +2923,7 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
2590
2923
|
function SessionConnectionService() {
|
|
2591
2924
|
var _this = this;
|
|
2592
2925
|
this.loggerService = inject(TYPES.loggerService);
|
|
2926
|
+
this.busService = inject(TYPES.busService);
|
|
2593
2927
|
this.contextService = inject(TYPES.contextService);
|
|
2594
2928
|
this.swarmConnectionService = inject(TYPES.swarmConnectionService);
|
|
2595
2929
|
this.swarmSchemaService = inject(TYPES.swarmSchemaService);
|
|
@@ -2604,7 +2938,7 @@ var SessionConnectionService = /** @class */ (function () {
|
|
|
2604
2938
|
return "".concat(clientId, "-").concat(swarmName);
|
|
2605
2939
|
}, function (clientId, swarmName) {
|
|
2606
2940
|
var callbacks = _this.swarmSchemaService.get(swarmName).callbacks;
|
|
2607
|
-
return new ClientSession(__assign({ clientId: clientId, logger: _this.loggerService, swarm: _this.swarmConnectionService.getSwarm(clientId, swarmName), swarmName: swarmName }, callbacks));
|
|
2941
|
+
return new ClientSession(__assign({ clientId: clientId, logger: _this.loggerService, bus: _this.busService, swarm: _this.swarmConnectionService.getSwarm(clientId, swarmName), swarmName: swarmName }, callbacks));
|
|
2608
2942
|
});
|
|
2609
2943
|
/**
|
|
2610
2944
|
* Emits a message to the session.
|
|
@@ -3540,6 +3874,39 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3540
3874
|
var _this = this;
|
|
3541
3875
|
this.loggerService = inject(TYPES.loggerService);
|
|
3542
3876
|
this.swarmConnectionService = inject(TYPES.swarmConnectionService);
|
|
3877
|
+
/**
|
|
3878
|
+
* Cancel the await of output by emit of empty string
|
|
3879
|
+
* @param {string} clientId - The client ID.
|
|
3880
|
+
* @param {SwarmName} swarmName - The swarm name.
|
|
3881
|
+
* @returns {Promise<void>}
|
|
3882
|
+
*/
|
|
3883
|
+
this.cancelOutput = function (clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
|
|
3884
|
+
var _this = this;
|
|
3885
|
+
return __generator(this, function (_a) {
|
|
3886
|
+
switch (_a.label) {
|
|
3887
|
+
case 0:
|
|
3888
|
+
this.loggerService.log("swarmPublicService cancelOutput", {
|
|
3889
|
+
clientId: clientId,
|
|
3890
|
+
swarmName: swarmName,
|
|
3891
|
+
});
|
|
3892
|
+
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3893
|
+
return __generator(this, function (_a) {
|
|
3894
|
+
switch (_a.label) {
|
|
3895
|
+
case 0: return [4 /*yield*/, this.swarmConnectionService.cancelOutput()];
|
|
3896
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
3897
|
+
}
|
|
3898
|
+
});
|
|
3899
|
+
}); }, {
|
|
3900
|
+
clientId: clientId,
|
|
3901
|
+
swarmName: swarmName,
|
|
3902
|
+
agentName: "",
|
|
3903
|
+
storageName: "",
|
|
3904
|
+
stateName: "",
|
|
3905
|
+
})];
|
|
3906
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
3907
|
+
}
|
|
3908
|
+
});
|
|
3909
|
+
}); };
|
|
3543
3910
|
/**
|
|
3544
3911
|
* Waits for output from the swarm.
|
|
3545
3912
|
* @param {string} clientId - The client ID.
|
|
@@ -4414,6 +4781,7 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4414
4781
|
*/
|
|
4415
4782
|
function ClientStorage(params) {
|
|
4416
4783
|
var _this = this;
|
|
4784
|
+
var _a;
|
|
4417
4785
|
this.params = params;
|
|
4418
4786
|
this._itemMap = new Map();
|
|
4419
4787
|
/**
|
|
@@ -4532,6 +4900,23 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4532
4900
|
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onSearch) {
|
|
4533
4901
|
(_b = this.params.callbacks) === null || _b === void 0 ? void 0 : _b.onSearch(search, indexed, this.params.clientId, this.params.storageName);
|
|
4534
4902
|
}
|
|
4903
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
4904
|
+
type: "take",
|
|
4905
|
+
source: "storage",
|
|
4906
|
+
input: {
|
|
4907
|
+
search: search,
|
|
4908
|
+
total: total,
|
|
4909
|
+
score: score,
|
|
4910
|
+
},
|
|
4911
|
+
output: {
|
|
4912
|
+
indexed: indexed,
|
|
4913
|
+
},
|
|
4914
|
+
context: {
|
|
4915
|
+
storageName: this.params.storageName,
|
|
4916
|
+
}
|
|
4917
|
+
})];
|
|
4918
|
+
case 3:
|
|
4919
|
+
_c.sent();
|
|
4535
4920
|
return [2 /*return*/, indexed.take(total, score)];
|
|
4536
4921
|
}
|
|
4537
4922
|
});
|
|
@@ -4558,6 +4943,19 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4558
4943
|
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onUpdate) {
|
|
4559
4944
|
(_b = this.params.callbacks) === null || _b === void 0 ? void 0 : _b.onUpdate(__spreadArray([], __read(this._itemMap.values()), false), this.params.clientId, this.params.storageName);
|
|
4560
4945
|
}
|
|
4946
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
4947
|
+
type: "upsert",
|
|
4948
|
+
source: "storage",
|
|
4949
|
+
input: {
|
|
4950
|
+
item: item,
|
|
4951
|
+
},
|
|
4952
|
+
output: {},
|
|
4953
|
+
context: {
|
|
4954
|
+
storageName: this.params.storageName,
|
|
4955
|
+
}
|
|
4956
|
+
})];
|
|
4957
|
+
case 2:
|
|
4958
|
+
_c.sent();
|
|
4561
4959
|
return [2 /*return*/];
|
|
4562
4960
|
}
|
|
4563
4961
|
});
|
|
@@ -4570,15 +4968,31 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4570
4968
|
this.remove = function (itemId) { return __awaiter(_this, void 0, void 0, function () {
|
|
4571
4969
|
var _a, _b;
|
|
4572
4970
|
return __generator(this, function (_c) {
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4971
|
+
switch (_c.label) {
|
|
4972
|
+
case 0:
|
|
4973
|
+
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " remove"), {
|
|
4974
|
+
id: itemId,
|
|
4975
|
+
});
|
|
4976
|
+
this._itemMap.delete(itemId);
|
|
4977
|
+
this._createEmbedding.clear(itemId);
|
|
4978
|
+
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onUpdate) {
|
|
4979
|
+
(_b = this.params.callbacks) === null || _b === void 0 ? void 0 : _b.onUpdate(__spreadArray([], __read(this._itemMap.values()), false), this.params.clientId, this.params.storageName);
|
|
4980
|
+
}
|
|
4981
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
4982
|
+
type: "remove",
|
|
4983
|
+
source: "storage",
|
|
4984
|
+
input: {
|
|
4985
|
+
itemId: itemId,
|
|
4986
|
+
},
|
|
4987
|
+
output: {},
|
|
4988
|
+
context: {
|
|
4989
|
+
storageName: this.params.storageName,
|
|
4990
|
+
}
|
|
4991
|
+
})];
|
|
4992
|
+
case 1:
|
|
4993
|
+
_c.sent();
|
|
4994
|
+
return [2 /*return*/];
|
|
4580
4995
|
}
|
|
4581
|
-
return [2 /*return*/];
|
|
4582
4996
|
});
|
|
4583
4997
|
}); };
|
|
4584
4998
|
/**
|
|
@@ -4587,10 +5001,24 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4587
5001
|
*/
|
|
4588
5002
|
this.clear = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
4589
5003
|
return __generator(this, function (_a) {
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
5004
|
+
switch (_a.label) {
|
|
5005
|
+
case 0:
|
|
5006
|
+
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " clear"));
|
|
5007
|
+
this._itemMap.clear();
|
|
5008
|
+
this._createEmbedding.clear();
|
|
5009
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
5010
|
+
type: "clear",
|
|
5011
|
+
source: "storage",
|
|
5012
|
+
input: {},
|
|
5013
|
+
output: {},
|
|
5014
|
+
context: {
|
|
5015
|
+
storageName: this.params.storageName,
|
|
5016
|
+
}
|
|
5017
|
+
})];
|
|
5018
|
+
case 1:
|
|
5019
|
+
_a.sent();
|
|
5020
|
+
return [2 /*return*/];
|
|
5021
|
+
}
|
|
4594
5022
|
});
|
|
4595
5023
|
}); };
|
|
4596
5024
|
/**
|
|
@@ -4599,12 +5027,32 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4599
5027
|
* @returns {Promise<T | null>} - The item or null if not found.
|
|
4600
5028
|
*/
|
|
4601
5029
|
this.get = function (itemId) { return __awaiter(_this, void 0, void 0, function () {
|
|
5030
|
+
var result;
|
|
4602
5031
|
var _a;
|
|
4603
5032
|
return __generator(this, function (_b) {
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
5033
|
+
switch (_b.label) {
|
|
5034
|
+
case 0:
|
|
5035
|
+
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " get"), {
|
|
5036
|
+
id: itemId,
|
|
5037
|
+
});
|
|
5038
|
+
result = (_a = this._itemMap.get(itemId)) !== null && _a !== void 0 ? _a : null;
|
|
5039
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
5040
|
+
type: "get",
|
|
5041
|
+
source: "storage",
|
|
5042
|
+
input: {
|
|
5043
|
+
itemId: itemId,
|
|
5044
|
+
},
|
|
5045
|
+
output: {
|
|
5046
|
+
result: result,
|
|
5047
|
+
},
|
|
5048
|
+
context: {
|
|
5049
|
+
storageName: this.params.storageName,
|
|
5050
|
+
}
|
|
5051
|
+
})];
|
|
5052
|
+
case 1:
|
|
5053
|
+
_b.sent();
|
|
5054
|
+
return [2 /*return*/, result];
|
|
5055
|
+
}
|
|
4608
5056
|
});
|
|
4609
5057
|
}); };
|
|
4610
5058
|
/**
|
|
@@ -4616,32 +5064,65 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4616
5064
|
var result, _a, _b, item;
|
|
4617
5065
|
var e_1, _c;
|
|
4618
5066
|
return __generator(this, function (_d) {
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
try {
|
|
4625
|
-
for (_a = __values(this._itemMap.values()), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
4626
|
-
item = _b.value;
|
|
4627
|
-
if (filter(item)) {
|
|
4628
|
-
result.push(item);
|
|
5067
|
+
switch (_d.label) {
|
|
5068
|
+
case 0:
|
|
5069
|
+
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " list"));
|
|
5070
|
+
if (!filter) {
|
|
5071
|
+
return [2 /*return*/, __spreadArray([], __read(this._itemMap.values()), false)];
|
|
4629
5072
|
}
|
|
4630
|
-
|
|
5073
|
+
result = [];
|
|
5074
|
+
try {
|
|
5075
|
+
for (_a = __values(this._itemMap.values()), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
5076
|
+
item = _b.value;
|
|
5077
|
+
if (filter(item)) {
|
|
5078
|
+
result.push(item);
|
|
5079
|
+
}
|
|
5080
|
+
}
|
|
5081
|
+
}
|
|
5082
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5083
|
+
finally {
|
|
5084
|
+
try {
|
|
5085
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
5086
|
+
}
|
|
5087
|
+
finally { if (e_1) throw e_1.error; }
|
|
5088
|
+
}
|
|
5089
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
5090
|
+
type: "list",
|
|
5091
|
+
source: "storage",
|
|
5092
|
+
input: {},
|
|
5093
|
+
output: {
|
|
5094
|
+
result: result,
|
|
5095
|
+
},
|
|
5096
|
+
context: {
|
|
5097
|
+
storageName: this.params.storageName,
|
|
5098
|
+
}
|
|
5099
|
+
})];
|
|
5100
|
+
case 1:
|
|
5101
|
+
_d.sent();
|
|
5102
|
+
return [2 /*return*/, result];
|
|
4631
5103
|
}
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
5104
|
+
});
|
|
5105
|
+
}); };
|
|
5106
|
+
/**
|
|
5107
|
+
* Disposes of the state.
|
|
5108
|
+
* @returns {Promise<void>}
|
|
5109
|
+
*/
|
|
5110
|
+
this.dispose = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5111
|
+
var _a;
|
|
5112
|
+
return __generator(this, function (_b) {
|
|
5113
|
+
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " dispose"));
|
|
5114
|
+
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onDispose) {
|
|
5115
|
+
this.params.callbacks.onDispose(this.params.clientId, this.params.storageName);
|
|
4638
5116
|
}
|
|
4639
|
-
return [2 /*return
|
|
5117
|
+
return [2 /*return*/];
|
|
4640
5118
|
});
|
|
4641
5119
|
}); };
|
|
4642
5120
|
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " CTOR"), {
|
|
4643
5121
|
params: params,
|
|
4644
5122
|
});
|
|
5123
|
+
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onInit) {
|
|
5124
|
+
this.params.callbacks.onInit(this.params.clientId, this.params.storageName);
|
|
5125
|
+
}
|
|
4645
5126
|
}
|
|
4646
5127
|
return ClientStorage;
|
|
4647
5128
|
}());
|
|
@@ -4654,6 +5135,7 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
4654
5135
|
function StorageConnectionService() {
|
|
4655
5136
|
var _this = this;
|
|
4656
5137
|
this.loggerService = inject(TYPES.loggerService);
|
|
5138
|
+
this.busService = inject(TYPES.busService);
|
|
4657
5139
|
this.contextService = inject(TYPES.contextService);
|
|
4658
5140
|
this.storageSchemaService = inject(TYPES.storageSchemaService);
|
|
4659
5141
|
this.sessionValidationService = inject(TYPES.sessionValidationService);
|
|
@@ -4673,7 +5155,7 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
4673
5155
|
if (!shared) {
|
|
4674
5156
|
throw new Error("agent-swarm storage not shared storageName=".concat(storageName));
|
|
4675
5157
|
}
|
|
4676
|
-
return new ClientStorage(__assign(__assign({ clientId: clientId, storageName: storageName, embedding: embeddingName, calculateSimilarity: calculateSimilarity, createEmbedding: createEmbedding, createIndex: createIndex, getData: getData, shared: shared, logger: _this.loggerService }, embedding), { callbacks: callbacks }));
|
|
5158
|
+
return new ClientStorage(__assign(__assign({ clientId: clientId, storageName: storageName, embedding: embeddingName, calculateSimilarity: calculateSimilarity, createEmbedding: createEmbedding, createIndex: createIndex, getData: getData, shared: shared, logger: _this.loggerService, bus: _this.busService }, embedding), { callbacks: callbacks }));
|
|
4677
5159
|
});
|
|
4678
5160
|
/**
|
|
4679
5161
|
* Retrieves a storage instance based on client ID and storage name.
|
|
@@ -4691,7 +5173,7 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
4691
5173
|
return _this.getSharedStorage(clientId, storageName);
|
|
4692
5174
|
}
|
|
4693
5175
|
var _c = _this.embeddingSchemaService.get(embeddingName), calculateSimilarity = _c.calculateSimilarity, createEmbedding = _c.createEmbedding, embedding = _c.callbacks;
|
|
4694
|
-
return new ClientStorage(__assign(__assign({ clientId: clientId, storageName: storageName, embedding: embeddingName, calculateSimilarity: calculateSimilarity, createEmbedding: createEmbedding, createIndex: createIndex, getData: getData, shared: shared, logger: _this.loggerService }, embedding), { callbacks: callbacks }));
|
|
5176
|
+
return new ClientStorage(__assign(__assign({ clientId: clientId, storageName: storageName, embedding: embeddingName, calculateSimilarity: calculateSimilarity, createEmbedding: createEmbedding, createIndex: createIndex, getData: getData, shared: shared, logger: _this.loggerService, bus: _this.busService }, embedding), { callbacks: callbacks }));
|
|
4695
5177
|
});
|
|
4696
5178
|
/**
|
|
4697
5179
|
* Retrieves a list of storage data based on a search query and total number of items.
|
|
@@ -4836,18 +5318,31 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
4836
5318
|
* @returns {Promise<void>}
|
|
4837
5319
|
*/
|
|
4838
5320
|
this.dispose = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
4839
|
-
var key;
|
|
5321
|
+
var key, storage;
|
|
4840
5322
|
return __generator(this, function (_a) {
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
5323
|
+
switch (_a.label) {
|
|
5324
|
+
case 0:
|
|
5325
|
+
this.loggerService.log("storageConnectionService dispose", {
|
|
5326
|
+
context: this.contextService.context,
|
|
5327
|
+
});
|
|
5328
|
+
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.storageName);
|
|
5329
|
+
if (!this.getStorage.has(key)) {
|
|
5330
|
+
return [2 /*return*/];
|
|
5331
|
+
}
|
|
5332
|
+
if (!!this.getSharedStorage.has(this.contextService.context.storageName)) return [3 /*break*/, 3];
|
|
5333
|
+
storage = this.getSharedStorage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
5334
|
+
return [4 /*yield*/, storage.waitForInit()];
|
|
5335
|
+
case 1:
|
|
5336
|
+
_a.sent();
|
|
5337
|
+
return [4 /*yield*/, storage.dispose()];
|
|
5338
|
+
case 2:
|
|
5339
|
+
_a.sent();
|
|
5340
|
+
_a.label = 3;
|
|
5341
|
+
case 3:
|
|
5342
|
+
this.getStorage.clear(key);
|
|
5343
|
+
this.sessionValidationService.removeStorageUsage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
5344
|
+
return [2 /*return*/];
|
|
4847
5345
|
}
|
|
4848
|
-
this.getStorage.clear(key);
|
|
4849
|
-
this.sessionValidationService.removeStorageUsage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
4850
|
-
return [2 /*return*/];
|
|
4851
5346
|
});
|
|
4852
5347
|
}); };
|
|
4853
5348
|
}
|
|
@@ -5266,12 +5761,12 @@ var ClientState = /** @class */ (function () {
|
|
|
5266
5761
|
return __generator(this, function (_c) {
|
|
5267
5762
|
switch (_c.label) {
|
|
5268
5763
|
case 0:
|
|
5269
|
-
this.params.logger.debug("
|
|
5764
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " waitForInit"));
|
|
5270
5765
|
_a = this;
|
|
5271
5766
|
return [4 /*yield*/, this.params.getState(this.params.clientId, this.params.stateName)];
|
|
5272
5767
|
case 1:
|
|
5273
5768
|
_a._state = _c.sent();
|
|
5274
|
-
this.params.logger.debug("
|
|
5769
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " waitForInit output"), { initialState: this._state });
|
|
5275
5770
|
if ((_b = this.params.callbacks) === null || _b === void 0 ? void 0 : _b.onLoad) {
|
|
5276
5771
|
this.params.callbacks.onLoad(this._state, this.params.clientId, this.params.stateName);
|
|
5277
5772
|
}
|
|
@@ -5290,7 +5785,7 @@ var ClientState = /** @class */ (function () {
|
|
|
5290
5785
|
return __generator(this, function (_b) {
|
|
5291
5786
|
switch (_b.label) {
|
|
5292
5787
|
case 0:
|
|
5293
|
-
this.params.logger.debug("
|
|
5788
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " setState"));
|
|
5294
5789
|
return [4 /*yield*/, this.dispatch("write", function (currentState) { return __awaiter(_this, void 0, void 0, function () {
|
|
5295
5790
|
var _a, _b, middleware, e_1_1;
|
|
5296
5791
|
var e_1, _c;
|
|
@@ -5328,12 +5823,25 @@ var ClientState = /** @class */ (function () {
|
|
|
5328
5823
|
}); })];
|
|
5329
5824
|
case 1:
|
|
5330
5825
|
_b.sent();
|
|
5331
|
-
this.params.logger.debug("
|
|
5826
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " setState output"), { pendingState: this._state });
|
|
5332
5827
|
this.params.setState &&
|
|
5333
5828
|
this.params.setState(this._state, this.params.clientId, this.params.stateName);
|
|
5334
5829
|
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onWrite) {
|
|
5335
5830
|
this.params.callbacks.onWrite(this._state, this.params.clientId, this.params.stateName);
|
|
5336
5831
|
}
|
|
5832
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
5833
|
+
type: "set-state",
|
|
5834
|
+
source: "state",
|
|
5835
|
+
input: {},
|
|
5836
|
+
output: {
|
|
5837
|
+
state: this._state,
|
|
5838
|
+
},
|
|
5839
|
+
context: {
|
|
5840
|
+
stateName: this.params.stateName,
|
|
5841
|
+
}
|
|
5842
|
+
})];
|
|
5843
|
+
case 2:
|
|
5844
|
+
_b.sent();
|
|
5337
5845
|
return [2 /*return*/, this._state];
|
|
5338
5846
|
}
|
|
5339
5847
|
});
|
|
@@ -5347,13 +5855,26 @@ var ClientState = /** @class */ (function () {
|
|
|
5347
5855
|
return __generator(this, function (_b) {
|
|
5348
5856
|
switch (_b.label) {
|
|
5349
5857
|
case 0:
|
|
5350
|
-
this.params.logger.debug("
|
|
5858
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " getState"));
|
|
5351
5859
|
return [4 /*yield*/, this.dispatch("read")];
|
|
5352
5860
|
case 1:
|
|
5353
5861
|
_b.sent();
|
|
5354
5862
|
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onRead) {
|
|
5355
5863
|
this.params.callbacks.onRead(this._state, this.params.clientId, this.params.stateName);
|
|
5356
5864
|
}
|
|
5865
|
+
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
5866
|
+
type: "get-state",
|
|
5867
|
+
source: "state",
|
|
5868
|
+
input: {},
|
|
5869
|
+
output: {
|
|
5870
|
+
state: this._state,
|
|
5871
|
+
},
|
|
5872
|
+
context: {
|
|
5873
|
+
stateName: this.params.stateName,
|
|
5874
|
+
}
|
|
5875
|
+
})];
|
|
5876
|
+
case 2:
|
|
5877
|
+
_b.sent();
|
|
5357
5878
|
return [2 /*return*/, this._state];
|
|
5358
5879
|
}
|
|
5359
5880
|
});
|
|
@@ -5365,13 +5886,16 @@ var ClientState = /** @class */ (function () {
|
|
|
5365
5886
|
this.dispose = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5366
5887
|
var _a;
|
|
5367
5888
|
return __generator(this, function (_b) {
|
|
5368
|
-
this.params.logger.debug("
|
|
5889
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " dispose"));
|
|
5369
5890
|
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onDispose) {
|
|
5370
5891
|
this.params.callbacks.onDispose(this.params.clientId, this.params.stateName);
|
|
5371
5892
|
}
|
|
5372
5893
|
return [2 /*return*/];
|
|
5373
5894
|
});
|
|
5374
5895
|
}); };
|
|
5896
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " CTOR"), {
|
|
5897
|
+
params: params,
|
|
5898
|
+
});
|
|
5375
5899
|
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onInit) {
|
|
5376
5900
|
this.params.callbacks.onInit(this.params.clientId, this.params.stateName);
|
|
5377
5901
|
}
|
|
@@ -5388,9 +5912,49 @@ var StateConnectionService = /** @class */ (function () {
|
|
|
5388
5912
|
function StateConnectionService() {
|
|
5389
5913
|
var _this = this;
|
|
5390
5914
|
this.loggerService = inject(TYPES.loggerService);
|
|
5915
|
+
this.busService = inject(TYPES.busService);
|
|
5391
5916
|
this.contextService = inject(TYPES.contextService);
|
|
5392
5917
|
this.stateSchemaService = inject(TYPES.stateSchemaService);
|
|
5393
5918
|
this.sessionValidationService = inject(TYPES.sessionValidationService);
|
|
5919
|
+
/**
|
|
5920
|
+
* Memoized function to get a shared state reference.
|
|
5921
|
+
* @param {string} clientId - The client ID.
|
|
5922
|
+
* @param {StateName} stateName - The state name.
|
|
5923
|
+
* @returns {ClientState} The client state.
|
|
5924
|
+
*/
|
|
5925
|
+
this.getSharedStateRef = memoize(function (_a) {
|
|
5926
|
+
var _b = __read(_a, 2), stateName = _b[1];
|
|
5927
|
+
return "".concat(stateName);
|
|
5928
|
+
}, function (clientId, stateName) {
|
|
5929
|
+
_this.sessionValidationService.addStateUsage(clientId, stateName);
|
|
5930
|
+
var _a = _this.stateSchemaService.get(stateName), getState = _a.getState, setState = _a.setState, _b = _a.middlewares, middlewares = _b === void 0 ? [] : _b, shared = _a.shared, callbacks = _a.callbacks;
|
|
5931
|
+
if (!shared) {
|
|
5932
|
+
throw new Error("agent-swarm state not shared stateName=".concat(stateName));
|
|
5933
|
+
}
|
|
5934
|
+
return new ClientState({
|
|
5935
|
+
clientId: clientId,
|
|
5936
|
+
stateName: stateName,
|
|
5937
|
+
logger: _this.loggerService,
|
|
5938
|
+
bus: _this.busService,
|
|
5939
|
+
setState: setState
|
|
5940
|
+
? queued(function () {
|
|
5941
|
+
var args = [];
|
|
5942
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
5943
|
+
args[_i] = arguments[_i];
|
|
5944
|
+
}
|
|
5945
|
+
return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
5946
|
+
switch (_a.label) {
|
|
5947
|
+
case 0: return [4 /*yield*/, setState.apply(void 0, __spreadArray([], __read(args), false))];
|
|
5948
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5949
|
+
}
|
|
5950
|
+
}); });
|
|
5951
|
+
})
|
|
5952
|
+
: setState,
|
|
5953
|
+
getState: getState,
|
|
5954
|
+
middlewares: middlewares,
|
|
5955
|
+
callbacks: callbacks,
|
|
5956
|
+
});
|
|
5957
|
+
});
|
|
5394
5958
|
/**
|
|
5395
5959
|
* Memoized function to get a state reference.
|
|
5396
5960
|
* @param {string} clientId - The client ID.
|
|
@@ -5402,11 +5966,15 @@ var StateConnectionService = /** @class */ (function () {
|
|
|
5402
5966
|
return "".concat(clientId, "-").concat(stateName);
|
|
5403
5967
|
}, function (clientId, stateName) {
|
|
5404
5968
|
_this.sessionValidationService.addStateUsage(clientId, stateName);
|
|
5405
|
-
var _a = _this.stateSchemaService.get(stateName), getState = _a.getState, setState = _a.setState, _b = _a.middlewares, middlewares = _b === void 0 ? [] : _b, callbacks = _a.callbacks;
|
|
5969
|
+
var _a = _this.stateSchemaService.get(stateName), getState = _a.getState, setState = _a.setState, _b = _a.middlewares, middlewares = _b === void 0 ? [] : _b, callbacks = _a.callbacks, _c = _a.shared, shared = _c === void 0 ? false : _c;
|
|
5970
|
+
if (shared) {
|
|
5971
|
+
return _this.getSharedStateRef(clientId, stateName);
|
|
5972
|
+
}
|
|
5406
5973
|
return new ClientState({
|
|
5407
5974
|
clientId: clientId,
|
|
5408
5975
|
stateName: stateName,
|
|
5409
5976
|
logger: _this.loggerService,
|
|
5977
|
+
bus: _this.busService,
|
|
5410
5978
|
setState: setState
|
|
5411
5979
|
? queued(function () {
|
|
5412
5980
|
var args = [];
|
|
@@ -5485,6 +6053,7 @@ var StateConnectionService = /** @class */ (function () {
|
|
|
5485
6053
|
if (!this.getStateRef.has(key)) {
|
|
5486
6054
|
return [2 /*return*/];
|
|
5487
6055
|
}
|
|
6056
|
+
if (!!this.getSharedStateRef.has(this.contextService.context.stateName)) return [3 /*break*/, 3];
|
|
5488
6057
|
state = this.getStateRef(this.contextService.context.clientId, this.contextService.context.stateName);
|
|
5489
6058
|
return [4 /*yield*/, state.waitForInit()];
|
|
5490
6059
|
case 1:
|
|
@@ -5492,6 +6061,8 @@ var StateConnectionService = /** @class */ (function () {
|
|
|
5492
6061
|
return [4 /*yield*/, state.dispose()];
|
|
5493
6062
|
case 2:
|
|
5494
6063
|
_a.sent();
|
|
6064
|
+
_a.label = 3;
|
|
6065
|
+
case 3:
|
|
5495
6066
|
this.getStateRef.clear(key);
|
|
5496
6067
|
this.sessionValidationService.removeStateUsage(this.contextService.context.clientId, this.contextService.context.stateName);
|
|
5497
6068
|
return [2 /*return*/];
|
|
@@ -5611,7 +6182,103 @@ var StatePublicService = /** @class */ (function () {
|
|
|
5611
6182
|
return StatePublicService;
|
|
5612
6183
|
}());
|
|
5613
6184
|
|
|
6185
|
+
var BusService = /** @class */ (function () {
|
|
6186
|
+
function BusService() {
|
|
6187
|
+
var _this = this;
|
|
6188
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
6189
|
+
this._eventSourceSet = new Set();
|
|
6190
|
+
this.getEventSubject = memoize(function (_a) {
|
|
6191
|
+
var _b = __read(_a, 2), clientId = _b[0], source = _b[1];
|
|
6192
|
+
return "".concat(clientId, "-").concat(source);
|
|
6193
|
+
}, function () { return new Subject(); });
|
|
6194
|
+
/**
|
|
6195
|
+
* Subscribes to events for a specific client and source.
|
|
6196
|
+
* @param {string} clientId - The client ID.
|
|
6197
|
+
* @param {EventSource} source - The event source.
|
|
6198
|
+
* @param {(event: T) => void} fn - The callback function to handle the event.
|
|
6199
|
+
* @returns {Subscription} The subscription object.
|
|
6200
|
+
*/
|
|
6201
|
+
this.subscribe = function (clientId, source, fn) {
|
|
6202
|
+
_this.loggerService.log("busService subscribe", {
|
|
6203
|
+
clientId: clientId,
|
|
6204
|
+
source: source,
|
|
6205
|
+
});
|
|
6206
|
+
_this._eventSourceSet.add(source);
|
|
6207
|
+
return _this.getEventSubject(clientId, source).subscribe(fn);
|
|
6208
|
+
};
|
|
6209
|
+
/**
|
|
6210
|
+
* Subscribes to a single event for a specific client and source.
|
|
6211
|
+
* @param {string} clientId - The client ID.
|
|
6212
|
+
* @param {EventSource} source - The event source.
|
|
6213
|
+
* @param {(event: T) => boolean} filterFn - The filter function to determine if the event should be handled.
|
|
6214
|
+
* @param {(event: T) => void} fn - The callback function to handle the event.
|
|
6215
|
+
* @returns {Subscription} The subscription object.
|
|
6216
|
+
*/
|
|
6217
|
+
this.once = function (clientId, source, filterFn, fn) {
|
|
6218
|
+
_this.loggerService.log("busService once", {
|
|
6219
|
+
clientId: clientId,
|
|
6220
|
+
source: source,
|
|
6221
|
+
});
|
|
6222
|
+
_this._eventSourceSet.add(source);
|
|
6223
|
+
return _this.getEventSubject(clientId, source).filter(filterFn).once(fn);
|
|
6224
|
+
};
|
|
6225
|
+
/**
|
|
6226
|
+
* Emits an event for a specific client.
|
|
6227
|
+
* @param {string} clientId - The client ID.
|
|
6228
|
+
* @param {T} event - The event to emit.
|
|
6229
|
+
* @returns {Promise<void>} A promise that resolves when the event has been emitted.
|
|
6230
|
+
*/
|
|
6231
|
+
this.emit = function (clientId, event) { return __awaiter(_this, void 0, void 0, function () {
|
|
6232
|
+
return __generator(this, function (_a) {
|
|
6233
|
+
switch (_a.label) {
|
|
6234
|
+
case 0:
|
|
6235
|
+
this.loggerService.debug("busService emit", {
|
|
6236
|
+
clientId: clientId,
|
|
6237
|
+
event: event,
|
|
6238
|
+
});
|
|
6239
|
+
if (!this.getEventSubject.has("".concat(clientId, "-").concat(event.source))) {
|
|
6240
|
+
return [2 /*return*/];
|
|
6241
|
+
}
|
|
6242
|
+
return [4 /*yield*/, this.getEventSubject(clientId, event.source).next(event)];
|
|
6243
|
+
case 1:
|
|
6244
|
+
_a.sent();
|
|
6245
|
+
return [2 /*return*/];
|
|
6246
|
+
}
|
|
6247
|
+
});
|
|
6248
|
+
}); };
|
|
6249
|
+
/**
|
|
6250
|
+
* Disposes of all event subscriptions for a specific client.
|
|
6251
|
+
* @param {string} clientId - The client ID.
|
|
6252
|
+
*/
|
|
6253
|
+
this.dispose = function (clientId) {
|
|
6254
|
+
var e_1, _a;
|
|
6255
|
+
_this.loggerService.log("busService dispose", {
|
|
6256
|
+
clientId: clientId,
|
|
6257
|
+
});
|
|
6258
|
+
try {
|
|
6259
|
+
for (var _b = __values(_this._eventSourceSet), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
6260
|
+
var source = _c.value;
|
|
6261
|
+
var key = "".concat(clientId, "-").concat(source);
|
|
6262
|
+
if (_this.getEventSubject.has(key)) {
|
|
6263
|
+
_this.getEventSubject(clientId, source).unsubscribeAll();
|
|
6264
|
+
}
|
|
6265
|
+
_this.getEventSubject.clear("".concat(clientId, "-").concat(source));
|
|
6266
|
+
}
|
|
6267
|
+
}
|
|
6268
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
6269
|
+
finally {
|
|
6270
|
+
try {
|
|
6271
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
6272
|
+
}
|
|
6273
|
+
finally { if (e_1) throw e_1.error; }
|
|
6274
|
+
}
|
|
6275
|
+
};
|
|
6276
|
+
}
|
|
6277
|
+
return BusService;
|
|
6278
|
+
}());
|
|
6279
|
+
|
|
5614
6280
|
{
|
|
6281
|
+
provide(TYPES.busService, function () { return new BusService(); });
|
|
5615
6282
|
provide(TYPES.loggerService, function () { return new LoggerService(); });
|
|
5616
6283
|
provide(TYPES.contextService, function () { return new ContextService(); });
|
|
5617
6284
|
}
|
|
@@ -5657,6 +6324,7 @@ var StatePublicService = /** @class */ (function () {
|
|
|
5657
6324
|
}
|
|
5658
6325
|
|
|
5659
6326
|
var baseServices = {
|
|
6327
|
+
busService: inject(TYPES.busService),
|
|
5660
6328
|
loggerService: inject(TYPES.loggerService),
|
|
5661
6329
|
contextService: inject(TYPES.contextService),
|
|
5662
6330
|
};
|
|
@@ -5766,10 +6434,15 @@ var addTool = function (toolSchema) {
|
|
|
5766
6434
|
* @returns {string} The name of the added state.
|
|
5767
6435
|
*/
|
|
5768
6436
|
var addState = function (stateSchema) {
|
|
5769
|
-
swarm.loggerService.log(
|
|
5770
|
-
stateSchema: stateSchema
|
|
6437
|
+
swarm.loggerService.log("function addState", {
|
|
6438
|
+
stateSchema: stateSchema,
|
|
5771
6439
|
});
|
|
5772
6440
|
swarm.stateSchemaService.register(stateSchema.stateName, stateSchema);
|
|
6441
|
+
if (stateSchema.shared) {
|
|
6442
|
+
swarm.stateConnectionService
|
|
6443
|
+
.getSharedStateRef("shared", stateSchema.stateName)
|
|
6444
|
+
.waitForInit();
|
|
6445
|
+
}
|
|
5773
6446
|
return stateSchema.stateName;
|
|
5774
6447
|
};
|
|
5775
6448
|
|
|
@@ -6109,69 +6782,64 @@ var disposeConnection = function (clientId, swarmName) { return __awaiter(void 0
|
|
|
6109
6782
|
});
|
|
6110
6783
|
swarm.swarmValidationService.validate(swarmName, "disposeConnection");
|
|
6111
6784
|
swarm.sessionValidationService.removeSession(clientId);
|
|
6785
|
+
swarm.busService.dispose(clientId);
|
|
6112
6786
|
return [4 /*yield*/, swarm.sessionPublicService.dispose(clientId, swarmName)];
|
|
6113
6787
|
case 1:
|
|
6114
6788
|
_a.sent();
|
|
6115
6789
|
return [4 /*yield*/, swarm.swarmPublicService.dispose(clientId, swarmName)];
|
|
6116
6790
|
case 2:
|
|
6117
6791
|
_a.sent();
|
|
6118
|
-
return [4 /*yield*/, Promise.all(
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
}); }),
|
|
6134
|
-
])];
|
|
6792
|
+
return [4 /*yield*/, Promise.all(swarm.swarmValidationService
|
|
6793
|
+
.getAgentList(swarmName)
|
|
6794
|
+
.map(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6795
|
+
return __generator(this, function (_a) {
|
|
6796
|
+
switch (_a.label) {
|
|
6797
|
+
case 0: return [4 /*yield*/, swarm.agentPublicService.dispose(clientId, agentName)];
|
|
6798
|
+
case 1:
|
|
6799
|
+
_a.sent();
|
|
6800
|
+
return [4 /*yield*/, swarm.historyPublicService.dispose(clientId, agentName)];
|
|
6801
|
+
case 2:
|
|
6802
|
+
_a.sent();
|
|
6803
|
+
return [2 /*return*/];
|
|
6804
|
+
}
|
|
6805
|
+
});
|
|
6806
|
+
}); }))];
|
|
6135
6807
|
case 3:
|
|
6136
6808
|
_a.sent();
|
|
6137
|
-
return [4 /*yield*/, Promise.all(
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
})
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
}); }),
|
|
6154
|
-
])];
|
|
6809
|
+
return [4 /*yield*/, Promise.all(swarm.swarmValidationService
|
|
6810
|
+
.getAgentList(swarmName)
|
|
6811
|
+
.flatMap(function (agentName) {
|
|
6812
|
+
return swarm.agentValidationService.getStorageList(agentName);
|
|
6813
|
+
})
|
|
6814
|
+
.filter(function (storageName) { return !!storageName; })
|
|
6815
|
+
.map(function (storageName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6816
|
+
return __generator(this, function (_a) {
|
|
6817
|
+
switch (_a.label) {
|
|
6818
|
+
case 0: return [4 /*yield*/, swarm.storagePublicService.dispose(clientId, storageName)];
|
|
6819
|
+
case 1:
|
|
6820
|
+
_a.sent();
|
|
6821
|
+
return [2 /*return*/];
|
|
6822
|
+
}
|
|
6823
|
+
});
|
|
6824
|
+
}); }))];
|
|
6155
6825
|
case 4:
|
|
6156
6826
|
_a.sent();
|
|
6157
|
-
return [4 /*yield*/, Promise.all(
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
})
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
}); }),
|
|
6174
|
-
])];
|
|
6827
|
+
return [4 /*yield*/, Promise.all(swarm.swarmValidationService
|
|
6828
|
+
.getAgentList(swarmName)
|
|
6829
|
+
.flatMap(function (agentName) {
|
|
6830
|
+
return swarm.agentValidationService.getStateList(agentName);
|
|
6831
|
+
})
|
|
6832
|
+
.filter(function (stateName) { return !!stateName; })
|
|
6833
|
+
.map(function (stateName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6834
|
+
return __generator(this, function (_a) {
|
|
6835
|
+
switch (_a.label) {
|
|
6836
|
+
case 0: return [4 /*yield*/, swarm.statePublicService.dispose(clientId, stateName)];
|
|
6837
|
+
case 1:
|
|
6838
|
+
_a.sent();
|
|
6839
|
+
return [2 /*return*/];
|
|
6840
|
+
}
|
|
6841
|
+
});
|
|
6842
|
+
}); }))];
|
|
6175
6843
|
case 5:
|
|
6176
6844
|
_a.sent();
|
|
6177
6845
|
return [4 /*yield*/, HistoryAdapter.dispose(clientId, null)];
|
|
@@ -6839,6 +7507,35 @@ var executeForce = function (content, clientId) { return __awaiter(void 0, void
|
|
|
6839
7507
|
});
|
|
6840
7508
|
}); };
|
|
6841
7509
|
|
|
7510
|
+
var DISALLOWED_EVENT_SOURCE_LIST$1 = new Set([
|
|
7511
|
+
"agent",
|
|
7512
|
+
"history",
|
|
7513
|
+
"session",
|
|
7514
|
+
"state",
|
|
7515
|
+
"storage",
|
|
7516
|
+
"swarm",
|
|
7517
|
+
]);
|
|
7518
|
+
/**
|
|
7519
|
+
* Listens for an event on the swarm bus service and executes a callback function when the event is received.
|
|
7520
|
+
*
|
|
7521
|
+
* @template T - The type of the data payload.
|
|
7522
|
+
* @param {string} clientId - The ID of the client to listen for events from.
|
|
7523
|
+
* @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.
|
|
7524
|
+
* @returns {void} - Returns nothing.
|
|
7525
|
+
*/
|
|
7526
|
+
var listenEvent = function (clientId, topicName, fn) {
|
|
7527
|
+
swarm.loggerService.log("function listenEvent", {
|
|
7528
|
+
clientId: clientId,
|
|
7529
|
+
});
|
|
7530
|
+
if (DISALLOWED_EVENT_SOURCE_LIST$1.has(topicName)) {
|
|
7531
|
+
throw new Error("agent-swarm listenEvent topic is reserved topicName=".concat(topicName));
|
|
7532
|
+
}
|
|
7533
|
+
return swarm.busService.subscribe(clientId, topicName, function (_a) {
|
|
7534
|
+
var payload = _a.payload;
|
|
7535
|
+
return fn(payload);
|
|
7536
|
+
});
|
|
7537
|
+
};
|
|
7538
|
+
|
|
6842
7539
|
/**
|
|
6843
7540
|
* Retrieves the last message sent by the user from the client's message history.
|
|
6844
7541
|
*
|
|
@@ -7021,6 +7718,184 @@ var makeAutoDispose = function (clientId, swarmName, _a) {
|
|
|
7021
7718
|
};
|
|
7022
7719
|
};
|
|
7023
7720
|
|
|
7721
|
+
var DISALLOWED_EVENT_SOURCE_LIST = new Set([
|
|
7722
|
+
"agent",
|
|
7723
|
+
"history",
|
|
7724
|
+
"session",
|
|
7725
|
+
"state",
|
|
7726
|
+
"storage",
|
|
7727
|
+
"swarm",
|
|
7728
|
+
]);
|
|
7729
|
+
/**
|
|
7730
|
+
* Emits an event to the swarm bus service.
|
|
7731
|
+
*
|
|
7732
|
+
* @template T - The type of the payload.
|
|
7733
|
+
* @param {string} clientId - The ID of the client emitting the event.
|
|
7734
|
+
* @param {T} payload - The payload of the event.
|
|
7735
|
+
* @returns {boolean} - Returns true if the event was successfully emitted.
|
|
7736
|
+
*/
|
|
7737
|
+
var event = function (clientId, topicName, payload) {
|
|
7738
|
+
swarm.loggerService.log("function listenEvent", {
|
|
7739
|
+
clientId: clientId,
|
|
7740
|
+
});
|
|
7741
|
+
if (DISALLOWED_EVENT_SOURCE_LIST.has(topicName)) {
|
|
7742
|
+
throw new Error("agent-swarm event topic is reserved topicName=".concat(topicName));
|
|
7743
|
+
}
|
|
7744
|
+
return swarm.busService.emit(clientId, {
|
|
7745
|
+
source: topicName,
|
|
7746
|
+
payload: payload,
|
|
7747
|
+
});
|
|
7748
|
+
};
|
|
7749
|
+
|
|
7750
|
+
/**
|
|
7751
|
+
* Cancel the await of output by emit of empty string
|
|
7752
|
+
*
|
|
7753
|
+
* @param {string} clientId - The ID of the client.
|
|
7754
|
+
* @param {string} agentName - The name of the agent.
|
|
7755
|
+
* @returns {Promise<void>} - A promise that resolves when the output is canceled
|
|
7756
|
+
*/
|
|
7757
|
+
var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7758
|
+
var swarmName, currentAgentName;
|
|
7759
|
+
return __generator(this, function (_a) {
|
|
7760
|
+
switch (_a.label) {
|
|
7761
|
+
case 0:
|
|
7762
|
+
swarm.loggerService.log('function cancelOutput', {
|
|
7763
|
+
clientId: clientId,
|
|
7764
|
+
agentName: agentName,
|
|
7765
|
+
});
|
|
7766
|
+
swarm.agentValidationService.validate(agentName, "cancelOutput");
|
|
7767
|
+
swarm.sessionValidationService.validate(clientId, "cancelOutput");
|
|
7768
|
+
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7769
|
+
swarm.swarmValidationService.validate(swarmName, "cancelOutput");
|
|
7770
|
+
return [4 /*yield*/, swarm.swarmPublicService.getAgentName(clientId, swarmName)];
|
|
7771
|
+
case 1:
|
|
7772
|
+
currentAgentName = _a.sent();
|
|
7773
|
+
if (currentAgentName !== agentName) {
|
|
7774
|
+
swarm.loggerService.log('function "cancelOutput" skipped due to the agent change', {
|
|
7775
|
+
currentAgentName: currentAgentName,
|
|
7776
|
+
agentName: agentName,
|
|
7777
|
+
clientId: clientId,
|
|
7778
|
+
});
|
|
7779
|
+
return [2 /*return*/];
|
|
7780
|
+
}
|
|
7781
|
+
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(clientId, swarmName)];
|
|
7782
|
+
case 2:
|
|
7783
|
+
_a.sent();
|
|
7784
|
+
return [2 /*return*/];
|
|
7785
|
+
}
|
|
7786
|
+
});
|
|
7787
|
+
}); };
|
|
7788
|
+
|
|
7789
|
+
/**
|
|
7790
|
+
* Cancel the await of output by emit of empty string without checking active agent
|
|
7791
|
+
*
|
|
7792
|
+
* @param {string} clientId - The ID of the client.
|
|
7793
|
+
* @param {string} agentName - The name of the agent.
|
|
7794
|
+
* @returns {Promise<void>} - A promise that resolves when the output is canceled
|
|
7795
|
+
*/
|
|
7796
|
+
var cancelOutputForce = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7797
|
+
var swarmName;
|
|
7798
|
+
return __generator(this, function (_a) {
|
|
7799
|
+
switch (_a.label) {
|
|
7800
|
+
case 0:
|
|
7801
|
+
swarm.loggerService.log('function cancelOutputForce', {
|
|
7802
|
+
clientId: clientId,
|
|
7803
|
+
});
|
|
7804
|
+
swarm.sessionValidationService.validate(clientId, "cancelOutputForce");
|
|
7805
|
+
swarmName = swarm.sessionValidationService.getSwarm(clientId);
|
|
7806
|
+
swarm.swarmValidationService.validate(swarmName, "cancelOutputForce");
|
|
7807
|
+
return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(clientId, swarmName)];
|
|
7808
|
+
case 1:
|
|
7809
|
+
_a.sent();
|
|
7810
|
+
return [2 /*return*/];
|
|
7811
|
+
}
|
|
7812
|
+
});
|
|
7813
|
+
}); };
|
|
7814
|
+
|
|
7815
|
+
/**
|
|
7816
|
+
* Hook to subscribe to agent events for a specific client.
|
|
7817
|
+
*
|
|
7818
|
+
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
7819
|
+
* @param {function} fn - The callback function to handle the event.
|
|
7820
|
+
* @returns {function} - A function to unsubscribe from the event.
|
|
7821
|
+
*/
|
|
7822
|
+
var listenAgentEvent = function (clientId, fn) {
|
|
7823
|
+
swarm.loggerService.log("middleware listenAgentEvent", {
|
|
7824
|
+
clientId: clientId,
|
|
7825
|
+
});
|
|
7826
|
+
return swarm.busService.subscribe(clientId, "agent", fn);
|
|
7827
|
+
};
|
|
7828
|
+
|
|
7829
|
+
/**
|
|
7830
|
+
* Hook to subscribe to history events for a specific client.
|
|
7831
|
+
*
|
|
7832
|
+
* @param {string} clientId - The ID of the client to subscribe to.
|
|
7833
|
+
* @param {(event: IBaseEvent) => void} fn - The callback function to handle the event.
|
|
7834
|
+
* @returns {Function} - The unsubscribe function.
|
|
7835
|
+
*/
|
|
7836
|
+
var listenHistoryEvent = function (clientId, fn) {
|
|
7837
|
+
swarm.loggerService.log("middleware listenHistoryEvent", {
|
|
7838
|
+
clientId: clientId,
|
|
7839
|
+
});
|
|
7840
|
+
return swarm.busService.subscribe(clientId, "history", fn);
|
|
7841
|
+
};
|
|
7842
|
+
|
|
7843
|
+
/**
|
|
7844
|
+
* Hook to subscribe to session events for a specific client.
|
|
7845
|
+
*
|
|
7846
|
+
* @param {string} clientId - The ID of the client to subscribe to session events for.
|
|
7847
|
+
* @param {function} fn - The callback function to handle the session events.
|
|
7848
|
+
* @returns {function} - The unsubscribe function to stop listening to session events.
|
|
7849
|
+
*/
|
|
7850
|
+
var listenSessionEvent = function (clientId, fn) {
|
|
7851
|
+
swarm.loggerService.log("middleware listenSessionEvent", {
|
|
7852
|
+
clientId: clientId,
|
|
7853
|
+
});
|
|
7854
|
+
return swarm.busService.subscribe(clientId, "session", fn);
|
|
7855
|
+
};
|
|
7856
|
+
|
|
7857
|
+
/**
|
|
7858
|
+
* Hook to subscribe to state events for a specific client.
|
|
7859
|
+
*
|
|
7860
|
+
* @param {string} clientId - The ID of the client to subscribe to.
|
|
7861
|
+
* @param {function} fn - The callback function to handle the event.
|
|
7862
|
+
* @returns {function} - The unsubscribe function to stop listening to the events.
|
|
7863
|
+
*/
|
|
7864
|
+
var listenStateEvent = function (clientId, fn) {
|
|
7865
|
+
swarm.loggerService.log("middleware listenStateEvent", {
|
|
7866
|
+
clientId: clientId,
|
|
7867
|
+
});
|
|
7868
|
+
return swarm.busService.subscribe(clientId, "state", fn);
|
|
7869
|
+
};
|
|
7870
|
+
|
|
7871
|
+
/**
|
|
7872
|
+
* Hook to subscribe to storage events for a specific client.
|
|
7873
|
+
*
|
|
7874
|
+
* @param {string} clientId - The ID of the client to subscribe to storage events for.
|
|
7875
|
+
* @param {function} fn - The callback function to handle the storage event.
|
|
7876
|
+
* @returns {function} - A function to unsubscribe from the storage events.
|
|
7877
|
+
*/
|
|
7878
|
+
var listenStorageEvent = function (clientId, fn) {
|
|
7879
|
+
swarm.loggerService.log("middleware listenStorageEvent", {
|
|
7880
|
+
clientId: clientId,
|
|
7881
|
+
});
|
|
7882
|
+
return swarm.busService.subscribe(clientId, "storage", fn);
|
|
7883
|
+
};
|
|
7884
|
+
|
|
7885
|
+
/**
|
|
7886
|
+
* Hook to subscribe to swarm events for a specific client.
|
|
7887
|
+
*
|
|
7888
|
+
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
7889
|
+
* @param {(event: IBaseEvent) => void} fn - The callback function to handle the event.
|
|
7890
|
+
* @returns {Function} - A function to unsubscribe from the event.
|
|
7891
|
+
*/
|
|
7892
|
+
var listenSwarmEvent = function (clientId, fn) {
|
|
7893
|
+
swarm.loggerService.log("middleware listenSwarmEvent", {
|
|
7894
|
+
clientId: clientId,
|
|
7895
|
+
});
|
|
7896
|
+
return swarm.busService.subscribe(clientId, "swarm", fn);
|
|
7897
|
+
};
|
|
7898
|
+
|
|
7024
7899
|
var StorageUtils = /** @class */ (function () {
|
|
7025
7900
|
function StorageUtils() {
|
|
7026
7901
|
var _this = this;
|
|
@@ -7264,4 +8139,4 @@ var StateUtils = /** @class */ (function () {
|
|
|
7264
8139
|
*/
|
|
7265
8140
|
var State = new StateUtils();
|
|
7266
8141
|
|
|
7267
|
-
export { ContextService, History, HistoryAdapter, HistoryInstance, State, Storage, addAgent, addCompletion, addEmbedding, addState, addStorage, addSwarm, addTool, changeAgent, commitFlush, commitFlushForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitUserMessage, commitUserMessageForce, complete, disposeConnection, emit, emitForce, execute, executeForce, getAgentHistory, getAgentName, getAssistantHistory, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getRawHistory, getSessionMode, getUserHistory, makeAutoDispose, makeConnection, session, setConfig, swarm };
|
|
8142
|
+
export { ContextService, History, HistoryAdapter, HistoryInstance, 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, listenEvent, listenHistoryEvent, listenSessionEvent, listenStateEvent, listenStorageEvent, listenSwarmEvent, makeAutoDispose, makeConnection, session, setConfig, swarm };
|