agent-swarm-kit 1.0.76 → 1.0.77

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.mjs CHANGED
@@ -152,12 +152,12 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
152
152
  };
153
153
 
154
154
  /**
155
- * Service providing context information.
155
+ * Service providing method call context information.
156
156
  */
157
- var ContextService = scoped(/** @class */ (function () {
157
+ var MethodContextService = scoped(/** @class */ (function () {
158
158
  /**
159
- * Creates an instance of ContextService.
160
- * @param {IContext} context - The context object.
159
+ * Creates an instance of MethodContextService.
160
+ * @param {IMethodContext} context - The context object.
161
161
  */
162
162
  function class_1(context) {
163
163
  this.context = context;
@@ -171,7 +171,10 @@ var init = (_a = createActivator("agent-swarm"), _a.init), inject = _a.inject, p
171
171
  var baseServices$1 = {
172
172
  busService: Symbol('busService'),
173
173
  loggerService: Symbol('loggerService'),
174
- contextService: Symbol('contextService'),
174
+ };
175
+ var contextServices$1 = {
176
+ methodContextService: Symbol('methodContextService'),
177
+ executionContextService: Symbol('executionContextService'),
175
178
  };
176
179
  var connectionServices$1 = {
177
180
  agentConnectionService: Symbol('agentConnectionService'),
@@ -207,7 +210,21 @@ var validationServices$1 = {
207
210
  embeddingValidationService: Symbol('embeddingValidationService'),
208
211
  storageValidationService: Symbol('storageValidationService'),
209
212
  };
210
- var TYPES = __assign(__assign(__assign(__assign(__assign({}, baseServices$1), schemaServices$1), connectionServices$1), publicServices$1), validationServices$1);
213
+ var TYPES = __assign(__assign(__assign(__assign(__assign(__assign({}, baseServices$1), contextServices$1), schemaServices$1), connectionServices$1), publicServices$1), validationServices$1);
214
+
215
+ /**
216
+ * Service providing execution context information.
217
+ */
218
+ var ExecutionContextService = scoped(/** @class */ (function () {
219
+ /**
220
+ * Creates an instance of ExecutionContextService.
221
+ * @param {IExecutionContext} context - The context object.
222
+ */
223
+ function class_1(context) {
224
+ this.context = context;
225
+ }
226
+ return class_1;
227
+ }()));
211
228
 
212
229
  /**
213
230
  * LoggerService class that implements the ILogger interface.
@@ -216,7 +233,8 @@ var TYPES = __assign(__assign(__assign(__assign(__assign({}, baseServices$1), sc
216
233
  var LoggerService = /** @class */ (function () {
217
234
  function LoggerService() {
218
235
  var _this = this;
219
- this.contextService = inject(TYPES.contextService);
236
+ this.methodContextService = inject(TYPES.methodContextService);
237
+ this.executionContextService = inject(TYPES.executionContextService);
220
238
  this._logger = {
221
239
  /**
222
240
  * Logs messages.
@@ -236,32 +254,39 @@ var LoggerService = /** @class */ (function () {
236
254
  * @param {...any} args - The messages to log.
237
255
  */
238
256
  this.log = function () {
239
- var _a, _b;
257
+ var _a;
240
258
  var args = [];
241
259
  for (var _i = 0; _i < arguments.length; _i++) {
242
260
  args[_i] = arguments[_i];
243
261
  }
244
- if (ContextService.hasContext()) {
245
- (_a = _this._logger).log.apply(_a, __spreadArray(__spreadArray([], __read(args), false), [_this.contextService.context], false));
246
- return;
247
- }
248
- (_b = _this._logger).log.apply(_b, __spreadArray([], __read(args), false));
262
+ var methodContext = MethodContextService.hasContext()
263
+ ? _this.methodContextService.context
264
+ : null;
265
+ var executionContext = ExecutionContextService.hasContext()
266
+ ? _this.executionContextService.context
267
+ : null;
268
+ (_a = _this._logger).log.apply(_a, __spreadArray(__spreadArray([], __read(args), false), [{
269
+ methodContext: methodContext,
270
+ executionContext: executionContext,
271
+ }], false));
249
272
  };
250
273
  /**
251
274
  * Logs debug messages using the current logger.
252
275
  * @param {...any} args - The debug messages to log.
253
276
  */
254
277
  this.debug = function () {
255
- var _a, _b;
278
+ var _a;
256
279
  var args = [];
257
280
  for (var _i = 0; _i < arguments.length; _i++) {
258
281
  args[_i] = arguments[_i];
259
282
  }
260
- if (ContextService.hasContext()) {
261
- (_a = _this._logger).debug.apply(_a, __spreadArray(__spreadArray([], __read(args), false), [_this.contextService.context], false));
262
- return;
263
- }
264
- (_b = _this._logger).debug.apply(_b, __spreadArray([], __read(args), false));
283
+ var methodContext = MethodContextService.hasContext()
284
+ ? _this.methodContextService.context
285
+ : null;
286
+ var executionContext = ExecutionContextService.hasContext()
287
+ ? _this.executionContextService.context
288
+ : null;
289
+ (_a = _this._logger).debug.apply(_a, __spreadArray(__spreadArray([], __read(args), false), [{ methodContext: methodContext, executionContext: executionContext }], false));
265
290
  };
266
291
  /**
267
292
  * Sets a new logger.
@@ -1521,7 +1546,7 @@ var AgentConnectionService = /** @class */ (function () {
1521
1546
  var _this = this;
1522
1547
  this.loggerService = inject(TYPES.loggerService);
1523
1548
  this.busService = inject(TYPES.busService);
1524
- this.contextService = inject(TYPES.contextService);
1549
+ this.methodContextService = inject(TYPES.methodContextService);
1525
1550
  this.sessionValidationService = inject(TYPES.sessionValidationService);
1526
1551
  this.historyConnectionService = inject(TYPES.historyConnectionService);
1527
1552
  this.storageConnectionService = inject(TYPES.storageConnectionService);
@@ -1566,7 +1591,7 @@ var AgentConnectionService = /** @class */ (function () {
1566
1591
  input: input,
1567
1592
  mode: mode,
1568
1593
  });
1569
- return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).execute(input, mode)];
1594
+ return [4 /*yield*/, this.getAgent(this.methodContextService.context.clientId, this.methodContextService.context.agentName).execute(input, mode)];
1570
1595
  case 1: return [2 /*return*/, _a.sent()];
1571
1596
  }
1572
1597
  });
@@ -1580,7 +1605,7 @@ var AgentConnectionService = /** @class */ (function () {
1580
1605
  switch (_a.label) {
1581
1606
  case 0:
1582
1607
  this.loggerService.log("agentConnectionService waitForOutput");
1583
- return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).waitForOutput()];
1608
+ return [4 /*yield*/, this.getAgent(this.methodContextService.context.clientId, this.methodContextService.context.agentName).waitForOutput()];
1584
1609
  case 1: return [2 /*return*/, _a.sent()];
1585
1610
  }
1586
1611
  });
@@ -1599,7 +1624,7 @@ var AgentConnectionService = /** @class */ (function () {
1599
1624
  content: content,
1600
1625
  toolId: toolId,
1601
1626
  });
1602
- return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitToolOutput(toolId, content)];
1627
+ return [4 /*yield*/, this.getAgent(this.methodContextService.context.clientId, this.methodContextService.context.agentName).commitToolOutput(toolId, content)];
1603
1628
  case 1: return [2 /*return*/, _a.sent()];
1604
1629
  }
1605
1630
  });
@@ -1616,7 +1641,7 @@ var AgentConnectionService = /** @class */ (function () {
1616
1641
  this.loggerService.log("agentConnectionService commitSystemMessage", {
1617
1642
  message: message,
1618
1643
  });
1619
- return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitSystemMessage(message)];
1644
+ return [4 /*yield*/, this.getAgent(this.methodContextService.context.clientId, this.methodContextService.context.agentName).commitSystemMessage(message)];
1620
1645
  case 1: return [2 /*return*/, _a.sent()];
1621
1646
  }
1622
1647
  });
@@ -1633,7 +1658,7 @@ var AgentConnectionService = /** @class */ (function () {
1633
1658
  this.loggerService.log("agentConnectionService commitUserMessage", {
1634
1659
  message: message,
1635
1660
  });
1636
- return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitUserMessage(message)];
1661
+ return [4 /*yield*/, this.getAgent(this.methodContextService.context.clientId, this.methodContextService.context.agentName).commitUserMessage(message)];
1637
1662
  case 1: return [2 /*return*/, _a.sent()];
1638
1663
  }
1639
1664
  });
@@ -1647,7 +1672,7 @@ var AgentConnectionService = /** @class */ (function () {
1647
1672
  switch (_a.label) {
1648
1673
  case 0:
1649
1674
  this.loggerService.log("agentConnectionService commitAgentChange");
1650
- return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitAgentChange()];
1675
+ return [4 /*yield*/, this.getAgent(this.methodContextService.context.clientId, this.methodContextService.context.agentName).commitAgentChange()];
1651
1676
  case 1: return [2 /*return*/, _a.sent()];
1652
1677
  }
1653
1678
  });
@@ -1661,7 +1686,7 @@ var AgentConnectionService = /** @class */ (function () {
1661
1686
  switch (_a.label) {
1662
1687
  case 0:
1663
1688
  this.loggerService.log("agentConnectionService commitFlush");
1664
- return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).commitFlush()];
1689
+ return [4 /*yield*/, this.getAgent(this.methodContextService.context.clientId, this.methodContextService.context.agentName).commitFlush()];
1665
1690
  case 1: return [2 /*return*/, _a.sent()];
1666
1691
  }
1667
1692
  });
@@ -1676,15 +1701,15 @@ var AgentConnectionService = /** @class */ (function () {
1676
1701
  switch (_a.label) {
1677
1702
  case 0:
1678
1703
  this.loggerService.log("agentConnectionService dispose");
1679
- key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.agentName);
1704
+ key = "".concat(this.methodContextService.context.clientId, "-").concat(this.methodContextService.context.agentName);
1680
1705
  if (!this.getAgent.has(key)) {
1681
1706
  return [2 /*return*/];
1682
1707
  }
1683
- return [4 /*yield*/, this.getAgent(this.contextService.context.clientId, this.contextService.context.agentName).dispose()];
1708
+ return [4 /*yield*/, this.getAgent(this.methodContextService.context.clientId, this.methodContextService.context.agentName).dispose()];
1684
1709
  case 1:
1685
1710
  _a.sent();
1686
1711
  this.getAgent.clear(key);
1687
- this.sessionValidationService.removeAgentUsage(this.contextService.context.clientId, this.contextService.context.agentName);
1712
+ this.sessionValidationService.removeAgentUsage(this.methodContextService.context.clientId, this.methodContextService.context.agentName);
1688
1713
  return [2 /*return*/];
1689
1714
  }
1690
1715
  });
@@ -1965,7 +1990,7 @@ var HistoryConnectionService = /** @class */ (function () {
1965
1990
  var _this = this;
1966
1991
  this.loggerService = inject(TYPES.loggerService);
1967
1992
  this.busService = inject(TYPES.busService);
1968
- this.contextService = inject(TYPES.contextService);
1993
+ this.methodContextService = inject(TYPES.methodContextService);
1969
1994
  this.sessionValidationService = inject(TYPES.sessionValidationService);
1970
1995
  /**
1971
1996
  * Retrieves the history for a given client and agent.
@@ -1998,7 +2023,7 @@ var HistoryConnectionService = /** @class */ (function () {
1998
2023
  this.loggerService.log("historyConnectionService push", {
1999
2024
  message: message,
2000
2025
  });
2001
- return [4 /*yield*/, this.getHistory(this.contextService.context.clientId, this.contextService.context.agentName).push(message)];
2026
+ return [4 /*yield*/, this.getHistory(this.methodContextService.context.clientId, this.methodContextService.context.agentName).push(message)];
2002
2027
  case 1: return [2 /*return*/, _a.sent()];
2003
2028
  }
2004
2029
  });
@@ -2015,7 +2040,7 @@ var HistoryConnectionService = /** @class */ (function () {
2015
2040
  this.loggerService.log("historyConnectionService toArrayForAgent", {
2016
2041
  prompt: prompt,
2017
2042
  });
2018
- return [4 /*yield*/, this.getHistory(this.contextService.context.clientId, this.contextService.context.agentName).toArrayForAgent(prompt)];
2043
+ return [4 /*yield*/, this.getHistory(this.methodContextService.context.clientId, this.methodContextService.context.agentName).toArrayForAgent(prompt)];
2019
2044
  case 1: return [2 /*return*/, _a.sent()];
2020
2045
  }
2021
2046
  });
@@ -2029,7 +2054,7 @@ var HistoryConnectionService = /** @class */ (function () {
2029
2054
  switch (_a.label) {
2030
2055
  case 0:
2031
2056
  this.loggerService.log("historyConnectionService toArrayForRaw");
2032
- return [4 /*yield*/, this.getHistory(this.contextService.context.clientId, this.contextService.context.agentName).toArrayForRaw()];
2057
+ return [4 /*yield*/, this.getHistory(this.methodContextService.context.clientId, this.methodContextService.context.agentName).toArrayForRaw()];
2033
2058
  case 1: return [2 /*return*/, _a.sent()];
2034
2059
  }
2035
2060
  });
@@ -2044,15 +2069,15 @@ var HistoryConnectionService = /** @class */ (function () {
2044
2069
  switch (_a.label) {
2045
2070
  case 0:
2046
2071
  this.loggerService.log("historyConnectionService dispose");
2047
- key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.agentName);
2072
+ key = "".concat(this.methodContextService.context.clientId, "-").concat(this.methodContextService.context.agentName);
2048
2073
  if (!this.getHistory.has(key)) {
2049
2074
  return [2 /*return*/];
2050
2075
  }
2051
- return [4 /*yield*/, this.getHistory(this.contextService.context.clientId, this.contextService.context.agentName).dispose()];
2076
+ return [4 /*yield*/, this.getHistory(this.methodContextService.context.clientId, this.methodContextService.context.agentName).dispose()];
2052
2077
  case 1:
2053
2078
  _a.sent();
2054
2079
  this.getHistory.clear(key);
2055
- this.sessionValidationService.removeHistoryUsage(this.contextService.context.clientId, this.contextService.context.agentName);
2080
+ this.sessionValidationService.removeHistoryUsage(this.methodContextService.context.clientId, this.methodContextService.context.agentName);
2056
2081
  return [2 /*return*/];
2057
2082
  }
2058
2083
  });
@@ -2373,7 +2398,7 @@ var SwarmConnectionService = /** @class */ (function () {
2373
2398
  var _this = this;
2374
2399
  this.loggerService = inject(TYPES.loggerService);
2375
2400
  this.busService = inject(TYPES.busService);
2376
- this.contextService = inject(TYPES.contextService);
2401
+ this.methodContextService = inject(TYPES.methodContextService);
2377
2402
  this.agentConnectionService = inject(TYPES.agentConnectionService);
2378
2403
  this.swarmSchemaService = inject(TYPES.swarmSchemaService);
2379
2404
  /**
@@ -2437,7 +2462,7 @@ var SwarmConnectionService = /** @class */ (function () {
2437
2462
  switch (_a.label) {
2438
2463
  case 0:
2439
2464
  this.loggerService.log("swarmConnectionService cancelOutput");
2440
- return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).cancelOutput()];
2465
+ return [4 /*yield*/, this.getSwarm(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).cancelOutput()];
2441
2466
  case 1: return [2 /*return*/, _a.sent()];
2442
2467
  }
2443
2468
  });
@@ -2451,7 +2476,7 @@ var SwarmConnectionService = /** @class */ (function () {
2451
2476
  switch (_a.label) {
2452
2477
  case 0:
2453
2478
  this.loggerService.log("swarmConnectionService waitForOutput");
2454
- return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).waitForOutput()];
2479
+ return [4 /*yield*/, this.getSwarm(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).waitForOutput()];
2455
2480
  case 1: return [2 /*return*/, _a.sent()];
2456
2481
  }
2457
2482
  });
@@ -2465,7 +2490,7 @@ var SwarmConnectionService = /** @class */ (function () {
2465
2490
  switch (_a.label) {
2466
2491
  case 0:
2467
2492
  this.loggerService.log("swarmConnectionService getAgentName");
2468
- return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).getAgentName()];
2493
+ return [4 /*yield*/, this.getSwarm(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).getAgentName()];
2469
2494
  case 1: return [2 /*return*/, _a.sent()];
2470
2495
  }
2471
2496
  });
@@ -2479,7 +2504,7 @@ var SwarmConnectionService = /** @class */ (function () {
2479
2504
  switch (_a.label) {
2480
2505
  case 0:
2481
2506
  this.loggerService.log("swarmConnectionService getAgent");
2482
- return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).getAgent()];
2507
+ return [4 /*yield*/, this.getSwarm(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).getAgent()];
2483
2508
  case 1: return [2 /*return*/, _a.sent()];
2484
2509
  }
2485
2510
  });
@@ -2497,7 +2522,7 @@ var SwarmConnectionService = /** @class */ (function () {
2497
2522
  this.loggerService.log("swarmConnectionService setAgentRef", {
2498
2523
  agentName: agentName,
2499
2524
  });
2500
- return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).setAgentRef(agentName, agent)];
2525
+ return [4 /*yield*/, this.getSwarm(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).setAgentRef(agentName, agent)];
2501
2526
  case 1: return [2 /*return*/, _a.sent()];
2502
2527
  }
2503
2528
  });
@@ -2514,7 +2539,7 @@ var SwarmConnectionService = /** @class */ (function () {
2514
2539
  this.loggerService.log("swarmConnectionService setAgentName", {
2515
2540
  agentName: agentName,
2516
2541
  });
2517
- return [4 /*yield*/, this.getSwarm(this.contextService.context.clientId, this.contextService.context.swarmName).setAgentName(agentName)];
2542
+ return [4 /*yield*/, this.getSwarm(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).setAgentName(agentName)];
2518
2543
  case 1: return [2 /*return*/, _a.sent()];
2519
2544
  }
2520
2545
  });
@@ -2527,7 +2552,7 @@ var SwarmConnectionService = /** @class */ (function () {
2527
2552
  var key;
2528
2553
  return __generator(this, function (_a) {
2529
2554
  this.loggerService.log("swarmConnectionService dispose");
2530
- key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.swarmName);
2555
+ key = "".concat(this.methodContextService.context.clientId, "-").concat(this.methodContextService.context.swarmName);
2531
2556
  if (!this.getSwarm.has(key)) {
2532
2557
  return [2 /*return*/];
2533
2558
  }
@@ -2932,7 +2957,7 @@ var SessionConnectionService = /** @class */ (function () {
2932
2957
  var _this = this;
2933
2958
  this.loggerService = inject(TYPES.loggerService);
2934
2959
  this.busService = inject(TYPES.busService);
2935
- this.contextService = inject(TYPES.contextService);
2960
+ this.methodContextService = inject(TYPES.methodContextService);
2936
2961
  this.swarmConnectionService = inject(TYPES.swarmConnectionService);
2937
2962
  this.swarmSchemaService = inject(TYPES.swarmSchemaService);
2938
2963
  /**
@@ -2960,7 +2985,7 @@ var SessionConnectionService = /** @class */ (function () {
2960
2985
  this.loggerService.log("sessionConnectionService emit", {
2961
2986
  content: content,
2962
2987
  });
2963
- return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).emit(content)];
2988
+ return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).emit(content)];
2964
2989
  case 1: return [2 /*return*/, _a.sent()];
2965
2990
  }
2966
2991
  });
@@ -2978,7 +3003,7 @@ var SessionConnectionService = /** @class */ (function () {
2978
3003
  content: content,
2979
3004
  mode: mode,
2980
3005
  });
2981
- return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).execute(content, mode)];
3006
+ return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).execute(content, mode)];
2982
3007
  case 1: return [2 /*return*/, _a.sent()];
2983
3008
  }
2984
3009
  });
@@ -3006,7 +3031,7 @@ var SessionConnectionService = /** @class */ (function () {
3006
3031
  content: content,
3007
3032
  toolId: toolId,
3008
3033
  });
3009
- return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).commitToolOutput(toolId, content)];
3034
+ return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).commitToolOutput(toolId, content)];
3010
3035
  case 1: return [2 /*return*/, _a.sent()];
3011
3036
  }
3012
3037
  });
@@ -3023,7 +3048,7 @@ var SessionConnectionService = /** @class */ (function () {
3023
3048
  this.loggerService.log("sessionConnectionService commitSystemMessage", {
3024
3049
  message: message,
3025
3050
  });
3026
- return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).commitSystemMessage(message)];
3051
+ return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).commitSystemMessage(message)];
3027
3052
  case 1: return [2 /*return*/, _a.sent()];
3028
3053
  }
3029
3054
  });
@@ -3040,7 +3065,7 @@ var SessionConnectionService = /** @class */ (function () {
3040
3065
  this.loggerService.log("sessionConnectionService commitUserMessage", {
3041
3066
  message: message,
3042
3067
  });
3043
- return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).commitUserMessage(message)];
3068
+ return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).commitUserMessage(message)];
3044
3069
  case 1: return [2 /*return*/, _a.sent()];
3045
3070
  }
3046
3071
  });
@@ -3055,7 +3080,7 @@ var SessionConnectionService = /** @class */ (function () {
3055
3080
  switch (_a.label) {
3056
3081
  case 0:
3057
3082
  this.loggerService.log("sessionConnectionService commitFlush");
3058
- return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).commitFlush()];
3083
+ return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).commitFlush()];
3059
3084
  case 1: return [2 /*return*/, _a.sent()];
3060
3085
  }
3061
3086
  });
@@ -3070,11 +3095,11 @@ var SessionConnectionService = /** @class */ (function () {
3070
3095
  switch (_a.label) {
3071
3096
  case 0:
3072
3097
  this.loggerService.log("sessionConnectionService dispose");
3073
- key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.swarmName);
3098
+ key = "".concat(this.methodContextService.context.clientId, "-").concat(this.methodContextService.context.swarmName);
3074
3099
  if (!this.getSession.has(key)) {
3075
3100
  return [2 /*return*/];
3076
3101
  }
3077
- return [4 /*yield*/, this.getSession(this.contextService.context.clientId, this.contextService.context.swarmName).dispose()];
3102
+ return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).dispose()];
3078
3103
  case 1:
3079
3104
  _a.sent();
3080
3105
  this.getSession.clear(key);
@@ -3100,17 +3125,17 @@ var AgentPublicService = /** @class */ (function () {
3100
3125
  * @param {AgentName} agentName - The name of the agent.
3101
3126
  * @returns {Promise<unknown>} The agent reference.
3102
3127
  */
3103
- this.createAgentRef = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3128
+ this.createAgentRef = function (methodName, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3104
3129
  var _this = this;
3105
3130
  return __generator(this, function (_a) {
3106
3131
  switch (_a.label) {
3107
3132
  case 0:
3108
3133
  this.loggerService.log("agentPublicService createAgentRef", {
3109
- requestId: requestId,
3134
+ methodName: methodName,
3110
3135
  clientId: clientId,
3111
3136
  agentName: agentName,
3112
3137
  });
3113
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3138
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3114
3139
  return __generator(this, function (_a) {
3115
3140
  switch (_a.label) {
3116
3141
  case 0: return [4 /*yield*/, this.agentConnectionService.getAgent(clientId, agentName)];
@@ -3118,7 +3143,7 @@ var AgentPublicService = /** @class */ (function () {
3118
3143
  }
3119
3144
  });
3120
3145
  }); }, {
3121
- requestId: requestId,
3146
+ methodName: methodName,
3122
3147
  clientId: clientId,
3123
3148
  agentName: agentName,
3124
3149
  swarmName: "",
@@ -3136,19 +3161,19 @@ var AgentPublicService = /** @class */ (function () {
3136
3161
  * @param {AgentName} agentName - The name of the agent.
3137
3162
  * @returns {Promise<unknown>} The execution result.
3138
3163
  */
3139
- this.execute = function (input, mode, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3164
+ this.execute = function (input, mode, methodName, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3140
3165
  var _this = this;
3141
3166
  return __generator(this, function (_a) {
3142
3167
  switch (_a.label) {
3143
3168
  case 0:
3144
3169
  this.loggerService.log("agentPublicService execute", {
3145
- requestId: requestId,
3170
+ methodName: methodName,
3146
3171
  input: input,
3147
3172
  clientId: clientId,
3148
3173
  agentName: agentName,
3149
3174
  mode: mode,
3150
3175
  });
3151
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3176
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3152
3177
  return __generator(this, function (_a) {
3153
3178
  switch (_a.label) {
3154
3179
  case 0: return [4 /*yield*/, this.agentConnectionService.execute(input, mode)];
@@ -3156,7 +3181,7 @@ var AgentPublicService = /** @class */ (function () {
3156
3181
  }
3157
3182
  });
3158
3183
  }); }, {
3159
- requestId: requestId,
3184
+ methodName: methodName,
3160
3185
  clientId: clientId,
3161
3186
  agentName: agentName,
3162
3187
  swarmName: "",
@@ -3173,17 +3198,17 @@ var AgentPublicService = /** @class */ (function () {
3173
3198
  * @param {AgentName} agentName - The name of the agent.
3174
3199
  * @returns {Promise<unknown>} The output result.
3175
3200
  */
3176
- this.waitForOutput = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3201
+ this.waitForOutput = function (methodName, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3177
3202
  var _this = this;
3178
3203
  return __generator(this, function (_a) {
3179
3204
  switch (_a.label) {
3180
3205
  case 0:
3181
3206
  this.loggerService.log("agentPublicService waitForOutput", {
3182
- requestId: requestId,
3207
+ methodName: methodName,
3183
3208
  clientId: clientId,
3184
3209
  agentName: agentName,
3185
3210
  });
3186
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3211
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3187
3212
  return __generator(this, function (_a) {
3188
3213
  switch (_a.label) {
3189
3214
  case 0: return [4 /*yield*/, this.agentConnectionService.waitForOutput()];
@@ -3191,7 +3216,7 @@ var AgentPublicService = /** @class */ (function () {
3191
3216
  }
3192
3217
  });
3193
3218
  }); }, {
3194
- requestId: requestId,
3219
+ methodName: methodName,
3195
3220
  clientId: clientId,
3196
3221
  agentName: agentName,
3197
3222
  swarmName: "",
@@ -3210,19 +3235,19 @@ var AgentPublicService = /** @class */ (function () {
3210
3235
  * @param {AgentName} agentName - The name of the agent.
3211
3236
  * @returns {Promise<unknown>} The commit result.
3212
3237
  */
3213
- this.commitToolOutput = function (toolId, content, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3238
+ this.commitToolOutput = function (toolId, content, methodName, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3214
3239
  var _this = this;
3215
3240
  return __generator(this, function (_a) {
3216
3241
  switch (_a.label) {
3217
3242
  case 0:
3218
3243
  this.loggerService.log("agentPublicService commitToolOutput", {
3219
- requestId: requestId,
3244
+ methodName: methodName,
3220
3245
  content: content,
3221
3246
  clientId: clientId,
3222
3247
  toolId: toolId,
3223
3248
  agentName: agentName,
3224
3249
  });
3225
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3250
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3226
3251
  return __generator(this, function (_a) {
3227
3252
  switch (_a.label) {
3228
3253
  case 0: return [4 /*yield*/, this.agentConnectionService.commitToolOutput(toolId, content)];
@@ -3230,7 +3255,7 @@ var AgentPublicService = /** @class */ (function () {
3230
3255
  }
3231
3256
  });
3232
3257
  }); }, {
3233
- requestId: requestId,
3258
+ methodName: methodName,
3234
3259
  clientId: clientId,
3235
3260
  agentName: agentName,
3236
3261
  swarmName: "",
@@ -3248,18 +3273,18 @@ var AgentPublicService = /** @class */ (function () {
3248
3273
  * @param {AgentName} agentName - The name of the agent.
3249
3274
  * @returns {Promise<unknown>} The commit result.
3250
3275
  */
3251
- this.commitSystemMessage = function (message, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3276
+ this.commitSystemMessage = function (message, methodName, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3252
3277
  var _this = this;
3253
3278
  return __generator(this, function (_a) {
3254
3279
  switch (_a.label) {
3255
3280
  case 0:
3256
3281
  this.loggerService.log("agentPublicService commitSystemMessage", {
3257
- requestId: requestId,
3282
+ methodName: methodName,
3258
3283
  message: message,
3259
3284
  clientId: clientId,
3260
3285
  agentName: agentName,
3261
3286
  });
3262
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3287
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3263
3288
  return __generator(this, function (_a) {
3264
3289
  switch (_a.label) {
3265
3290
  case 0: return [4 /*yield*/, this.agentConnectionService.commitSystemMessage(message)];
@@ -3267,7 +3292,7 @@ var AgentPublicService = /** @class */ (function () {
3267
3292
  }
3268
3293
  });
3269
3294
  }); }, {
3270
- requestId: requestId,
3295
+ methodName: methodName,
3271
3296
  clientId: clientId,
3272
3297
  agentName: agentName,
3273
3298
  swarmName: "",
@@ -3285,18 +3310,18 @@ var AgentPublicService = /** @class */ (function () {
3285
3310
  * @param {AgentName} agentName - The name of the agent.
3286
3311
  * @returns {Promise<unknown>} The commit result.
3287
3312
  */
3288
- this.commitUserMessage = function (message, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3313
+ this.commitUserMessage = function (message, methodName, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3289
3314
  var _this = this;
3290
3315
  return __generator(this, function (_a) {
3291
3316
  switch (_a.label) {
3292
3317
  case 0:
3293
3318
  this.loggerService.log("agentPublicService commitUserMessage", {
3294
- requestId: requestId,
3319
+ methodName: methodName,
3295
3320
  message: message,
3296
3321
  clientId: clientId,
3297
3322
  agentName: agentName,
3298
3323
  });
3299
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3324
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3300
3325
  return __generator(this, function (_a) {
3301
3326
  switch (_a.label) {
3302
3327
  case 0: return [4 /*yield*/, this.agentConnectionService.commitUserMessage(message)];
@@ -3304,7 +3329,7 @@ var AgentPublicService = /** @class */ (function () {
3304
3329
  }
3305
3330
  });
3306
3331
  }); }, {
3307
- requestId: requestId,
3332
+ methodName: methodName,
3308
3333
  clientId: clientId,
3309
3334
  agentName: agentName,
3310
3335
  swarmName: "",
@@ -3321,17 +3346,17 @@ var AgentPublicService = /** @class */ (function () {
3321
3346
  * @param {AgentName} agentName - The name of the agent.
3322
3347
  * @returns {Promise<unknown>} The commit result.
3323
3348
  */
3324
- this.commitFlush = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3349
+ this.commitFlush = function (methodName, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3325
3350
  var _this = this;
3326
3351
  return __generator(this, function (_a) {
3327
3352
  switch (_a.label) {
3328
3353
  case 0:
3329
3354
  this.loggerService.log("agentPublicService commitFlush", {
3330
- requestId: requestId,
3355
+ methodName: methodName,
3331
3356
  clientId: clientId,
3332
3357
  agentName: agentName,
3333
3358
  });
3334
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3359
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3335
3360
  return __generator(this, function (_a) {
3336
3361
  switch (_a.label) {
3337
3362
  case 0: return [4 /*yield*/, this.agentConnectionService.commitFlush()];
@@ -3339,7 +3364,7 @@ var AgentPublicService = /** @class */ (function () {
3339
3364
  }
3340
3365
  });
3341
3366
  }); }, {
3342
- requestId: requestId,
3367
+ methodName: methodName,
3343
3368
  clientId: clientId,
3344
3369
  agentName: agentName,
3345
3370
  swarmName: "",
@@ -3356,17 +3381,17 @@ var AgentPublicService = /** @class */ (function () {
3356
3381
  * @param {AgentName} agentName - The name of the agent.
3357
3382
  * @returns {Promise<unknown>} The commit result.
3358
3383
  */
3359
- this.commitAgentChange = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3384
+ this.commitAgentChange = function (methodName, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3360
3385
  var _this = this;
3361
3386
  return __generator(this, function (_a) {
3362
3387
  switch (_a.label) {
3363
3388
  case 0:
3364
3389
  this.loggerService.log("agentPublicService commitAgentChange", {
3365
- requestId: requestId,
3390
+ methodName: methodName,
3366
3391
  clientId: clientId,
3367
3392
  agentName: agentName,
3368
3393
  });
3369
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3394
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3370
3395
  return __generator(this, function (_a) {
3371
3396
  switch (_a.label) {
3372
3397
  case 0: return [4 /*yield*/, this.agentConnectionService.commitAgentChange()];
@@ -3374,7 +3399,7 @@ var AgentPublicService = /** @class */ (function () {
3374
3399
  }
3375
3400
  });
3376
3401
  }); }, {
3377
- requestId: requestId,
3402
+ methodName: methodName,
3378
3403
  clientId: clientId,
3379
3404
  agentName: agentName,
3380
3405
  swarmName: "",
@@ -3391,17 +3416,17 @@ var AgentPublicService = /** @class */ (function () {
3391
3416
  * @param {AgentName} agentName - The name of the agent.
3392
3417
  * @returns {Promise<unknown>} The dispose result.
3393
3418
  */
3394
- this.dispose = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3419
+ this.dispose = function (methodName, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3395
3420
  var _this = this;
3396
3421
  return __generator(this, function (_a) {
3397
3422
  switch (_a.label) {
3398
3423
  case 0:
3399
3424
  this.loggerService.log("agentPublicService dispose", {
3400
- requestId: requestId,
3425
+ methodName: methodName,
3401
3426
  clientId: clientId,
3402
3427
  agentName: agentName,
3403
3428
  });
3404
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3429
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3405
3430
  return __generator(this, function (_a) {
3406
3431
  switch (_a.label) {
3407
3432
  case 0: return [4 /*yield*/, this.agentConnectionService.dispose()];
@@ -3409,7 +3434,7 @@ var AgentPublicService = /** @class */ (function () {
3409
3434
  }
3410
3435
  });
3411
3436
  }); }, {
3412
- requestId: requestId,
3437
+ methodName: methodName,
3413
3438
  clientId: clientId,
3414
3439
  agentName: agentName,
3415
3440
  swarmName: "",
@@ -3439,18 +3464,18 @@ var HistoryPublicService = /** @class */ (function () {
3439
3464
  * @param {AgentName} agentName - The agent name.
3440
3465
  * @returns {Promise<void>} A promise that resolves when the operation is complete.
3441
3466
  */
3442
- this.push = function (message, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3467
+ this.push = function (message, methodName, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3443
3468
  var _this = this;
3444
3469
  return __generator(this, function (_a) {
3445
3470
  switch (_a.label) {
3446
3471
  case 0:
3447
3472
  this.loggerService.log("historyPublicService push", {
3448
- requestId: requestId,
3473
+ methodName: methodName,
3449
3474
  message: message,
3450
3475
  clientId: clientId,
3451
3476
  agentName: agentName,
3452
3477
  });
3453
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3478
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3454
3479
  return __generator(this, function (_a) {
3455
3480
  switch (_a.label) {
3456
3481
  case 0: return [4 /*yield*/, this.historyConnectionService.push(message)];
@@ -3458,7 +3483,7 @@ var HistoryPublicService = /** @class */ (function () {
3458
3483
  }
3459
3484
  });
3460
3485
  }); }, {
3461
- requestId: requestId,
3486
+ methodName: methodName,
3462
3487
  clientId: clientId,
3463
3488
  agentName: agentName,
3464
3489
  swarmName: "",
@@ -3476,7 +3501,7 @@ var HistoryPublicService = /** @class */ (function () {
3476
3501
  * @param {AgentName} agentName - The agent name.
3477
3502
  * @returns {Promise<any[]>} A promise that resolves to an array of history items.
3478
3503
  */
3479
- this.toArrayForAgent = function (prompt, requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3504
+ this.toArrayForAgent = function (prompt, methodName, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3480
3505
  var _this = this;
3481
3506
  return __generator(this, function (_a) {
3482
3507
  switch (_a.label) {
@@ -3486,7 +3511,7 @@ var HistoryPublicService = /** @class */ (function () {
3486
3511
  clientId: clientId,
3487
3512
  agentName: agentName,
3488
3513
  });
3489
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3514
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3490
3515
  return __generator(this, function (_a) {
3491
3516
  switch (_a.label) {
3492
3517
  case 0: return [4 /*yield*/, this.historyConnectionService.toArrayForAgent(prompt)];
@@ -3494,7 +3519,7 @@ var HistoryPublicService = /** @class */ (function () {
3494
3519
  }
3495
3520
  });
3496
3521
  }); }, {
3497
- requestId: requestId,
3522
+ methodName: methodName,
3498
3523
  clientId: clientId,
3499
3524
  agentName: agentName,
3500
3525
  swarmName: "",
@@ -3511,17 +3536,17 @@ var HistoryPublicService = /** @class */ (function () {
3511
3536
  * @param {AgentName} agentName - The agent name.
3512
3537
  * @returns {Promise<any[]>} A promise that resolves to a raw array of history items.
3513
3538
  */
3514
- this.toArrayForRaw = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3539
+ this.toArrayForRaw = function (methodName, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3515
3540
  var _this = this;
3516
3541
  return __generator(this, function (_a) {
3517
3542
  switch (_a.label) {
3518
3543
  case 0:
3519
3544
  this.loggerService.log("historyPublicService toArrayForRaw", {
3520
- requestId: requestId,
3545
+ methodName: methodName,
3521
3546
  clientId: clientId,
3522
3547
  agentName: agentName,
3523
3548
  });
3524
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3549
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3525
3550
  return __generator(this, function (_a) {
3526
3551
  switch (_a.label) {
3527
3552
  case 0: return [4 /*yield*/, this.historyConnectionService.toArrayForRaw()];
@@ -3529,7 +3554,7 @@ var HistoryPublicService = /** @class */ (function () {
3529
3554
  }
3530
3555
  });
3531
3556
  }); }, {
3532
- requestId: requestId,
3557
+ methodName: methodName,
3533
3558
  clientId: clientId,
3534
3559
  agentName: agentName,
3535
3560
  swarmName: "",
@@ -3546,7 +3571,7 @@ var HistoryPublicService = /** @class */ (function () {
3546
3571
  * @param {AgentName} agentName - The agent name.
3547
3572
  * @returns {Promise<void>} A promise that resolves when the operation is complete.
3548
3573
  */
3549
- this.dispose = function (requestId, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3574
+ this.dispose = function (methodName, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
3550
3575
  var _this = this;
3551
3576
  return __generator(this, function (_a) {
3552
3577
  switch (_a.label) {
@@ -3555,7 +3580,7 @@ var HistoryPublicService = /** @class */ (function () {
3555
3580
  clientId: clientId,
3556
3581
  agentName: agentName,
3557
3582
  });
3558
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3583
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3559
3584
  return __generator(this, function (_a) {
3560
3585
  switch (_a.label) {
3561
3586
  case 0: return [4 /*yield*/, this.historyConnectionService.dispose()];
@@ -3563,7 +3588,7 @@ var HistoryPublicService = /** @class */ (function () {
3563
3588
  }
3564
3589
  });
3565
3590
  }); }, {
3566
- requestId: requestId,
3591
+ methodName: methodName,
3567
3592
  clientId: clientId,
3568
3593
  agentName: agentName,
3569
3594
  swarmName: "",
@@ -3593,7 +3618,7 @@ var SessionPublicService = /** @class */ (function () {
3593
3618
  * @param {SwarmName} swarmName - The swarm name.
3594
3619
  * @returns {Promise<void>}
3595
3620
  */
3596
- this.emit = function (content, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3621
+ this.emit = function (content, methodName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3597
3622
  var _this = this;
3598
3623
  return __generator(this, function (_a) {
3599
3624
  switch (_a.label) {
@@ -3601,10 +3626,10 @@ var SessionPublicService = /** @class */ (function () {
3601
3626
  this.loggerService.log("sessionPublicService emit", {
3602
3627
  content: content,
3603
3628
  clientId: clientId,
3604
- requestId: requestId,
3629
+ methodName: methodName,
3605
3630
  swarmName: swarmName,
3606
3631
  });
3607
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3632
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3608
3633
  return __generator(this, function (_a) {
3609
3634
  switch (_a.label) {
3610
3635
  case 0: return [4 /*yield*/, this.sessionConnectionService.emit(content)];
@@ -3612,7 +3637,7 @@ var SessionPublicService = /** @class */ (function () {
3612
3637
  }
3613
3638
  });
3614
3639
  }); }, {
3615
- requestId: requestId,
3640
+ methodName: methodName,
3616
3641
  clientId: clientId,
3617
3642
  swarmName: swarmName,
3618
3643
  agentName: "",
@@ -3630,7 +3655,7 @@ var SessionPublicService = /** @class */ (function () {
3630
3655
  * @param {SwarmName} swarmName - The swarm name.
3631
3656
  * @returns {Promise<void>}
3632
3657
  */
3633
- this.execute = function (content, mode, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3658
+ this.execute = function (content, mode, methodName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3634
3659
  var _this = this;
3635
3660
  return __generator(this, function (_a) {
3636
3661
  switch (_a.label) {
@@ -3641,7 +3666,7 @@ var SessionPublicService = /** @class */ (function () {
3641
3666
  clientId: clientId,
3642
3667
  swarmName: swarmName,
3643
3668
  });
3644
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3669
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3645
3670
  return __generator(this, function (_a) {
3646
3671
  switch (_a.label) {
3647
3672
  case 0: return [4 /*yield*/, this.sessionConnectionService.execute(content, mode)];
@@ -3649,7 +3674,7 @@ var SessionPublicService = /** @class */ (function () {
3649
3674
  }
3650
3675
  });
3651
3676
  }); }, {
3652
- requestId: requestId,
3677
+ methodName: methodName,
3653
3678
  clientId: clientId,
3654
3679
  swarmName: swarmName,
3655
3680
  agentName: "",
@@ -3667,13 +3692,31 @@ var SessionPublicService = /** @class */ (function () {
3667
3692
  * @param {SwarmName} swarmName - The swarm name.
3668
3693
  * @returns {ReceiveMessageFn}
3669
3694
  */
3670
- this.connect = function (connector, requestId, clientId, swarmName) {
3695
+ this.connect = function (connector, methodName, clientId, swarmName) {
3671
3696
  _this.loggerService.log("sessionPublicService connect", {
3672
- requestId: requestId,
3697
+ methodName: methodName,
3673
3698
  clientId: clientId,
3674
3699
  swarmName: swarmName,
3675
3700
  });
3676
- return _this.sessionConnectionService.connect(connector, clientId, swarmName);
3701
+ var send = _this.sessionConnectionService.connect(connector, clientId, swarmName);
3702
+ return function (incoming) { return __awaiter(_this, void 0, void 0, function () {
3703
+ var executionId;
3704
+ var _this = this;
3705
+ return __generator(this, function (_a) {
3706
+ executionId = randomString();
3707
+ return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3708
+ return __generator(this, function (_a) {
3709
+ switch (_a.label) {
3710
+ case 0: return [4 /*yield*/, send(incoming)];
3711
+ case 1: return [2 /*return*/, _a.sent()];
3712
+ }
3713
+ });
3714
+ }); }, {
3715
+ clientId: clientId,
3716
+ executionId: executionId,
3717
+ })];
3718
+ });
3719
+ }); };
3677
3720
  };
3678
3721
  /**
3679
3722
  * Commits tool output to the session.
@@ -3683,19 +3726,19 @@ var SessionPublicService = /** @class */ (function () {
3683
3726
  * @param {SwarmName} swarmName - The swarm name.
3684
3727
  * @returns {Promise<void>}
3685
3728
  */
3686
- this.commitToolOutput = function (toolId, content, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3729
+ this.commitToolOutput = function (toolId, content, methodName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3687
3730
  var _this = this;
3688
3731
  return __generator(this, function (_a) {
3689
3732
  switch (_a.label) {
3690
3733
  case 0:
3691
3734
  this.loggerService.log("sessionPublicService commitToolOutput", {
3692
- requestId: requestId,
3735
+ methodName: methodName,
3693
3736
  toolId: toolId,
3694
3737
  content: content,
3695
3738
  clientId: clientId,
3696
3739
  swarmName: swarmName,
3697
3740
  });
3698
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3741
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3699
3742
  return __generator(this, function (_a) {
3700
3743
  switch (_a.label) {
3701
3744
  case 0: return [4 /*yield*/, this.sessionConnectionService.commitToolOutput(toolId, content)];
@@ -3703,7 +3746,7 @@ var SessionPublicService = /** @class */ (function () {
3703
3746
  }
3704
3747
  });
3705
3748
  }); }, {
3706
- requestId: requestId,
3749
+ methodName: methodName,
3707
3750
  clientId: clientId,
3708
3751
  swarmName: swarmName,
3709
3752
  agentName: "",
@@ -3721,18 +3764,18 @@ var SessionPublicService = /** @class */ (function () {
3721
3764
  * @param {SwarmName} swarmName - The swarm name.
3722
3765
  * @returns {Promise<void>}
3723
3766
  */
3724
- this.commitSystemMessage = function (message, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3767
+ this.commitSystemMessage = function (message, methodName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3725
3768
  var _this = this;
3726
3769
  return __generator(this, function (_a) {
3727
3770
  switch (_a.label) {
3728
3771
  case 0:
3729
3772
  this.loggerService.log("sessionPublicService commitSystemMessage", {
3730
- requestId: requestId,
3773
+ methodName: methodName,
3731
3774
  message: message,
3732
3775
  clientId: clientId,
3733
3776
  swarmName: swarmName,
3734
3777
  });
3735
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3778
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3736
3779
  return __generator(this, function (_a) {
3737
3780
  switch (_a.label) {
3738
3781
  case 0: return [4 /*yield*/, this.sessionConnectionService.commitSystemMessage(message)];
@@ -3740,7 +3783,7 @@ var SessionPublicService = /** @class */ (function () {
3740
3783
  }
3741
3784
  });
3742
3785
  }); }, {
3743
- requestId: requestId,
3786
+ methodName: methodName,
3744
3787
  clientId: clientId,
3745
3788
  swarmName: swarmName,
3746
3789
  agentName: "",
@@ -3758,18 +3801,18 @@ var SessionPublicService = /** @class */ (function () {
3758
3801
  * @param {SwarmName} swarmName - The swarm name.
3759
3802
  * @returns {Promise<void>}
3760
3803
  */
3761
- this.commitUserMessage = function (message, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3804
+ this.commitUserMessage = function (message, methodName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3762
3805
  var _this = this;
3763
3806
  return __generator(this, function (_a) {
3764
3807
  switch (_a.label) {
3765
3808
  case 0:
3766
3809
  this.loggerService.log("sessionPublicService commitUserMessage", {
3767
- requestId: requestId,
3810
+ methodName: methodName,
3768
3811
  message: message,
3769
3812
  clientId: clientId,
3770
3813
  swarmName: swarmName,
3771
3814
  });
3772
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3815
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3773
3816
  return __generator(this, function (_a) {
3774
3817
  switch (_a.label) {
3775
3818
  case 0: return [4 /*yield*/, this.sessionConnectionService.commitUserMessage(message)];
@@ -3777,7 +3820,7 @@ var SessionPublicService = /** @class */ (function () {
3777
3820
  }
3778
3821
  });
3779
3822
  }); }, {
3780
- requestId: requestId,
3823
+ methodName: methodName,
3781
3824
  clientId: clientId,
3782
3825
  swarmName: swarmName,
3783
3826
  agentName: "",
@@ -3794,7 +3837,7 @@ var SessionPublicService = /** @class */ (function () {
3794
3837
  * @param {SwarmName} swarmName - The swarm name.
3795
3838
  * @returns {Promise<void>}
3796
3839
  */
3797
- this.commitFlush = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3840
+ this.commitFlush = function (methodName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3798
3841
  var _this = this;
3799
3842
  return __generator(this, function (_a) {
3800
3843
  switch (_a.label) {
@@ -3803,7 +3846,7 @@ var SessionPublicService = /** @class */ (function () {
3803
3846
  clientId: clientId,
3804
3847
  swarmName: swarmName,
3805
3848
  });
3806
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3849
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3807
3850
  return __generator(this, function (_a) {
3808
3851
  switch (_a.label) {
3809
3852
  case 0: return [4 /*yield*/, this.sessionConnectionService.commitFlush()];
@@ -3811,7 +3854,7 @@ var SessionPublicService = /** @class */ (function () {
3811
3854
  }
3812
3855
  });
3813
3856
  }); }, {
3814
- requestId: requestId,
3857
+ methodName: methodName,
3815
3858
  clientId: clientId,
3816
3859
  swarmName: swarmName,
3817
3860
  agentName: "",
@@ -3828,17 +3871,17 @@ var SessionPublicService = /** @class */ (function () {
3828
3871
  * @param {SwarmName} swarmName - The swarm name.
3829
3872
  * @returns {Promise<void>}
3830
3873
  */
3831
- this.dispose = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3874
+ this.dispose = function (methodName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3832
3875
  var _this = this;
3833
3876
  return __generator(this, function (_a) {
3834
3877
  switch (_a.label) {
3835
3878
  case 0:
3836
3879
  this.loggerService.log("sessionPublicService dispose", {
3837
- requestId: requestId,
3880
+ methodName: methodName,
3838
3881
  clientId: clientId,
3839
3882
  swarmName: swarmName,
3840
3883
  });
3841
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3884
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3842
3885
  return __generator(this, function (_a) {
3843
3886
  switch (_a.label) {
3844
3887
  case 0: return [4 /*yield*/, this.sessionConnectionService.dispose()];
@@ -3846,7 +3889,7 @@ var SessionPublicService = /** @class */ (function () {
3846
3889
  }
3847
3890
  });
3848
3891
  }); }, {
3849
- requestId: requestId,
3892
+ methodName: methodName,
3850
3893
  clientId: clientId,
3851
3894
  swarmName: swarmName,
3852
3895
  agentName: "",
@@ -3875,7 +3918,7 @@ var SwarmPublicService = /** @class */ (function () {
3875
3918
  * @param {SwarmName} swarmName - The swarm name.
3876
3919
  * @returns {Promise<void>}
3877
3920
  */
3878
- this.cancelOutput = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3921
+ this.cancelOutput = function (methodName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3879
3922
  var _this = this;
3880
3923
  return __generator(this, function (_a) {
3881
3924
  switch (_a.label) {
@@ -3884,7 +3927,7 @@ var SwarmPublicService = /** @class */ (function () {
3884
3927
  clientId: clientId,
3885
3928
  swarmName: swarmName,
3886
3929
  });
3887
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3930
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3888
3931
  return __generator(this, function (_a) {
3889
3932
  switch (_a.label) {
3890
3933
  case 0: return [4 /*yield*/, this.swarmConnectionService.cancelOutput()];
@@ -3892,7 +3935,7 @@ var SwarmPublicService = /** @class */ (function () {
3892
3935
  }
3893
3936
  });
3894
3937
  }); }, {
3895
- requestId: requestId,
3938
+ methodName: methodName,
3896
3939
  clientId: clientId,
3897
3940
  swarmName: swarmName,
3898
3941
  agentName: "",
@@ -3909,17 +3952,17 @@ var SwarmPublicService = /** @class */ (function () {
3909
3952
  * @param {SwarmName} swarmName - The swarm name.
3910
3953
  * @returns {Promise<void>}
3911
3954
  */
3912
- this.waitForOutput = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3955
+ this.waitForOutput = function (methodName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3913
3956
  var _this = this;
3914
3957
  return __generator(this, function (_a) {
3915
3958
  switch (_a.label) {
3916
3959
  case 0:
3917
3960
  this.loggerService.log("swarmPublicService waitForOutput", {
3918
3961
  clientId: clientId,
3919
- requestId: requestId,
3962
+ methodName: methodName,
3920
3963
  swarmName: swarmName,
3921
3964
  });
3922
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3965
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3923
3966
  return __generator(this, function (_a) {
3924
3967
  switch (_a.label) {
3925
3968
  case 0: return [4 /*yield*/, this.swarmConnectionService.waitForOutput()];
@@ -3927,7 +3970,7 @@ var SwarmPublicService = /** @class */ (function () {
3927
3970
  }
3928
3971
  });
3929
3972
  }); }, {
3930
- requestId: requestId,
3973
+ methodName: methodName,
3931
3974
  clientId: clientId,
3932
3975
  swarmName: swarmName,
3933
3976
  agentName: "",
@@ -3944,7 +3987,7 @@ var SwarmPublicService = /** @class */ (function () {
3944
3987
  * @param {SwarmName} swarmName - The swarm name.
3945
3988
  * @returns {Promise<string>}
3946
3989
  */
3947
- this.getAgentName = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3990
+ this.getAgentName = function (methodName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3948
3991
  var _this = this;
3949
3992
  return __generator(this, function (_a) {
3950
3993
  switch (_a.label) {
@@ -3952,9 +3995,9 @@ var SwarmPublicService = /** @class */ (function () {
3952
3995
  this.loggerService.log("swarmPublicService getAgentName", {
3953
3996
  clientId: clientId,
3954
3997
  swarmName: swarmName,
3955
- requestId: requestId,
3998
+ methodName: methodName,
3956
3999
  });
3957
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
4000
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3958
4001
  return __generator(this, function (_a) {
3959
4002
  switch (_a.label) {
3960
4003
  case 0: return [4 /*yield*/, this.swarmConnectionService.getAgentName()];
@@ -3962,7 +4005,7 @@ var SwarmPublicService = /** @class */ (function () {
3962
4005
  }
3963
4006
  });
3964
4007
  }); }, {
3965
- requestId: requestId,
4008
+ methodName: methodName,
3966
4009
  clientId: clientId,
3967
4010
  swarmName: swarmName,
3968
4011
  agentName: "",
@@ -3979,7 +4022,7 @@ var SwarmPublicService = /** @class */ (function () {
3979
4022
  * @param {SwarmName} swarmName - The swarm name.
3980
4023
  * @returns {Promise<IAgent>}
3981
4024
  */
3982
- this.getAgent = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
4025
+ this.getAgent = function (methodName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
3983
4026
  var _this = this;
3984
4027
  return __generator(this, function (_a) {
3985
4028
  switch (_a.label) {
@@ -3988,7 +4031,7 @@ var SwarmPublicService = /** @class */ (function () {
3988
4031
  clientId: clientId,
3989
4032
  swarmName: swarmName,
3990
4033
  });
3991
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
4034
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
3992
4035
  return __generator(this, function (_a) {
3993
4036
  switch (_a.label) {
3994
4037
  case 0: return [4 /*yield*/, this.swarmConnectionService.getAgent()];
@@ -3996,7 +4039,7 @@ var SwarmPublicService = /** @class */ (function () {
3996
4039
  }
3997
4040
  });
3998
4041
  }); }, {
3999
- requestId: requestId,
4042
+ methodName: methodName,
4000
4043
  clientId: clientId,
4001
4044
  swarmName: swarmName,
4002
4045
  agentName: "",
@@ -4015,19 +4058,19 @@ var SwarmPublicService = /** @class */ (function () {
4015
4058
  * @param {IAgent} agent - The agent instance.
4016
4059
  * @returns {Promise<void>}
4017
4060
  */
4018
- this.setAgentRef = function (requestId, clientId, swarmName, agentName, agent) { return __awaiter(_this, void 0, void 0, function () {
4061
+ this.setAgentRef = function (methodName, clientId, swarmName, agentName, agent) { return __awaiter(_this, void 0, void 0, function () {
4019
4062
  var _this = this;
4020
4063
  return __generator(this, function (_a) {
4021
4064
  switch (_a.label) {
4022
4065
  case 0:
4023
4066
  this.loggerService.log("swarmPublicService setAgentRef", {
4024
- requestId: requestId,
4067
+ methodName: methodName,
4025
4068
  agentName: agentName,
4026
4069
  agent: agent,
4027
4070
  clientId: clientId,
4028
4071
  swarmName: swarmName,
4029
4072
  });
4030
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
4073
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
4031
4074
  return __generator(this, function (_a) {
4032
4075
  switch (_a.label) {
4033
4076
  case 0: return [4 /*yield*/, this.swarmConnectionService.setAgentRef(agentName, agent)];
@@ -4035,7 +4078,7 @@ var SwarmPublicService = /** @class */ (function () {
4035
4078
  }
4036
4079
  });
4037
4080
  }); }, {
4038
- requestId: requestId,
4081
+ methodName: methodName,
4039
4082
  clientId: clientId,
4040
4083
  swarmName: swarmName,
4041
4084
  agentName: "",
@@ -4053,18 +4096,18 @@ var SwarmPublicService = /** @class */ (function () {
4053
4096
  * @param {SwarmName} swarmName - The swarm name.
4054
4097
  * @returns {Promise<void>}
4055
4098
  */
4056
- this.setAgentName = function (agentName, requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
4099
+ this.setAgentName = function (agentName, methodName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
4057
4100
  var _this = this;
4058
4101
  return __generator(this, function (_a) {
4059
4102
  switch (_a.label) {
4060
4103
  case 0:
4061
4104
  this.loggerService.log("swarmPublicService setAgentName", {
4062
- requestId: requestId,
4105
+ methodName: methodName,
4063
4106
  agentName: agentName,
4064
4107
  clientId: clientId,
4065
4108
  swarmName: swarmName,
4066
4109
  });
4067
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
4110
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
4068
4111
  return __generator(this, function (_a) {
4069
4112
  switch (_a.label) {
4070
4113
  case 0: return [4 /*yield*/, this.swarmConnectionService.setAgentName(agentName)];
@@ -4072,7 +4115,7 @@ var SwarmPublicService = /** @class */ (function () {
4072
4115
  }
4073
4116
  });
4074
4117
  }); }, {
4075
- requestId: requestId,
4118
+ methodName: methodName,
4076
4119
  clientId: clientId,
4077
4120
  swarmName: swarmName,
4078
4121
  agentName: "",
@@ -4089,17 +4132,17 @@ var SwarmPublicService = /** @class */ (function () {
4089
4132
  * @param {SwarmName} swarmName - The swarm name.
4090
4133
  * @returns {Promise<void>}
4091
4134
  */
4092
- this.dispose = function (requestId, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
4135
+ this.dispose = function (methodName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
4093
4136
  var _this = this;
4094
4137
  return __generator(this, function (_a) {
4095
4138
  switch (_a.label) {
4096
4139
  case 0:
4097
4140
  this.loggerService.log("swarmPublicService dispose", {
4098
- requestId: requestId,
4141
+ methodName: methodName,
4099
4142
  clientId: clientId,
4100
4143
  swarmName: swarmName,
4101
4144
  });
4102
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
4145
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
4103
4146
  return __generator(this, function (_a) {
4104
4147
  switch (_a.label) {
4105
4148
  case 0: return [4 /*yield*/, this.swarmConnectionService.dispose()];
@@ -4107,7 +4150,7 @@ var SwarmPublicService = /** @class */ (function () {
4107
4150
  }
4108
4151
  });
4109
4152
  }); }, {
4110
- requestId: requestId,
4153
+ methodName: methodName,
4111
4154
  clientId: clientId,
4112
4155
  swarmName: swarmName,
4113
4156
  agentName: "",
@@ -5149,7 +5192,7 @@ var StorageConnectionService = /** @class */ (function () {
5149
5192
  var _this = this;
5150
5193
  this.loggerService = inject(TYPES.loggerService);
5151
5194
  this.busService = inject(TYPES.busService);
5152
- this.contextService = inject(TYPES.contextService);
5195
+ this.methodContextService = inject(TYPES.methodContextService);
5153
5196
  this.storageSchemaService = inject(TYPES.storageSchemaService);
5154
5197
  this.sessionValidationService = inject(TYPES.sessionValidationService);
5155
5198
  this.embeddingSchemaService = inject(TYPES.embeddingSchemaService);
@@ -5204,7 +5247,7 @@ var StorageConnectionService = /** @class */ (function () {
5204
5247
  total: total,
5205
5248
  score: score,
5206
5249
  });
5207
- storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
5250
+ storage = this.getStorage(this.methodContextService.context.clientId, this.methodContextService.context.storageName);
5208
5251
  return [4 /*yield*/, storage.waitForInit()];
5209
5252
  case 1:
5210
5253
  _a.sent();
@@ -5226,7 +5269,7 @@ var StorageConnectionService = /** @class */ (function () {
5226
5269
  this.loggerService.log("storageConnectionService upsert", {
5227
5270
  item: item,
5228
5271
  });
5229
- storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
5272
+ storage = this.getStorage(this.methodContextService.context.clientId, this.methodContextService.context.storageName);
5230
5273
  return [4 /*yield*/, storage.waitForInit()];
5231
5274
  case 1:
5232
5275
  _a.sent();
@@ -5248,7 +5291,7 @@ var StorageConnectionService = /** @class */ (function () {
5248
5291
  this.loggerService.log("storageConnectionService remove", {
5249
5292
  itemId: itemId,
5250
5293
  });
5251
- storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
5294
+ storage = this.getStorage(this.methodContextService.context.clientId, this.methodContextService.context.storageName);
5252
5295
  return [4 /*yield*/, storage.waitForInit()];
5253
5296
  case 1:
5254
5297
  _a.sent();
@@ -5270,7 +5313,7 @@ var StorageConnectionService = /** @class */ (function () {
5270
5313
  this.loggerService.log("storageConnectionService get", {
5271
5314
  itemId: itemId,
5272
5315
  });
5273
- storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
5316
+ storage = this.getStorage(this.methodContextService.context.clientId, this.methodContextService.context.storageName);
5274
5317
  return [4 /*yield*/, storage.waitForInit()];
5275
5318
  case 1:
5276
5319
  _a.sent();
@@ -5290,7 +5333,7 @@ var StorageConnectionService = /** @class */ (function () {
5290
5333
  switch (_a.label) {
5291
5334
  case 0:
5292
5335
  this.loggerService.log("storageConnectionService list");
5293
- storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
5336
+ storage = this.getStorage(this.methodContextService.context.clientId, this.methodContextService.context.storageName);
5294
5337
  return [4 /*yield*/, storage.waitForInit()];
5295
5338
  case 1:
5296
5339
  _a.sent();
@@ -5309,7 +5352,7 @@ var StorageConnectionService = /** @class */ (function () {
5309
5352
  switch (_a.label) {
5310
5353
  case 0:
5311
5354
  this.loggerService.log("storageConnectionService clear");
5312
- storage = this.getStorage(this.contextService.context.clientId, this.contextService.context.storageName);
5355
+ storage = this.getStorage(this.methodContextService.context.clientId, this.methodContextService.context.storageName);
5313
5356
  return [4 /*yield*/, storage.waitForInit()];
5314
5357
  case 1:
5315
5358
  _a.sent();
@@ -5328,12 +5371,12 @@ var StorageConnectionService = /** @class */ (function () {
5328
5371
  switch (_a.label) {
5329
5372
  case 0:
5330
5373
  this.loggerService.log("storageConnectionService dispose");
5331
- key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.storageName);
5374
+ key = "".concat(this.methodContextService.context.clientId, "-").concat(this.methodContextService.context.storageName);
5332
5375
  if (!this.getStorage.has(key)) {
5333
5376
  return [2 /*return*/];
5334
5377
  }
5335
- if (!!this.getSharedStorage.has(this.contextService.context.storageName)) return [3 /*break*/, 3];
5336
- storage = this.getSharedStorage(this.contextService.context.clientId, this.contextService.context.storageName);
5378
+ if (!!this.getSharedStorage.has(this.methodContextService.context.storageName)) return [3 /*break*/, 3];
5379
+ storage = this.getSharedStorage(this.methodContextService.context.clientId, this.methodContextService.context.storageName);
5337
5380
  return [4 /*yield*/, storage.waitForInit()];
5338
5381
  case 1:
5339
5382
  _a.sent();
@@ -5343,7 +5386,7 @@ var StorageConnectionService = /** @class */ (function () {
5343
5386
  _a.label = 3;
5344
5387
  case 3:
5345
5388
  this.getStorage.clear(key);
5346
- this.sessionValidationService.removeStorageUsage(this.contextService.context.clientId, this.contextService.context.storageName);
5389
+ this.sessionValidationService.removeStorageUsage(this.methodContextService.context.clientId, this.methodContextService.context.storageName);
5347
5390
  return [2 /*return*/];
5348
5391
  }
5349
5392
  });
@@ -5366,20 +5409,20 @@ var StoragePublicService = /** @class */ (function () {
5366
5409
  * @param {number} total - The total number of items to retrieve.
5367
5410
  * @returns {Promise<IStorageData[]>} The list of storage data.
5368
5411
  */
5369
- this.take = function (search, total, requestId, clientId, storageName, score) { return __awaiter(_this, void 0, void 0, function () {
5412
+ this.take = function (search, total, methodName, clientId, storageName, score) { return __awaiter(_this, void 0, void 0, function () {
5370
5413
  var _this = this;
5371
5414
  return __generator(this, function (_a) {
5372
5415
  switch (_a.label) {
5373
5416
  case 0:
5374
5417
  this.loggerService.log("storagePublicService take", {
5375
- requestId: requestId,
5418
+ methodName: methodName,
5376
5419
  search: search,
5377
5420
  total: total,
5378
5421
  clientId: clientId,
5379
5422
  storageName: storageName,
5380
5423
  score: score,
5381
5424
  });
5382
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
5425
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
5383
5426
  return __generator(this, function (_a) {
5384
5427
  switch (_a.label) {
5385
5428
  case 0: return [4 /*yield*/, this.storageConnectionService.take(search, total, score)];
@@ -5387,7 +5430,7 @@ var StoragePublicService = /** @class */ (function () {
5387
5430
  }
5388
5431
  });
5389
5432
  }); }, {
5390
- requestId: requestId,
5433
+ methodName: methodName,
5391
5434
  clientId: clientId,
5392
5435
  storageName: storageName,
5393
5436
  agentName: "",
@@ -5403,7 +5446,7 @@ var StoragePublicService = /** @class */ (function () {
5403
5446
  * @param {IStorageData} item - The item to upsert.
5404
5447
  * @returns {Promise<void>}
5405
5448
  */
5406
- this.upsert = function (item, requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
5449
+ this.upsert = function (item, methodName, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
5407
5450
  var _this = this;
5408
5451
  return __generator(this, function (_a) {
5409
5452
  switch (_a.label) {
@@ -5413,7 +5456,7 @@ var StoragePublicService = /** @class */ (function () {
5413
5456
  clientId: clientId,
5414
5457
  storageName: storageName,
5415
5458
  });
5416
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
5459
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
5417
5460
  return __generator(this, function (_a) {
5418
5461
  switch (_a.label) {
5419
5462
  case 0: return [4 /*yield*/, this.storageConnectionService.upsert(item)];
@@ -5421,7 +5464,7 @@ var StoragePublicService = /** @class */ (function () {
5421
5464
  }
5422
5465
  });
5423
5466
  }); }, {
5424
- requestId: requestId,
5467
+ methodName: methodName,
5425
5468
  clientId: clientId,
5426
5469
  storageName: storageName,
5427
5470
  agentName: "",
@@ -5437,7 +5480,7 @@ var StoragePublicService = /** @class */ (function () {
5437
5480
  * @param {IStorageData["id"]} itemId - The ID of the item to remove.
5438
5481
  * @returns {Promise<void>}
5439
5482
  */
5440
- this.remove = function (itemId, requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
5483
+ this.remove = function (itemId, methodName, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
5441
5484
  var _this = this;
5442
5485
  return __generator(this, function (_a) {
5443
5486
  switch (_a.label) {
@@ -5447,7 +5490,7 @@ var StoragePublicService = /** @class */ (function () {
5447
5490
  clientId: clientId,
5448
5491
  storageName: storageName,
5449
5492
  });
5450
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
5493
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
5451
5494
  return __generator(this, function (_a) {
5452
5495
  switch (_a.label) {
5453
5496
  case 0: return [4 /*yield*/, this.storageConnectionService.remove(itemId)];
@@ -5455,7 +5498,7 @@ var StoragePublicService = /** @class */ (function () {
5455
5498
  }
5456
5499
  });
5457
5500
  }); }, {
5458
- requestId: requestId,
5501
+ methodName: methodName,
5459
5502
  clientId: clientId,
5460
5503
  storageName: storageName,
5461
5504
  agentName: "",
@@ -5471,18 +5514,18 @@ var StoragePublicService = /** @class */ (function () {
5471
5514
  * @param {IStorageData["id"]} itemId - The ID of the item to retrieve.
5472
5515
  * @returns {Promise<IStorageData>} The retrieved item.
5473
5516
  */
5474
- this.get = function (itemId, requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
5517
+ this.get = function (itemId, methodName, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
5475
5518
  var _this = this;
5476
5519
  return __generator(this, function (_a) {
5477
5520
  switch (_a.label) {
5478
5521
  case 0:
5479
5522
  this.loggerService.log("storagePublicService get", {
5480
- requestId: requestId,
5523
+ methodName: methodName,
5481
5524
  itemId: itemId,
5482
5525
  clientId: clientId,
5483
5526
  storageName: storageName,
5484
5527
  });
5485
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
5528
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
5486
5529
  return __generator(this, function (_a) {
5487
5530
  switch (_a.label) {
5488
5531
  case 0: return [4 /*yield*/, this.storageConnectionService.get(itemId)];
@@ -5490,7 +5533,7 @@ var StoragePublicService = /** @class */ (function () {
5490
5533
  }
5491
5534
  });
5492
5535
  }); }, {
5493
- requestId: requestId,
5536
+ methodName: methodName,
5494
5537
  clientId: clientId,
5495
5538
  storageName: storageName,
5496
5539
  agentName: "",
@@ -5506,17 +5549,17 @@ var StoragePublicService = /** @class */ (function () {
5506
5549
  * @param {function(IStorageData): boolean} [filter] - The optional filter function.
5507
5550
  * @returns {Promise<IStorageData[]>} The list of items.
5508
5551
  */
5509
- this.list = function (requestId, clientId, storageName, filter) { return __awaiter(_this, void 0, void 0, function () {
5552
+ this.list = function (methodName, clientId, storageName, filter) { return __awaiter(_this, void 0, void 0, function () {
5510
5553
  var _this = this;
5511
5554
  return __generator(this, function (_a) {
5512
5555
  switch (_a.label) {
5513
5556
  case 0:
5514
5557
  this.loggerService.log("storagePublicService list", {
5515
- requestId: requestId,
5558
+ methodName: methodName,
5516
5559
  clientId: clientId,
5517
5560
  storageName: storageName,
5518
5561
  });
5519
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
5562
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
5520
5563
  return __generator(this, function (_a) {
5521
5564
  switch (_a.label) {
5522
5565
  case 0: return [4 /*yield*/, this.storageConnectionService.list(filter)];
@@ -5524,7 +5567,7 @@ var StoragePublicService = /** @class */ (function () {
5524
5567
  }
5525
5568
  });
5526
5569
  }); }, {
5527
- requestId: requestId,
5570
+ methodName: methodName,
5528
5571
  clientId: clientId,
5529
5572
  storageName: storageName,
5530
5573
  agentName: "",
@@ -5539,17 +5582,17 @@ var StoragePublicService = /** @class */ (function () {
5539
5582
  * Clears all items from the storage.
5540
5583
  * @returns {Promise<void>}
5541
5584
  */
5542
- this.clear = function (requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
5585
+ this.clear = function (methodName, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
5543
5586
  var _this = this;
5544
5587
  return __generator(this, function (_a) {
5545
5588
  switch (_a.label) {
5546
5589
  case 0:
5547
5590
  this.loggerService.log("storagePublicService clear", {
5548
- requestId: requestId,
5591
+ methodName: methodName,
5549
5592
  clientId: clientId,
5550
5593
  storageName: storageName,
5551
5594
  });
5552
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
5595
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
5553
5596
  return __generator(this, function (_a) {
5554
5597
  switch (_a.label) {
5555
5598
  case 0: return [4 /*yield*/, this.storageConnectionService.clear()];
@@ -5557,7 +5600,7 @@ var StoragePublicService = /** @class */ (function () {
5557
5600
  }
5558
5601
  });
5559
5602
  }); }, {
5560
- requestId: requestId,
5603
+ methodName: methodName,
5561
5604
  clientId: clientId,
5562
5605
  storageName: storageName,
5563
5606
  agentName: "",
@@ -5574,7 +5617,7 @@ var StoragePublicService = /** @class */ (function () {
5574
5617
  * @param {StorageName} storageName - The storage name.
5575
5618
  * @returns {Promise<void>}
5576
5619
  */
5577
- this.dispose = function (requestId, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
5620
+ this.dispose = function (methodName, clientId, storageName) { return __awaiter(_this, void 0, void 0, function () {
5578
5621
  var _this = this;
5579
5622
  return __generator(this, function (_a) {
5580
5623
  switch (_a.label) {
@@ -5583,7 +5626,7 @@ var StoragePublicService = /** @class */ (function () {
5583
5626
  clientId: clientId,
5584
5627
  storageName: storageName,
5585
5628
  });
5586
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
5629
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
5587
5630
  return __generator(this, function (_a) {
5588
5631
  switch (_a.label) {
5589
5632
  case 0: return [4 /*yield*/, this.storageConnectionService.dispose()];
@@ -5591,7 +5634,7 @@ var StoragePublicService = /** @class */ (function () {
5591
5634
  }
5592
5635
  });
5593
5636
  }); }, {
5594
- requestId: requestId,
5637
+ methodName: methodName,
5595
5638
  clientId: clientId,
5596
5639
  storageName: storageName,
5597
5640
  agentName: "",
@@ -5929,7 +5972,7 @@ var StateConnectionService = /** @class */ (function () {
5929
5972
  var _this = this;
5930
5973
  this.loggerService = inject(TYPES.loggerService);
5931
5974
  this.busService = inject(TYPES.busService);
5932
- this.contextService = inject(TYPES.contextService);
5975
+ this.methodContextService = inject(TYPES.methodContextService);
5933
5976
  this.stateSchemaService = inject(TYPES.stateSchemaService);
5934
5977
  this.sessionValidationService = inject(TYPES.sessionValidationService);
5935
5978
  /**
@@ -6021,7 +6064,7 @@ var StateConnectionService = /** @class */ (function () {
6021
6064
  switch (_a.label) {
6022
6065
  case 0:
6023
6066
  this.loggerService.log("stateConnectionService setState");
6024
- state = this.getStateRef(this.contextService.context.clientId, this.contextService.context.stateName);
6067
+ state = this.getStateRef(this.methodContextService.context.clientId, this.methodContextService.context.stateName);
6025
6068
  return [4 /*yield*/, state.waitForInit()];
6026
6069
  case 1:
6027
6070
  _a.sent();
@@ -6040,7 +6083,7 @@ var StateConnectionService = /** @class */ (function () {
6040
6083
  switch (_a.label) {
6041
6084
  case 0:
6042
6085
  this.loggerService.log("stateConnectionService getState");
6043
- state = this.getStateRef(this.contextService.context.clientId, this.contextService.context.stateName);
6086
+ state = this.getStateRef(this.methodContextService.context.clientId, this.methodContextService.context.stateName);
6044
6087
  return [4 /*yield*/, state.waitForInit()];
6045
6088
  case 1:
6046
6089
  _a.sent();
@@ -6059,12 +6102,12 @@ var StateConnectionService = /** @class */ (function () {
6059
6102
  switch (_a.label) {
6060
6103
  case 0:
6061
6104
  this.loggerService.log("stateConnectionService dispose");
6062
- key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.stateName);
6105
+ key = "".concat(this.methodContextService.context.clientId, "-").concat(this.methodContextService.context.stateName);
6063
6106
  if (!this.getStateRef.has(key)) {
6064
6107
  return [2 /*return*/];
6065
6108
  }
6066
- if (!!this.getSharedStateRef.has(this.contextService.context.stateName)) return [3 /*break*/, 3];
6067
- state = this.getStateRef(this.contextService.context.clientId, this.contextService.context.stateName);
6109
+ if (!!this.getSharedStateRef.has(this.methodContextService.context.stateName)) return [3 /*break*/, 3];
6110
+ state = this.getStateRef(this.methodContextService.context.clientId, this.methodContextService.context.stateName);
6068
6111
  return [4 /*yield*/, state.waitForInit()];
6069
6112
  case 1:
6070
6113
  _a.sent();
@@ -6074,7 +6117,7 @@ var StateConnectionService = /** @class */ (function () {
6074
6117
  _a.label = 3;
6075
6118
  case 3:
6076
6119
  this.getStateRef.clear(key);
6077
- this.sessionValidationService.removeStateUsage(this.contextService.context.clientId, this.contextService.context.stateName);
6120
+ this.sessionValidationService.removeStateUsage(this.methodContextService.context.clientId, this.methodContextService.context.stateName);
6078
6121
  return [2 /*return*/];
6079
6122
  }
6080
6123
  });
@@ -6095,17 +6138,17 @@ var StatePublicService = /** @class */ (function () {
6095
6138
  * @param {StateName} stateName - The name of the state.
6096
6139
  * @returns {Promise<T>} - The updated state.
6097
6140
  */
6098
- this.setState = function (dispatchFn, requestId, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
6141
+ this.setState = function (dispatchFn, methodName, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
6099
6142
  var _this = this;
6100
6143
  return __generator(this, function (_a) {
6101
6144
  switch (_a.label) {
6102
6145
  case 0:
6103
6146
  this.loggerService.log("statePublicService setState", {
6104
- requestId: requestId,
6147
+ methodName: methodName,
6105
6148
  clientId: clientId,
6106
6149
  stateName: stateName,
6107
6150
  });
6108
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
6151
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
6109
6152
  return __generator(this, function (_a) {
6110
6153
  switch (_a.label) {
6111
6154
  case 0: return [4 /*yield*/, this.stateConnectionService.setState(dispatchFn)];
@@ -6113,7 +6156,7 @@ var StatePublicService = /** @class */ (function () {
6113
6156
  }
6114
6157
  });
6115
6158
  }); }, {
6116
- requestId: requestId,
6159
+ methodName: methodName,
6117
6160
  clientId: clientId,
6118
6161
  stateName: stateName,
6119
6162
  agentName: "",
@@ -6130,7 +6173,7 @@ var StatePublicService = /** @class */ (function () {
6130
6173
  * @param {StateName} stateName - The name of the state.
6131
6174
  * @returns {Promise<T>} - The current state.
6132
6175
  */
6133
- this.getState = function (requestId, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
6176
+ this.getState = function (methodName, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
6134
6177
  var _this = this;
6135
6178
  return __generator(this, function (_a) {
6136
6179
  switch (_a.label) {
@@ -6139,7 +6182,7 @@ var StatePublicService = /** @class */ (function () {
6139
6182
  clientId: clientId,
6140
6183
  stateName: stateName,
6141
6184
  });
6142
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
6185
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
6143
6186
  return __generator(this, function (_a) {
6144
6187
  switch (_a.label) {
6145
6188
  case 0: return [4 /*yield*/, this.stateConnectionService.getState()];
@@ -6147,7 +6190,7 @@ var StatePublicService = /** @class */ (function () {
6147
6190
  }
6148
6191
  });
6149
6192
  }); }, {
6150
- requestId: requestId,
6193
+ methodName: methodName,
6151
6194
  clientId: clientId,
6152
6195
  stateName: stateName,
6153
6196
  agentName: "",
@@ -6164,17 +6207,17 @@ var StatePublicService = /** @class */ (function () {
6164
6207
  * @param {StateName} stateName - The name of the state.
6165
6208
  * @returns {Promise<void>} - A promise that resolves when the state is disposed.
6166
6209
  */
6167
- this.dispose = function (requestId, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
6210
+ this.dispose = function (methodName, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
6168
6211
  var _this = this;
6169
6212
  return __generator(this, function (_a) {
6170
6213
  switch (_a.label) {
6171
6214
  case 0:
6172
6215
  this.loggerService.log("statePublicService dispose", {
6173
- requestId: requestId,
6216
+ methodName: methodName,
6174
6217
  clientId: clientId,
6175
6218
  stateName: stateName,
6176
6219
  });
6177
- return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
6220
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
6178
6221
  return __generator(this, function (_a) {
6179
6222
  switch (_a.label) {
6180
6223
  case 0: return [4 /*yield*/, this.stateConnectionService.dispose()];
@@ -6182,7 +6225,7 @@ var StatePublicService = /** @class */ (function () {
6182
6225
  }
6183
6226
  });
6184
6227
  }); }, {
6185
- requestId: requestId,
6228
+ methodName: methodName,
6186
6229
  clientId: clientId,
6187
6230
  stateName: stateName,
6188
6231
  agentName: "",
@@ -6310,7 +6353,10 @@ var BusService = /** @class */ (function () {
6310
6353
  {
6311
6354
  provide(TYPES.busService, function () { return new BusService(); });
6312
6355
  provide(TYPES.loggerService, function () { return new LoggerService(); });
6313
- provide(TYPES.contextService, function () { return new ContextService(); });
6356
+ }
6357
+ {
6358
+ provide(TYPES.methodContextService, function () { return new MethodContextService(); });
6359
+ provide(TYPES.executionContextService, function () { return new ExecutionContextService(); });
6314
6360
  }
6315
6361
  {
6316
6362
  provide(TYPES.agentConnectionService, function () { return new AgentConnectionService(); });
@@ -6356,7 +6402,10 @@ var BusService = /** @class */ (function () {
6356
6402
  var baseServices = {
6357
6403
  busService: inject(TYPES.busService),
6358
6404
  loggerService: inject(TYPES.loggerService),
6359
- contextService: inject(TYPES.contextService),
6405
+ };
6406
+ var contextServices = {
6407
+ methodContextService: inject(TYPES.methodContextService),
6408
+ executionContextService: inject(TYPES.executionContextService),
6360
6409
  };
6361
6410
  var connectionServices = {
6362
6411
  agentConnectionService: inject(TYPES.agentConnectionService),
@@ -6392,7 +6441,7 @@ var validationServices = {
6392
6441
  storageValidationService: inject(TYPES.storageValidationService),
6393
6442
  embeddingValidationService: inject(TYPES.embeddingValidationService),
6394
6443
  };
6395
- var swarm = __assign(__assign(__assign(__assign(__assign({}, baseServices), connectionServices), schemaServices), publicServices), validationServices);
6444
+ var swarm = __assign(__assign(__assign(__assign(__assign(__assign({}, baseServices), contextServices), connectionServices), schemaServices), publicServices), validationServices);
6396
6445
  init();
6397
6446
 
6398
6447
  /**
@@ -6520,22 +6569,21 @@ var addStorage = function (storageSchema) {
6520
6569
  * @returns {Promise<void>} - A promise that resolves when the message is committed.
6521
6570
  */
6522
6571
  var commitUserMessage = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
6523
- var requestId, swarmName, currentAgentName;
6572
+ var methodName, swarmName, currentAgentName;
6524
6573
  return __generator(this, function (_a) {
6525
6574
  switch (_a.label) {
6526
6575
  case 0:
6527
- requestId = randomString();
6576
+ methodName = 'function commitSystemMessage';
6528
6577
  swarm.loggerService.log('function commitSystemMessage', {
6529
6578
  content: content,
6530
6579
  clientId: clientId,
6531
6580
  agentName: agentName,
6532
- requestId: requestId,
6533
6581
  });
6534
6582
  swarm.agentValidationService.validate(agentName, "commitUserMessage");
6535
6583
  swarm.sessionValidationService.validate(clientId, "commitUserMessage");
6536
6584
  swarmName = swarm.sessionValidationService.getSwarm(clientId);
6537
6585
  swarm.swarmValidationService.validate(swarmName, "commitUserMessage");
6538
- return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
6586
+ return [4 /*yield*/, swarm.swarmPublicService.getAgentName(methodName, clientId, swarmName)];
6539
6587
  case 1:
6540
6588
  currentAgentName = _a.sent();
6541
6589
  if (currentAgentName !== agentName) {
@@ -6546,7 +6594,7 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
6546
6594
  });
6547
6595
  return [2 /*return*/];
6548
6596
  }
6549
- return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, requestId, clientId, swarmName)];
6597
+ return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, methodName, clientId, swarmName)];
6550
6598
  case 2:
6551
6599
  _a.sent();
6552
6600
  return [2 /*return*/];
@@ -6562,19 +6610,18 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
6562
6610
  * @throws Will throw an error if the client ID is invalid or if the swarm validation fails.
6563
6611
  */
6564
6612
  var getAgentName = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
6565
- var requestId, swarmName;
6613
+ var methodName, swarmName;
6566
6614
  return __generator(this, function (_a) {
6567
6615
  switch (_a.label) {
6568
6616
  case 0:
6569
- requestId = randomString();
6617
+ methodName = "function getAgentName";
6570
6618
  swarm.loggerService.log("function getAgentName", {
6571
6619
  clientId: clientId,
6572
- requestId: requestId,
6573
6620
  });
6574
6621
  swarm.sessionValidationService.validate(clientId, "getAgentName");
6575
6622
  swarmName = swarm.sessionValidationService.getSwarm(clientId);
6576
6623
  swarm.swarmValidationService.validate(swarmName, "getAgentName");
6577
- return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
6624
+ return [4 /*yield*/, swarm.swarmPublicService.getAgentName(methodName, clientId, swarmName)];
6578
6625
  case 1: return [2 /*return*/, _a.sent()];
6579
6626
  }
6580
6627
  });
@@ -6590,15 +6637,14 @@ var SCHEDULED_DELAY$1 = 1000;
6590
6637
  * @returns {SendMessageFn} - A function to send messages to the swarm.
6591
6638
  */
6592
6639
  var makeConnection = function (connector, clientId, swarmName) {
6593
- var requestId = randomString();
6640
+ var methodName = "function makeConnection";
6594
6641
  swarm.loggerService.log("function makeConnection", {
6595
6642
  clientId: clientId,
6596
6643
  swarmName: swarmName,
6597
- requestId: requestId,
6598
6644
  });
6599
6645
  swarm.swarmValidationService.validate(swarmName, "makeConnection");
6600
6646
  swarm.sessionValidationService.addSession(clientId, swarmName, "makeConnection");
6601
- var send = swarm.sessionPublicService.connect(connector, requestId, clientId, swarmName);
6647
+ var send = swarm.sessionPublicService.connect(connector, methodName, clientId, swarmName);
6602
6648
  return queued(function (outgoing) { return __awaiter(void 0, void 0, void 0, function () {
6603
6649
  var _a;
6604
6650
  var _b;
@@ -6610,7 +6656,7 @@ var makeConnection = function (connector, clientId, swarmName) {
6610
6656
  _b = {
6611
6657
  data: outgoing
6612
6658
  };
6613
- return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
6659
+ return [4 /*yield*/, swarm.swarmPublicService.getAgentName(methodName, clientId, swarmName)];
6614
6660
  case 1: return [4 /*yield*/, _a.apply(void 0, [(_b.agentName = _c.sent(),
6615
6661
  _b.clientId = clientId,
6616
6662
  _b)])];
@@ -6713,7 +6759,7 @@ var CHANGE_AGENT_GC = 60 * 1000;
6713
6759
  * @returns {TChangeAgentRun} - The change agent function.
6714
6760
  */
6715
6761
  var createChangeAgent = ttl(function (clientId) {
6716
- return queued(function (requestId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
6762
+ return queued(function (methodName, agentName) { return __awaiter(void 0, void 0, void 0, function () {
6717
6763
  var swarmName, _a, _b, _c;
6718
6764
  return __generator(this, function (_d) {
6719
6765
  switch (_d.label) {
@@ -6726,7 +6772,7 @@ var createChangeAgent = ttl(function (clientId) {
6726
6772
  .map(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
6727
6773
  return __generator(this, function (_a) {
6728
6774
  switch (_a.label) {
6729
- case 0: return [4 /*yield*/, swarm.agentPublicService.commitAgentChange(requestId, clientId, agentName)];
6775
+ case 0: return [4 /*yield*/, swarm.agentPublicService.commitAgentChange(methodName, clientId, agentName)];
6730
6776
  case 1:
6731
6777
  _a.sent();
6732
6778
  return [2 /*return*/];
@@ -6735,22 +6781,22 @@ var createChangeAgent = ttl(function (clientId) {
6735
6781
  }); }))];
6736
6782
  case 1:
6737
6783
  _d.sent();
6738
- return [4 /*yield*/, swarm.agentPublicService.dispose(requestId, clientId, agentName)];
6784
+ return [4 /*yield*/, swarm.agentPublicService.dispose(methodName, clientId, agentName)];
6739
6785
  case 2:
6740
6786
  _d.sent();
6741
- return [4 /*yield*/, swarm.historyPublicService.dispose(requestId, clientId, agentName)];
6787
+ return [4 /*yield*/, swarm.historyPublicService.dispose(methodName, clientId, agentName)];
6742
6788
  case 3:
6743
6789
  _d.sent();
6744
6790
  _b = (_a = swarm.swarmPublicService).setAgentRef;
6745
- _c = [requestId,
6791
+ _c = [methodName,
6746
6792
  clientId,
6747
6793
  swarmName,
6748
6794
  agentName];
6749
- return [4 /*yield*/, swarm.agentPublicService.createAgentRef(requestId, clientId, agentName)];
6795
+ return [4 /*yield*/, swarm.agentPublicService.createAgentRef(methodName, clientId, agentName)];
6750
6796
  case 4: return [4 /*yield*/, _b.apply(_a, _c.concat([_d.sent()]))];
6751
6797
  case 5:
6752
6798
  _d.sent();
6753
- return [4 /*yield*/, swarm.swarmPublicService.setAgentName(agentName, requestId, clientId, swarmName)];
6799
+ return [4 /*yield*/, swarm.swarmPublicService.setAgentName(agentName, methodName, clientId, swarmName)];
6754
6800
  case 6:
6755
6801
  _d.sent();
6756
6802
  return [2 /*return*/];
@@ -6784,11 +6830,11 @@ var createGc$1 = singleshot(function () { return __awaiter(void 0, void 0, void
6784
6830
  * @returns {Promise<void>} - A promise that resolves when the agent is changed.
6785
6831
  */
6786
6832
  var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void 0, void 0, function () {
6787
- var requestId, run;
6833
+ var methodName, run;
6788
6834
  return __generator(this, function (_a) {
6789
6835
  switch (_a.label) {
6790
6836
  case 0:
6791
- requestId = randomString();
6837
+ methodName = "function changeAgent";
6792
6838
  swarm.loggerService.log("function changeAgent", {
6793
6839
  agentName: agentName,
6794
6840
  clientId: clientId,
@@ -6797,7 +6843,7 @@ var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void
6797
6843
  case 1:
6798
6844
  run = _a.sent();
6799
6845
  createGc$1();
6800
- return [4 /*yield*/, run(requestId, agentName)];
6846
+ return [4 /*yield*/, run(methodName, agentName)];
6801
6847
  case 2: return [2 /*return*/, _a.sent()];
6802
6848
  }
6803
6849
  });
@@ -6815,23 +6861,22 @@ var disposeConnection = function (clientId_1, swarmName_1) {
6815
6861
  for (var _i = 2; _i < arguments.length; _i++) {
6816
6862
  args_1[_i - 2] = arguments[_i];
6817
6863
  }
6818
- return __awaiter(void 0, __spreadArray([clientId_1, swarmName_1], __read(args_1), false), void 0, function (clientId, swarmName, requestId) {
6819
- if (requestId === void 0) { requestId = randomString(); }
6864
+ return __awaiter(void 0, __spreadArray([clientId_1, swarmName_1], __read(args_1), false), void 0, function (clientId, swarmName, methodName) {
6865
+ if (methodName === void 0) { methodName = "function disposeConnection"; }
6820
6866
  return __generator(this, function (_a) {
6821
6867
  switch (_a.label) {
6822
6868
  case 0:
6823
6869
  swarm.loggerService.log("function disposeConnection", {
6824
6870
  clientId: clientId,
6825
6871
  swarmName: swarmName,
6826
- requestId: requestId,
6827
6872
  });
6828
6873
  swarm.swarmValidationService.validate(swarmName, "disposeConnection");
6829
6874
  swarm.sessionValidationService.removeSession(clientId);
6830
6875
  swarm.busService.dispose(clientId);
6831
- return [4 /*yield*/, swarm.sessionPublicService.dispose(requestId, clientId, swarmName)];
6876
+ return [4 /*yield*/, swarm.sessionPublicService.dispose(methodName, clientId, swarmName)];
6832
6877
  case 1:
6833
6878
  _a.sent();
6834
- return [4 /*yield*/, swarm.swarmPublicService.dispose(requestId, clientId, swarmName)];
6879
+ return [4 /*yield*/, swarm.swarmPublicService.dispose(methodName, clientId, swarmName)];
6835
6880
  case 2:
6836
6881
  _a.sent();
6837
6882
  return [4 /*yield*/, Promise.all(swarm.swarmValidationService
@@ -6839,10 +6884,10 @@ var disposeConnection = function (clientId_1, swarmName_1) {
6839
6884
  .map(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
6840
6885
  return __generator(this, function (_a) {
6841
6886
  switch (_a.label) {
6842
- case 0: return [4 /*yield*/, swarm.agentPublicService.dispose(requestId, clientId, agentName)];
6887
+ case 0: return [4 /*yield*/, swarm.agentPublicService.dispose(methodName, clientId, agentName)];
6843
6888
  case 1:
6844
6889
  _a.sent();
6845
- return [4 /*yield*/, swarm.historyPublicService.dispose(requestId, clientId, agentName)];
6890
+ return [4 /*yield*/, swarm.historyPublicService.dispose(methodName, clientId, agentName)];
6846
6891
  case 2:
6847
6892
  _a.sent();
6848
6893
  return [2 /*return*/];
@@ -6860,7 +6905,7 @@ var disposeConnection = function (clientId_1, swarmName_1) {
6860
6905
  .map(function (storageName) { return __awaiter(void 0, void 0, void 0, function () {
6861
6906
  return __generator(this, function (_a) {
6862
6907
  switch (_a.label) {
6863
- case 0: return [4 /*yield*/, swarm.storagePublicService.dispose(requestId, clientId, storageName)];
6908
+ case 0: return [4 /*yield*/, swarm.storagePublicService.dispose(methodName, clientId, storageName)];
6864
6909
  case 1:
6865
6910
  _a.sent();
6866
6911
  return [2 /*return*/];
@@ -6878,7 +6923,7 @@ var disposeConnection = function (clientId_1, swarmName_1) {
6878
6923
  .map(function (stateName) { return __awaiter(void 0, void 0, void 0, function () {
6879
6924
  return __generator(this, function (_a) {
6880
6925
  switch (_a.label) {
6881
- case 0: return [4 /*yield*/, swarm.statePublicService.dispose(requestId, clientId, stateName)];
6926
+ case 0: return [4 /*yield*/, swarm.statePublicService.dispose(methodName, clientId, stateName)];
6882
6927
  case 1:
6883
6928
  _a.sent();
6884
6929
  return [2 /*return*/];
@@ -6905,17 +6950,17 @@ var COMPLETE_GC = 60 * 1000;
6905
6950
  * @returns {TCompleteRun} The complete run function.
6906
6951
  */
6907
6952
  var createComplete = ttl(function (clientId, swarmName) {
6908
- return queued(function (requestId, content) { return __awaiter(void 0, void 0, void 0, function () {
6953
+ return queued(function (methodName, content) { return __awaiter(void 0, void 0, void 0, function () {
6909
6954
  var result;
6910
6955
  return __generator(this, function (_a) {
6911
6956
  switch (_a.label) {
6912
6957
  case 0:
6913
6958
  swarm.swarmValidationService.validate(swarmName, "complete");
6914
6959
  swarm.sessionValidationService.addSession(clientId, swarmName, "complete");
6915
- return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", requestId, clientId, swarmName)];
6960
+ return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", methodName, clientId, swarmName)];
6916
6961
  case 1:
6917
6962
  result = _a.sent();
6918
- return [4 /*yield*/, disposeConnection(clientId, swarmName, requestId)];
6963
+ return [4 /*yield*/, disposeConnection(clientId, swarmName, methodName)];
6919
6964
  case 2:
6920
6965
  _a.sent();
6921
6966
  return [2 /*return*/, result];
@@ -6949,23 +6994,33 @@ var createGc = singleshot(function () { return __awaiter(void 0, void 0, void 0,
6949
6994
  * @returns {Promise<string>} The result of the complete function.
6950
6995
  */
6951
6996
  var complete = function (content, clientId, swarmName) { return __awaiter(void 0, void 0, void 0, function () {
6952
- var requestId, run;
6997
+ var methodName, executionId, run;
6953
6998
  return __generator(this, function (_a) {
6954
6999
  switch (_a.label) {
6955
7000
  case 0:
6956
- requestId = randomString();
7001
+ methodName = "function complete";
7002
+ executionId = randomString();
6957
7003
  swarm.loggerService.log("function complete", {
6958
7004
  content: content,
6959
7005
  clientId: clientId,
7006
+ executionId: executionId,
6960
7007
  swarmName: swarmName,
6961
- requestId: requestId,
6962
7008
  });
6963
7009
  return [4 /*yield*/, createComplete(clientId, swarmName)];
6964
7010
  case 1:
6965
7011
  run = _a.sent();
6966
7012
  createGc();
6967
- return [4 /*yield*/, run(requestId, content)];
6968
- case 2: return [2 /*return*/, _a.sent()];
7013
+ return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(void 0, void 0, void 0, function () {
7014
+ return __generator(this, function (_a) {
7015
+ switch (_a.label) {
7016
+ case 0: return [4 /*yield*/, run(methodName, content)];
7017
+ case 1: return [2 /*return*/, _a.sent()];
7018
+ }
7019
+ });
7020
+ }); }, {
7021
+ clientId: clientId,
7022
+ executionId: executionId,
7023
+ })];
6969
7024
  }
6970
7025
  });
6971
7026
  }); };
@@ -6981,11 +7036,12 @@ var SCHEDULED_DELAY = 1000;
6981
7036
  * @returns {Function} dispose - A function to dispose of the session.
6982
7037
  */
6983
7038
  var session = function (clientId, swarmName) {
6984
- var requestId = randomString();
7039
+ var methodName = "function session";
7040
+ var executionId = randomString();
6985
7041
  swarm.loggerService.log("function session", {
6986
7042
  clientId: clientId,
6987
7043
  swarmName: swarmName,
6988
- requestId: requestId,
7044
+ executionId: executionId,
6989
7045
  });
6990
7046
  swarm.swarmValidationService.validate(swarmName, "session");
6991
7047
  swarm.sessionValidationService.addSession(clientId, swarmName, "session");
@@ -6998,12 +7054,18 @@ var session = function (clientId, swarmName) {
6998
7054
  */
6999
7055
  complete: queued(function (content) { return __awaiter(void 0, void 0, void 0, function () {
7000
7056
  return __generator(this, function (_a) {
7001
- switch (_a.label) {
7002
- case 0:
7003
- swarm.sessionValidationService.validate(clientId, "session");
7004
- return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", requestId, clientId, swarmName)];
7005
- case 1: return [2 /*return*/, _a.sent()];
7006
- }
7057
+ swarm.sessionValidationService.validate(clientId, "session");
7058
+ return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(void 0, void 0, void 0, function () {
7059
+ return __generator(this, function (_a) {
7060
+ switch (_a.label) {
7061
+ case 0: return [4 /*yield*/, swarm.sessionPublicService.execute(content, "user", methodName, clientId, swarmName)];
7062
+ case 1: return [2 /*return*/, _a.sent()];
7063
+ }
7064
+ });
7065
+ }); }, {
7066
+ clientId: clientId,
7067
+ executionId: executionId,
7068
+ })];
7007
7069
  });
7008
7070
  }); }),
7009
7071
  /**
@@ -7014,7 +7076,7 @@ var session = function (clientId, swarmName) {
7014
7076
  dispose: function () { return __awaiter(void 0, void 0, void 0, function () {
7015
7077
  return __generator(this, function (_a) {
7016
7078
  switch (_a.label) {
7017
- case 0: return [4 /*yield*/, disposeConnection(clientId, swarmName, requestId)];
7079
+ case 0: return [4 /*yield*/, disposeConnection(clientId, swarmName, methodName)];
7018
7080
  case 1: return [2 /*return*/, _a.sent()];
7019
7081
  }
7020
7082
  });
@@ -7124,23 +7186,22 @@ var getRawHistory = function (clientId_1) {
7124
7186
  for (var _i = 1; _i < arguments.length; _i++) {
7125
7187
  args_1[_i - 1] = arguments[_i];
7126
7188
  }
7127
- return __awaiter(void 0, __spreadArray([clientId_1], __read(args_1), false), void 0, function (clientId, requestId) {
7189
+ return __awaiter(void 0, __spreadArray([clientId_1], __read(args_1), false), void 0, function (clientId, methodName) {
7128
7190
  var swarmName, agentName, history;
7129
- if (requestId === void 0) { requestId = randomString(); }
7191
+ if (methodName === void 0) { methodName = "function getRawHistory"; }
7130
7192
  return __generator(this, function (_a) {
7131
7193
  switch (_a.label) {
7132
7194
  case 0:
7133
7195
  swarm.loggerService.log("function getRawHistory", {
7134
7196
  clientId: clientId,
7135
- requestId: requestId,
7136
7197
  });
7137
7198
  swarm.sessionValidationService.validate(clientId, "getRawHistory");
7138
7199
  swarmName = swarm.sessionValidationService.getSwarm(clientId);
7139
7200
  swarm.swarmValidationService.validate(swarmName, "getRawHistory");
7140
- return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
7201
+ return [4 /*yield*/, swarm.swarmPublicService.getAgentName(methodName, clientId, swarmName)];
7141
7202
  case 1:
7142
7203
  agentName = _a.sent();
7143
- return [4 /*yield*/, swarm.historyPublicService.toArrayForRaw(requestId, clientId, agentName)];
7204
+ return [4 /*yield*/, swarm.historyPublicService.toArrayForRaw(methodName, clientId, agentName)];
7144
7205
  case 2:
7145
7206
  history = _a.sent();
7146
7207
  return [2 /*return*/, __spreadArray([], __read(history), false)];
@@ -7157,19 +7218,18 @@ var getRawHistory = function (clientId_1) {
7157
7218
  * @returns {Promise<Array>} - A promise that resolves to an array containing the agent's history.
7158
7219
  */
7159
7220
  var getAgentHistory = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
7160
- var requestId, prompt, history;
7221
+ var methodName, prompt, history;
7161
7222
  return __generator(this, function (_a) {
7162
7223
  switch (_a.label) {
7163
7224
  case 0:
7164
- requestId = randomString();
7225
+ methodName = "function getAgentHistory";
7165
7226
  swarm.loggerService.log("function getAgentHistory", {
7166
7227
  clientId: clientId,
7167
7228
  agentName: agentName,
7168
- requestId: requestId,
7169
7229
  });
7170
7230
  swarm.agentValidationService.validate(agentName, "getAgentHistory");
7171
7231
  prompt = swarm.agentSchemaService.get(agentName).prompt;
7172
- return [4 /*yield*/, swarm.historyPublicService.toArrayForAgent(prompt, requestId, clientId, agentName)];
7232
+ return [4 /*yield*/, swarm.historyPublicService.toArrayForAgent(prompt, methodName, clientId, agentName)];
7173
7233
  case 1:
7174
7234
  history = _a.sent();
7175
7235
  return [2 /*return*/, __spreadArray([], __read(history), false)];
@@ -7203,23 +7263,23 @@ var getSessionMode = function (clientId) { return __awaiter(void 0, void 0, void
7203
7263
  * @returns {Promise<void>} - A promise that resolves when the operation is complete.
7204
7264
  */
7205
7265
  var commitToolOutput = function (toolId, content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
7206
- var requestId, swarmName, currentAgentName;
7266
+ var methodName, swarmName, currentAgentName;
7207
7267
  return __generator(this, function (_a) {
7208
7268
  switch (_a.label) {
7209
7269
  case 0:
7210
- requestId = randomString();
7270
+ methodName = 'function commitToolOutput';
7211
7271
  swarm.loggerService.log('function commitToolOutput', {
7212
7272
  toolId: toolId,
7213
7273
  content: content,
7214
7274
  clientId: clientId,
7215
7275
  agentName: agentName,
7216
- requestId: requestId,
7276
+ methodName: methodName,
7217
7277
  });
7218
7278
  swarm.agentValidationService.validate(agentName, "commitSystemMessage");
7219
7279
  swarm.sessionValidationService.validate(clientId, "commitToolOutput");
7220
7280
  swarmName = swarm.sessionValidationService.getSwarm(clientId);
7221
7281
  swarm.swarmValidationService.validate(swarmName, "commitToolOutput");
7222
- return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
7282
+ return [4 /*yield*/, swarm.swarmPublicService.getAgentName(methodName, clientId, swarmName)];
7223
7283
  case 1:
7224
7284
  currentAgentName = _a.sent();
7225
7285
  if (currentAgentName !== agentName) {
@@ -7231,7 +7291,7 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
7231
7291
  });
7232
7292
  return [2 /*return*/];
7233
7293
  }
7234
- return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, requestId, clientId, swarmName)];
7294
+ return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, methodName, clientId, swarmName)];
7235
7295
  case 2:
7236
7296
  _a.sent();
7237
7297
  return [2 /*return*/];
@@ -7248,22 +7308,21 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
7248
7308
  * @returns {Promise<void>} - A promise that resolves when the message is committed.
7249
7309
  */
7250
7310
  var commitSystemMessage = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
7251
- var requestId, swarmName, currentAgentName;
7311
+ var methodName, swarmName, currentAgentName;
7252
7312
  return __generator(this, function (_a) {
7253
7313
  switch (_a.label) {
7254
7314
  case 0:
7255
- requestId = randomString();
7315
+ methodName = 'function commitSystemMessage';
7256
7316
  swarm.loggerService.log('function commitSystemMessage', {
7257
7317
  content: content,
7258
7318
  clientId: clientId,
7259
7319
  agentName: agentName,
7260
- requestId: requestId,
7261
7320
  });
7262
7321
  swarm.agentValidationService.validate(agentName, "commitSystemMessage");
7263
7322
  swarm.sessionValidationService.validate(clientId, "commitSystemMessage");
7264
7323
  swarmName = swarm.sessionValidationService.getSwarm(clientId);
7265
7324
  swarm.swarmValidationService.validate(swarmName, "commitSystemMessage");
7266
- return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
7325
+ return [4 /*yield*/, swarm.swarmPublicService.getAgentName(methodName, clientId, swarmName)];
7267
7326
  case 1:
7268
7327
  currentAgentName = _a.sent();
7269
7328
  if (currentAgentName !== agentName) {
@@ -7274,7 +7333,7 @@ var commitSystemMessage = function (content, clientId, agentName) { return __awa
7274
7333
  });
7275
7334
  return [2 /*return*/];
7276
7335
  }
7277
- return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, requestId, clientId, swarmName)];
7336
+ return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, methodName, clientId, swarmName)];
7278
7337
  case 2:
7279
7338
  _a.sent();
7280
7339
  return [2 /*return*/];
@@ -7290,21 +7349,20 @@ var commitSystemMessage = function (content, clientId, agentName) { return __awa
7290
7349
  * @returns {Promise<void>} - A promise that resolves when the message is committed.
7291
7350
  */
7292
7351
  var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
7293
- var requestId, swarmName, currentAgentName;
7352
+ var methodName, swarmName, currentAgentName;
7294
7353
  return __generator(this, function (_a) {
7295
7354
  switch (_a.label) {
7296
7355
  case 0:
7297
- requestId = randomString();
7356
+ methodName = 'function commitFlush';
7298
7357
  swarm.loggerService.log('function commitFlush', {
7299
7358
  clientId: clientId,
7300
7359
  agentName: agentName,
7301
- requestId: requestId,
7302
7360
  });
7303
7361
  swarm.agentValidationService.validate(agentName, "commitFlush");
7304
7362
  swarm.sessionValidationService.validate(clientId, "commitFlush");
7305
7363
  swarmName = swarm.sessionValidationService.getSwarm(clientId);
7306
7364
  swarm.swarmValidationService.validate(swarmName, "commitFlush");
7307
- return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
7365
+ return [4 /*yield*/, swarm.swarmPublicService.getAgentName(methodName, clientId, swarmName)];
7308
7366
  case 1:
7309
7367
  currentAgentName = _a.sent();
7310
7368
  if (currentAgentName !== agentName) {
@@ -7315,7 +7373,7 @@ var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void
7315
7373
  });
7316
7374
  return [2 /*return*/];
7317
7375
  }
7318
- return [4 /*yield*/, swarm.sessionPublicService.commitFlush(requestId, clientId, swarmName)];
7376
+ return [4 /*yield*/, swarm.sessionPublicService.commitFlush(methodName, clientId, swarmName)];
7319
7377
  case 2:
7320
7378
  _a.sent();
7321
7379
  return [2 /*return*/];
@@ -7333,22 +7391,24 @@ var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void
7333
7391
  * @returns {Promise<void>} - A promise that resolves when the execution is complete.
7334
7392
  */
7335
7393
  var execute = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
7336
- var requestId, swarmName, currentAgentName;
7394
+ var methodName, executionId, swarmName, currentAgentName;
7337
7395
  return __generator(this, function (_a) {
7338
7396
  switch (_a.label) {
7339
7397
  case 0:
7340
- requestId = randomString();
7398
+ methodName = "function execute";
7399
+ executionId = randomString();
7341
7400
  swarm.loggerService.log("function execute", {
7342
7401
  content: content,
7343
7402
  clientId: clientId,
7344
7403
  agentName: agentName,
7345
- requestId: requestId,
7404
+ methodName: methodName,
7405
+ executionId: executionId,
7346
7406
  });
7347
7407
  swarm.agentValidationService.validate(agentName, "execute");
7348
7408
  swarm.sessionValidationService.validate(clientId, "execute");
7349
7409
  swarmName = swarm.sessionValidationService.getSwarm(clientId);
7350
7410
  swarm.swarmValidationService.validate(swarmName, "execute");
7351
- return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
7411
+ return [4 /*yield*/, swarm.swarmPublicService.getAgentName(methodName, clientId, swarmName)];
7352
7412
  case 1:
7353
7413
  currentAgentName = _a.sent();
7354
7414
  if (currentAgentName !== agentName) {
@@ -7359,8 +7419,17 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
7359
7419
  });
7360
7420
  return [2 /*return*/];
7361
7421
  }
7362
- return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", requestId, clientId, swarmName)];
7363
- case 2: return [2 /*return*/, _a.sent()];
7422
+ return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(void 0, void 0, void 0, function () {
7423
+ return __generator(this, function (_a) {
7424
+ switch (_a.label) {
7425
+ case 0: return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", methodName, clientId, swarmName)];
7426
+ case 1: return [2 /*return*/, _a.sent()];
7427
+ }
7428
+ });
7429
+ }); }, {
7430
+ clientId: clientId,
7431
+ executionId: executionId,
7432
+ })];
7364
7433
  }
7365
7434
  });
7366
7435
  }); };
@@ -7376,16 +7445,15 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
7376
7445
  * @returns {Promise<void>} A promise that resolves when the content is emitted.
7377
7446
  */
7378
7447
  var emit = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
7379
- var requestId, swarmName, currentAgentName;
7448
+ var methodName, swarmName, currentAgentName;
7380
7449
  return __generator(this, function (_a) {
7381
7450
  switch (_a.label) {
7382
7451
  case 0:
7383
- requestId = randomString();
7452
+ methodName = "function emit";
7384
7453
  swarm.loggerService.log("function emit", {
7385
7454
  content: content,
7386
7455
  clientId: clientId,
7387
7456
  agentName: agentName,
7388
- requestId: requestId,
7389
7457
  });
7390
7458
  if (swarm.sessionValidationService.getSessionMode(clientId) !== "makeConnection") {
7391
7459
  throw new Error("agent-swarm-kit emit session is not makeConnection clientId=".concat(clientId));
@@ -7394,7 +7462,7 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
7394
7462
  swarm.sessionValidationService.validate(clientId, "emit");
7395
7463
  swarmName = swarm.sessionValidationService.getSwarm(clientId);
7396
7464
  swarm.swarmValidationService.validate(swarmName, "emit");
7397
- return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
7465
+ return [4 /*yield*/, swarm.swarmPublicService.getAgentName(methodName, clientId, swarmName)];
7398
7466
  case 1:
7399
7467
  currentAgentName = _a.sent();
7400
7468
  if (currentAgentName !== agentName) {
@@ -7405,7 +7473,7 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
7405
7473
  });
7406
7474
  return [2 /*return*/];
7407
7475
  }
7408
- return [4 /*yield*/, swarm.sessionPublicService.emit(content, requestId, clientId, swarmName)];
7476
+ return [4 /*yield*/, swarm.sessionPublicService.emit(content, methodName, clientId, swarmName)];
7409
7477
  case 2: return [2 /*return*/, _a.sent()];
7410
7478
  }
7411
7479
  });
@@ -7419,21 +7487,20 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
7419
7487
  * @returns {Promise<void>} - A promise that resolves when the operation is complete.
7420
7488
  */
7421
7489
  var commitToolOutputForce = function (toolId, content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
7422
- var requestId, swarmName;
7490
+ var methodName, swarmName;
7423
7491
  return __generator(this, function (_a) {
7424
7492
  switch (_a.label) {
7425
7493
  case 0:
7426
- requestId = randomString();
7494
+ methodName = 'function commitToolOutputForce';
7427
7495
  swarm.loggerService.log('function commitToolOutputForce', {
7428
7496
  toolId: toolId,
7429
7497
  content: content,
7430
7498
  clientId: clientId,
7431
- requestId: requestId,
7432
7499
  });
7433
7500
  swarm.sessionValidationService.validate(clientId, "commitToolOutputForce");
7434
7501
  swarmName = swarm.sessionValidationService.getSwarm(clientId);
7435
7502
  swarm.swarmValidationService.validate(swarmName, "commitToolOutputForce");
7436
- return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, requestId, clientId, swarmName)];
7503
+ return [4 /*yield*/, swarm.sessionPublicService.commitToolOutput(toolId, content, methodName, clientId, swarmName)];
7437
7504
  case 1:
7438
7505
  _a.sent();
7439
7506
  return [2 /*return*/];
@@ -7449,20 +7516,19 @@ var commitToolOutputForce = function (toolId, content, clientId) { return __awai
7449
7516
  * @returns {Promise<void>} - A promise that resolves when the message is committed.
7450
7517
  */
7451
7518
  var commitSystemMessageForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
7452
- var requestId, swarmName;
7519
+ var methodName, swarmName;
7453
7520
  return __generator(this, function (_a) {
7454
7521
  switch (_a.label) {
7455
7522
  case 0:
7456
- requestId = randomString();
7523
+ methodName = 'function commitSystemMessageForce';
7457
7524
  swarm.loggerService.log('function commitSystemMessageForce', {
7458
7525
  content: content,
7459
7526
  clientId: clientId,
7460
- requestId: requestId,
7461
7527
  });
7462
7528
  swarm.sessionValidationService.validate(clientId, "commitSystemMessageForce");
7463
7529
  swarmName = swarm.sessionValidationService.getSwarm(clientId);
7464
7530
  swarm.swarmValidationService.validate(swarmName, "commitSystemMessageForce");
7465
- return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, requestId, clientId, swarmName)];
7531
+ return [4 /*yield*/, swarm.sessionPublicService.commitSystemMessage(content, methodName, clientId, swarmName)];
7466
7532
  case 1:
7467
7533
  _a.sent();
7468
7534
  return [2 /*return*/];
@@ -7477,19 +7543,19 @@ var commitSystemMessageForce = function (content, clientId) { return __awaiter(v
7477
7543
  * @returns {Promise<void>} - A promise that resolves when the message is committed.
7478
7544
  */
7479
7545
  var commitFlushForce = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
7480
- var requestId, swarmName;
7546
+ var methodName, swarmName;
7481
7547
  return __generator(this, function (_a) {
7482
7548
  switch (_a.label) {
7483
7549
  case 0:
7484
- requestId = randomString();
7550
+ methodName = 'function commitFlushForce';
7485
7551
  swarm.loggerService.log('function commitFlushForce', {
7486
7552
  clientId: clientId,
7487
- requestId: requestId,
7553
+ methodName: methodName,
7488
7554
  });
7489
7555
  swarm.sessionValidationService.validate(clientId, "commitFlushForce");
7490
7556
  swarmName = swarm.sessionValidationService.getSwarm(clientId);
7491
7557
  swarm.swarmValidationService.validate(swarmName, "commitFlushForce");
7492
- return [4 /*yield*/, swarm.sessionPublicService.commitFlush(requestId, clientId, swarmName)];
7558
+ return [4 /*yield*/, swarm.sessionPublicService.commitFlush(methodName, clientId, swarmName)];
7493
7559
  case 1:
7494
7560
  _a.sent();
7495
7561
  return [2 /*return*/];
@@ -7505,20 +7571,19 @@ var commitFlushForce = function (clientId) { return __awaiter(void 0, void 0, vo
7505
7571
  * @returns {Promise<void>} - A promise that resolves when the message is committed.
7506
7572
  */
7507
7573
  var commitUserMessageForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
7508
- var requestId, swarmName;
7574
+ var methodName, swarmName;
7509
7575
  return __generator(this, function (_a) {
7510
7576
  switch (_a.label) {
7511
7577
  case 0:
7512
- requestId = randomString();
7578
+ methodName = 'function commitSystemMessage';
7513
7579
  swarm.loggerService.log('function commitSystemMessage', {
7514
7580
  content: content,
7515
7581
  clientId: clientId,
7516
- requestId: requestId,
7517
7582
  });
7518
7583
  swarm.sessionValidationService.validate(clientId, "commitUserMessageForce");
7519
7584
  swarmName = swarm.sessionValidationService.getSwarm(clientId);
7520
7585
  swarm.swarmValidationService.validate(swarmName, "commitUserMessageForce");
7521
- return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, requestId, clientId, swarmName)];
7586
+ return [4 /*yield*/, swarm.sessionPublicService.commitUserMessage(content, methodName, clientId, swarmName)];
7522
7587
  case 1:
7523
7588
  _a.sent();
7524
7589
  return [2 /*return*/];
@@ -7537,15 +7602,14 @@ var commitUserMessageForce = function (content, clientId) { return __awaiter(voi
7537
7602
  * @returns {Promise<void>} A promise that resolves when the content is emitted.
7538
7603
  */
7539
7604
  var emitForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
7540
- var requestId, swarmName;
7605
+ var methodName, swarmName;
7541
7606
  return __generator(this, function (_a) {
7542
7607
  switch (_a.label) {
7543
7608
  case 0:
7544
- requestId = randomString();
7609
+ methodName = "function emitForce";
7545
7610
  swarm.loggerService.log("function emitForce", {
7546
7611
  content: content,
7547
7612
  clientId: clientId,
7548
- requestId: requestId,
7549
7613
  });
7550
7614
  if (swarm.sessionValidationService.getSessionMode(clientId) !== "makeConnection") {
7551
7615
  throw new Error("agent-swarm-kit emitForce session is not makeConnection clientId=".concat(clientId));
@@ -7553,7 +7617,7 @@ var emitForce = function (content, clientId) { return __awaiter(void 0, void 0,
7553
7617
  swarm.sessionValidationService.validate(clientId, "emitForce");
7554
7618
  swarmName = swarm.sessionValidationService.getSwarm(clientId);
7555
7619
  swarm.swarmValidationService.validate(swarmName, "emitForce");
7556
- return [4 /*yield*/, swarm.sessionPublicService.emit(content, requestId, clientId, swarmName)];
7620
+ return [4 /*yield*/, swarm.sessionPublicService.emit(content, methodName, clientId, swarmName)];
7557
7621
  case 1: return [2 /*return*/, _a.sent()];
7558
7622
  }
7559
7623
  });
@@ -7570,22 +7634,29 @@ var emitForce = function (content, clientId) { return __awaiter(void 0, void 0,
7570
7634
  * @returns {Promise<void>} - A promise that resolves when the execution is complete.
7571
7635
  */
7572
7636
  var executeForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
7573
- var requestId, swarmName;
7637
+ var methodName, executionId, swarmName;
7574
7638
  return __generator(this, function (_a) {
7575
- switch (_a.label) {
7576
- case 0:
7577
- requestId = randomString();
7578
- swarm.loggerService.log("function executeForce", {
7579
- content: content,
7580
- clientId: clientId,
7581
- requestId: requestId,
7639
+ methodName = "function executeForce";
7640
+ executionId = randomString();
7641
+ swarm.loggerService.log("function executeForce", {
7642
+ content: content,
7643
+ clientId: clientId,
7644
+ executionId: executionId,
7645
+ });
7646
+ swarm.sessionValidationService.validate(clientId, "executeForce");
7647
+ swarmName = swarm.sessionValidationService.getSwarm(clientId);
7648
+ swarm.swarmValidationService.validate(swarmName, "executeForce");
7649
+ return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(void 0, void 0, void 0, function () {
7650
+ return __generator(this, function (_a) {
7651
+ switch (_a.label) {
7652
+ case 0: return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", methodName, clientId, swarmName)];
7653
+ case 1: return [2 /*return*/, _a.sent()];
7654
+ }
7582
7655
  });
7583
- swarm.sessionValidationService.validate(clientId, "executeForce");
7584
- swarmName = swarm.sessionValidationService.getSwarm(clientId);
7585
- swarm.swarmValidationService.validate(swarmName, "executeForce");
7586
- return [4 /*yield*/, swarm.sessionPublicService.execute(content, "tool", requestId, clientId, swarmName)];
7587
- case 1: return [2 /*return*/, _a.sent()];
7588
- }
7656
+ }); }, {
7657
+ clientId: clientId,
7658
+ executionId: executionId,
7659
+ })];
7589
7660
  });
7590
7661
  }); };
7591
7662
 
@@ -7673,16 +7744,15 @@ var listenEventOnce = function (clientId, topicName, filterFn, fn) {
7673
7744
  * @returns {Promise<string | null>} - The content of the last user message, or null if no user message is found.
7674
7745
  */
7675
7746
  var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
7676
- var requestId, history, last;
7747
+ var methodName, history, last;
7677
7748
  return __generator(this, function (_a) {
7678
7749
  switch (_a.label) {
7679
7750
  case 0:
7680
- requestId = randomString();
7751
+ methodName = "function getLastUserMessage";
7681
7752
  swarm.loggerService.log("function getLastUserMessage", {
7682
7753
  clientId: clientId,
7683
- requestId: requestId,
7684
7754
  });
7685
- return [4 /*yield*/, getRawHistory(clientId, requestId)];
7755
+ return [4 /*yield*/, getRawHistory(clientId, methodName)];
7686
7756
  case 1:
7687
7757
  history = _a.sent();
7688
7758
  last = history.findLast(function (_a) {
@@ -7701,16 +7771,15 @@ var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0,
7701
7771
  * @returns {Promise<Array>} A promise that resolves to an array of history objects filtered by user role.
7702
7772
  */
7703
7773
  var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
7704
- var requestId, history;
7774
+ var methodName, history;
7705
7775
  return __generator(this, function (_a) {
7706
7776
  switch (_a.label) {
7707
7777
  case 0:
7708
- requestId = randomString();
7778
+ methodName = "function getUserHistory";
7709
7779
  swarm.loggerService.log("function getUserHistory", {
7710
7780
  clientId: clientId,
7711
- requestId: requestId,
7712
7781
  });
7713
- return [4 /*yield*/, getRawHistory(clientId, requestId)];
7782
+ return [4 /*yield*/, getRawHistory(clientId, methodName)];
7714
7783
  case 1:
7715
7784
  history = _a.sent();
7716
7785
  return [2 /*return*/, history.filter(function (_a) {
@@ -7728,16 +7797,15 @@ var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void
7728
7797
  * @returns {Promise<Array>} - A promise that resolves to an array of history objects where the role is "assistant".
7729
7798
  */
7730
7799
  var getAssistantHistory = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
7731
- var requestId, history;
7800
+ var methodName, history;
7732
7801
  return __generator(this, function (_a) {
7733
7802
  switch (_a.label) {
7734
7803
  case 0:
7735
- requestId = randomString();
7804
+ methodName = "function getAssistantHistory";
7736
7805
  swarm.loggerService.log("function getAssistantHistory", {
7737
7806
  clientId: clientId,
7738
- requestId: requestId,
7739
7807
  });
7740
- return [4 /*yield*/, getRawHistory(clientId, requestId)];
7808
+ return [4 /*yield*/, getRawHistory(clientId, methodName)];
7741
7809
  case 1:
7742
7810
  history = _a.sent();
7743
7811
  return [2 /*return*/, history.filter(function (_a) {
@@ -7755,16 +7823,15 @@ var getAssistantHistory = function (clientId) { return __awaiter(void 0, void 0,
7755
7823
  * @returns {Promise<string | null>} - The content of the last assistant message, or null if no user message is found.
7756
7824
  */
7757
7825
  var getLastAssistantMessage = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
7758
- var requestId, history, last;
7826
+ var methodName, history, last;
7759
7827
  return __generator(this, function (_a) {
7760
7828
  switch (_a.label) {
7761
7829
  case 0:
7762
- requestId = randomString();
7830
+ methodName = "function getLastAssistantMessage";
7763
7831
  swarm.loggerService.log("function getLastAssistantMessage", {
7764
7832
  clientId: clientId,
7765
- requestId: requestId,
7766
7833
  });
7767
- return [4 /*yield*/, getRawHistory(clientId, requestId)];
7834
+ return [4 /*yield*/, getRawHistory(clientId, methodName)];
7768
7835
  case 1:
7769
7836
  history = _a.sent();
7770
7837
  last = history.findLast(function (_a) {
@@ -7783,16 +7850,15 @@ var getLastAssistantMessage = function (clientId) { return __awaiter(void 0, voi
7783
7850
  * @returns {Promise<string | null>} - The content of the last system message, or null if no user message is found.
7784
7851
  */
7785
7852
  var getLastSystemMessage = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
7786
- var requestId, history, last;
7853
+ var methodName, history, last;
7787
7854
  return __generator(this, function (_a) {
7788
7855
  switch (_a.label) {
7789
7856
  case 0:
7790
- requestId = randomString();
7857
+ methodName = "function getLastSystemMessage";
7791
7858
  swarm.loggerService.log("function getLastSystemMessage", {
7792
7859
  clientId: clientId,
7793
- requestId: requestId,
7794
7860
  });
7795
- return [4 /*yield*/, getRawHistory(clientId, requestId)];
7861
+ return [4 /*yield*/, getRawHistory(clientId, methodName)];
7796
7862
  case 1:
7797
7863
  history = _a.sent();
7798
7864
  last = history.findLast(function (_a) {
@@ -7896,21 +7962,20 @@ var event = function (clientId, topicName, payload) {
7896
7962
  * @returns {Promise<void>} - A promise that resolves when the output is canceled
7897
7963
  */
7898
7964
  var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
7899
- var requestId, swarmName, currentAgentName;
7965
+ var methodName, swarmName, currentAgentName;
7900
7966
  return __generator(this, function (_a) {
7901
7967
  switch (_a.label) {
7902
7968
  case 0:
7903
- requestId = randomString();
7969
+ methodName = 'function cancelOutput';
7904
7970
  swarm.loggerService.log('function cancelOutput', {
7905
7971
  clientId: clientId,
7906
7972
  agentName: agentName,
7907
- requestId: requestId,
7908
7973
  });
7909
7974
  swarm.agentValidationService.validate(agentName, "cancelOutput");
7910
7975
  swarm.sessionValidationService.validate(clientId, "cancelOutput");
7911
7976
  swarmName = swarm.sessionValidationService.getSwarm(clientId);
7912
7977
  swarm.swarmValidationService.validate(swarmName, "cancelOutput");
7913
- return [4 /*yield*/, swarm.swarmPublicService.getAgentName(requestId, clientId, swarmName)];
7978
+ return [4 /*yield*/, swarm.swarmPublicService.getAgentName(methodName, clientId, swarmName)];
7914
7979
  case 1:
7915
7980
  currentAgentName = _a.sent();
7916
7981
  if (currentAgentName !== agentName) {
@@ -7921,7 +7986,7 @@ var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, voi
7921
7986
  });
7922
7987
  return [2 /*return*/];
7923
7988
  }
7924
- return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(requestId, clientId, swarmName)];
7989
+ return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(methodName, clientId, swarmName)];
7925
7990
  case 2:
7926
7991
  _a.sent();
7927
7992
  return [2 /*return*/];
@@ -7937,19 +8002,18 @@ var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, voi
7937
8002
  * @returns {Promise<void>} - A promise that resolves when the output is canceled
7938
8003
  */
7939
8004
  var cancelOutputForce = function (clientId) { return __awaiter(void 0, void 0, void 0, function () {
7940
- var requestId, swarmName;
8005
+ var methodName, swarmName;
7941
8006
  return __generator(this, function (_a) {
7942
8007
  switch (_a.label) {
7943
8008
  case 0:
7944
- requestId = randomString();
8009
+ methodName = 'function cancelOutputForce';
7945
8010
  swarm.loggerService.log('function cancelOutputForce', {
7946
8011
  clientId: clientId,
7947
- requestId: requestId
7948
8012
  });
7949
8013
  swarm.sessionValidationService.validate(clientId, "cancelOutputForce");
7950
8014
  swarmName = swarm.sessionValidationService.getSwarm(clientId);
7951
8015
  swarm.swarmValidationService.validate(swarmName, "cancelOutputForce");
7952
- return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(requestId, clientId, swarmName)];
8016
+ return [4 /*yield*/, swarm.swarmPublicService.cancelOutput(methodName, clientId, swarmName)];
7953
8017
  case 1:
7954
8018
  _a.sent();
7955
8019
  return [2 /*return*/];
@@ -8235,24 +8299,23 @@ var StorageUtils = /** @class */ (function () {
8235
8299
  * @template T
8236
8300
  */
8237
8301
  this.take = function (payload) { return __awaiter(_this, void 0, void 0, function () {
8238
- var requestId;
8302
+ var methodName;
8239
8303
  return __generator(this, function (_a) {
8240
8304
  switch (_a.label) {
8241
8305
  case 0:
8242
- requestId = randomString();
8306
+ methodName = "StorageUtils take";
8243
8307
  swarm.loggerService.log("StorageUtils take", {
8244
8308
  search: payload.search,
8245
8309
  total: payload.total,
8246
8310
  clientId: payload.clientId,
8247
8311
  storageName: payload.storageName,
8248
8312
  score: payload.score,
8249
- requestId: requestId,
8250
8313
  });
8251
8314
  swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
8252
8315
  if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
8253
8316
  throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (take)"));
8254
8317
  }
8255
- return [4 /*yield*/, swarm.storagePublicService.take(payload.search, payload.total, requestId, payload.clientId, payload.storageName, payload.score)];
8318
+ return [4 /*yield*/, swarm.storagePublicService.take(payload.search, payload.total, methodName, payload.clientId, payload.storageName, payload.score)];
8256
8319
  case 1: return [2 /*return*/, (_a.sent())];
8257
8320
  }
8258
8321
  });
@@ -8267,22 +8330,21 @@ var StorageUtils = /** @class */ (function () {
8267
8330
  * @template T
8268
8331
  */
8269
8332
  this.upsert = function (payload) { return __awaiter(_this, void 0, void 0, function () {
8270
- var requestId;
8333
+ var methodName;
8271
8334
  return __generator(this, function (_a) {
8272
8335
  switch (_a.label) {
8273
8336
  case 0:
8274
- requestId = randomString();
8337
+ methodName = "StorageUtils upsert";
8275
8338
  swarm.loggerService.log("StorageUtils upsert", {
8276
8339
  item: payload.item,
8277
8340
  clientId: payload.clientId,
8278
8341
  storageName: payload.storageName,
8279
- requestId: requestId,
8280
8342
  });
8281
8343
  swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
8282
8344
  if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
8283
8345
  throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (upsert)"));
8284
8346
  }
8285
- return [4 /*yield*/, swarm.storagePublicService.upsert(payload.item, requestId, payload.clientId, payload.storageName)];
8347
+ return [4 /*yield*/, swarm.storagePublicService.upsert(payload.item, methodName, payload.clientId, payload.storageName)];
8286
8348
  case 1: return [2 /*return*/, _a.sent()];
8287
8349
  }
8288
8350
  });
@@ -8296,22 +8358,21 @@ var StorageUtils = /** @class */ (function () {
8296
8358
  * @returns {Promise<void>} - A promise that resolves when the operation is complete.
8297
8359
  */
8298
8360
  this.remove = function (payload) { return __awaiter(_this, void 0, void 0, function () {
8299
- var requestId;
8361
+ var methodName;
8300
8362
  return __generator(this, function (_a) {
8301
8363
  switch (_a.label) {
8302
8364
  case 0:
8303
- requestId = randomString();
8365
+ methodName = "StorageUtils remove";
8304
8366
  swarm.loggerService.log("StorageUtils remove", {
8305
8367
  itemId: payload.itemId,
8306
8368
  clientId: payload.clientId,
8307
8369
  storageName: payload.storageName,
8308
- requestId: requestId,
8309
8370
  });
8310
8371
  swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
8311
8372
  if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
8312
8373
  throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (remove)"));
8313
8374
  }
8314
- return [4 /*yield*/, swarm.storagePublicService.remove(payload.itemId, requestId, payload.clientId, payload.storageName)];
8375
+ return [4 /*yield*/, swarm.storagePublicService.remove(payload.itemId, methodName, payload.clientId, payload.storageName)];
8315
8376
  case 1: return [2 /*return*/, _a.sent()];
8316
8377
  }
8317
8378
  });
@@ -8326,22 +8387,21 @@ var StorageUtils = /** @class */ (function () {
8326
8387
  * @template T
8327
8388
  */
8328
8389
  this.get = function (payload) { return __awaiter(_this, void 0, void 0, function () {
8329
- var requestId;
8390
+ var methodName;
8330
8391
  return __generator(this, function (_a) {
8331
8392
  switch (_a.label) {
8332
8393
  case 0:
8333
- requestId = randomString();
8394
+ methodName = "StorageUtils get";
8334
8395
  swarm.loggerService.log("StorageUtils get", {
8335
8396
  itemId: payload.itemId,
8336
8397
  clientId: payload.clientId,
8337
8398
  storageName: payload.storageName,
8338
- requestId: requestId,
8339
8399
  });
8340
8400
  swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
8341
8401
  if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
8342
8402
  throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (get)"));
8343
8403
  }
8344
- return [4 /*yield*/, swarm.storagePublicService.get(payload.itemId, requestId, payload.clientId, payload.storageName)];
8404
+ return [4 /*yield*/, swarm.storagePublicService.get(payload.itemId, methodName, payload.clientId, payload.storageName)];
8345
8405
  case 1: return [2 /*return*/, (_a.sent())];
8346
8406
  }
8347
8407
  });
@@ -8356,21 +8416,20 @@ var StorageUtils = /** @class */ (function () {
8356
8416
  * @template T
8357
8417
  */
8358
8418
  this.list = function (payload) { return __awaiter(_this, void 0, void 0, function () {
8359
- var requestId;
8419
+ var methodName;
8360
8420
  return __generator(this, function (_a) {
8361
8421
  switch (_a.label) {
8362
8422
  case 0:
8363
- requestId = randomString();
8423
+ methodName = "StorageUtils list";
8364
8424
  swarm.loggerService.log("StorageUtils list", {
8365
8425
  clientId: payload.clientId,
8366
8426
  storageName: payload.storageName,
8367
- requestId: requestId,
8368
8427
  });
8369
8428
  swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
8370
8429
  if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
8371
8430
  throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (list)"));
8372
8431
  }
8373
- return [4 /*yield*/, swarm.storagePublicService.list(requestId, payload.clientId, payload.storageName, payload.filter)];
8432
+ return [4 /*yield*/, swarm.storagePublicService.list(methodName, payload.clientId, payload.storageName, payload.filter)];
8374
8433
  case 1: return [2 /*return*/, (_a.sent())];
8375
8434
  }
8376
8435
  });
@@ -8383,21 +8442,20 @@ var StorageUtils = /** @class */ (function () {
8383
8442
  * @returns {Promise<void>} - A promise that resolves when the operation is complete.
8384
8443
  */
8385
8444
  this.clear = function (payload) { return __awaiter(_this, void 0, void 0, function () {
8386
- var requestId;
8445
+ var methodName;
8387
8446
  return __generator(this, function (_a) {
8388
8447
  switch (_a.label) {
8389
8448
  case 0:
8390
- requestId = randomString();
8449
+ methodName = "StorageUtils clear";
8391
8450
  swarm.loggerService.log("StorageUtils clear", {
8392
8451
  clientId: payload.clientId,
8393
8452
  storageName: payload.storageName,
8394
- requestId: requestId,
8395
8453
  });
8396
8454
  swarm.storageValidationService.validate(payload.storageName, "StorageUtils");
8397
8455
  if (!swarm.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
8398
8456
  throw new Error("agent-swarm StorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (clear)"));
8399
8457
  }
8400
- return [4 /*yield*/, swarm.storagePublicService.clear(requestId, payload.clientId, payload.storageName)];
8458
+ return [4 /*yield*/, swarm.storagePublicService.clear(methodName, payload.clientId, payload.storageName)];
8401
8459
  case 1: return [2 /*return*/, _a.sent()];
8402
8460
  }
8403
8461
  });
@@ -8425,20 +8483,19 @@ var StateUtils = /** @class */ (function () {
8425
8483
  * @throws Will throw an error if the state is not registered in the agent.
8426
8484
  */
8427
8485
  this.getState = function (payload) { return __awaiter(_this, void 0, void 0, function () {
8428
- var requestId;
8486
+ var methodName;
8429
8487
  return __generator(this, function (_a) {
8430
8488
  switch (_a.label) {
8431
8489
  case 0:
8432
- requestId = randomString();
8490
+ methodName = "StateUtils getState";
8433
8491
  swarm.loggerService.log("StateUtils getState", {
8434
8492
  clientId: payload.clientId,
8435
8493
  stateName: payload.stateName,
8436
- requestId: requestId,
8437
8494
  });
8438
8495
  if (!swarm.agentValidationService.hasState(payload.agentName, payload.stateName)) {
8439
8496
  throw new Error("agent-swarm StateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (getState)"));
8440
8497
  }
8441
- return [4 /*yield*/, swarm.statePublicService.getState(requestId, payload.clientId, payload.stateName)];
8498
+ return [4 /*yield*/, swarm.statePublicService.getState(methodName, payload.clientId, payload.stateName)];
8442
8499
  case 1: return [2 /*return*/, _a.sent()];
8443
8500
  }
8444
8501
  });
@@ -8455,26 +8512,25 @@ var StateUtils = /** @class */ (function () {
8455
8512
  * @throws Will throw an error if the state is not registered in the agent.
8456
8513
  */
8457
8514
  this.setState = function (dispatchFn, payload) { return __awaiter(_this, void 0, void 0, function () {
8458
- var requestId;
8515
+ var methodName;
8459
8516
  var _this = this;
8460
8517
  return __generator(this, function (_a) {
8461
8518
  switch (_a.label) {
8462
8519
  case 0:
8463
- requestId = randomString();
8520
+ methodName = "StateUtils setState";
8464
8521
  swarm.loggerService.log("StateUtils setState", {
8465
8522
  clientId: payload.clientId,
8466
8523
  stateName: payload.stateName,
8467
- requestId: requestId,
8468
8524
  });
8469
8525
  if (!swarm.agentValidationService.hasState(payload.agentName, payload.stateName)) {
8470
8526
  throw new Error("agent-swarm StateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (setState)"));
8471
8527
  }
8472
8528
  if (!(typeof dispatchFn === "function")) return [3 /*break*/, 2];
8473
- return [4 /*yield*/, swarm.statePublicService.setState(dispatchFn, requestId, payload.clientId, payload.stateName)];
8529
+ return [4 /*yield*/, swarm.statePublicService.setState(dispatchFn, methodName, payload.clientId, payload.stateName)];
8474
8530
  case 1: return [2 /*return*/, _a.sent()];
8475
8531
  case 2: return [4 /*yield*/, swarm.statePublicService.setState(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
8476
8532
  return [2 /*return*/, dispatchFn];
8477
- }); }); }, requestId, payload.clientId, payload.stateName)];
8533
+ }); }); }, methodName, payload.clientId, payload.stateName)];
8478
8534
  case 3: return [2 /*return*/, _a.sent()];
8479
8535
  }
8480
8536
  });
@@ -8507,4 +8563,4 @@ var LoggerUtils = /** @class */ (function () {
8507
8563
  */
8508
8564
  var Logger = new LoggerUtils();
8509
8565
 
8510
- export { ContextService, History, HistoryAdapter, HistoryInstance, Logger, State, Storage, addAgent, addCompletion, addEmbedding, addState, addStorage, addSwarm, addTool, cancelOutput, cancelOutputForce, changeAgent, commitFlush, commitFlushForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitUserMessage, commitUserMessageForce, complete, disposeConnection, emit, emitForce, event, execute, executeForce, getAgentHistory, getAgentName, getAssistantHistory, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getRawHistory, getSessionMode, getUserHistory, listenAgentEvent, listenAgentEventOnce, listenEvent, listenEventOnce, listenHistoryEvent, listenHistoryEventOnce, listenSessionEvent, listenSessionEventOnce, listenStateEvent, listenStateEventOnce, listenStorageEvent, listenStorageEventOnce, listenSwarmEvent, listenSwarmEventOnce, makeAutoDispose, makeConnection, session, setConfig, swarm };
8566
+ export { ExecutionContextService, History, HistoryAdapter, HistoryInstance, Logger, MethodContextService, State, Storage, addAgent, addCompletion, addEmbedding, addState, addStorage, addSwarm, addTool, cancelOutput, cancelOutputForce, changeAgent, commitFlush, commitFlushForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitUserMessage, commitUserMessageForce, complete, disposeConnection, emit, emitForce, event, execute, executeForce, getAgentHistory, getAgentName, getAssistantHistory, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getRawHistory, getSessionMode, getUserHistory, listenAgentEvent, listenAgentEventOnce, listenEvent, listenEventOnce, listenHistoryEvent, listenHistoryEventOnce, listenSessionEvent, listenSessionEventOnce, listenStateEvent, listenStateEventOnce, listenStorageEvent, listenStorageEventOnce, listenSwarmEvent, listenSwarmEventOnce, makeAutoDispose, makeConnection, session, setConfig, swarm };