agent-swarm-kit 1.0.113 → 1.0.115

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
@@ -197,6 +197,7 @@ var schemaServices$1 = {
197
197
  embeddingSchemaService: Symbol('embeddingSchemaService'),
198
198
  storageSchemaService: Symbol('storageSchemaService'),
199
199
  stateSchemaService: Symbol('stateSchemaService'),
200
+ memorySchemaService: Symbol('memorySchemaService'),
200
201
  };
201
202
  var metaServices$1 = {
202
203
  agentMetaService: Symbol('agentMetaService'),
@@ -2350,6 +2351,85 @@ var ClientAgent = /** @class */ (function () {
2350
2351
  }
2351
2352
  });
2352
2353
  }); });
2354
+ /**
2355
+ * Run the completion stateless and return the output
2356
+ * @param {string} incoming - The incoming message content.
2357
+ * @returns {Promise<void>}
2358
+ */
2359
+ this.run = queued(function (incoming) { return __awaiter(_this, void 0, void 0, function () {
2360
+ var messages, args, rawMessage, message, result, validation;
2361
+ var _a, _b, _c;
2362
+ return __generator(this, function (_d) {
2363
+ switch (_d.label) {
2364
+ case 0:
2365
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
2366
+ this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " run begin"), { incoming: incoming });
2367
+ this.params.onRun &&
2368
+ this.params.onRun(this.params.clientId, this.params.agentName, incoming);
2369
+ return [4 /*yield*/, this.params.history.toArrayForAgent(this.params.prompt, this.params.system)];
2370
+ case 1:
2371
+ messages = _d.sent();
2372
+ messages.push({
2373
+ agentName: this.params.agentName,
2374
+ content: incoming,
2375
+ mode: "user",
2376
+ role: "assistant",
2377
+ });
2378
+ args = {
2379
+ clientId: this.params.clientId,
2380
+ agentName: this.params.agentName,
2381
+ messages: messages,
2382
+ mode: "user",
2383
+ tools: (_a = this.params.tools) === null || _a === void 0 ? void 0 : _a.map(function (t) {
2384
+ return omit(t, "toolName", "docNote", "call", "validate", "callbacks");
2385
+ }),
2386
+ };
2387
+ return [4 /*yield*/, this.params.completion.getCompletion(args)];
2388
+ case 2:
2389
+ rawMessage = _d.sent();
2390
+ ((_b = this.params.completion.callbacks) === null || _b === void 0 ? void 0 : _b.onComplete) &&
2391
+ ((_c = this.params.completion.callbacks) === null || _c === void 0 ? void 0 : _c.onComplete(args, rawMessage));
2392
+ return [4 /*yield*/, this.params.map(rawMessage, this.params.clientId, this.params.agentName)];
2393
+ case 3:
2394
+ message = _d.sent();
2395
+ return [4 /*yield*/, this.params.transform(message.content, this.params.clientId, this.params.agentName)];
2396
+ case 4:
2397
+ result = _d.sent();
2398
+ return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
2399
+ type: "run",
2400
+ source: "agent-bus",
2401
+ input: {
2402
+ message: message,
2403
+ },
2404
+ output: {
2405
+ result: result,
2406
+ },
2407
+ context: {
2408
+ agentName: this.params.agentName,
2409
+ },
2410
+ clientId: this.params.clientId,
2411
+ })];
2412
+ case 5:
2413
+ _d.sent();
2414
+ if (message.tool_calls) {
2415
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
2416
+ this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " run should not call tools"), { incoming: incoming, result: result });
2417
+ return [2 /*return*/, ""];
2418
+ }
2419
+ validation = null;
2420
+ return [4 /*yield*/, this.params.validate(result)];
2421
+ case 6:
2422
+ if ((validation = _d.sent())) {
2423
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
2424
+ this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " run validation not passed: ").concat(validation), { incoming: incoming, result: result });
2425
+ return [2 /*return*/, ""];
2426
+ }
2427
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
2428
+ this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " run end result=").concat(result));
2429
+ return [2 /*return*/, result];
2430
+ }
2431
+ });
2432
+ }); });
2353
2433
  /**
2354
2434
  * Should call on agent dispose
2355
2435
  * @returns {Promise<void>}
@@ -2432,6 +2512,24 @@ var AgentConnectionService = /** @class */ (function () {
2432
2512
  }
2433
2513
  });
2434
2514
  }); };
2515
+ /**
2516
+ * Run the completion stateless
2517
+ * @param {string} input - The input command.
2518
+ * @returns {Promise<any>} The execution result.
2519
+ */
2520
+ this.run = function (input) { return __awaiter(_this, void 0, void 0, function () {
2521
+ return __generator(this, function (_a) {
2522
+ switch (_a.label) {
2523
+ case 0:
2524
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
2525
+ this.loggerService.info("agentConnectionService run", {
2526
+ input: input,
2527
+ });
2528
+ return [4 /*yield*/, this.getAgent(this.methodContextService.context.clientId, this.methodContextService.context.agentName).run(input)];
2529
+ case 1: return [2 /*return*/, _a.sent()];
2530
+ }
2531
+ });
2532
+ }); };
2435
2533
  /**
2436
2534
  * Waits for the output from the agent.
2437
2535
  * @returns {Promise<any>} The output result.
@@ -3732,6 +3830,48 @@ var ClientSession = /** @class */ (function () {
3732
3830
  }
3733
3831
  });
3734
3832
  }); };
3833
+ /**
3834
+ * Run the completion stateless
3835
+ * @param {string} message - The message to run.
3836
+ * @returns {Promise<string>} - The output of the execution.
3837
+ */
3838
+ this.run = function (message) { return __awaiter(_this, void 0, void 0, function () {
3839
+ var agent, output;
3840
+ return __generator(this, function (_a) {
3841
+ switch (_a.label) {
3842
+ case 0:
3843
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
3844
+ this.params.logger.debug("ClientSession clientId=".concat(this.params.clientId, " run"), {
3845
+ message: message,
3846
+ });
3847
+ this.params.onRun &&
3848
+ this.params.onRun(this.params.clientId, this.params.swarmName, message);
3849
+ return [4 /*yield*/, this.params.swarm.getAgent()];
3850
+ case 1:
3851
+ agent = _a.sent();
3852
+ return [4 /*yield*/, agent.run(message)];
3853
+ case 2:
3854
+ output = _a.sent();
3855
+ return [4 /*yield*/, this.params.bus.emit(this.params.clientId, {
3856
+ type: "run",
3857
+ source: "session-bus",
3858
+ input: {
3859
+ message: message,
3860
+ },
3861
+ output: {
3862
+ result: output,
3863
+ },
3864
+ context: {
3865
+ swarmName: this.params.swarmName,
3866
+ },
3867
+ clientId: this.params.clientId,
3868
+ })];
3869
+ case 3:
3870
+ _a.sent();
3871
+ return [2 /*return*/, output];
3872
+ }
3873
+ });
3874
+ }); };
3735
3875
  /**
3736
3876
  * Commits tool output.
3737
3877
  * @param {string} toolId - The `tool_call_id` for openai history
@@ -4104,6 +4244,24 @@ var SessionConnectionService = /** @class */ (function () {
4104
4244
  }
4105
4245
  });
4106
4246
  }); };
4247
+ /**
4248
+ * Run the completion stateless
4249
+ * @param {string} content - The content to execute.
4250
+ * @returns {Promise<string>} A promise that resolves with the execution result.
4251
+ */
4252
+ this.run = function (content) { return __awaiter(_this, void 0, void 0, function () {
4253
+ return __generator(this, function (_a) {
4254
+ switch (_a.label) {
4255
+ case 0:
4256
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
4257
+ this.loggerService.info("sessionConnectionService run", {
4258
+ content: content,
4259
+ });
4260
+ return [4 /*yield*/, this.getSession(this.methodContextService.context.clientId, this.methodContextService.context.swarmName).run(content)];
4261
+ case 1: return [2 /*return*/, _a.sent()];
4262
+ }
4263
+ });
4264
+ }); };
4107
4265
  /**
4108
4266
  * Connects to the session using the provided connector.
4109
4267
  * @param {SendMessageFn} connector - The function to send messages.
@@ -4330,6 +4488,44 @@ var AgentPublicService = /** @class */ (function () {
4330
4488
  }
4331
4489
  });
4332
4490
  }); };
4491
+ /**
4492
+ * Run the completion stateless
4493
+ * @param {string} input - The input command.
4494
+ * @param {string} clientId - The client ID.
4495
+ * @param {AgentName} agentName - The name of the agent.
4496
+ * @returns {Promise<unknown>} The execution result.
4497
+ */
4498
+ this.run = function (input, methodName, clientId, agentName) { return __awaiter(_this, void 0, void 0, function () {
4499
+ var _this = this;
4500
+ return __generator(this, function (_a) {
4501
+ switch (_a.label) {
4502
+ case 0:
4503
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
4504
+ this.loggerService.info("agentPublicService run", {
4505
+ methodName: methodName,
4506
+ input: input,
4507
+ clientId: clientId,
4508
+ agentName: agentName,
4509
+ });
4510
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
4511
+ return __generator(this, function (_a) {
4512
+ switch (_a.label) {
4513
+ case 0: return [4 /*yield*/, this.agentConnectionService.run(input)];
4514
+ case 1: return [2 /*return*/, _a.sent()];
4515
+ }
4516
+ });
4517
+ }); }, {
4518
+ methodName: methodName,
4519
+ clientId: clientId,
4520
+ agentName: agentName,
4521
+ swarmName: "",
4522
+ storageName: "",
4523
+ stateName: "",
4524
+ })];
4525
+ case 1: return [2 /*return*/, _a.sent()];
4526
+ }
4527
+ });
4528
+ }); };
4333
4529
  /**
4334
4530
  * Waits for the agent's output.
4335
4531
  * @param {string} clientId - The client ID.
@@ -4910,6 +5106,43 @@ var SessionPublicService = /** @class */ (function () {
4910
5106
  }
4911
5107
  });
4912
5108
  }); };
5109
+ /**
5110
+ * Run the completion stateless
5111
+ * @param {string} content - The content to execute.
5112
+ * @param {string} clientId - The client ID.
5113
+ * @param {SwarmName} swarmName - The swarm name.
5114
+ * @returns {Promise<void>}
5115
+ */
5116
+ this.run = function (content, methodName, clientId, swarmName) { return __awaiter(_this, void 0, void 0, function () {
5117
+ var _this = this;
5118
+ return __generator(this, function (_a) {
5119
+ switch (_a.label) {
5120
+ case 0:
5121
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
5122
+ this.loggerService.info("sessionPublicService run", {
5123
+ content: content,
5124
+ clientId: clientId,
5125
+ swarmName: swarmName,
5126
+ });
5127
+ return [4 /*yield*/, MethodContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
5128
+ return __generator(this, function (_a) {
5129
+ switch (_a.label) {
5130
+ case 0: return [4 /*yield*/, this.sessionConnectionService.run(content)];
5131
+ case 1: return [2 /*return*/, _a.sent()];
5132
+ }
5133
+ });
5134
+ }); }, {
5135
+ methodName: methodName,
5136
+ clientId: clientId,
5137
+ swarmName: swarmName,
5138
+ agentName: "",
5139
+ storageName: "",
5140
+ stateName: "",
5141
+ })];
5142
+ case 1: return [2 /*return*/, _a.sent()];
5143
+ }
5144
+ });
5145
+ }); };
4913
5146
  /**
4914
5147
  * Connects to the session.
4915
5148
  * @param {SendMessageFn} connector - The function to send messages.
@@ -9178,6 +9411,63 @@ var SharedStoragePublicService = /** @class */ (function () {
9178
9411
  return SharedStoragePublicService;
9179
9412
  }());
9180
9413
 
9414
+ /**
9415
+ * Service to manage memory schema for different sessions.
9416
+ */
9417
+ var MemorySchemaService = /** @class */ (function () {
9418
+ function MemorySchemaService() {
9419
+ var _this = this;
9420
+ this.loggerService = inject(TYPES.loggerService);
9421
+ this.memoryMap = new Map();
9422
+ /**
9423
+ * Writes a value to the memory map for a given client ID.
9424
+ *
9425
+ * @template T - The type of the value to be written.
9426
+ * @param {string} clientId - The ID of the client.
9427
+ * @param {T} value - The value to be written.
9428
+ */
9429
+ this.writeValue = function (clientId, value) {
9430
+ var _a;
9431
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
9432
+ _this.loggerService.info("memorySchemaService setValue", {
9433
+ clientId: clientId,
9434
+ value: value,
9435
+ });
9436
+ var pendingValue = Object.assign((_a = _this.memoryMap.get(clientId)) !== null && _a !== void 0 ? _a : {}, value);
9437
+ _this.memoryMap.set(clientId, pendingValue);
9438
+ return pendingValue;
9439
+ };
9440
+ /**
9441
+ * Reads a value from the memory map for a given client ID.
9442
+ *
9443
+ * @template T - The type of the value to be read.
9444
+ * @param {string} clientId - The ID of the client.
9445
+ * @returns {T} - The value associated with the client ID.
9446
+ */
9447
+ this.readValue = function (clientId) {
9448
+ var _a;
9449
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
9450
+ _this.loggerService.info("memorySchemaService getValue", {
9451
+ clientId: clientId,
9452
+ });
9453
+ return ((_a = _this.memoryMap.get(clientId)) !== null && _a !== void 0 ? _a : {});
9454
+ };
9455
+ /**
9456
+ * Disposes the memory map entry for a given client ID.
9457
+ *
9458
+ * @param {string} clientId - The ID of the client.
9459
+ */
9460
+ this.dispose = function (clientId) {
9461
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
9462
+ _this.loggerService.info("memorySchemaService dispose", {
9463
+ clientId: clientId,
9464
+ });
9465
+ _this.memoryMap.delete(clientId);
9466
+ };
9467
+ }
9468
+ return MemorySchemaService;
9469
+ }());
9470
+
9181
9471
  {
9182
9472
  provide(TYPES.docService, function () { return new DocService(); });
9183
9473
  provide(TYPES.busService, function () { return new BusService(); });
@@ -9205,6 +9495,7 @@ var SharedStoragePublicService = /** @class */ (function () {
9205
9495
  provide(TYPES.embeddingSchemaService, function () { return new EmbeddingSchemaService(); });
9206
9496
  provide(TYPES.storageSchemaService, function () { return new StorageSchemaService(); });
9207
9497
  provide(TYPES.stateSchemaService, function () { return new StateSchemaService(); });
9498
+ provide(TYPES.memorySchemaService, function () { return new MemorySchemaService(); });
9208
9499
  }
9209
9500
  {
9210
9501
  provide(TYPES.agentPublicService, function () { return new AgentPublicService(); });
@@ -9257,6 +9548,7 @@ var schemaServices = {
9257
9548
  embeddingSchemaService: inject(TYPES.embeddingSchemaService),
9258
9549
  storageSchemaService: inject(TYPES.storageSchemaService),
9259
9550
  stateSchemaService: inject(TYPES.stateSchemaService),
9551
+ memorySchemaService: inject(TYPES.memorySchemaService),
9260
9552
  };
9261
9553
  var publicServices = {
9262
9554
  agentPublicService: inject(TYPES.agentPublicService),
@@ -9285,7 +9577,7 @@ var swarm = __assign(__assign(__assign(__assign(__assign(__assign(__assign({}, b
9285
9577
  init();
9286
9578
  var swarm$1 = swarm;
9287
9579
 
9288
- var METHOD_NAME$L = "cli.dumpDocs";
9580
+ var METHOD_NAME$O = "cli.dumpDocs";
9289
9581
  /**
9290
9582
  * Dumps the documentation for the agents and swarms.
9291
9583
  *
@@ -9296,7 +9588,7 @@ var METHOD_NAME$L = "cli.dumpDocs";
9296
9588
  var dumpDocs = function (dirName, PlantUML) {
9297
9589
  if (dirName === void 0) { dirName = "./docs/chat"; }
9298
9590
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9299
- swarm$1.loggerService.log(METHOD_NAME$L, {
9591
+ swarm$1.loggerService.log(METHOD_NAME$O, {
9300
9592
  dirName: dirName,
9301
9593
  });
9302
9594
  if (PlantUML) {
@@ -9307,12 +9599,12 @@ var dumpDocs = function (dirName, PlantUML) {
9307
9599
  swarm$1.agentValidationService
9308
9600
  .getAgentList()
9309
9601
  .forEach(function (agentName) {
9310
- return swarm$1.agentValidationService.validate(agentName, METHOD_NAME$L);
9602
+ return swarm$1.agentValidationService.validate(agentName, METHOD_NAME$O);
9311
9603
  });
9312
9604
  swarm$1.swarmValidationService
9313
9605
  .getSwarmList()
9314
9606
  .forEach(function (swarmName) {
9315
- return swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$L);
9607
+ return swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$O);
9316
9608
  });
9317
9609
  swarm$1.agentValidationService.getAgentList().forEach(function (agentName) {
9318
9610
  var dependsOn = swarm$1.agentSchemaService.get(agentName).dependsOn;
@@ -9323,7 +9615,7 @@ var dumpDocs = function (dirName, PlantUML) {
9323
9615
  return swarm$1.docService.dumpDocs(dirName);
9324
9616
  };
9325
9617
 
9326
- var METHOD_NAME$K = "cli.dumpAgent";
9618
+ var METHOD_NAME$N = "cli.dumpAgent";
9327
9619
  /**
9328
9620
  * Dumps the agent information into PlantUML format.
9329
9621
  *
@@ -9333,14 +9625,14 @@ var METHOD_NAME$K = "cli.dumpAgent";
9333
9625
  var dumpAgent = function (agentName, _a) {
9334
9626
  var _b = _a === void 0 ? {} : _a, _c = _b.withSubtree, withSubtree = _c === void 0 ? false : _c;
9335
9627
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9336
- swarm$1.loggerService.log(METHOD_NAME$K, {
9628
+ swarm$1.loggerService.log(METHOD_NAME$N, {
9337
9629
  agentName: agentName,
9338
9630
  });
9339
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$K);
9631
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$N);
9340
9632
  return swarm$1.agentMetaService.toUML(agentName, withSubtree);
9341
9633
  };
9342
9634
 
9343
- var METHOD_NAME$J = "cli.dumpSwarm";
9635
+ var METHOD_NAME$M = "cli.dumpSwarm";
9344
9636
  /**
9345
9637
  * Dumps the swarm information into PlantUML format.
9346
9638
  *
@@ -9349,14 +9641,14 @@ var METHOD_NAME$J = "cli.dumpSwarm";
9349
9641
  */
9350
9642
  var dumpSwarm = function (swarmName) {
9351
9643
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9352
- swarm$1.loggerService.log(METHOD_NAME$J, {
9644
+ swarm$1.loggerService.log(METHOD_NAME$M, {
9353
9645
  swarmName: swarmName,
9354
9646
  });
9355
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$J);
9647
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$M);
9356
9648
  return swarm$1.swarmMetaService.toUML(swarmName);
9357
9649
  };
9358
9650
 
9359
- var METHOD_NAME$I = "function.addAgent";
9651
+ var METHOD_NAME$L = "function.setup.addAgent";
9360
9652
  /**
9361
9653
  * Adds a new agent to the agent registry. The swarm takes only those agents which was registered
9362
9654
  *
@@ -9365,7 +9657,7 @@ var METHOD_NAME$I = "function.addAgent";
9365
9657
  */
9366
9658
  var addAgent = function (agentSchema) {
9367
9659
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9368
- swarm$1.loggerService.log(METHOD_NAME$I, {
9660
+ swarm$1.loggerService.log(METHOD_NAME$L, {
9369
9661
  agentSchema: agentSchema,
9370
9662
  });
9371
9663
  swarm$1.agentValidationService.addAgent(agentSchema.agentName, agentSchema);
@@ -9373,7 +9665,7 @@ var addAgent = function (agentSchema) {
9373
9665
  return agentSchema.agentName;
9374
9666
  };
9375
9667
 
9376
- var METHOD_NAME$H = "function.addCompletion";
9668
+ var METHOD_NAME$K = "function.setup.addCompletion";
9377
9669
  /**
9378
9670
  * Adds a completion engine for agents. Agents could use different models and
9379
9671
  * framewords for completion like: mock, gpt4all, ollama, openai
@@ -9383,7 +9675,7 @@ var METHOD_NAME$H = "function.addCompletion";
9383
9675
  */
9384
9676
  var addCompletion = function (completionSchema) {
9385
9677
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9386
- swarm$1.loggerService.log(METHOD_NAME$H, {
9678
+ swarm$1.loggerService.log(METHOD_NAME$K, {
9387
9679
  completionSchema: completionSchema,
9388
9680
  });
9389
9681
  swarm$1.completionValidationService.addCompletion(completionSchema.completionName);
@@ -9391,7 +9683,7 @@ var addCompletion = function (completionSchema) {
9391
9683
  return completionSchema.completionName;
9392
9684
  };
9393
9685
 
9394
- var METHOD_NAME$G = "function.addSwarm";
9686
+ var METHOD_NAME$J = "function.setup.addSwarm";
9395
9687
  /**
9396
9688
  * Adds a new swarm to the system. The swarm is a root for starting client session
9397
9689
  *
@@ -9400,7 +9692,7 @@ var METHOD_NAME$G = "function.addSwarm";
9400
9692
  */
9401
9693
  var addSwarm = function (swarmSchema) {
9402
9694
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9403
- swarm$1.loggerService.log(METHOD_NAME$G, {
9695
+ swarm$1.loggerService.log(METHOD_NAME$J, {
9404
9696
  swarmSchema: swarmSchema,
9405
9697
  });
9406
9698
  swarm$1.swarmValidationService.addSwarm(swarmSchema.swarmName, swarmSchema);
@@ -9408,7 +9700,7 @@ var addSwarm = function (swarmSchema) {
9408
9700
  return swarmSchema.swarmName;
9409
9701
  };
9410
9702
 
9411
- var METHOD_NAME$F = "function.addTool";
9703
+ var METHOD_NAME$I = "function.setup.addTool";
9412
9704
  /**
9413
9705
  * Adds a new tool for agents in a swarm. Tool should be registered in `addAgent`
9414
9706
  * declaration
@@ -9418,7 +9710,7 @@ var METHOD_NAME$F = "function.addTool";
9418
9710
  */
9419
9711
  var addTool = function (toolSchema) {
9420
9712
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9421
- swarm$1.loggerService.log(METHOD_NAME$F, {
9713
+ swarm$1.loggerService.log(METHOD_NAME$I, {
9422
9714
  toolSchema: toolSchema,
9423
9715
  });
9424
9716
  swarm$1.toolValidationService.addTool(toolSchema.toolName, toolSchema);
@@ -9426,7 +9718,7 @@ var addTool = function (toolSchema) {
9426
9718
  return toolSchema.toolName;
9427
9719
  };
9428
9720
 
9429
- var METHOD_NAME$E = "function.addState";
9721
+ var METHOD_NAME$H = "function.setup.addState";
9430
9722
  /**
9431
9723
  * Adds a new state to the state registry. The swarm takes only those states which was registered
9432
9724
  *
@@ -9435,7 +9727,7 @@ var METHOD_NAME$E = "function.addState";
9435
9727
  */
9436
9728
  var addState = function (stateSchema) {
9437
9729
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9438
- swarm$1.loggerService.log(METHOD_NAME$E, {
9730
+ swarm$1.loggerService.log(METHOD_NAME$H, {
9439
9731
  stateSchema: stateSchema,
9440
9732
  });
9441
9733
  swarm$1.stateSchemaService.register(stateSchema.stateName, stateSchema);
@@ -9447,7 +9739,7 @@ var addState = function (stateSchema) {
9447
9739
  return stateSchema.stateName;
9448
9740
  };
9449
9741
 
9450
- var METHOD_NAME$D = "function.addEmbedding";
9742
+ var METHOD_NAME$G = "function.setup.addEmbedding";
9451
9743
  /**
9452
9744
  * Adds a new embedding to the embedding registry. The swarm takes only those embeddings which was registered
9453
9745
  *
@@ -9456,7 +9748,7 @@ var METHOD_NAME$D = "function.addEmbedding";
9456
9748
  */
9457
9749
  var addEmbedding = function (embeddingSchema) {
9458
9750
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9459
- swarm$1.loggerService.log(METHOD_NAME$D, {
9751
+ swarm$1.loggerService.log(METHOD_NAME$G, {
9460
9752
  embeddingSchema: embeddingSchema,
9461
9753
  });
9462
9754
  swarm$1.embeddingValidationService.addEmbedding(embeddingSchema.embeddingName, embeddingSchema);
@@ -9464,7 +9756,7 @@ var addEmbedding = function (embeddingSchema) {
9464
9756
  return embeddingSchema.embeddingName;
9465
9757
  };
9466
9758
 
9467
- var METHOD_NAME$C = "function.addStorage";
9759
+ var METHOD_NAME$F = "function.setup.addStorage";
9468
9760
  /**
9469
9761
  * Adds a new storage to the storage registry. The swarm takes only those storages which was registered
9470
9762
  *
@@ -9473,7 +9765,7 @@ var METHOD_NAME$C = "function.addStorage";
9473
9765
  */
9474
9766
  var addStorage = function (storageSchema) {
9475
9767
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9476
- swarm$1.loggerService.log(METHOD_NAME$C, {
9768
+ swarm$1.loggerService.log(METHOD_NAME$F, {
9477
9769
  storageSchema: storageSchema,
9478
9770
  });
9479
9771
  swarm$1.storageValidationService.addStorage(storageSchema.storageName, storageSchema);
@@ -9486,7 +9778,7 @@ var addStorage = function (storageSchema) {
9486
9778
  return storageSchema.storageName;
9487
9779
  };
9488
9780
 
9489
- var METHOD_NAME$B = "function.commitToolOutput";
9781
+ var METHOD_NAME$E = "function.commit.commitToolOutput";
9490
9782
  /**
9491
9783
  * Commits the tool output to the active agent in a swarm session
9492
9784
  *
@@ -9501,17 +9793,17 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
9501
9793
  switch (_a.label) {
9502
9794
  case 0:
9503
9795
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9504
- swarm$1.loggerService.log(METHOD_NAME$B, {
9796
+ swarm$1.loggerService.log(METHOD_NAME$E, {
9505
9797
  toolId: toolId,
9506
9798
  content: content,
9507
9799
  clientId: clientId,
9508
9800
  agentName: agentName,
9509
9801
  });
9510
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$B);
9511
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$B);
9802
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$E);
9803
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$E);
9512
9804
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
9513
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$B);
9514
- return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$B, clientId, swarmName)];
9805
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$E);
9806
+ return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$E, clientId, swarmName)];
9515
9807
  case 1:
9516
9808
  currentAgentName = _a.sent();
9517
9809
  if (currentAgentName !== agentName) {
@@ -9524,7 +9816,7 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
9524
9816
  });
9525
9817
  return [2 /*return*/];
9526
9818
  }
9527
- return [4 /*yield*/, swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$B, clientId, swarmName)];
9819
+ return [4 /*yield*/, swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$E, clientId, swarmName)];
9528
9820
  case 2:
9529
9821
  _a.sent();
9530
9822
  return [2 /*return*/];
@@ -9532,7 +9824,7 @@ var commitToolOutput = function (toolId, content, clientId, agentName) { return
9532
9824
  });
9533
9825
  }); };
9534
9826
 
9535
- var METHOD_NAME$A = "function.commitSystemMessage";
9827
+ var METHOD_NAME$D = "function.commit.commitSystemMessage";
9536
9828
  /**
9537
9829
  * Commits a system message to the active agent in the swarm.
9538
9830
  *
@@ -9547,16 +9839,16 @@ var commitSystemMessage = function (content, clientId, agentName) { return __awa
9547
9839
  switch (_a.label) {
9548
9840
  case 0:
9549
9841
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9550
- swarm$1.loggerService.log(METHOD_NAME$A, {
9842
+ swarm$1.loggerService.log(METHOD_NAME$D, {
9551
9843
  content: content,
9552
9844
  clientId: clientId,
9553
9845
  agentName: agentName,
9554
9846
  });
9555
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$A);
9556
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$A);
9847
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$D);
9848
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$D);
9557
9849
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
9558
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$A);
9559
- return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$A, clientId, swarmName)];
9850
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$D);
9851
+ return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$D, clientId, swarmName)];
9560
9852
  case 1:
9561
9853
  currentAgentName = _a.sent();
9562
9854
  if (currentAgentName !== agentName) {
@@ -9568,7 +9860,7 @@ var commitSystemMessage = function (content, clientId, agentName) { return __awa
9568
9860
  });
9569
9861
  return [2 /*return*/];
9570
9862
  }
9571
- return [4 /*yield*/, swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$A, clientId, swarmName)];
9863
+ return [4 /*yield*/, swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$D, clientId, swarmName)];
9572
9864
  case 2:
9573
9865
  _a.sent();
9574
9866
  return [2 /*return*/];
@@ -9576,7 +9868,7 @@ var commitSystemMessage = function (content, clientId, agentName) { return __awa
9576
9868
  });
9577
9869
  }); };
9578
9870
 
9579
- var METHOD_NAME$z = "function.commitFlush";
9871
+ var METHOD_NAME$C = "function.commit.commitFlush";
9580
9872
  /**
9581
9873
  * Commits flush of agent history
9582
9874
  *
@@ -9590,15 +9882,15 @@ var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void
9590
9882
  switch (_a.label) {
9591
9883
  case 0:
9592
9884
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9593
- swarm$1.loggerService.log(METHOD_NAME$z, {
9885
+ swarm$1.loggerService.log(METHOD_NAME$C, {
9594
9886
  clientId: clientId,
9595
9887
  agentName: agentName,
9596
9888
  });
9597
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$z);
9598
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$z);
9889
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$C);
9890
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$C);
9599
9891
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
9600
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$z);
9601
- return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$z, clientId, swarmName)];
9892
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$C);
9893
+ return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$C, clientId, swarmName)];
9602
9894
  case 1:
9603
9895
  currentAgentName = _a.sent();
9604
9896
  if (currentAgentName !== agentName) {
@@ -9610,7 +9902,7 @@ var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void
9610
9902
  });
9611
9903
  return [2 /*return*/];
9612
9904
  }
9613
- return [4 /*yield*/, swarm$1.sessionPublicService.commitFlush(METHOD_NAME$z, clientId, swarmName)];
9905
+ return [4 /*yield*/, swarm$1.sessionPublicService.commitFlush(METHOD_NAME$C, clientId, swarmName)];
9614
9906
  case 2:
9615
9907
  _a.sent();
9616
9908
  return [2 /*return*/];
@@ -9618,7 +9910,7 @@ var commitFlush = function (clientId, agentName) { return __awaiter(void 0, void
9618
9910
  });
9619
9911
  }); };
9620
9912
 
9621
- var METHOD_NAME$y = "function.commitSystemMessage";
9913
+ var METHOD_NAME$B = "function.commit.commitSystemMessage";
9622
9914
  /**
9623
9915
  * Commits a user message to the active agent history in as swarm without answer.
9624
9916
  *
@@ -9633,16 +9925,16 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
9633
9925
  switch (_a.label) {
9634
9926
  case 0:
9635
9927
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9636
- swarm$1.loggerService.log(METHOD_NAME$y, {
9928
+ swarm$1.loggerService.log(METHOD_NAME$B, {
9637
9929
  content: content,
9638
9930
  clientId: clientId,
9639
9931
  agentName: agentName,
9640
9932
  });
9641
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$y);
9642
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$y);
9933
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$B);
9934
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$B);
9643
9935
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
9644
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$y);
9645
- return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$y, clientId, swarmName)];
9936
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$B);
9937
+ return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$B, clientId, swarmName)];
9646
9938
  case 1:
9647
9939
  currentAgentName = _a.sent();
9648
9940
  if (currentAgentName !== agentName) {
@@ -9654,7 +9946,7 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
9654
9946
  });
9655
9947
  return [2 /*return*/];
9656
9948
  }
9657
- return [4 /*yield*/, swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$y, clientId, swarmName)];
9949
+ return [4 /*yield*/, swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$B, clientId, swarmName)];
9658
9950
  case 2:
9659
9951
  _a.sent();
9660
9952
  return [2 /*return*/];
@@ -9662,7 +9954,7 @@ var commitUserMessage = function (content, clientId, agentName) { return __await
9662
9954
  });
9663
9955
  }); };
9664
9956
 
9665
- var METHOD_NAME$x = "function.commitToolOutputForce";
9957
+ var METHOD_NAME$A = "function.commit.commitToolOutputForce";
9666
9958
  /**
9667
9959
  * Commits the tool output to the active agent in a swarm session without checking active agent
9668
9960
  *
@@ -9676,15 +9968,15 @@ var commitToolOutputForce = function (toolId, content, clientId) { return __awai
9676
9968
  switch (_a.label) {
9677
9969
  case 0:
9678
9970
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9679
- swarm$1.loggerService.log(METHOD_NAME$x, {
9971
+ swarm$1.loggerService.log(METHOD_NAME$A, {
9680
9972
  toolId: toolId,
9681
9973
  content: content,
9682
9974
  clientId: clientId,
9683
9975
  });
9684
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$x);
9976
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$A);
9685
9977
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
9686
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$x);
9687
- return [4 /*yield*/, swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$x, clientId, swarmName)];
9978
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$A);
9979
+ return [4 /*yield*/, swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$A, clientId, swarmName)];
9688
9980
  case 1:
9689
9981
  _a.sent();
9690
9982
  return [2 /*return*/];
@@ -9692,7 +9984,7 @@ var commitToolOutputForce = function (toolId, content, clientId) { return __awai
9692
9984
  });
9693
9985
  }); };
9694
9986
 
9695
- var METHOD_NAME$w = "function.commitSystemMessageForce";
9987
+ var METHOD_NAME$z = "function.commit.commitSystemMessageForce";
9696
9988
  /**
9697
9989
  * Commits a system message to the active agent in as swarm without checking active agent.
9698
9990
  *
@@ -9706,14 +9998,14 @@ var commitSystemMessageForce = function (content, clientId) { return __awaiter(v
9706
9998
  switch (_a.label) {
9707
9999
  case 0:
9708
10000
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9709
- swarm$1.loggerService.log(METHOD_NAME$w, {
10001
+ swarm$1.loggerService.log(METHOD_NAME$z, {
9710
10002
  content: content,
9711
10003
  clientId: clientId,
9712
10004
  });
9713
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$w);
10005
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$z);
9714
10006
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
9715
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$w);
9716
- return [4 /*yield*/, swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$w, clientId, swarmName)];
10007
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$z);
10008
+ return [4 /*yield*/, swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$z, clientId, swarmName)];
9717
10009
  case 1:
9718
10010
  _a.sent();
9719
10011
  return [2 /*return*/];
@@ -9721,7 +10013,7 @@ var commitSystemMessageForce = function (content, clientId) { return __awaiter(v
9721
10013
  });
9722
10014
  }); };
9723
10015
 
9724
- var METHOD_NAME$v = "function.commitFlushForce";
10016
+ var METHOD_NAME$y = "function.commit.commitFlushForce";
9725
10017
  /**
9726
10018
  * Commits flush of agent history without active agent check
9727
10019
  *
@@ -9734,14 +10026,14 @@ var commitFlushForce = function (clientId) { return __awaiter(void 0, void 0, vo
9734
10026
  switch (_a.label) {
9735
10027
  case 0:
9736
10028
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9737
- swarm$1.loggerService.log(METHOD_NAME$v, {
10029
+ swarm$1.loggerService.log(METHOD_NAME$y, {
9738
10030
  clientId: clientId,
9739
- METHOD_NAME: METHOD_NAME$v,
10031
+ METHOD_NAME: METHOD_NAME$y,
9740
10032
  });
9741
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$v);
10033
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$y);
9742
10034
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
9743
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$v);
9744
- return [4 /*yield*/, swarm$1.sessionPublicService.commitFlush(METHOD_NAME$v, clientId, swarmName)];
10035
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$y);
10036
+ return [4 /*yield*/, swarm$1.sessionPublicService.commitFlush(METHOD_NAME$y, clientId, swarmName)];
9745
10037
  case 1:
9746
10038
  _a.sent();
9747
10039
  return [2 /*return*/];
@@ -9749,7 +10041,7 @@ var commitFlushForce = function (clientId) { return __awaiter(void 0, void 0, vo
9749
10041
  });
9750
10042
  }); };
9751
10043
 
9752
- var METHOD_NAME$u = "function.commitSystemMessage";
10044
+ var METHOD_NAME$x = "function.commit.commitSystemMessage";
9753
10045
  /**
9754
10046
  * Commits a user message to the active agent history in as swarm without answer and checking active agent
9755
10047
  *
@@ -9763,14 +10055,14 @@ var commitUserMessageForce = function (content, clientId) { return __awaiter(voi
9763
10055
  switch (_a.label) {
9764
10056
  case 0:
9765
10057
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9766
- swarm$1.loggerService.log(METHOD_NAME$u, {
10058
+ swarm$1.loggerService.log(METHOD_NAME$x, {
9767
10059
  content: content,
9768
10060
  clientId: clientId,
9769
10061
  });
9770
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$u);
10062
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$x);
9771
10063
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
9772
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$u);
9773
- return [4 /*yield*/, swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$u, clientId, swarmName)];
10064
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$x);
10065
+ return [4 /*yield*/, swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$x, clientId, swarmName)];
9774
10066
  case 1:
9775
10067
  _a.sent();
9776
10068
  return [2 /*return*/];
@@ -9778,7 +10070,7 @@ var commitUserMessageForce = function (content, clientId) { return __awaiter(voi
9778
10070
  });
9779
10071
  }); };
9780
10072
 
9781
- var METHOD_NAME$t = "function.commitAssistantMessage";
10073
+ var METHOD_NAME$w = "function.commit.commitAssistantMessage";
9782
10074
  /**
9783
10075
  * Commits an assistant message to the active agent in the swarm.
9784
10076
  *
@@ -9793,16 +10085,16 @@ var commitAssistantMessage = function (content, clientId, agentName) { return __
9793
10085
  switch (_a.label) {
9794
10086
  case 0:
9795
10087
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9796
- swarm$1.loggerService.log(METHOD_NAME$t, {
10088
+ swarm$1.loggerService.log(METHOD_NAME$w, {
9797
10089
  content: content,
9798
10090
  clientId: clientId,
9799
10091
  agentName: agentName,
9800
10092
  });
9801
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$t);
9802
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$t);
10093
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$w);
10094
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$w);
9803
10095
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
9804
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$t);
9805
- return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$t, clientId, swarmName)];
10096
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$w);
10097
+ return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$w, clientId, swarmName)];
9806
10098
  case 1:
9807
10099
  currentAgentName = _a.sent();
9808
10100
  if (currentAgentName !== agentName) {
@@ -9814,7 +10106,7 @@ var commitAssistantMessage = function (content, clientId, agentName) { return __
9814
10106
  });
9815
10107
  return [2 /*return*/];
9816
10108
  }
9817
- return [4 /*yield*/, swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$t, clientId, swarmName)];
10109
+ return [4 /*yield*/, swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$w, clientId, swarmName)];
9818
10110
  case 2:
9819
10111
  _a.sent();
9820
10112
  return [2 /*return*/];
@@ -9822,7 +10114,7 @@ var commitAssistantMessage = function (content, clientId, agentName) { return __
9822
10114
  });
9823
10115
  }); };
9824
10116
 
9825
- var METHOD_NAME$s = "function.commitAssistantMessageForce";
10117
+ var METHOD_NAME$v = "function.commit.commitAssistantMessageForce";
9826
10118
  /**
9827
10119
  * Commits an assistant message to the active agent in as swarm without checking active agent.
9828
10120
  *
@@ -9836,14 +10128,14 @@ var commitAssistantMessageForce = function (content, clientId) { return __awaite
9836
10128
  switch (_a.label) {
9837
10129
  case 0:
9838
10130
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9839
- swarm$1.loggerService.log(METHOD_NAME$s, {
10131
+ swarm$1.loggerService.log(METHOD_NAME$v, {
9840
10132
  content: content,
9841
10133
  clientId: clientId,
9842
10134
  });
9843
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$s);
10135
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$v);
9844
10136
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
9845
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$s);
9846
- return [4 /*yield*/, swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$s, clientId, swarmName)];
10137
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$v);
10138
+ return [4 /*yield*/, swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$v, clientId, swarmName)];
9847
10139
  case 1:
9848
10140
  _a.sent();
9849
10141
  return [2 /*return*/];
@@ -9851,7 +10143,7 @@ var commitAssistantMessageForce = function (content, clientId) { return __awaite
9851
10143
  });
9852
10144
  }); };
9853
10145
 
9854
- var METHOD_NAME$r = "function.cancelOutput";
10146
+ var METHOD_NAME$u = "function.commit.cancelOutput";
9855
10147
  /**
9856
10148
  * Cancel the await of output by emit of empty string
9857
10149
  *
@@ -9865,15 +10157,15 @@ var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, voi
9865
10157
  switch (_a.label) {
9866
10158
  case 0:
9867
10159
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9868
- swarm$1.loggerService.log(METHOD_NAME$r, {
10160
+ swarm$1.loggerService.log(METHOD_NAME$u, {
9869
10161
  clientId: clientId,
9870
10162
  agentName: agentName,
9871
10163
  });
9872
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$r);
9873
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$r);
10164
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$u);
10165
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$u);
9874
10166
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
9875
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$r);
9876
- return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$r, clientId, swarmName)];
10167
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$u);
10168
+ return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$u, clientId, swarmName)];
9877
10169
  case 1:
9878
10170
  currentAgentName = _a.sent();
9879
10171
  if (currentAgentName !== agentName) {
@@ -9885,7 +10177,7 @@ var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, voi
9885
10177
  });
9886
10178
  return [2 /*return*/];
9887
10179
  }
9888
- return [4 /*yield*/, swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$r, clientId, swarmName)];
10180
+ return [4 /*yield*/, swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$u, clientId, swarmName)];
9889
10181
  case 2:
9890
10182
  _a.sent();
9891
10183
  return [2 /*return*/];
@@ -9893,7 +10185,7 @@ var cancelOutput = function (clientId, agentName) { return __awaiter(void 0, voi
9893
10185
  });
9894
10186
  }); };
9895
10187
 
9896
- var METHOD_NAME$q = "function.cancelOutputForce";
10188
+ var METHOD_NAME$t = "function.commit.cancelOutputForce";
9897
10189
  /**
9898
10190
  * Cancel the await of output by emit of empty string without checking active agent
9899
10191
  *
@@ -9907,13 +10199,13 @@ var cancelOutputForce = function (clientId) { return __awaiter(void 0, void 0, v
9907
10199
  switch (_a.label) {
9908
10200
  case 0:
9909
10201
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9910
- swarm$1.loggerService.log(METHOD_NAME$q, {
10202
+ swarm$1.loggerService.log(METHOD_NAME$t, {
9911
10203
  clientId: clientId,
9912
10204
  });
9913
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$q);
10205
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$t);
9914
10206
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
9915
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$q);
9916
- return [4 /*yield*/, swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$q, clientId, swarmName)];
10207
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$t);
10208
+ return [4 /*yield*/, swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$t, clientId, swarmName)];
9917
10209
  case 1:
9918
10210
  _a.sent();
9919
10211
  return [2 /*return*/];
@@ -9921,7 +10213,7 @@ var cancelOutputForce = function (clientId) { return __awaiter(void 0, void 0, v
9921
10213
  });
9922
10214
  }); };
9923
10215
 
9924
- var METHOD_NAME$p = "function.commitStopTools";
10216
+ var METHOD_NAME$s = "function.commit.commitStopTools";
9925
10217
  /**
9926
10218
  * Prevent the next tool from being executed
9927
10219
  *
@@ -9935,15 +10227,15 @@ var commitStopTools = function (clientId, agentName) { return __awaiter(void 0,
9935
10227
  switch (_a.label) {
9936
10228
  case 0:
9937
10229
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9938
- swarm$1.loggerService.log(METHOD_NAME$p, {
10230
+ swarm$1.loggerService.log(METHOD_NAME$s, {
9939
10231
  clientId: clientId,
9940
10232
  agentName: agentName,
9941
10233
  });
9942
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$p);
9943
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$p);
10234
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$s);
10235
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$s);
9944
10236
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
9945
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$p);
9946
- return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$p, clientId, swarmName)];
10237
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$s);
10238
+ return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$s, clientId, swarmName)];
9947
10239
  case 1:
9948
10240
  currentAgentName = _a.sent();
9949
10241
  if (currentAgentName !== agentName) {
@@ -9955,7 +10247,7 @@ var commitStopTools = function (clientId, agentName) { return __awaiter(void 0,
9955
10247
  });
9956
10248
  return [2 /*return*/];
9957
10249
  }
9958
- return [4 /*yield*/, swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$p, clientId, swarmName)];
10250
+ return [4 /*yield*/, swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$s, clientId, swarmName)];
9959
10251
  case 2:
9960
10252
  _a.sent();
9961
10253
  return [2 /*return*/];
@@ -9963,7 +10255,7 @@ var commitStopTools = function (clientId, agentName) { return __awaiter(void 0,
9963
10255
  });
9964
10256
  }); };
9965
10257
 
9966
- var METHOD_NAME$o = "function.commitStopToolsForce";
10258
+ var METHOD_NAME$r = "function.commit.commitStopToolsForce";
9967
10259
  /**
9968
10260
  * Prevent the next tool from being executed without active agent check
9969
10261
  *
@@ -9976,14 +10268,14 @@ var commitStopToolsForce = function (clientId) { return __awaiter(void 0, void 0
9976
10268
  switch (_a.label) {
9977
10269
  case 0:
9978
10270
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
9979
- swarm$1.loggerService.log(METHOD_NAME$o, {
10271
+ swarm$1.loggerService.log(METHOD_NAME$r, {
9980
10272
  clientId: clientId,
9981
- METHOD_NAME: METHOD_NAME$o,
10273
+ METHOD_NAME: METHOD_NAME$r,
9982
10274
  });
9983
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$o);
10275
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$r);
9984
10276
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
9985
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$o);
9986
- return [4 /*yield*/, swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$o, clientId, swarmName)];
10277
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$r);
10278
+ return [4 /*yield*/, swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$r, clientId, swarmName)];
9987
10279
  case 1:
9988
10280
  _a.sent();
9989
10281
  return [2 /*return*/];
@@ -9991,7 +10283,7 @@ var commitStopToolsForce = function (clientId) { return __awaiter(void 0, void 0
9991
10283
  });
9992
10284
  }); };
9993
10285
 
9994
- var METHOD_NAME$n = "function.emitForce";
10286
+ var METHOD_NAME$q = "function.target.emitForce";
9995
10287
  /**
9996
10288
  * Emits a string constant as the model output without executing incoming message and checking active agent
9997
10289
  * Works only for `makeConnection`
@@ -10008,23 +10300,23 @@ var emitForce = function (content, clientId) { return __awaiter(void 0, void 0,
10008
10300
  switch (_a.label) {
10009
10301
  case 0:
10010
10302
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
10011
- swarm$1.loggerService.log(METHOD_NAME$n, {
10303
+ swarm$1.loggerService.log(METHOD_NAME$q, {
10012
10304
  content: content,
10013
10305
  clientId: clientId,
10014
10306
  });
10015
10307
  if (swarm$1.sessionValidationService.getSessionMode(clientId) !== "makeConnection") {
10016
10308
  throw new Error("agent-swarm-kit emitForce session is not makeConnection clientId=".concat(clientId));
10017
10309
  }
10018
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$n);
10310
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$q);
10019
10311
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
10020
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$n);
10021
- return [4 /*yield*/, swarm$1.sessionPublicService.emit(content, METHOD_NAME$n, clientId, swarmName)];
10312
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$q);
10313
+ return [4 /*yield*/, swarm$1.sessionPublicService.emit(content, METHOD_NAME$q, clientId, swarmName)];
10022
10314
  case 1: return [2 /*return*/, _a.sent()];
10023
10315
  }
10024
10316
  });
10025
10317
  }); };
10026
10318
 
10027
- var METHOD_NAME$m = "function.executeForce";
10319
+ var METHOD_NAME$p = "function.target.executeForce";
10028
10320
  /**
10029
10321
  * Send the message to the active agent in the swarm content like it income from client side
10030
10322
  * Should be used to review tool output and initiate conversation from the model side to client
@@ -10040,18 +10332,18 @@ var executeForce = function (content, clientId) { return __awaiter(void 0, void
10040
10332
  return __generator(this, function (_a) {
10041
10333
  executionId = randomString();
10042
10334
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
10043
- swarm$1.loggerService.log(METHOD_NAME$m, {
10335
+ swarm$1.loggerService.log(METHOD_NAME$p, {
10044
10336
  content: content,
10045
10337
  clientId: clientId,
10046
10338
  executionId: executionId,
10047
10339
  });
10048
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$m);
10340
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$p);
10049
10341
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
10050
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$m);
10342
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$p);
10051
10343
  return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(void 0, void 0, void 0, function () {
10052
10344
  return __generator(this, function (_a) {
10053
10345
  switch (_a.label) {
10054
- case 0: return [4 /*yield*/, swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$m, clientId, swarmName)];
10346
+ case 0: return [4 /*yield*/, swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$p, clientId, swarmName)];
10055
10347
  case 1: return [2 /*return*/, _a.sent()];
10056
10348
  }
10057
10349
  });
@@ -10062,7 +10354,7 @@ var executeForce = function (content, clientId) { return __awaiter(void 0, void
10062
10354
  });
10063
10355
  }); };
10064
10356
 
10065
- var METHOD_NAME$l = "function.disposeConnection";
10357
+ var METHOD_NAME$o = "function.target.disposeConnection";
10066
10358
  /**
10067
10359
  * Disposes the session for a given client with all related swarms and agents.
10068
10360
  *
@@ -10076,12 +10368,12 @@ var disposeConnection = function (clientId_1, swarmName_1) {
10076
10368
  args_1[_i - 2] = arguments[_i];
10077
10369
  }
10078
10370
  return __awaiter(void 0, __spreadArray([clientId_1, swarmName_1], __read(args_1), false), void 0, function (clientId, swarmName, methodName) {
10079
- if (methodName === void 0) { methodName = METHOD_NAME$l; }
10371
+ if (methodName === void 0) { methodName = METHOD_NAME$o; }
10080
10372
  return __generator(this, function (_a) {
10081
10373
  switch (_a.label) {
10082
10374
  case 0:
10083
10375
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
10084
- swarm$1.loggerService.log(METHOD_NAME$l, {
10376
+ swarm$1.loggerService.log(METHOD_NAME$o, {
10085
10377
  clientId: clientId,
10086
10378
  swarmName: swarmName,
10087
10379
  });
@@ -10155,13 +10447,14 @@ var disposeConnection = function (clientId_1, swarmName_1) {
10155
10447
  swarm$1.sessionValidationService.removeSession(clientId);
10156
10448
  swarm$1.busService.dispose(clientId);
10157
10449
  swarm$1.sessionValidationService.dispose(clientId);
10450
+ swarm$1.memorySchemaService.dispose(clientId);
10158
10451
  return [2 /*return*/];
10159
10452
  }
10160
10453
  });
10161
10454
  });
10162
10455
  };
10163
10456
 
10164
- var METHOD_NAME$k = "function.makeAutoDispose";
10457
+ var METHOD_NAME$n = "function.target.makeAutoDispose";
10165
10458
  var DEFAULT_TIMEOUT = 15 * 60;
10166
10459
  /**
10167
10460
  * Creates an auto-dispose mechanism for a client in a swarm.
@@ -10174,7 +10467,7 @@ var DEFAULT_TIMEOUT = 15 * 60;
10174
10467
  var makeAutoDispose = function (clientId, swarmName, _a) {
10175
10468
  var _b = _a === void 0 ? {} : _a, _c = _b.timeoutSeconds, timeoutSeconds = _c === void 0 ? DEFAULT_TIMEOUT : _c, onDestroy = _b.onDestroy;
10176
10469
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
10177
- swarm$1.loggerService.log(METHOD_NAME$k, {
10470
+ swarm$1.loggerService.log(METHOD_NAME$n, {
10178
10471
  clientId: clientId,
10179
10472
  swarmName: swarmName,
10180
10473
  });
@@ -10221,7 +10514,7 @@ var makeAutoDispose = function (clientId, swarmName, _a) {
10221
10514
  };
10222
10515
  };
10223
10516
 
10224
- var METHOD_NAME$j = "function.execute";
10517
+ var METHOD_NAME$m = "function.target.execute";
10225
10518
  /**
10226
10519
  * Send the message to the active agent in the swarm content like it income from client side
10227
10520
  * Should be used to review tool output and initiate conversation from the model side to client
@@ -10238,17 +10531,17 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
10238
10531
  case 0:
10239
10532
  executionId = randomString();
10240
10533
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
10241
- swarm$1.loggerService.log(METHOD_NAME$j, {
10534
+ swarm$1.loggerService.log(METHOD_NAME$m, {
10242
10535
  content: content,
10243
10536
  clientId: clientId,
10244
10537
  agentName: agentName,
10245
10538
  executionId: executionId,
10246
10539
  });
10247
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$j);
10248
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$j);
10540
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$m);
10541
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$m);
10249
10542
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
10250
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$j);
10251
- return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$j, clientId, swarmName)];
10543
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$m);
10544
+ return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$m, clientId, swarmName)];
10252
10545
  case 1:
10253
10546
  currentAgentName = _a.sent();
10254
10547
  if (currentAgentName !== agentName) {
@@ -10263,7 +10556,7 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
10263
10556
  return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(void 0, void 0, void 0, function () {
10264
10557
  return __generator(this, function (_a) {
10265
10558
  switch (_a.label) {
10266
- case 0: return [4 /*yield*/, swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$j, clientId, swarmName)];
10559
+ case 0: return [4 /*yield*/, swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$m, clientId, swarmName)];
10267
10560
  case 1: return [2 /*return*/, _a.sent()];
10268
10561
  }
10269
10562
  });
@@ -10275,7 +10568,7 @@ var execute = function (content, clientId, agentName) { return __awaiter(void 0,
10275
10568
  });
10276
10569
  }); };
10277
10570
 
10278
- var METHOD_NAME$i = "function.emit";
10571
+ var METHOD_NAME$l = "function.target.emit";
10279
10572
  /**
10280
10573
  * Emits a string constant as the model output without executing incoming message
10281
10574
  * Works only for `makeConnection`
@@ -10292,7 +10585,7 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
10292
10585
  switch (_a.label) {
10293
10586
  case 0:
10294
10587
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
10295
- swarm$1.loggerService.log(METHOD_NAME$i, {
10588
+ swarm$1.loggerService.log(METHOD_NAME$l, {
10296
10589
  content: content,
10297
10590
  clientId: clientId,
10298
10591
  agentName: agentName,
@@ -10300,11 +10593,11 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
10300
10593
  if (swarm$1.sessionValidationService.getSessionMode(clientId) !== "makeConnection") {
10301
10594
  throw new Error("agent-swarm-kit emit session is not makeConnection clientId=".concat(clientId));
10302
10595
  }
10303
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$i);
10304
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$i);
10596
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$l);
10597
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$l);
10305
10598
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
10306
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$i);
10307
- return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$i, clientId, swarmName)];
10599
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$l);
10600
+ return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$l, clientId, swarmName)];
10308
10601
  case 1:
10309
10602
  currentAgentName = _a.sent();
10310
10603
  if (currentAgentName !== agentName) {
@@ -10316,13 +10609,105 @@ var emit = function (content, clientId, agentName) { return __awaiter(void 0, vo
10316
10609
  });
10317
10610
  return [2 /*return*/];
10318
10611
  }
10319
- return [4 /*yield*/, swarm$1.sessionPublicService.emit(content, METHOD_NAME$i, clientId, swarmName)];
10612
+ return [4 /*yield*/, swarm$1.sessionPublicService.emit(content, METHOD_NAME$l, clientId, swarmName)];
10320
10613
  case 2: return [2 /*return*/, _a.sent()];
10321
10614
  }
10322
10615
  });
10323
10616
  }); };
10324
10617
 
10325
- var METHOD_NAME$h = "function.getAgentName";
10618
+ var METHOD_NAME$k = "function.target.run";
10619
+ /**
10620
+ * Complete the message stateless without append to the chat history
10621
+ * Use to prevent model from history overflow while handling storage output
10622
+ *
10623
+ * @param {string} content - The content to be runned.
10624
+ * @param {string} clientId - The ID of the client requesting run.
10625
+ * @param {AgentName} agentName - The name of the agent running the command.
10626
+ * @returns {Promise<string>} - A promise that resolves the run result
10627
+ */
10628
+ var run = function (content, clientId, agentName) { return __awaiter(void 0, void 0, void 0, function () {
10629
+ var executionId, swarmName, currentAgentName;
10630
+ return __generator(this, function (_a) {
10631
+ switch (_a.label) {
10632
+ case 0:
10633
+ executionId = randomString();
10634
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
10635
+ swarm$1.loggerService.log(METHOD_NAME$k, {
10636
+ content: content,
10637
+ clientId: clientId,
10638
+ agentName: agentName,
10639
+ executionId: executionId,
10640
+ });
10641
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$k);
10642
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$k);
10643
+ swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
10644
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$k);
10645
+ return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$k, clientId, swarmName)];
10646
+ case 1:
10647
+ currentAgentName = _a.sent();
10648
+ if (currentAgentName !== agentName) {
10649
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
10650
+ swarm$1.loggerService.log('function "run" skipped due to the agent change', {
10651
+ currentAgentName: currentAgentName,
10652
+ agentName: agentName,
10653
+ clientId: clientId,
10654
+ });
10655
+ return [2 /*return*/];
10656
+ }
10657
+ return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(void 0, void 0, void 0, function () {
10658
+ return __generator(this, function (_a) {
10659
+ switch (_a.label) {
10660
+ case 0: return [4 /*yield*/, swarm$1.sessionPublicService.run(content, METHOD_NAME$k, clientId, swarmName)];
10661
+ case 1: return [2 /*return*/, _a.sent()];
10662
+ }
10663
+ });
10664
+ }); }, {
10665
+ clientId: clientId,
10666
+ executionId: executionId,
10667
+ })];
10668
+ }
10669
+ });
10670
+ }); };
10671
+
10672
+ var METHOD_NAME$j = "function.target.runForce";
10673
+ /**
10674
+ * Complete the message stateless without append to the chat history
10675
+ * Use to prevent model from history overflow while handling storage output
10676
+ *
10677
+ * Will run even if the agent is inactive
10678
+ *
10679
+ * @param {string} content - The content to be runned.
10680
+ * @param {string} clientId - The ID of the client requesting run.
10681
+ * @returns {Promise<string>} - A promise that resolves the run result
10682
+ */
10683
+ var runForce = function (content, clientId) { return __awaiter(void 0, void 0, void 0, function () {
10684
+ var executionId, swarmName;
10685
+ return __generator(this, function (_a) {
10686
+ executionId = randomString();
10687
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
10688
+ swarm$1.loggerService.log(METHOD_NAME$j, {
10689
+ content: content,
10690
+ clientId: clientId,
10691
+ executionId: executionId,
10692
+ });
10693
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$j);
10694
+ swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
10695
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$j);
10696
+ return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(void 0, void 0, void 0, function () {
10697
+ return __generator(this, function (_a) {
10698
+ switch (_a.label) {
10699
+ case 0: return [4 /*yield*/, swarm$1.sessionPublicService.run(content, METHOD_NAME$j, clientId, swarmName)];
10700
+ case 1: return [2 /*return*/, _a.sent()];
10701
+ }
10702
+ });
10703
+ }); }, {
10704
+ clientId: clientId,
10705
+ executionId: executionId,
10706
+ })];
10707
+ });
10708
+ }); };
10709
+
10710
+ var METHOD_NAME$i = "function.common.getAgentName";
10326
10711
  /**
10327
10712
  * Retrieves the agent name for a given client ID.
10328
10713
  *
@@ -10336,20 +10721,20 @@ var getAgentName = function (clientId) { return __awaiter(void 0, void 0, void 0
10336
10721
  switch (_a.label) {
10337
10722
  case 0:
10338
10723
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
10339
- swarm$1.loggerService.log(METHOD_NAME$h, {
10724
+ swarm$1.loggerService.log(METHOD_NAME$i, {
10340
10725
  clientId: clientId,
10341
10726
  });
10342
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$h);
10727
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$i);
10343
10728
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
10344
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$h);
10345
- return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$h, clientId, swarmName)];
10729
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$i);
10730
+ return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$i, clientId, swarmName)];
10346
10731
  case 1: return [2 /*return*/, _a.sent()];
10347
10732
  }
10348
10733
  });
10349
10734
  }); };
10350
10735
 
10351
10736
  var SCHEDULED_DELAY$1 = 1000;
10352
- var METHOD_NAME$g = "function.makeConnection";
10737
+ var METHOD_NAME$h = "function.target.makeConnection";
10353
10738
  /**
10354
10739
  * A connection factory for a client to a swarm and returns a function to send messages.
10355
10740
  *
@@ -10360,25 +10745,25 @@ var METHOD_NAME$g = "function.makeConnection";
10360
10745
  */
10361
10746
  var makeConnection = function (connector, clientId, swarmName) {
10362
10747
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
10363
- swarm$1.loggerService.log(METHOD_NAME$g, {
10748
+ swarm$1.loggerService.log(METHOD_NAME$h, {
10364
10749
  clientId: clientId,
10365
10750
  swarmName: swarmName,
10366
10751
  });
10367
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$g);
10752
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$h);
10368
10753
  swarm$1.sessionValidationService.addSession(clientId, swarmName, "makeConnection");
10369
- var send = swarm$1.sessionPublicService.connect(connector, METHOD_NAME$g, clientId, swarmName);
10754
+ var send = swarm$1.sessionPublicService.connect(connector, METHOD_NAME$h, clientId, swarmName);
10370
10755
  return queued(function (outgoing) { return __awaiter(void 0, void 0, void 0, function () {
10371
10756
  var _a;
10372
10757
  var _b;
10373
10758
  return __generator(this, function (_c) {
10374
10759
  switch (_c.label) {
10375
10760
  case 0:
10376
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$g);
10761
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$h);
10377
10762
  _a = send;
10378
10763
  _b = {
10379
10764
  data: outgoing
10380
10765
  };
10381
- return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$g, clientId, swarmName)];
10766
+ return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$h, clientId, swarmName)];
10382
10767
  case 1: return [4 /*yield*/, _a.apply(void 0, [(_b.agentName = _c.sent(),
10383
10768
  _b.clientId = clientId,
10384
10769
  _b)])];
@@ -10464,7 +10849,7 @@ makeConnection.scheduled = function (connector, clientId, swarmName, _a) {
10464
10849
  }); };
10465
10850
  };
10466
10851
 
10467
- var METHOD_NAME$f = "function.complete";
10852
+ var METHOD_NAME$g = "function.target.complete";
10468
10853
  var COMPLETE_TTL = 15 * 60 * 1000;
10469
10854
  var COMPLETE_GC = 60 * 1000;
10470
10855
  /**
@@ -10524,7 +10909,7 @@ var complete = function (content, clientId, swarmName) { return __awaiter(void 0
10524
10909
  case 0:
10525
10910
  executionId = randomString();
10526
10911
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
10527
- swarm$1.loggerService.log(METHOD_NAME$f, {
10912
+ swarm$1.loggerService.log(METHOD_NAME$g, {
10528
10913
  content: content,
10529
10914
  clientId: clientId,
10530
10915
  executionId: executionId,
@@ -10537,7 +10922,7 @@ var complete = function (content, clientId, swarmName) { return __awaiter(void 0
10537
10922
  return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(void 0, void 0, void 0, function () {
10538
10923
  return __generator(this, function (_a) {
10539
10924
  switch (_a.label) {
10540
- case 0: return [4 /*yield*/, run(METHOD_NAME$f, content)];
10925
+ case 0: return [4 /*yield*/, run(METHOD_NAME$g, content)];
10541
10926
  case 1: return [2 /*return*/, _a.sent()];
10542
10927
  }
10543
10928
  });
@@ -10550,7 +10935,7 @@ var complete = function (content, clientId, swarmName) { return __awaiter(void 0
10550
10935
  }); };
10551
10936
 
10552
10937
  var SCHEDULED_DELAY = 1000;
10553
- var METHOD_NAME$e = "function.session";
10938
+ var METHOD_NAME$f = "function.target.session";
10554
10939
  /**
10555
10940
  * Creates a session for the given client and swarm.
10556
10941
  *
@@ -10563,12 +10948,12 @@ var METHOD_NAME$e = "function.session";
10563
10948
  var session = function (clientId, swarmName) {
10564
10949
  var executionId = randomString();
10565
10950
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
10566
- swarm$1.loggerService.log(METHOD_NAME$e, {
10951
+ swarm$1.loggerService.log(METHOD_NAME$f, {
10567
10952
  clientId: clientId,
10568
10953
  swarmName: swarmName,
10569
10954
  executionId: executionId,
10570
10955
  });
10571
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$e);
10956
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$f);
10572
10957
  swarm$1.sessionValidationService.addSession(clientId, swarmName, "session");
10573
10958
  return {
10574
10959
  /**
@@ -10579,11 +10964,11 @@ var session = function (clientId, swarmName) {
10579
10964
  */
10580
10965
  complete: queued(function (content) { return __awaiter(void 0, void 0, void 0, function () {
10581
10966
  return __generator(this, function (_a) {
10582
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$e);
10967
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$f);
10583
10968
  return [2 /*return*/, ExecutionContextService.runInContext(function () { return __awaiter(void 0, void 0, void 0, function () {
10584
10969
  return __generator(this, function (_a) {
10585
10970
  switch (_a.label) {
10586
- case 0: return [4 /*yield*/, swarm$1.sessionPublicService.execute(content, "user", METHOD_NAME$e, clientId, swarmName)];
10971
+ case 0: return [4 /*yield*/, swarm$1.sessionPublicService.execute(content, "user", METHOD_NAME$f, clientId, swarmName)];
10587
10972
  case 1: return [2 /*return*/, _a.sent()];
10588
10973
  }
10589
10974
  });
@@ -10601,7 +10986,7 @@ var session = function (clientId, swarmName) {
10601
10986
  dispose: function () { return __awaiter(void 0, void 0, void 0, function () {
10602
10987
  return __generator(this, function (_a) {
10603
10988
  switch (_a.label) {
10604
- case 0: return [4 /*yield*/, disposeConnection(clientId, swarmName, METHOD_NAME$e)];
10989
+ case 0: return [4 /*yield*/, disposeConnection(clientId, swarmName, METHOD_NAME$f)];
10605
10990
  case 1: return [2 /*return*/, _a.sent()];
10606
10991
  }
10607
10992
  });
@@ -10700,7 +11085,7 @@ session.scheduled = function (clientId, swarmName, _a) {
10700
11085
  };
10701
11086
  };
10702
11087
 
10703
- var METHOD_NAME$d = "function.getAgentHistory";
11088
+ var METHOD_NAME$e = "function.common.getAgentHistory";
10704
11089
  /**
10705
11090
  * Retrieves the history prepared for a specific agent with resque algorithm tweaks
10706
11091
  *
@@ -10714,13 +11099,14 @@ var getAgentHistory = function (clientId, agentName) { return __awaiter(void 0,
10714
11099
  switch (_a.label) {
10715
11100
  case 0:
10716
11101
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
10717
- swarm$1.loggerService.log(METHOD_NAME$d, {
11102
+ swarm$1.loggerService.log(METHOD_NAME$e, {
10718
11103
  clientId: clientId,
10719
11104
  agentName: agentName,
10720
11105
  });
10721
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$d);
11106
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$e);
11107
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$e);
10722
11108
  prompt = swarm$1.agentSchemaService.get(agentName).prompt;
10723
- return [4 /*yield*/, swarm$1.historyPublicService.toArrayForAgent(prompt, METHOD_NAME$d, clientId, agentName)];
11109
+ return [4 /*yield*/, swarm$1.historyPublicService.toArrayForAgent(prompt, METHOD_NAME$e, clientId, agentName)];
10724
11110
  case 1:
10725
11111
  history = _a.sent();
10726
11112
  return [2 /*return*/, __spreadArray([], __read(history), false)];
@@ -10728,7 +11114,7 @@ var getAgentHistory = function (clientId, agentName) { return __awaiter(void 0,
10728
11114
  });
10729
11115
  }); };
10730
11116
 
10731
- var METHOD_NAME$c = "function.getSessionMode";
11117
+ var METHOD_NAME$d = "function.common.getSessionMode";
10732
11118
  /**
10733
11119
  * Return the session mode (`"session" | "makeConnection" | "complete"`) for clientId
10734
11120
  *
@@ -10738,16 +11124,45 @@ var getSessionMode = function (clientId) { return __awaiter(void 0, void 0, void
10738
11124
  var swarmName;
10739
11125
  return __generator(this, function (_a) {
10740
11126
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
10741
- swarm$1.loggerService.log(METHOD_NAME$c, {
11127
+ swarm$1.loggerService.log(METHOD_NAME$d, {
10742
11128
  clientId: clientId,
10743
11129
  });
11130
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$d);
10744
11131
  swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
10745
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$c);
11132
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$d);
10746
11133
  return [2 /*return*/, swarm$1.sessionValidationService.getSessionMode(clientId)];
10747
11134
  });
10748
11135
  }); };
10749
11136
 
10750
- var METHOD_NAME$b = "function.getRawHistory";
11137
+ var METHOD_NAME$c = "function.common.getSessionContext";
11138
+ /**
11139
+ * Retrieves the session context for a given client ID.
11140
+ *
11141
+ * @param {string} clientId - The ID of the client.
11142
+ * @returns {Promise<ISessionContext>} A promise that resolves to the session context.
11143
+ */
11144
+ var getSessionContext = function () { return __awaiter(void 0, void 0, void 0, function () {
11145
+ var methodContext, executionContext, clientId;
11146
+ var _a;
11147
+ return __generator(this, function (_b) {
11148
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
11149
+ swarm$1.loggerService.log(METHOD_NAME$c);
11150
+ methodContext = MethodContextService.hasContext()
11151
+ ? swarm$1.methodContextService.context
11152
+ : null;
11153
+ executionContext = ExecutionContextService.hasContext()
11154
+ ? swarm$1.executionContextService.context
11155
+ : null;
11156
+ clientId = (_a = methodContext === null || methodContext === void 0 ? void 0 : methodContext.clientId) !== null && _a !== void 0 ? _a : executionContext === null || executionContext === void 0 ? void 0 : executionContext.clientId;
11157
+ return [2 /*return*/, {
11158
+ clientId: clientId,
11159
+ methodContext: methodContext,
11160
+ executionContext: executionContext,
11161
+ }];
11162
+ });
11163
+ }); };
11164
+
11165
+ var METHOD_NAME$b = "function.history.getRawHistory";
10751
11166
  /**
10752
11167
  * Retrieves the raw history as it is for a given client ID without any modifications.
10753
11168
  *
@@ -10784,7 +11199,7 @@ var getRawHistory = function (clientId_1) {
10784
11199
  });
10785
11200
  };
10786
11201
 
10787
- var METHOD_NAME$a = "function.getLastUserMessage";
11202
+ var METHOD_NAME$a = "function.history.getLastUserMessage";
10788
11203
  /**
10789
11204
  * Retrieves the last message sent by the user from the client's message history.
10790
11205
  *
@@ -10812,7 +11227,7 @@ var getLastUserMessage = function (clientId) { return __awaiter(void 0, void 0,
10812
11227
  });
10813
11228
  }); };
10814
11229
 
10815
- var METHOD_NAME$9 = "function.getUserHistory";
11230
+ var METHOD_NAME$9 = "function.history.getUserHistory";
10816
11231
  /**
10817
11232
  * Retrieves the user history for a given client ID.
10818
11233
  *
@@ -10839,7 +11254,7 @@ var getUserHistory = function (clientId) { return __awaiter(void 0, void 0, void
10839
11254
  });
10840
11255
  }); };
10841
11256
 
10842
- var METHOD_NAME$8 = "function.getAssistantHistory";
11257
+ var METHOD_NAME$8 = "function.history.getAssistantHistory";
10843
11258
  /**
10844
11259
  * Retrieves the assistant's history for a given client.
10845
11260
  *
@@ -10866,7 +11281,7 @@ var getAssistantHistory = function (clientId) { return __awaiter(void 0, void 0,
10866
11281
  });
10867
11282
  }); };
10868
11283
 
10869
- var METHOD_NAME$7 = "function.getLastAssistantMessage";
11284
+ var METHOD_NAME$7 = "function.history.getLastAssistantMessage";
10870
11285
  /**
10871
11286
  * Retrieves the last message sent by the assistant from the client's message history.
10872
11287
  *
@@ -10894,7 +11309,7 @@ var getLastAssistantMessage = function (clientId) { return __awaiter(void 0, voi
10894
11309
  });
10895
11310
  }); };
10896
11311
 
10897
- var METHOD_NAME$6 = "function.getLastSystemMessage";
11312
+ var METHOD_NAME$6 = "function.history.getLastSystemMessage";
10898
11313
  /**
10899
11314
  * Retrieves the last message sent by the system from the client's message history.
10900
11315
  *
@@ -10922,7 +11337,7 @@ var getLastSystemMessage = function (clientId) { return __awaiter(void 0, void 0
10922
11337
  });
10923
11338
  }); };
10924
11339
 
10925
- var METHOD_NAME$5 = "function.listenEvent";
11340
+ var METHOD_NAME$5 = "function.event.listenEvent";
10926
11341
  var DISALLOWED_EVENT_SOURCE_LIST$2 = new Set([
10927
11342
  "agent-bus",
10928
11343
  "history-bus",
@@ -10954,7 +11369,7 @@ var event = function (clientId, topicName, payload) {
10954
11369
  });
10955
11370
  };
10956
11371
 
10957
- var METHOD_NAME$4 = "function.listenEvent";
11372
+ var METHOD_NAME$4 = "function.event.listenEvent";
10958
11373
  var DISALLOWED_EVENT_SOURCE_LIST$1 = new Set([
10959
11374
  "agent-bus",
10960
11375
  "history-bus",
@@ -10987,13 +11402,18 @@ var listenEvent = function (clientId, topicName, fn) {
10987
11402
  throw new Error("agent-swarm listenEvent topic is reserved topicName=".concat(topicName));
10988
11403
  }
10989
11404
  validateClientId$d(clientId);
10990
- return swarm$1.busService.subscribe(clientId, topicName, function (_a) {
10991
- var payload = _a.payload;
10992
- return fn(payload);
10993
- });
11405
+ return swarm$1.busService.subscribe(clientId, topicName, queued(function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
11406
+ var payload = _b.payload;
11407
+ return __generator(this, function (_c) {
11408
+ switch (_c.label) {
11409
+ case 0: return [4 /*yield*/, fn(payload)];
11410
+ case 1: return [2 /*return*/, _c.sent()];
11411
+ }
11412
+ });
11413
+ }); }));
10994
11414
  };
10995
11415
 
10996
- var METHOD_NAME$3 = "function.listenEventOnce";
11416
+ var METHOD_NAME$3 = "function.event.listenEventOnce";
10997
11417
  var DISALLOWED_EVENT_SOURCE_LIST = new Set([
10998
11418
  "agent-bus",
10999
11419
  "history-bus",
@@ -11029,13 +11449,18 @@ var listenEventOnce = function (clientId, topicName, filterFn, fn) {
11029
11449
  return swarm$1.busService.once(clientId, topicName, function (_a) {
11030
11450
  var payload = _a.payload;
11031
11451
  return filterFn(payload);
11032
- }, function (_a) {
11033
- var payload = _a.payload;
11034
- return fn(payload);
11035
- });
11452
+ }, queued(function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
11453
+ var payload = _b.payload;
11454
+ return __generator(this, function (_c) {
11455
+ switch (_c.label) {
11456
+ case 0: return [4 /*yield*/, fn(payload)];
11457
+ case 1: return [2 /*return*/, _c.sent()];
11458
+ }
11459
+ });
11460
+ }); }));
11036
11461
  };
11037
11462
 
11038
- var METHOD_NAME$2 = "function.changeToAgent";
11463
+ var METHOD_NAME$2 = "function.navigate.changeToAgent";
11039
11464
  /**
11040
11465
  * Time-to-live for the change agent function in milliseconds.
11041
11466
  * @constant {number}
@@ -11151,7 +11576,7 @@ var changeToAgent = function (agentName, clientId) { return __awaiter(void 0, vo
11151
11576
  });
11152
11577
  }); };
11153
11578
 
11154
- var METHOD_NAME$1 = "function.changeToPrevAgent";
11579
+ var METHOD_NAME$1 = "function.navigate.changeToPrevAgent";
11155
11580
  /**
11156
11581
  * Time-to-live for the change agent function in milliseconds.
11157
11582
  * @constant {number}
@@ -11264,7 +11689,7 @@ var changeToPrevAgent = function (clientId) { return __awaiter(void 0, void 0, v
11264
11689
  });
11265
11690
  }); };
11266
11691
 
11267
- var METHOD_NAME = "function.changeToDefaultAgent";
11692
+ var METHOD_NAME = "function.navigate.changeToDefaultAgent";
11268
11693
  /**
11269
11694
  * Time-to-live for the change agent function in milliseconds.
11270
11695
  * @constant {number}
@@ -11394,7 +11819,12 @@ var listenAgentEvent = function (clientId, fn) {
11394
11819
  clientId: clientId,
11395
11820
  });
11396
11821
  validateClientId$b(clientId);
11397
- return swarm$1.busService.subscribe(clientId, "agent-bus", fn);
11822
+ return swarm$1.busService.subscribe(clientId, "agent-bus", queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
11823
+ switch (_a.label) {
11824
+ case 0: return [4 /*yield*/, fn(e)];
11825
+ case 1: return [2 /*return*/, _a.sent()];
11826
+ }
11827
+ }); }); }));
11398
11828
  };
11399
11829
 
11400
11830
  var validateClientId$a = function (clientId) {
@@ -11416,7 +11846,12 @@ var listenHistoryEvent = function (clientId, fn) {
11416
11846
  clientId: clientId,
11417
11847
  });
11418
11848
  validateClientId$a(clientId);
11419
- return swarm$1.busService.subscribe(clientId, "history-bus", fn);
11849
+ return swarm$1.busService.subscribe(clientId, "history-bus", queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
11850
+ switch (_a.label) {
11851
+ case 0: return [4 /*yield*/, fn(e)];
11852
+ case 1: return [2 /*return*/, _a.sent()];
11853
+ }
11854
+ }); }); }));
11420
11855
  };
11421
11856
 
11422
11857
  var validateClientId$9 = function (clientId) {
@@ -11438,7 +11873,12 @@ var listenSessionEvent = function (clientId, fn) {
11438
11873
  clientId: clientId,
11439
11874
  });
11440
11875
  validateClientId$9(clientId);
11441
- return swarm$1.busService.subscribe(clientId, "session-bus", fn);
11876
+ return swarm$1.busService.subscribe(clientId, "session-bus", queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
11877
+ switch (_a.label) {
11878
+ case 0: return [4 /*yield*/, fn(e)];
11879
+ case 1: return [2 /*return*/, _a.sent()];
11880
+ }
11881
+ }); }); }));
11442
11882
  };
11443
11883
 
11444
11884
  var validateClientId$8 = function (clientId) {
@@ -11460,7 +11900,12 @@ var listenStateEvent = function (clientId, fn) {
11460
11900
  clientId: clientId,
11461
11901
  });
11462
11902
  validateClientId$8(clientId);
11463
- return swarm$1.busService.subscribe(clientId, "state-bus", fn);
11903
+ return swarm$1.busService.subscribe(clientId, "state-bus", queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
11904
+ switch (_a.label) {
11905
+ case 0: return [4 /*yield*/, fn(e)];
11906
+ case 1: return [2 /*return*/, _a.sent()];
11907
+ }
11908
+ }); }); }));
11464
11909
  };
11465
11910
 
11466
11911
  var validateClientId$7 = function (clientId) {
@@ -11482,7 +11927,12 @@ var listenStorageEvent = function (clientId, fn) {
11482
11927
  clientId: clientId,
11483
11928
  });
11484
11929
  validateClientId$7(clientId);
11485
- return swarm$1.busService.subscribe(clientId, "storage-bus", fn);
11930
+ return swarm$1.busService.subscribe(clientId, "storage-bus", queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
11931
+ switch (_a.label) {
11932
+ case 0: return [4 /*yield*/, fn(e)];
11933
+ case 1: return [2 /*return*/, _a.sent()];
11934
+ }
11935
+ }); }); }));
11486
11936
  };
11487
11937
 
11488
11938
  var validateClientId$6 = function (clientId) {
@@ -11504,7 +11954,12 @@ var listenSwarmEvent = function (clientId, fn) {
11504
11954
  clientId: clientId,
11505
11955
  });
11506
11956
  validateClientId$6(clientId);
11507
- return swarm$1.busService.subscribe(clientId, "swarm-bus", fn);
11957
+ return swarm$1.busService.subscribe(clientId, "swarm-bus", queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
11958
+ switch (_a.label) {
11959
+ case 0: return [4 /*yield*/, fn(e)];
11960
+ case 1: return [2 /*return*/, _a.sent()];
11961
+ }
11962
+ }); }); }));
11508
11963
  };
11509
11964
 
11510
11965
  var validateClientId$5 = function (clientId) {
@@ -11526,7 +11981,12 @@ var listenAgentEventOnce = function (clientId, filterFn, fn) {
11526
11981
  clientId: clientId,
11527
11982
  });
11528
11983
  validateClientId$5(clientId);
11529
- return swarm$1.busService.once(clientId, "agent-bus", filterFn, fn);
11984
+ return swarm$1.busService.once(clientId, "agent-bus", filterFn, queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
11985
+ switch (_a.label) {
11986
+ case 0: return [4 /*yield*/, fn(e)];
11987
+ case 1: return [2 /*return*/, _a.sent()];
11988
+ }
11989
+ }); }); }));
11530
11990
  };
11531
11991
 
11532
11992
  var validateClientId$4 = function (clientId) {
@@ -11548,7 +12008,12 @@ var listenHistoryEventOnce = function (clientId, filterFn, fn) {
11548
12008
  clientId: clientId,
11549
12009
  });
11550
12010
  validateClientId$4(clientId);
11551
- return swarm$1.busService.once(clientId, "history-bus", filterFn, fn);
12011
+ return swarm$1.busService.once(clientId, "history-bus", filterFn, queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
12012
+ switch (_a.label) {
12013
+ case 0: return [4 /*yield*/, fn(e)];
12014
+ case 1: return [2 /*return*/, _a.sent()];
12015
+ }
12016
+ }); }); }));
11552
12017
  };
11553
12018
 
11554
12019
  var validateClientId$3 = function (clientId) {
@@ -11570,7 +12035,12 @@ var listenSessionEventOnce = function (clientId, filterFn, fn) {
11570
12035
  clientId: clientId,
11571
12036
  });
11572
12037
  validateClientId$3(clientId);
11573
- return swarm$1.busService.once(clientId, "session-bus", filterFn, fn);
12038
+ return swarm$1.busService.once(clientId, "session-bus", filterFn, queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
12039
+ switch (_a.label) {
12040
+ case 0: return [4 /*yield*/, fn(e)];
12041
+ case 1: return [2 /*return*/, _a.sent()];
12042
+ }
12043
+ }); }); }));
11574
12044
  };
11575
12045
 
11576
12046
  var validateClientId$2 = function (clientId) {
@@ -11592,7 +12062,12 @@ var listenStateEventOnce = function (clientId, filterFn, fn) {
11592
12062
  clientId: clientId,
11593
12063
  });
11594
12064
  validateClientId$2(clientId);
11595
- return swarm$1.busService.once(clientId, "state-bus", filterFn, fn);
12065
+ return swarm$1.busService.once(clientId, "state-bus", filterFn, queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
12066
+ switch (_a.label) {
12067
+ case 0: return [4 /*yield*/, fn(e)];
12068
+ case 1: return [2 /*return*/, _a.sent()];
12069
+ }
12070
+ }); }); }));
11596
12071
  };
11597
12072
 
11598
12073
  var validateClientId$1 = function (clientId) {
@@ -11614,7 +12089,12 @@ var listenStorageEventOnce = function (clientId, filterFn, fn) {
11614
12089
  clientId: clientId,
11615
12090
  });
11616
12091
  validateClientId$1(clientId);
11617
- return swarm$1.busService.once(clientId, "storage-bus", filterFn, fn);
12092
+ return swarm$1.busService.once(clientId, "storage-bus", filterFn, queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
12093
+ switch (_a.label) {
12094
+ case 0: return [4 /*yield*/, fn(e)];
12095
+ case 1: return [2 /*return*/, _a.sent()];
12096
+ }
12097
+ }); }); }));
11618
12098
  };
11619
12099
 
11620
12100
  var validateClientId = function (clientId) {
@@ -11636,7 +12116,12 @@ var listenSwarmEventOnce = function (clientId, filterFn, fn) {
11636
12116
  clientId: clientId,
11637
12117
  });
11638
12118
  validateClientId(clientId);
11639
- return swarm$1.busService.once(clientId, "swarm-bus", filterFn, fn);
12119
+ return swarm$1.busService.once(clientId, "swarm-bus", filterFn, queued(function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
12120
+ switch (_a.label) {
12121
+ case 0: return [4 /*yield*/, fn(e)];
12122
+ case 1: return [2 /*return*/, _a.sent()];
12123
+ }
12124
+ }); }); }));
11640
12125
  };
11641
12126
 
11642
12127
  var METHOD_NAME_GET$3 = "StateUtils.getState";
@@ -11763,23 +12248,19 @@ var SharedStateUtils = /** @class */ (function () {
11763
12248
  * Retrieves the state for a given client and state name.
11764
12249
  * @template T
11765
12250
  * @param {Object} payload - The payload containing client and state information.
11766
- * @param {AgentName} payload.agentName - The agent name.
11767
12251
  * @param {StateName} payload.stateName - The state name.
11768
12252
  * @returns {Promise<T>} The state data.
11769
12253
  * @throws Will throw an error if the state is not registered in the agent.
11770
12254
  */
11771
- this.getState = function (payload) { return __awaiter(_this, void 0, void 0, function () {
12255
+ this.getState = function (stateName) { return __awaiter(_this, void 0, void 0, function () {
11772
12256
  return __generator(this, function (_a) {
11773
12257
  switch (_a.label) {
11774
12258
  case 0:
11775
12259
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
11776
12260
  swarm$1.loggerService.log(METHOD_NAME_GET$2, {
11777
- stateName: payload.stateName,
12261
+ stateName: stateName,
11778
12262
  });
11779
- if (!swarm$1.agentValidationService.hasState(payload.agentName, payload.stateName)) {
11780
- throw new Error("agent-swarm SharedStateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (getSharedState)"));
11781
- }
11782
- return [4 /*yield*/, swarm$1.sharedStatePublicService.getState(METHOD_NAME_GET$2, payload.stateName)];
12263
+ return [4 /*yield*/, swarm$1.sharedStatePublicService.getState(METHOD_NAME_GET$2, stateName)];
11783
12264
  case 1: return [2 /*return*/, _a.sent()];
11784
12265
  }
11785
12266
  });
@@ -11788,30 +12269,25 @@ var SharedStateUtils = /** @class */ (function () {
11788
12269
  * Sets the state for a given client and state name.
11789
12270
  * @template T
11790
12271
  * @param {T | ((prevSharedState: T) => Promise<T>)} dispatchFn - The new state or a function that returns the new state.
11791
- * @param {Object} payload - The payload containing client and state information.
11792
- * @param {AgentName} payload.agentName - The agent name.
11793
- * @param {StateName} payload.stateName - The state name.
12272
+ * @param {StateName} stateName - The state name.
11794
12273
  * @returns {Promise<void>}
11795
12274
  * @throws Will throw an error if the state is not registered in the agent.
11796
12275
  */
11797
- this.setState = function (dispatchFn, payload) { return __awaiter(_this, void 0, void 0, function () {
12276
+ this.setState = function (dispatchFn, stateName) { return __awaiter(_this, void 0, void 0, function () {
11798
12277
  var _this = this;
11799
12278
  return __generator(this, function (_a) {
11800
12279
  switch (_a.label) {
11801
12280
  case 0:
11802
12281
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
11803
12282
  swarm$1.loggerService.log(METHOD_NAME_SET, {
11804
- stateName: payload.stateName,
12283
+ stateName: stateName,
11805
12284
  });
11806
- if (!swarm$1.agentValidationService.hasState(payload.agentName, payload.stateName)) {
11807
- throw new Error("agent-swarm SharedStateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (setState)"));
11808
- }
11809
12285
  if (!(typeof dispatchFn === "function")) return [3 /*break*/, 2];
11810
- return [4 /*yield*/, swarm$1.sharedStatePublicService.setState(dispatchFn, METHOD_NAME_SET, payload.stateName)];
12286
+ return [4 /*yield*/, swarm$1.sharedStatePublicService.setState(dispatchFn, METHOD_NAME_SET, stateName)];
11811
12287
  case 1: return [2 /*return*/, _a.sent()];
11812
12288
  case 2: return [4 /*yield*/, swarm$1.sharedStatePublicService.setState(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
11813
12289
  return [2 /*return*/, dispatchFn];
11814
- }); }); }, METHOD_NAME_SET, payload.stateName)];
12290
+ }); }); }, METHOD_NAME_SET, stateName)];
11815
12291
  case 3: return [2 /*return*/, _a.sent()];
11816
12292
  }
11817
12293
  });
@@ -11819,24 +12295,19 @@ var SharedStateUtils = /** @class */ (function () {
11819
12295
  /**
11820
12296
  * Set the state to initial value
11821
12297
  * @template T
11822
- * @param {Object} payload - The payload containing client and state information.
11823
- * @param {AgentName} payload.agentName - The agent name.
11824
12298
  * @param {StateName} payload.stateName - The state name.
11825
12299
  * @returns {Promise<void>}
11826
12300
  * @throws Will throw an error if the state is not registered in the agent.
11827
12301
  */
11828
- this.clearState = function (payload) { return __awaiter(_this, void 0, void 0, function () {
12302
+ this.clearState = function (stateName) { return __awaiter(_this, void 0, void 0, function () {
11829
12303
  return __generator(this, function (_a) {
11830
12304
  switch (_a.label) {
11831
12305
  case 0:
11832
12306
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
11833
12307
  swarm$1.loggerService.log(METHOD_NAME_SET, {
11834
- stateName: payload.stateName,
12308
+ stateName: stateName,
11835
12309
  });
11836
- if (!swarm$1.agentValidationService.hasState(payload.agentName, payload.stateName)) {
11837
- throw new Error("agent-swarm SharedStateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (clearState)"));
11838
- }
11839
- return [4 /*yield*/, swarm$1.sharedStatePublicService.clearState(METHOD_NAME_CLEAR$2, payload.stateName)];
12310
+ return [4 /*yield*/, swarm$1.sharedStatePublicService.clearState(METHOD_NAME_CLEAR$2, stateName)];
11840
12311
  case 1: return [2 /*return*/, _a.sent()];
11841
12312
  }
11842
12313
  });
@@ -12046,7 +12517,6 @@ var SharedStorageUtils = /** @class */ (function () {
12046
12517
  * Takes items from the storage.
12047
12518
  * @param {string} search - The search query.
12048
12519
  * @param {number} total - The total number of items to take.
12049
- * @param {AgentName} agentName - The agent name.
12050
12520
  * @param {StorageName} storageName - The storage name.
12051
12521
  * @returns {Promise<T[]>} - A promise that resolves to an array of items.
12052
12522
  * @template T
@@ -12063,9 +12533,6 @@ var SharedStorageUtils = /** @class */ (function () {
12063
12533
  score: payload.score,
12064
12534
  });
12065
12535
  swarm$1.storageValidationService.validate(payload.storageName, METHOD_NAME_TAKE);
12066
- if (!swarm$1.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
12067
- throw new Error("agent-swarm SharedStorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (take)"));
12068
- }
12069
12536
  return [4 /*yield*/, swarm$1.sharedStoragePublicService.take(payload.search, payload.total, METHOD_NAME_TAKE, payload.storageName, payload.score)];
12070
12537
  case 1: return [2 /*return*/, (_a.sent())];
12071
12538
  }
@@ -12074,25 +12541,21 @@ var SharedStorageUtils = /** @class */ (function () {
12074
12541
  /**
12075
12542
  * Upserts an item in the storage.
12076
12543
  * @param {T} item - The item to upsert.
12077
- * @param {AgentName} agentName - The agent name.
12078
12544
  * @param {StorageName} storageName - The storage name.
12079
12545
  * @returns {Promise<void>} - A promise that resolves when the operation is complete.
12080
12546
  * @template T
12081
12547
  */
12082
- this.upsert = function (payload) { return __awaiter(_this, void 0, void 0, function () {
12548
+ this.upsert = function (item, storageName) { return __awaiter(_this, void 0, void 0, function () {
12083
12549
  return __generator(this, function (_a) {
12084
12550
  switch (_a.label) {
12085
12551
  case 0:
12086
12552
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
12087
12553
  swarm$1.loggerService.log(METHOD_NAME_UPSERT, {
12088
- item: payload.item,
12089
- storageName: payload.storageName,
12554
+ item: item,
12555
+ storageName: storageName,
12090
12556
  });
12091
- swarm$1.storageValidationService.validate(payload.storageName, METHOD_NAME_UPSERT);
12092
- if (!swarm$1.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
12093
- throw new Error("agent-swarm SharedStorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (upsert)"));
12094
- }
12095
- return [4 /*yield*/, swarm$1.sharedStoragePublicService.upsert(payload.item, METHOD_NAME_UPSERT, payload.storageName)];
12557
+ swarm$1.storageValidationService.validate(storageName, METHOD_NAME_UPSERT);
12558
+ return [4 /*yield*/, swarm$1.sharedStoragePublicService.upsert(item, METHOD_NAME_UPSERT, storageName)];
12096
12559
  case 1: return [2 /*return*/, _a.sent()];
12097
12560
  }
12098
12561
  });
@@ -12100,24 +12563,20 @@ var SharedStorageUtils = /** @class */ (function () {
12100
12563
  /**
12101
12564
  * Removes an item from the storage.
12102
12565
  * @param {IStorageData["id"]} itemId - The ID of the item to remove.
12103
- * @param {AgentName} agentName - The agent name.
12104
12566
  * @param {StorageName} storageName - The storage name.
12105
12567
  * @returns {Promise<void>} - A promise that resolves when the operation is complete.
12106
12568
  */
12107
- this.remove = function (payload) { return __awaiter(_this, void 0, void 0, function () {
12569
+ this.remove = function (itemId, storageName) { return __awaiter(_this, void 0, void 0, function () {
12108
12570
  return __generator(this, function (_a) {
12109
12571
  switch (_a.label) {
12110
12572
  case 0:
12111
12573
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
12112
12574
  swarm$1.loggerService.log(METHOD_NAME_REMOVE, {
12113
- itemId: payload.itemId,
12114
- storageName: payload.storageName,
12575
+ itemId: itemId,
12576
+ storageName: storageName,
12115
12577
  });
12116
- swarm$1.storageValidationService.validate(payload.storageName, METHOD_NAME_REMOVE);
12117
- if (!swarm$1.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
12118
- throw new Error("agent-swarm SharedStorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (remove)"));
12119
- }
12120
- return [4 /*yield*/, swarm$1.sharedStoragePublicService.remove(payload.itemId, METHOD_NAME_REMOVE, payload.storageName)];
12578
+ swarm$1.storageValidationService.validate(storageName, METHOD_NAME_REMOVE);
12579
+ return [4 /*yield*/, swarm$1.sharedStoragePublicService.remove(itemId, METHOD_NAME_REMOVE, storageName)];
12121
12580
  case 1: return [2 /*return*/, _a.sent()];
12122
12581
  }
12123
12582
  });
@@ -12125,73 +12584,61 @@ var SharedStorageUtils = /** @class */ (function () {
12125
12584
  /**
12126
12585
  * Gets an item from the storage.
12127
12586
  * @param {IStorageData["id"]} itemId - The ID of the item to get.
12128
- * @param {AgentName} agentName - The agent name.
12129
12587
  * @param {StorageName} storageName - The storage name.
12130
12588
  * @returns {Promise<T | null>} - A promise that resolves to the item or null if not found.
12131
12589
  * @template T
12132
12590
  */
12133
- this.get = function (payload) { return __awaiter(_this, void 0, void 0, function () {
12591
+ this.get = function (itemId, storageName) { return __awaiter(_this, void 0, void 0, function () {
12134
12592
  return __generator(this, function (_a) {
12135
12593
  switch (_a.label) {
12136
12594
  case 0:
12137
12595
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
12138
12596
  swarm$1.loggerService.log(METHOD_NAME_GET, {
12139
- itemId: payload.itemId,
12140
- storageName: payload.storageName,
12597
+ itemId: itemId,
12598
+ storageName: storageName,
12141
12599
  });
12142
- swarm$1.storageValidationService.validate(payload.storageName, METHOD_NAME_GET);
12143
- if (!swarm$1.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
12144
- throw new Error("agent-swarm SharedStorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (get)"));
12145
- }
12146
- return [4 /*yield*/, swarm$1.sharedStoragePublicService.get(payload.itemId, METHOD_NAME_GET, payload.storageName)];
12600
+ swarm$1.storageValidationService.validate(storageName, METHOD_NAME_GET);
12601
+ return [4 /*yield*/, swarm$1.sharedStoragePublicService.get(itemId, METHOD_NAME_GET, storageName)];
12147
12602
  case 1: return [2 /*return*/, (_a.sent())];
12148
12603
  }
12149
12604
  });
12150
12605
  }); };
12151
12606
  /**
12152
12607
  * Lists items from the storage.
12153
- * @param {AgentName} agentName - The agent name.
12154
12608
  * @param {StorageName} storageName - The storage name.
12155
12609
  * @param {(item: T) => boolean} [filter] - Optional filter function.
12156
12610
  * @returns {Promise<T[]>} - A promise that resolves to an array of items.
12157
12611
  * @template T
12158
12612
  */
12159
- this.list = function (payload) { return __awaiter(_this, void 0, void 0, function () {
12613
+ this.list = function (storageName, filter) { return __awaiter(_this, void 0, void 0, function () {
12160
12614
  return __generator(this, function (_a) {
12161
12615
  switch (_a.label) {
12162
12616
  case 0:
12163
12617
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
12164
12618
  swarm$1.loggerService.log(METHOD_NAME_LIST, {
12165
- storageName: payload.storageName,
12619
+ storageName: storageName,
12166
12620
  });
12167
- swarm$1.storageValidationService.validate(payload.storageName, METHOD_NAME_LIST);
12168
- if (!swarm$1.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
12169
- throw new Error("agent-swarm SharedStorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (list)"));
12170
- }
12171
- return [4 /*yield*/, swarm$1.sharedStoragePublicService.list(METHOD_NAME_LIST, payload.storageName, payload.filter)];
12621
+ swarm$1.storageValidationService.validate(storageName, METHOD_NAME_LIST);
12622
+ return [4 /*yield*/, swarm$1.sharedStoragePublicService.list(METHOD_NAME_LIST, storageName, filter)];
12172
12623
  case 1: return [2 /*return*/, (_a.sent())];
12173
12624
  }
12174
12625
  });
12175
12626
  }); };
12176
12627
  /**
12177
12628
  * Clears the storage.
12178
- * @param {AgentName} agentName - The agent name.
12179
12629
  * @param {StorageName} storageName - The storage name.
12180
12630
  * @returns {Promise<void>} - A promise that resolves when the operation is complete.
12181
12631
  */
12182
- this.clear = function (payload) { return __awaiter(_this, void 0, void 0, function () {
12632
+ this.clear = function (storageName) { return __awaiter(_this, void 0, void 0, function () {
12183
12633
  return __generator(this, function (_a) {
12184
12634
  switch (_a.label) {
12185
12635
  case 0:
12186
12636
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
12187
12637
  swarm$1.loggerService.log(METHOD_NAME_CLEAR, {
12188
- storageName: payload.storageName,
12638
+ storageName: storageName,
12189
12639
  });
12190
- swarm$1.storageValidationService.validate(payload.storageName, METHOD_NAME_CLEAR);
12191
- if (!swarm$1.agentValidationService.hasStorage(payload.agentName, payload.storageName)) {
12192
- throw new Error("agent-swarm SharedStorageUtils ".concat(payload.storageName, " not registered in ").concat(payload.agentName, " (clear)"));
12193
- }
12194
- return [4 /*yield*/, swarm$1.sharedStoragePublicService.clear(METHOD_NAME_CLEAR, payload.storageName)];
12640
+ swarm$1.storageValidationService.validate(storageName, METHOD_NAME_CLEAR);
12641
+ return [4 /*yield*/, swarm$1.sharedStoragePublicService.clear(METHOD_NAME_CLEAR, storageName)];
12195
12642
  case 1: return [2 /*return*/, _a.sent()];
12196
12643
  }
12197
12644
  });
@@ -12236,11 +12683,44 @@ var objectFlat = function (data) {
12236
12683
 
12237
12684
  var LIST_SEPARATOR = Array.from({ length: 80 }, function () { return "-"; });
12238
12685
  var METHOD_NAME_SERIALIZE = "SchemaUtils.serialize";
12686
+ var METHOD_NAME_WRITE = "SchemaUtils.write";
12239
12687
  /**
12240
12688
  * Utility class for schema-related operations.
12241
12689
  */
12242
12690
  var SchemaUtils = /** @class */ (function () {
12243
12691
  function SchemaUtils() {
12692
+ /**
12693
+ * Writes a value to the session memory for a given client.
12694
+ *
12695
+ * @template T - The type of the value to write.
12696
+ * @param {string} clientId - The ID of the client.
12697
+ * @param {T} value - The value to write to the session memory.
12698
+ * @returns {T} The actual value from the session memory.
12699
+ */
12700
+ this.writeSessionMemory = function (clientId, value) {
12701
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
12702
+ swarm$1.loggerService.log(METHOD_NAME_WRITE, {
12703
+ clientId: clientId,
12704
+ value: value,
12705
+ });
12706
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME_WRITE);
12707
+ return swarm$1.memorySchemaService.writeValue(clientId, value);
12708
+ };
12709
+ /**
12710
+ * Reads a value from the session memory for a given client.
12711
+ *
12712
+ * @template T - The type of the value to read.
12713
+ * @param {string} clientId - The ID of the client.
12714
+ * @returns {T} The value read from the session memory.
12715
+ */
12716
+ this.readSessionMemory = function (clientId) {
12717
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
12718
+ swarm$1.loggerService.log(METHOD_NAME_WRITE, {
12719
+ clientId: clientId,
12720
+ });
12721
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME_WRITE);
12722
+ return swarm$1.memorySchemaService.readValue(clientId);
12723
+ };
12244
12724
  /**
12245
12725
  * Serializes an object or an array of objects into a formatted string.
12246
12726
  *
@@ -12288,4 +12768,4 @@ var SchemaUtils = /** @class */ (function () {
12288
12768
  */
12289
12769
  var Schema = new SchemaUtils();
12290
12770
 
12291
- export { ExecutionContextService, History, HistoryAdapter, HistoryInstance, Logger, LoggerAdapter, LoggerInstance, MethodContextService, Schema, SharedState, SharedStorage, State, Storage, addAgent, addCompletion, addEmbedding, addState, addStorage, addSwarm, addTool, cancelOutput, cancelOutputForce, changeToAgent, changeToDefaultAgent, changeToPrevAgent, commitAssistantMessage, commitAssistantMessageForce, commitFlush, commitFlushForce, commitStopTools, commitStopToolsForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitUserMessage, commitUserMessageForce, complete, disposeConnection, dumpAgent, dumpDocs, dumpSwarm, 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 };
12771
+ export { ExecutionContextService, History, HistoryAdapter, HistoryInstance, Logger, LoggerAdapter, LoggerInstance, MethodContextService, Schema, SharedState, SharedStorage, State, Storage, addAgent, addCompletion, addEmbedding, addState, addStorage, addSwarm, addTool, cancelOutput, cancelOutputForce, changeToAgent, changeToDefaultAgent, changeToPrevAgent, commitAssistantMessage, commitAssistantMessageForce, commitFlush, commitFlushForce, commitStopTools, commitStopToolsForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitUserMessage, commitUserMessageForce, complete, disposeConnection, dumpAgent, dumpDocs, dumpSwarm, emit, emitForce, event, execute, executeForce, getAgentHistory, getAgentName, getAssistantHistory, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getRawHistory, getSessionContext, getSessionMode, getUserHistory, listenAgentEvent, listenAgentEventOnce, listenEvent, listenEventOnce, listenHistoryEvent, listenHistoryEventOnce, listenSessionEvent, listenSessionEventOnce, listenStateEvent, listenStateEventOnce, listenStorageEvent, listenStorageEventOnce, listenSwarmEvent, listenSwarmEventOnce, makeAutoDispose, makeConnection, run, runForce, session, setConfig, swarm };