agent-swarm-kit 1.0.72 → 1.0.74
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 +182 -81
- package/build/index.mjs +182 -81
- package/package.json +1 -1
- package/types.d.ts +34 -20
package/build/index.cjs
CHANGED
|
@@ -973,7 +973,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
973
973
|
_a.sent();
|
|
974
974
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
975
975
|
type: "emit-output",
|
|
976
|
-
source: "agent",
|
|
976
|
+
source: "agent-bus",
|
|
977
977
|
input: {
|
|
978
978
|
mode: mode,
|
|
979
979
|
rawResult: rawResult_1,
|
|
@@ -983,7 +983,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
983
983
|
},
|
|
984
984
|
context: {
|
|
985
985
|
agentName: this.params.agentName,
|
|
986
|
-
}
|
|
986
|
+
},
|
|
987
|
+
clientId: this.params.clientId,
|
|
987
988
|
})];
|
|
988
989
|
case 7:
|
|
989
990
|
_a.sent();
|
|
@@ -996,7 +997,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
996
997
|
_a.sent();
|
|
997
998
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
998
999
|
type: "emit-output",
|
|
999
|
-
source: "agent",
|
|
1000
|
+
source: "agent-bus",
|
|
1000
1001
|
input: {
|
|
1001
1002
|
mode: mode,
|
|
1002
1003
|
rawResult: rawResult,
|
|
@@ -1006,7 +1007,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1006
1007
|
},
|
|
1007
1008
|
context: {
|
|
1008
1009
|
agentName: this.params.agentName,
|
|
1009
|
-
}
|
|
1010
|
+
},
|
|
1011
|
+
clientId: this.params.clientId,
|
|
1010
1012
|
})];
|
|
1011
1013
|
case 10:
|
|
1012
1014
|
_a.sent();
|
|
@@ -1143,14 +1145,15 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1143
1145
|
_a.sent();
|
|
1144
1146
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
1145
1147
|
type: "commit-user-message",
|
|
1146
|
-
source: "agent",
|
|
1148
|
+
source: "agent-bus",
|
|
1147
1149
|
input: {
|
|
1148
1150
|
message: message,
|
|
1149
1151
|
},
|
|
1150
1152
|
output: {},
|
|
1151
1153
|
context: {
|
|
1152
1154
|
agentName: this.params.agentName,
|
|
1153
|
-
}
|
|
1155
|
+
},
|
|
1156
|
+
clientId: this.params.clientId,
|
|
1154
1157
|
})];
|
|
1155
1158
|
case 2:
|
|
1156
1159
|
_a.sent();
|
|
@@ -1179,12 +1182,13 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1179
1182
|
_a.sent();
|
|
1180
1183
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
1181
1184
|
type: "commit-flush",
|
|
1182
|
-
source: "agent",
|
|
1185
|
+
source: "agent-bus",
|
|
1183
1186
|
input: {},
|
|
1184
1187
|
output: {},
|
|
1185
1188
|
context: {
|
|
1186
1189
|
agentName: this.params.agentName,
|
|
1187
|
-
}
|
|
1190
|
+
},
|
|
1191
|
+
clientId: this.params.clientId,
|
|
1188
1192
|
})];
|
|
1189
1193
|
case 2:
|
|
1190
1194
|
_a.sent();
|
|
@@ -1206,12 +1210,13 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1206
1210
|
_a.sent();
|
|
1207
1211
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
1208
1212
|
type: "commit-agent-change",
|
|
1209
|
-
source: "agent",
|
|
1213
|
+
source: "agent-bus",
|
|
1210
1214
|
input: {},
|
|
1211
1215
|
output: {},
|
|
1212
1216
|
context: {
|
|
1213
1217
|
agentName: this.params.agentName,
|
|
1214
|
-
}
|
|
1218
|
+
},
|
|
1219
|
+
clientId: this.params.clientId,
|
|
1215
1220
|
})];
|
|
1216
1221
|
case 2:
|
|
1217
1222
|
_a.sent();
|
|
@@ -1241,14 +1246,15 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1241
1246
|
_a.sent();
|
|
1242
1247
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
1243
1248
|
type: "commit-system-message",
|
|
1244
|
-
source: "agent",
|
|
1249
|
+
source: "agent-bus",
|
|
1245
1250
|
input: {
|
|
1246
1251
|
message: message,
|
|
1247
1252
|
},
|
|
1248
1253
|
output: {},
|
|
1249
1254
|
context: {
|
|
1250
1255
|
agentName: this.params.agentName,
|
|
1251
|
-
}
|
|
1256
|
+
},
|
|
1257
|
+
clientId: this.params.clientId,
|
|
1252
1258
|
})];
|
|
1253
1259
|
case 2:
|
|
1254
1260
|
_a.sent();
|
|
@@ -1282,7 +1288,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1282
1288
|
_a.sent();
|
|
1283
1289
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
1284
1290
|
type: "commit-tool-output",
|
|
1285
|
-
source: "agent",
|
|
1291
|
+
source: "agent-bus",
|
|
1286
1292
|
input: {
|
|
1287
1293
|
toolId: toolId,
|
|
1288
1294
|
content: content,
|
|
@@ -1290,7 +1296,8 @@ var ClientAgent = /** @class */ (function () {
|
|
|
1290
1296
|
output: {},
|
|
1291
1297
|
context: {
|
|
1292
1298
|
agentName: this.params.agentName,
|
|
1293
|
-
}
|
|
1299
|
+
},
|
|
1300
|
+
clientId: this.params.clientId,
|
|
1294
1301
|
})];
|
|
1295
1302
|
case 3:
|
|
1296
1303
|
_a.sent();
|
|
@@ -1718,14 +1725,15 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1718
1725
|
_a.sent();
|
|
1719
1726
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
1720
1727
|
type: "push",
|
|
1721
|
-
source: "history",
|
|
1728
|
+
source: "history-bus",
|
|
1722
1729
|
input: {
|
|
1723
1730
|
message: message
|
|
1724
1731
|
},
|
|
1725
1732
|
output: {},
|
|
1726
1733
|
context: {
|
|
1727
1734
|
agentName: this.params.agentName,
|
|
1728
|
-
}
|
|
1735
|
+
},
|
|
1736
|
+
clientId: this.params.clientId,
|
|
1729
1737
|
})];
|
|
1730
1738
|
case 2:
|
|
1731
1739
|
_a.sent();
|
|
@@ -2128,12 +2136,13 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2128
2136
|
_d.sent();
|
|
2129
2137
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2130
2138
|
type: "cancel-output",
|
|
2131
|
-
source: "swarm",
|
|
2139
|
+
source: "swarm-bus",
|
|
2132
2140
|
input: {},
|
|
2133
2141
|
output: {},
|
|
2134
2142
|
context: {
|
|
2135
2143
|
swarmName: this.params.swarmName,
|
|
2136
2144
|
},
|
|
2145
|
+
clientId: this.params.clientId,
|
|
2137
2146
|
})];
|
|
2138
2147
|
case 3:
|
|
2139
2148
|
_d.sent();
|
|
@@ -2200,7 +2209,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2200
2209
|
this.params.logger.debug("ClientSwarm swarmName=".concat(this.params.swarmName, " clientId=").concat(this.params.clientId, " waitForAgent agent miss"), { agentName: agentName, expectAgent: expectAgent });
|
|
2201
2210
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2202
2211
|
type: "wait-for-output",
|
|
2203
|
-
source: "swarm",
|
|
2212
|
+
source: "swarm-bus",
|
|
2204
2213
|
input: {},
|
|
2205
2214
|
output: {
|
|
2206
2215
|
result: output,
|
|
@@ -2208,6 +2217,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2208
2217
|
context: {
|
|
2209
2218
|
swarmName: this.params.swarmName,
|
|
2210
2219
|
},
|
|
2220
|
+
clientId: this.params.clientId,
|
|
2211
2221
|
})];
|
|
2212
2222
|
case 3:
|
|
2213
2223
|
_c.sent();
|
|
@@ -2233,7 +2243,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2233
2243
|
_b.label = 2;
|
|
2234
2244
|
case 2: return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2235
2245
|
type: "get-agent-name",
|
|
2236
|
-
source: "swarm",
|
|
2246
|
+
source: "swarm-bus",
|
|
2237
2247
|
input: {},
|
|
2238
2248
|
output: {
|
|
2239
2249
|
activeAgent: this._activeAgent,
|
|
@@ -2241,6 +2251,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2241
2251
|
context: {
|
|
2242
2252
|
swarmName: this.params.swarmName,
|
|
2243
2253
|
},
|
|
2254
|
+
clientId: this.params.clientId,
|
|
2244
2255
|
})];
|
|
2245
2256
|
case 3:
|
|
2246
2257
|
_b.sent();
|
|
@@ -2264,7 +2275,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2264
2275
|
result = this.params.agentMap[agent];
|
|
2265
2276
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2266
2277
|
type: "get-agent",
|
|
2267
|
-
source: "swarm",
|
|
2278
|
+
source: "swarm-bus",
|
|
2268
2279
|
input: {
|
|
2269
2280
|
result: result,
|
|
2270
2281
|
},
|
|
@@ -2272,6 +2283,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2272
2283
|
context: {
|
|
2273
2284
|
swarmName: this.params.swarmName,
|
|
2274
2285
|
},
|
|
2286
|
+
clientId: this.params.clientId,
|
|
2275
2287
|
})];
|
|
2276
2288
|
case 2:
|
|
2277
2289
|
_a.sent();
|
|
@@ -2296,7 +2308,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2296
2308
|
this.params.agentMap[agentName] = agent;
|
|
2297
2309
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2298
2310
|
type: "set-agent-ref",
|
|
2299
|
-
source: "swarm",
|
|
2311
|
+
source: "swarm-bus",
|
|
2300
2312
|
input: {
|
|
2301
2313
|
agentName: agentName,
|
|
2302
2314
|
agent: agent,
|
|
@@ -2305,6 +2317,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2305
2317
|
context: {
|
|
2306
2318
|
swarmName: this.params.swarmName,
|
|
2307
2319
|
},
|
|
2320
|
+
clientId: this.params.clientId,
|
|
2308
2321
|
})];
|
|
2309
2322
|
case 1:
|
|
2310
2323
|
_a.sent();
|
|
@@ -2330,7 +2343,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2330
2343
|
_a.sent();
|
|
2331
2344
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2332
2345
|
type: "set-agent-name",
|
|
2333
|
-
source: "swarm",
|
|
2346
|
+
source: "swarm-bus",
|
|
2334
2347
|
input: {
|
|
2335
2348
|
agentName: agentName,
|
|
2336
2349
|
},
|
|
@@ -2338,6 +2351,7 @@ var ClientSwarm = /** @class */ (function () {
|
|
|
2338
2351
|
context: {
|
|
2339
2352
|
swarmName: this.params.swarmName,
|
|
2340
2353
|
},
|
|
2354
|
+
clientId: this.params.clientId,
|
|
2341
2355
|
})];
|
|
2342
2356
|
case 2:
|
|
2343
2357
|
_a.sent();
|
|
@@ -2636,14 +2650,15 @@ var ClientSession = /** @class */ (function () {
|
|
|
2636
2650
|
_a.sent();
|
|
2637
2651
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2638
2652
|
type: "emit",
|
|
2639
|
-
source: "session",
|
|
2653
|
+
source: "session-bus",
|
|
2640
2654
|
input: {
|
|
2641
2655
|
message: message
|
|
2642
2656
|
},
|
|
2643
2657
|
output: {},
|
|
2644
2658
|
context: {
|
|
2645
2659
|
swarmName: this.params.swarmName,
|
|
2646
|
-
}
|
|
2660
|
+
},
|
|
2661
|
+
clientId: this.params.clientId,
|
|
2647
2662
|
})];
|
|
2648
2663
|
case 2:
|
|
2649
2664
|
_a.sent();
|
|
@@ -2678,7 +2693,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
2678
2693
|
output = _a.sent();
|
|
2679
2694
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2680
2695
|
type: "execute",
|
|
2681
|
-
source: "session",
|
|
2696
|
+
source: "session-bus",
|
|
2682
2697
|
input: {
|
|
2683
2698
|
message: message,
|
|
2684
2699
|
mode: mode,
|
|
@@ -2688,7 +2703,8 @@ var ClientSession = /** @class */ (function () {
|
|
|
2688
2703
|
},
|
|
2689
2704
|
context: {
|
|
2690
2705
|
swarmName: this.params.swarmName,
|
|
2691
|
-
}
|
|
2706
|
+
},
|
|
2707
|
+
clientId: this.params.clientId,
|
|
2692
2708
|
})];
|
|
2693
2709
|
case 3:
|
|
2694
2710
|
_a.sent();
|
|
@@ -2719,7 +2735,7 @@ var ClientSession = /** @class */ (function () {
|
|
|
2719
2735
|
result = _a.sent();
|
|
2720
2736
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2721
2737
|
type: "commit-tool-output",
|
|
2722
|
-
source: "session",
|
|
2738
|
+
source: "session-bus",
|
|
2723
2739
|
input: {
|
|
2724
2740
|
toolId: toolId,
|
|
2725
2741
|
content: content,
|
|
@@ -2727,7 +2743,8 @@ var ClientSession = /** @class */ (function () {
|
|
|
2727
2743
|
output: {},
|
|
2728
2744
|
context: {
|
|
2729
2745
|
swarmName: this.params.swarmName,
|
|
2730
|
-
}
|
|
2746
|
+
},
|
|
2747
|
+
clientId: this.params.clientId,
|
|
2731
2748
|
})];
|
|
2732
2749
|
case 3:
|
|
2733
2750
|
_a.sent();
|
|
@@ -2756,14 +2773,15 @@ var ClientSession = /** @class */ (function () {
|
|
|
2756
2773
|
result = _a.sent();
|
|
2757
2774
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2758
2775
|
type: "commit-user-message",
|
|
2759
|
-
source: "session",
|
|
2776
|
+
source: "session-bus",
|
|
2760
2777
|
input: {
|
|
2761
2778
|
message: message,
|
|
2762
2779
|
},
|
|
2763
2780
|
output: {},
|
|
2764
2781
|
context: {
|
|
2765
2782
|
swarmName: this.params.swarmName,
|
|
2766
|
-
}
|
|
2783
|
+
},
|
|
2784
|
+
clientId: this.params.clientId,
|
|
2767
2785
|
})];
|
|
2768
2786
|
case 3:
|
|
2769
2787
|
_a.sent();
|
|
@@ -2789,12 +2807,13 @@ var ClientSession = /** @class */ (function () {
|
|
|
2789
2807
|
result = _a.sent();
|
|
2790
2808
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2791
2809
|
type: "commit-flush",
|
|
2792
|
-
source: "session",
|
|
2810
|
+
source: "session-bus",
|
|
2793
2811
|
input: {},
|
|
2794
2812
|
output: {},
|
|
2795
2813
|
context: {
|
|
2796
2814
|
swarmName: this.params.swarmName,
|
|
2797
|
-
}
|
|
2815
|
+
},
|
|
2816
|
+
clientId: this.params.clientId,
|
|
2798
2817
|
})];
|
|
2799
2818
|
case 3:
|
|
2800
2819
|
_a.sent();
|
|
@@ -2823,14 +2842,15 @@ var ClientSession = /** @class */ (function () {
|
|
|
2823
2842
|
result = _a.sent();
|
|
2824
2843
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
2825
2844
|
type: "commit-system-message",
|
|
2826
|
-
source: "session",
|
|
2845
|
+
source: "session-bus",
|
|
2827
2846
|
input: {
|
|
2828
2847
|
message: message
|
|
2829
2848
|
},
|
|
2830
2849
|
output: {},
|
|
2831
2850
|
context: {
|
|
2832
2851
|
swarmName: this.params.swarmName,
|
|
2833
|
-
}
|
|
2852
|
+
},
|
|
2853
|
+
clientId: this.params.clientId,
|
|
2834
2854
|
})];
|
|
2835
2855
|
case 3:
|
|
2836
2856
|
_a.sent();
|
|
@@ -2867,12 +2887,13 @@ var ClientSession = /** @class */ (function () {
|
|
|
2867
2887
|
}); });
|
|
2868
2888
|
_this.params.bus.emit(_this.params.clientId, {
|
|
2869
2889
|
type: "connect",
|
|
2870
|
-
source: "session",
|
|
2890
|
+
source: "session-bus",
|
|
2871
2891
|
input: {},
|
|
2872
2892
|
output: {},
|
|
2873
2893
|
context: {
|
|
2874
2894
|
swarmName: _this.params.swarmName,
|
|
2875
|
-
}
|
|
2895
|
+
},
|
|
2896
|
+
clientId: _this.params.clientId,
|
|
2876
2897
|
});
|
|
2877
2898
|
return function (incoming) { return __awaiter(_this, void 0, void 0, function () {
|
|
2878
2899
|
var _a;
|
|
@@ -4904,7 +4925,7 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4904
4925
|
}
|
|
4905
4926
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
4906
4927
|
type: "take",
|
|
4907
|
-
source: "storage",
|
|
4928
|
+
source: "storage-bus",
|
|
4908
4929
|
input: {
|
|
4909
4930
|
search: search,
|
|
4910
4931
|
total: total,
|
|
@@ -4915,7 +4936,8 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4915
4936
|
},
|
|
4916
4937
|
context: {
|
|
4917
4938
|
storageName: this.params.storageName,
|
|
4918
|
-
}
|
|
4939
|
+
},
|
|
4940
|
+
clientId: this.params.clientId,
|
|
4919
4941
|
})];
|
|
4920
4942
|
case 3:
|
|
4921
4943
|
_c.sent();
|
|
@@ -4947,14 +4969,15 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4947
4969
|
}
|
|
4948
4970
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
4949
4971
|
type: "upsert",
|
|
4950
|
-
source: "storage",
|
|
4972
|
+
source: "storage-bus",
|
|
4951
4973
|
input: {
|
|
4952
4974
|
item: item,
|
|
4953
4975
|
},
|
|
4954
4976
|
output: {},
|
|
4955
4977
|
context: {
|
|
4956
4978
|
storageName: this.params.storageName,
|
|
4957
|
-
}
|
|
4979
|
+
},
|
|
4980
|
+
clientId: this.params.clientId,
|
|
4958
4981
|
})];
|
|
4959
4982
|
case 2:
|
|
4960
4983
|
_c.sent();
|
|
@@ -4982,14 +5005,15 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4982
5005
|
}
|
|
4983
5006
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
4984
5007
|
type: "remove",
|
|
4985
|
-
source: "storage",
|
|
5008
|
+
source: "storage-bus",
|
|
4986
5009
|
input: {
|
|
4987
5010
|
itemId: itemId,
|
|
4988
5011
|
},
|
|
4989
5012
|
output: {},
|
|
4990
5013
|
context: {
|
|
4991
5014
|
storageName: this.params.storageName,
|
|
4992
|
-
}
|
|
5015
|
+
},
|
|
5016
|
+
clientId: this.params.clientId,
|
|
4993
5017
|
})];
|
|
4994
5018
|
case 1:
|
|
4995
5019
|
_c.sent();
|
|
@@ -5010,12 +5034,13 @@ var ClientStorage = /** @class */ (function () {
|
|
|
5010
5034
|
this._createEmbedding.clear();
|
|
5011
5035
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
5012
5036
|
type: "clear",
|
|
5013
|
-
source: "storage",
|
|
5037
|
+
source: "storage-bus",
|
|
5014
5038
|
input: {},
|
|
5015
5039
|
output: {},
|
|
5016
5040
|
context: {
|
|
5017
5041
|
storageName: this.params.storageName,
|
|
5018
|
-
}
|
|
5042
|
+
},
|
|
5043
|
+
clientId: this.params.clientId,
|
|
5019
5044
|
})];
|
|
5020
5045
|
case 1:
|
|
5021
5046
|
_a.sent();
|
|
@@ -5040,7 +5065,7 @@ var ClientStorage = /** @class */ (function () {
|
|
|
5040
5065
|
result = (_a = this._itemMap.get(itemId)) !== null && _a !== void 0 ? _a : null;
|
|
5041
5066
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
5042
5067
|
type: "get",
|
|
5043
|
-
source: "storage",
|
|
5068
|
+
source: "storage-bus",
|
|
5044
5069
|
input: {
|
|
5045
5070
|
itemId: itemId,
|
|
5046
5071
|
},
|
|
@@ -5049,7 +5074,8 @@ var ClientStorage = /** @class */ (function () {
|
|
|
5049
5074
|
},
|
|
5050
5075
|
context: {
|
|
5051
5076
|
storageName: this.params.storageName,
|
|
5052
|
-
}
|
|
5077
|
+
},
|
|
5078
|
+
clientId: this.params.clientId,
|
|
5053
5079
|
})];
|
|
5054
5080
|
case 1:
|
|
5055
5081
|
_b.sent();
|
|
@@ -5090,14 +5116,15 @@ var ClientStorage = /** @class */ (function () {
|
|
|
5090
5116
|
}
|
|
5091
5117
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
5092
5118
|
type: "list",
|
|
5093
|
-
source: "storage",
|
|
5119
|
+
source: "storage-bus",
|
|
5094
5120
|
input: {},
|
|
5095
5121
|
output: {
|
|
5096
5122
|
result: result,
|
|
5097
5123
|
},
|
|
5098
5124
|
context: {
|
|
5099
5125
|
storageName: this.params.storageName,
|
|
5100
|
-
}
|
|
5126
|
+
},
|
|
5127
|
+
clientId: this.params.clientId,
|
|
5101
5128
|
})];
|
|
5102
5129
|
case 1:
|
|
5103
5130
|
_d.sent();
|
|
@@ -5833,14 +5860,15 @@ var ClientState = /** @class */ (function () {
|
|
|
5833
5860
|
}
|
|
5834
5861
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
5835
5862
|
type: "set-state",
|
|
5836
|
-
source: "state",
|
|
5863
|
+
source: "state-bus",
|
|
5837
5864
|
input: {},
|
|
5838
5865
|
output: {
|
|
5839
5866
|
state: this._state,
|
|
5840
5867
|
},
|
|
5841
5868
|
context: {
|
|
5842
5869
|
stateName: this.params.stateName,
|
|
5843
|
-
}
|
|
5870
|
+
},
|
|
5871
|
+
clientId: this.params.clientId,
|
|
5844
5872
|
})];
|
|
5845
5873
|
case 2:
|
|
5846
5874
|
_b.sent();
|
|
@@ -5866,14 +5894,15 @@ var ClientState = /** @class */ (function () {
|
|
|
5866
5894
|
}
|
|
5867
5895
|
return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
|
|
5868
5896
|
type: "get-state",
|
|
5869
|
-
source: "state",
|
|
5897
|
+
source: "state-bus",
|
|
5870
5898
|
input: {},
|
|
5871
5899
|
output: {
|
|
5872
5900
|
state: this._state,
|
|
5873
5901
|
},
|
|
5874
5902
|
context: {
|
|
5875
5903
|
stateName: this.params.stateName,
|
|
5876
|
-
}
|
|
5904
|
+
},
|
|
5905
|
+
clientId: this.params.clientId,
|
|
5877
5906
|
})];
|
|
5878
5907
|
case 2:
|
|
5879
5908
|
_b.sent();
|
|
@@ -6188,7 +6217,9 @@ var BusService = /** @class */ (function () {
|
|
|
6188
6217
|
function BusService() {
|
|
6189
6218
|
var _this = this;
|
|
6190
6219
|
this.loggerService = inject(TYPES.loggerService);
|
|
6220
|
+
this.sessionValidationService = inject(TYPES.sessionValidationService);
|
|
6191
6221
|
this._eventSourceSet = new Set();
|
|
6222
|
+
this._eventWildcardMap = new Map();
|
|
6192
6223
|
this.getEventSubject = functoolsKit.memoize(function (_a) {
|
|
6193
6224
|
var _b = __read(_a, 2), clientId = _b[0], source = _b[1];
|
|
6194
6225
|
return "".concat(clientId, "-").concat(source);
|
|
@@ -6198,15 +6229,17 @@ var BusService = /** @class */ (function () {
|
|
|
6198
6229
|
* @param {string} clientId - The client ID.
|
|
6199
6230
|
* @param {EventSource} source - The event source.
|
|
6200
6231
|
* @param {(event: T) => void} fn - The callback function to handle the event.
|
|
6201
|
-
* @returns {Subscription} The subscription object.
|
|
6202
6232
|
*/
|
|
6203
6233
|
this.subscribe = function (clientId, source, fn) {
|
|
6204
6234
|
_this.loggerService.log("busService subscribe", {
|
|
6205
6235
|
clientId: clientId,
|
|
6206
6236
|
source: source,
|
|
6207
6237
|
});
|
|
6238
|
+
if (clientId === "*") {
|
|
6239
|
+
_this._eventWildcardMap.set(source, true);
|
|
6240
|
+
}
|
|
6208
6241
|
_this._eventSourceSet.add(source);
|
|
6209
|
-
|
|
6242
|
+
_this.getEventSubject(clientId, source).subscribe(fn);
|
|
6210
6243
|
};
|
|
6211
6244
|
/**
|
|
6212
6245
|
* Subscribes to a single event for a specific client and source.
|
|
@@ -6221,6 +6254,9 @@ var BusService = /** @class */ (function () {
|
|
|
6221
6254
|
clientId: clientId,
|
|
6222
6255
|
source: source,
|
|
6223
6256
|
});
|
|
6257
|
+
if (clientId === "*") {
|
|
6258
|
+
_this._eventWildcardMap.set(source, true);
|
|
6259
|
+
}
|
|
6224
6260
|
_this._eventSourceSet.add(source);
|
|
6225
6261
|
return _this.getEventSubject(clientId, source).filter(filterFn).once(fn);
|
|
6226
6262
|
};
|
|
@@ -6238,13 +6274,21 @@ var BusService = /** @class */ (function () {
|
|
|
6238
6274
|
clientId: clientId,
|
|
6239
6275
|
event: event,
|
|
6240
6276
|
});
|
|
6241
|
-
if (!this.
|
|
6277
|
+
if (!this.sessionValidationService.hasSession(clientId)) {
|
|
6242
6278
|
return [2 /*return*/];
|
|
6243
6279
|
}
|
|
6280
|
+
if (!this.getEventSubject.has("".concat(clientId, "-").concat(event.source))) return [3 /*break*/, 2];
|
|
6244
6281
|
return [4 /*yield*/, this.getEventSubject(clientId, event.source).next(event)];
|
|
6245
6282
|
case 1:
|
|
6246
6283
|
_a.sent();
|
|
6247
|
-
|
|
6284
|
+
_a.label = 2;
|
|
6285
|
+
case 2:
|
|
6286
|
+
if (!this._eventWildcardMap.has(event.source)) return [3 /*break*/, 4];
|
|
6287
|
+
return [4 /*yield*/, this.getEventSubject("*", event.source).next(event)];
|
|
6288
|
+
case 3:
|
|
6289
|
+
_a.sent();
|
|
6290
|
+
_a.label = 4;
|
|
6291
|
+
case 4: return [2 /*return*/];
|
|
6248
6292
|
}
|
|
6249
6293
|
});
|
|
6250
6294
|
}); };
|
|
@@ -7510,20 +7554,27 @@ var executeForce = function (content, clientId) { return __awaiter(void 0, void
|
|
|
7510
7554
|
}); };
|
|
7511
7555
|
|
|
7512
7556
|
var DISALLOWED_EVENT_SOURCE_LIST$1 = new Set([
|
|
7513
|
-
"agent",
|
|
7514
|
-
"history",
|
|
7515
|
-
"session",
|
|
7516
|
-
"state",
|
|
7517
|
-
"storage",
|
|
7518
|
-
"swarm",
|
|
7557
|
+
"agent-bus",
|
|
7558
|
+
"history-bus",
|
|
7559
|
+
"session-bus",
|
|
7560
|
+
"state-bus",
|
|
7561
|
+
"storage-bus",
|
|
7562
|
+
"swarm-bus",
|
|
7519
7563
|
]);
|
|
7564
|
+
var validateClientId$6 = function (clientId) {
|
|
7565
|
+
if (clientId === "*") {
|
|
7566
|
+
return;
|
|
7567
|
+
}
|
|
7568
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
7569
|
+
throw new Error("agent-swarm listenEvent session not found for clientId=".concat(clientId));
|
|
7570
|
+
}
|
|
7571
|
+
};
|
|
7520
7572
|
/**
|
|
7521
7573
|
* Listens for an event on the swarm bus service and executes a callback function when the event is received.
|
|
7522
7574
|
*
|
|
7523
7575
|
* @template T - The type of the data payload.
|
|
7524
7576
|
* @param {string} clientId - The ID of the client to listen for events from.
|
|
7525
7577
|
* @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.
|
|
7526
|
-
* @returns {void} - Returns nothing.
|
|
7527
7578
|
*/
|
|
7528
7579
|
var listenEvent = function (clientId, topicName, fn) {
|
|
7529
7580
|
swarm.loggerService.log("function listenEvent", {
|
|
@@ -7532,6 +7583,7 @@ var listenEvent = function (clientId, topicName, fn) {
|
|
|
7532
7583
|
if (DISALLOWED_EVENT_SOURCE_LIST$1.has(topicName)) {
|
|
7533
7584
|
throw new Error("agent-swarm listenEvent topic is reserved topicName=".concat(topicName));
|
|
7534
7585
|
}
|
|
7586
|
+
validateClientId$6(clientId);
|
|
7535
7587
|
return swarm.busService.subscribe(clientId, topicName, function (_a) {
|
|
7536
7588
|
var payload = _a.payload;
|
|
7537
7589
|
return fn(payload);
|
|
@@ -7721,12 +7773,12 @@ var makeAutoDispose = function (clientId, swarmName, _a) {
|
|
|
7721
7773
|
};
|
|
7722
7774
|
|
|
7723
7775
|
var DISALLOWED_EVENT_SOURCE_LIST = new Set([
|
|
7724
|
-
"agent",
|
|
7725
|
-
"history",
|
|
7726
|
-
"session",
|
|
7727
|
-
"state",
|
|
7728
|
-
"storage",
|
|
7729
|
-
"swarm",
|
|
7776
|
+
"agent-bus",
|
|
7777
|
+
"history-bus",
|
|
7778
|
+
"session-bus",
|
|
7779
|
+
"state-bus",
|
|
7780
|
+
"storage-bus",
|
|
7781
|
+
"swarm-bus",
|
|
7730
7782
|
]);
|
|
7731
7783
|
/**
|
|
7732
7784
|
* Emits an event to the swarm bus service.
|
|
@@ -7746,6 +7798,7 @@ var event = function (clientId, topicName, payload) {
|
|
|
7746
7798
|
return swarm.busService.emit(clientId, {
|
|
7747
7799
|
source: topicName,
|
|
7748
7800
|
payload: payload,
|
|
7801
|
+
clientId: clientId,
|
|
7749
7802
|
});
|
|
7750
7803
|
};
|
|
7751
7804
|
|
|
@@ -7814,88 +7867,136 @@ var cancelOutputForce = function (clientId) { return __awaiter(void 0, void 0, v
|
|
|
7814
7867
|
});
|
|
7815
7868
|
}); };
|
|
7816
7869
|
|
|
7870
|
+
var validateClientId$5 = function (clientId) {
|
|
7871
|
+
if (clientId === "*") {
|
|
7872
|
+
return;
|
|
7873
|
+
}
|
|
7874
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
7875
|
+
throw new Error("agent-swarm listenAgentEvent session not found for clientId=".concat(clientId));
|
|
7876
|
+
}
|
|
7877
|
+
};
|
|
7817
7878
|
/**
|
|
7818
7879
|
* Hook to subscribe to agent events for a specific client.
|
|
7819
7880
|
*
|
|
7820
7881
|
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
7821
7882
|
* @param {function} fn - The callback function to handle the event.
|
|
7822
|
-
* @returns {function} - A function to unsubscribe from the event.
|
|
7823
7883
|
*/
|
|
7824
7884
|
var listenAgentEvent = function (clientId, fn) {
|
|
7825
7885
|
swarm.loggerService.log("middleware listenAgentEvent", {
|
|
7826
7886
|
clientId: clientId,
|
|
7827
7887
|
});
|
|
7828
|
-
|
|
7888
|
+
validateClientId$5(clientId);
|
|
7889
|
+
swarm.busService.subscribe(clientId, "agent-bus", fn);
|
|
7829
7890
|
};
|
|
7830
7891
|
|
|
7892
|
+
var validateClientId$4 = function (clientId) {
|
|
7893
|
+
if (clientId === "*") {
|
|
7894
|
+
return;
|
|
7895
|
+
}
|
|
7896
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
7897
|
+
throw new Error("agent-swarm listenHistoryEvent session not found for clientId=".concat(clientId));
|
|
7898
|
+
}
|
|
7899
|
+
};
|
|
7831
7900
|
/**
|
|
7832
7901
|
* Hook to subscribe to history events for a specific client.
|
|
7833
7902
|
*
|
|
7834
7903
|
* @param {string} clientId - The ID of the client to subscribe to.
|
|
7835
7904
|
* @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
|
|
7836
|
-
* @returns {Function} - The unsubscribe function.
|
|
7837
7905
|
*/
|
|
7838
7906
|
var listenHistoryEvent = function (clientId, fn) {
|
|
7839
7907
|
swarm.loggerService.log("middleware listenHistoryEvent", {
|
|
7840
7908
|
clientId: clientId,
|
|
7841
7909
|
});
|
|
7842
|
-
|
|
7910
|
+
validateClientId$4(clientId);
|
|
7911
|
+
swarm.busService.subscribe(clientId, "history-bus", fn);
|
|
7843
7912
|
};
|
|
7844
7913
|
|
|
7914
|
+
var validateClientId$3 = function (clientId) {
|
|
7915
|
+
if (clientId === "*") {
|
|
7916
|
+
return;
|
|
7917
|
+
}
|
|
7918
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
7919
|
+
throw new Error("agent-swarm listenSessionEvent session not found for clientId=".concat(clientId));
|
|
7920
|
+
}
|
|
7921
|
+
};
|
|
7845
7922
|
/**
|
|
7846
7923
|
* Hook to subscribe to session events for a specific client.
|
|
7847
7924
|
*
|
|
7848
7925
|
* @param {string} clientId - The ID of the client to subscribe to session events for.
|
|
7849
7926
|
* @param {function} fn - The callback function to handle the session events.
|
|
7850
|
-
* @returns {function} - The unsubscribe function to stop listening to session events.
|
|
7851
7927
|
*/
|
|
7852
7928
|
var listenSessionEvent = function (clientId, fn) {
|
|
7853
7929
|
swarm.loggerService.log("middleware listenSessionEvent", {
|
|
7854
7930
|
clientId: clientId,
|
|
7855
7931
|
});
|
|
7856
|
-
|
|
7932
|
+
validateClientId$3(clientId);
|
|
7933
|
+
swarm.busService.subscribe(clientId, "session-bus", fn);
|
|
7857
7934
|
};
|
|
7858
7935
|
|
|
7936
|
+
var validateClientId$2 = function (clientId) {
|
|
7937
|
+
if (clientId === "*") {
|
|
7938
|
+
return;
|
|
7939
|
+
}
|
|
7940
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
7941
|
+
throw new Error("agent-swarm listenStateEvent session not found for clientId=".concat(clientId));
|
|
7942
|
+
}
|
|
7943
|
+
};
|
|
7859
7944
|
/**
|
|
7860
7945
|
* Hook to subscribe to state events for a specific client.
|
|
7861
7946
|
*
|
|
7862
7947
|
* @param {string} clientId - The ID of the client to subscribe to.
|
|
7863
7948
|
* @param {function} fn - The callback function to handle the event.
|
|
7864
|
-
* @returns {function} - The unsubscribe function to stop listening to the events.
|
|
7865
7949
|
*/
|
|
7866
7950
|
var listenStateEvent = function (clientId, fn) {
|
|
7867
7951
|
swarm.loggerService.log("middleware listenStateEvent", {
|
|
7868
7952
|
clientId: clientId,
|
|
7869
7953
|
});
|
|
7870
|
-
|
|
7954
|
+
validateClientId$2(clientId);
|
|
7955
|
+
swarm.busService.subscribe(clientId, "state-bus", fn);
|
|
7871
7956
|
};
|
|
7872
7957
|
|
|
7958
|
+
var validateClientId$1 = function (clientId) {
|
|
7959
|
+
if (clientId === "*") {
|
|
7960
|
+
return;
|
|
7961
|
+
}
|
|
7962
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
7963
|
+
throw new Error("agent-swarm listenStorageEvent session not found for clientId=".concat(clientId));
|
|
7964
|
+
}
|
|
7965
|
+
};
|
|
7873
7966
|
/**
|
|
7874
7967
|
* Hook to subscribe to storage events for a specific client.
|
|
7875
7968
|
*
|
|
7876
7969
|
* @param {string} clientId - The ID of the client to subscribe to storage events for.
|
|
7877
7970
|
* @param {function} fn - The callback function to handle the storage event.
|
|
7878
|
-
* @returns {function} - A function to unsubscribe from the storage events.
|
|
7879
7971
|
*/
|
|
7880
7972
|
var listenStorageEvent = function (clientId, fn) {
|
|
7881
7973
|
swarm.loggerService.log("middleware listenStorageEvent", {
|
|
7882
7974
|
clientId: clientId,
|
|
7883
7975
|
});
|
|
7884
|
-
|
|
7976
|
+
validateClientId$1(clientId);
|
|
7977
|
+
swarm.busService.subscribe(clientId, "storage-bus", fn);
|
|
7885
7978
|
};
|
|
7886
7979
|
|
|
7980
|
+
var validateClientId = function (clientId) {
|
|
7981
|
+
if (clientId === "*") {
|
|
7982
|
+
return;
|
|
7983
|
+
}
|
|
7984
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) {
|
|
7985
|
+
throw new Error("agent-swarm listenSwarmEvent session not found for clientId=".concat(clientId));
|
|
7986
|
+
}
|
|
7987
|
+
};
|
|
7887
7988
|
/**
|
|
7888
7989
|
* Hook to subscribe to swarm events for a specific client.
|
|
7889
7990
|
*
|
|
7890
7991
|
* @param {string} clientId - The ID of the client to subscribe to events for.
|
|
7891
7992
|
* @param {(event: IBusEvent) => void} fn - The callback function to handle the event.
|
|
7892
|
-
* @returns {Function} - A function to unsubscribe from the event.
|
|
7893
7993
|
*/
|
|
7894
7994
|
var listenSwarmEvent = function (clientId, fn) {
|
|
7895
7995
|
swarm.loggerService.log("middleware listenSwarmEvent", {
|
|
7896
7996
|
clientId: clientId,
|
|
7897
7997
|
});
|
|
7898
|
-
|
|
7998
|
+
validateClientId(clientId);
|
|
7999
|
+
swarm.busService.subscribe(clientId, "swarm-bus", fn);
|
|
7899
8000
|
};
|
|
7900
8001
|
|
|
7901
8002
|
var StorageUtils = /** @class */ (function () {
|