agent-swarm-kit 1.1.13 → 1.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.cjs CHANGED
@@ -4652,6 +4652,245 @@ class ClientOperator {
4652
4652
  }
4653
4653
  }
4654
4654
 
4655
+ const METHOD_NAME$1d = "function.commit.commitToolOutput";
4656
+ /**
4657
+ * Commits the output of a tool execution to the active agent in a swarm session.
4658
+ *
4659
+ * This function ensures that the tool output is committed only if the specified agent is still the active agent in the swarm session.
4660
+ * It performs validation checks on the agent, session, and swarm, logs the operation if enabled, and delegates the commit operation to the session public service.
4661
+ * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
4662
+ *
4663
+ * @param {string} toolId - The unique identifier of the tool whose output is being committed.
4664
+ * @param {string} content - The content or result of the tool execution to be committed.
4665
+ * @param {string} clientId - The unique identifier of the client session associated with the operation.
4666
+ * @param {AgentName} agentName - The name of the agent committing the tool output.
4667
+ * @returns {Promise<void>} A promise that resolves when the tool output is successfully committed, or immediately if the operation is skipped due to an agent change.
4668
+ * @throws {Error} If validation fails (e.g., invalid agent, session, or swarm) or if the session public service encounters an error during the commit operation.
4669
+ * @example
4670
+ * await commitToolOutput("tool-123", "Tool execution result", "client-456", "AgentX");
4671
+ */
4672
+ const commitToolOutput = beginContext(async (toolId, content, clientId, agentName) => {
4673
+ // Log the operation details if logging is enabled in GLOBAL_CONFIG
4674
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
4675
+ swarm$1.loggerService.log(METHOD_NAME$1d, {
4676
+ toolId,
4677
+ content,
4678
+ clientId,
4679
+ agentName,
4680
+ });
4681
+ // Validate the agent, session, and swarm to ensure they exist and are accessible
4682
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$1d);
4683
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$1d);
4684
+ const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
4685
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$1d);
4686
+ // Check if the specified agent is still the active agent in the swarm session
4687
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$1d, clientId, swarmName);
4688
+ if (currentAgentName !== agentName) {
4689
+ // Log a skip message if the agent has changed during the operation
4690
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
4691
+ swarm$1.loggerService.log('function "commitToolOutput" skipped due to the agent change', {
4692
+ toolId,
4693
+ currentAgentName,
4694
+ agentName,
4695
+ clientId,
4696
+ });
4697
+ return;
4698
+ }
4699
+ // Commit the tool output to the session via the session public service
4700
+ await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$1d, clientId, swarmName);
4701
+ });
4702
+
4703
+ const METHOD_NAME$1c = "function.target.execute";
4704
+ /**
4705
+ * Sends a message to the active agent in a swarm session as if it originated from the client side.
4706
+ *
4707
+ * This function executes a command or message on behalf of the specified agent within a swarm session, designed for scenarios like reviewing tool output
4708
+ * or initiating a model-to-client conversation. It validates the agent and session, checks if the specified agent is still active, and executes the content
4709
+ * with performance tracking and event bus notifications. The execution is wrapped in `beginContext` for a clean environment and runs within an
4710
+ * `ExecutionContextService` context for metadata tracking. If the active agent has changed, the operation is skipped.
4711
+ *
4712
+ * @param {string} content - The content or command to be executed by the agent.
4713
+ * @param {string} clientId - The unique identifier of the client session requesting the execution.
4714
+ * @param {AgentName} agentName - The name of the agent intended to execute the command.
4715
+ * @returns {Promise<string>} A promise that resolves to the result of the execution, or an empty string if skipped due to an agent change.
4716
+ * @throws {Error} If agent, session, or swarm validation fails, or if the execution process encounters an error.
4717
+ * @example
4718
+ * const result = await execute("Review this output", "client-123", "AgentX");
4719
+ * console.log(result); // Outputs the agent's response or "" if skipped
4720
+ */
4721
+ const execute = beginContext(async (content, clientId, agentName) => {
4722
+ const executionId = functoolsKit.randomString();
4723
+ // Log the operation details if logging is enabled in GLOBAL_CONFIG
4724
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
4725
+ swarm$1.loggerService.log(METHOD_NAME$1c, {
4726
+ content,
4727
+ clientId,
4728
+ agentName,
4729
+ executionId,
4730
+ });
4731
+ // Validate the agent, session, and swarm
4732
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$1c);
4733
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$1c);
4734
+ const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
4735
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$1c);
4736
+ // Check if the specified agent is still the active agent
4737
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$1c, clientId, swarmName);
4738
+ if (currentAgentName !== agentName) {
4739
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
4740
+ swarm$1.loggerService.log('function "execute" skipped due to the agent change', {
4741
+ currentAgentName,
4742
+ agentName,
4743
+ clientId,
4744
+ });
4745
+ return "";
4746
+ }
4747
+ // Execute the command within an execution context with performance tracking
4748
+ return ExecutionContextService.runInContext(async () => {
4749
+ let isFinished = false;
4750
+ swarm$1.perfService.startExecution(executionId, clientId, content.length);
4751
+ try {
4752
+ swarm$1.busService.commitExecutionBegin(clientId, {
4753
+ agentName,
4754
+ swarmName,
4755
+ });
4756
+ const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$1c, clientId, swarmName);
4757
+ isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
4758
+ swarm$1.busService.commitExecutionEnd(clientId, {
4759
+ agentName,
4760
+ swarmName,
4761
+ });
4762
+ return result;
4763
+ }
4764
+ finally {
4765
+ if (!isFinished) {
4766
+ swarm$1.perfService.endExecution(executionId, clientId, 0);
4767
+ }
4768
+ }
4769
+ }, {
4770
+ clientId,
4771
+ executionId,
4772
+ processId: GLOBAL_CONFIG.CC_PROCESS_UUID,
4773
+ });
4774
+ });
4775
+
4776
+ /** @private Constant defining the method name for logging and validation context */
4777
+ const METHOD_NAME$1b = "function.commit.commitFlush";
4778
+ /**
4779
+ * Commits a flush of agent history for a specific client and agent in the swarm system.
4780
+ * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before flushing the history.
4781
+ * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
4782
+ * Integrates with AgentValidationService (agent validation), SessionValidationService (session and swarm retrieval),
4783
+ * SwarmValidationService (swarm validation), SwarmPublicService (agent retrieval), SessionPublicService (history flush),
4784
+ * and LoggerService (logging). Complements functions like commitAssistantMessage by clearing agent history rather than adding messages.
4785
+ *
4786
+ * @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
4787
+ * @param {string} agentName - The name of the agent whose history is to be flushed, validated against registered agents.
4788
+ * @returns {Promise<void>} A promise that resolves when the history flush is committed or skipped (e.g., agent mismatch).
4789
+ * @throws {Error} If agent, session, or swarm validation fails, propagated from respective validation services.
4790
+ */
4791
+ const commitFlush = beginContext(async (clientId, agentName) => {
4792
+ // Log the flush attempt if enabled
4793
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
4794
+ swarm$1.loggerService.log(METHOD_NAME$1b, {
4795
+ clientId,
4796
+ agentName,
4797
+ });
4798
+ // Validate the agent exists
4799
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$1b);
4800
+ // Validate the session exists and retrieve the associated swarm
4801
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$1b);
4802
+ const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
4803
+ // Validate the swarm configuration
4804
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$1b);
4805
+ // Check if the current agent matches the provided agent
4806
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$1b, clientId, swarmName);
4807
+ if (currentAgentName !== agentName) {
4808
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
4809
+ swarm$1.loggerService.log('function "commitFlush" skipped due to the agent change', {
4810
+ currentAgentName,
4811
+ agentName,
4812
+ clientId,
4813
+ });
4814
+ return;
4815
+ }
4816
+ // Commit the flush of agent history via SessionPublicService
4817
+ await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$1b, clientId, swarmName);
4818
+ });
4819
+
4820
+ const METHOD_NAME$1a = "function.target.emit";
4821
+ /**
4822
+ * Emits a string as model output without executing an incoming message, with agent activity validation.
4823
+ *
4824
+ * This function directly emits a provided string as output from the swarm session, bypassing message execution, and is designed exclusively
4825
+ * for sessions established via `makeConnection`. It validates the session, swarm, and specified agent, ensuring the agent is still active
4826
+ * before emitting. If the active agent has changed, the operation is skipped. The execution is wrapped in `beginContext` for a clean environment,
4827
+ * logs the operation if enabled, and throws an error if the session mode is not "makeConnection".
4828
+ *
4829
+ * @param {string} content - The content to be emitted as the model output.
4830
+ * @param {string} clientId - The unique identifier of the client session emitting the content.
4831
+ * @param {AgentName} agentName - The name of the agent intended to emit the content.
4832
+ * @returns {Promise<void>} A promise that resolves when the content is emitted, or resolves early if skipped due to an agent change.
4833
+ * @throws {Error} If the session mode is not "makeConnection", or if agent, session, or swarm validation fails.
4834
+ * @example
4835
+ * await emit("Direct output", "client-123", "AgentX"); // Emits "Direct output" if AgentX is active
4836
+ */
4837
+ const emit = beginContext(async (content, clientId, agentName) => {
4838
+ // Log the operation details if logging is enabled in GLOBAL_CONFIG
4839
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
4840
+ swarm$1.loggerService.log(METHOD_NAME$1a, {
4841
+ content,
4842
+ clientId,
4843
+ agentName,
4844
+ });
4845
+ // Validate the agent, session, and swarm
4846
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$1a);
4847
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$1a);
4848
+ const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
4849
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$1a);
4850
+ // Check if the specified agent is still the active agent
4851
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$1a, clientId, swarmName);
4852
+ if (currentAgentName !== agentName) {
4853
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
4854
+ swarm$1.loggerService.log('function "emit" skipped due to the agent change', {
4855
+ currentAgentName,
4856
+ agentName,
4857
+ clientId,
4858
+ });
4859
+ return;
4860
+ }
4861
+ // Emit the content directly via the session public service
4862
+ return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$1a, clientId, swarmName);
4863
+ });
4864
+
4865
+ const METHOD_NAME$19 = "function.common.getAgentName";
4866
+ /**
4867
+ * Retrieves the name of the active agent for a given client session in a swarm.
4868
+ *
4869
+ * This function fetches the name of the currently active agent associated with the specified client session within a swarm.
4870
+ * It validates the client session and swarm, logs the operation if enabled, and delegates the retrieval to the swarm public service.
4871
+ * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
4872
+ *
4873
+ * @param {string} clientId - The unique identifier of the client session whose active agent name is being retrieved.
4874
+ * @returns {Promise<string>} A promise that resolves to the name of the active agent (`AgentName`) associated with the client session.
4875
+ * @throws {Error} If the client session is invalid, the swarm validation fails, or the swarm public service encounters an error during retrieval.
4876
+ * @example
4877
+ * const agentName = await getAgentName("client-123");
4878
+ * console.log(agentName); // Outputs "AgentX"
4879
+ */
4880
+ const getAgentName = beginContext(async (clientId) => {
4881
+ // Log the operation details if logging is enabled in GLOBAL_CONFIG
4882
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
4883
+ swarm$1.loggerService.log(METHOD_NAME$19, {
4884
+ clientId,
4885
+ });
4886
+ // Validate the session and swarm to ensure they exist and are accessible
4887
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$19);
4888
+ const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
4889
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$19);
4890
+ // Retrieve the active agent name via the swarm public service
4891
+ return await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$19, clientId, swarmName);
4892
+ });
4893
+
4655
4894
  /**
4656
4895
  * A no-operation implementation of the IMCP interface.
4657
4896
  * This class provides empty or error-throwing implementations of MCP methods.
@@ -4774,7 +5013,20 @@ class MergeMCP {
4774
5013
  });
4775
5014
  for (const mcp of this.mcpList) {
4776
5015
  if (await mcp.hasTool(toolName, dto.clientId)) {
4777
- return await mcp.callTool(toolName, dto);
5016
+ const agentName = await getAgentName(dto.clientId);
5017
+ try {
5018
+ const toolOutput = await mcp.callTool(toolName, dto);
5019
+ if (typeof toolOutput === "string") {
5020
+ await commitToolOutput(dto.toolId, toolOutput, dto.clientId, agentName);
5021
+ await execute("", dto.clientId, agentName);
5022
+ }
5023
+ }
5024
+ catch (error) {
5025
+ console.error(`agent-swarm MCP tool error toolName=${toolName} agentName=${agentName} error=${functoolsKit.getErrorMessage(error)}`);
5026
+ await commitFlush(dto.clientId, agentName);
5027
+ await emit(createPlaceholder(), dto.clientId, agentName);
5028
+ }
5029
+ return;
4778
5030
  }
4779
5031
  }
4780
5032
  throw new Error(`MergeMCP callTool agentName=${this.agentName} tool not found toolName=${toolName}`);
@@ -5074,7 +5326,7 @@ class AgentConnectionService {
5074
5326
  }
5075
5327
 
5076
5328
  /** @private Constant defining the method name for logging purposes */
5077
- const METHOD_NAME$1d = "function.common.getPayload";
5329
+ const METHOD_NAME$18 = "function.common.getPayload";
5078
5330
  /**
5079
5331
  * Retrieves the payload from the current PayloadContextService context.
5080
5332
  * Returns null if no context is available. Logs the operation if logging is enabled.
@@ -5085,7 +5337,7 @@ const METHOD_NAME$1d = "function.common.getPayload";
5085
5337
  * console.log(payload); // { id: number } or null
5086
5338
  */
5087
5339
  const getPayload = () => {
5088
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$1d);
5340
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$18);
5089
5341
  if (PayloadContextService.hasContext()) {
5090
5342
  const { payload } = swarm$1.payloadContextService.context;
5091
5343
  return payload;
@@ -15296,7 +15548,7 @@ const swarm = {
15296
15548
  init();
15297
15549
  var swarm$1 = swarm;
15298
15550
 
15299
- const METHOD_NAME$1c = "cli.dumpDocs";
15551
+ const METHOD_NAME$17 = "cli.dumpDocs";
15300
15552
  /**
15301
15553
  * Dumps the documentation for the agents and swarms.
15302
15554
  *
@@ -15306,7 +15558,7 @@ const METHOD_NAME$1c = "cli.dumpDocs";
15306
15558
  */
15307
15559
  const dumpDocs = beginContext((prefix = "swarm", dirName = "./docs/chat", PlantUML) => {
15308
15560
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15309
- swarm$1.loggerService.log(METHOD_NAME$1c, {
15561
+ swarm$1.loggerService.log(METHOD_NAME$17, {
15310
15562
  dirName,
15311
15563
  });
15312
15564
  if (PlantUML) {
@@ -15316,10 +15568,10 @@ const dumpDocs = beginContext((prefix = "swarm", dirName = "./docs/chat", PlantU
15316
15568
  }
15317
15569
  swarm$1.agentValidationService
15318
15570
  .getAgentList()
15319
- .forEach((agentName) => swarm$1.agentValidationService.validate(agentName, METHOD_NAME$1c));
15571
+ .forEach((agentName) => swarm$1.agentValidationService.validate(agentName, METHOD_NAME$17));
15320
15572
  swarm$1.swarmValidationService
15321
15573
  .getSwarmList()
15322
- .forEach((swarmName) => swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$1c));
15574
+ .forEach((swarmName) => swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$17));
15323
15575
  swarm$1.agentValidationService.getAgentList().forEach((agentName) => {
15324
15576
  const { dependsOn } = swarm$1.agentSchemaService.get(agentName);
15325
15577
  if (!dependsOn) {
@@ -15329,7 +15581,7 @@ const dumpDocs = beginContext((prefix = "swarm", dirName = "./docs/chat", PlantU
15329
15581
  return swarm$1.docService.dumpDocs(prefix, dirName);
15330
15582
  });
15331
15583
 
15332
- const METHOD_NAME$1b = "cli.dumpAgent";
15584
+ const METHOD_NAME$16 = "cli.dumpAgent";
15333
15585
  /**
15334
15586
  * Dumps the agent information into PlantUML format.
15335
15587
  *
@@ -15338,14 +15590,14 @@ const METHOD_NAME$1b = "cli.dumpAgent";
15338
15590
  */
15339
15591
  const dumpAgent = beginContext((agentName, { withSubtree = false } = {}) => {
15340
15592
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15341
- swarm$1.loggerService.log(METHOD_NAME$1b, {
15593
+ swarm$1.loggerService.log(METHOD_NAME$16, {
15342
15594
  agentName,
15343
15595
  });
15344
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$1b);
15596
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$16);
15345
15597
  return swarm$1.agentMetaService.toUML(agentName, withSubtree);
15346
15598
  });
15347
15599
 
15348
- const METHOD_NAME$1a = "cli.dumpSwarm";
15600
+ const METHOD_NAME$15 = "cli.dumpSwarm";
15349
15601
  /**
15350
15602
  * Dumps the swarm information into PlantUML format.
15351
15603
  *
@@ -15354,14 +15606,14 @@ const METHOD_NAME$1a = "cli.dumpSwarm";
15354
15606
  */
15355
15607
  const dumpSwarm = beginContext((swarmName) => {
15356
15608
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15357
- swarm$1.loggerService.log(METHOD_NAME$1a, {
15609
+ swarm$1.loggerService.log(METHOD_NAME$15, {
15358
15610
  swarmName,
15359
15611
  });
15360
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$1a);
15612
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$15);
15361
15613
  return swarm$1.swarmMetaService.toUML(swarmName);
15362
15614
  });
15363
15615
 
15364
- const METHOD_NAME$19 = "cli.dumpPerfomance";
15616
+ const METHOD_NAME$14 = "cli.dumpPerfomance";
15365
15617
  const METHOD_NAME_INTERNAL$1 = "cli.dumpPerfomance.internal";
15366
15618
  const METHOD_NAME_INTERVAL = "cli.dumpPerfomance.interval";
15367
15619
  /**
@@ -15380,7 +15632,7 @@ const dumpPerfomanceInternal = beginContext(async (dirName = "./logs/meta") => {
15380
15632
  * @returns {Promise<void>} A promise that resolves when the performance data has been dumped.
15381
15633
  */
15382
15634
  const dumpPerfomance = async (dirName = "./logs/meta") => {
15383
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$19);
15635
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$14);
15384
15636
  await dumpPerfomanceInternal(dirName);
15385
15637
  };
15386
15638
  /**
@@ -15438,7 +15690,7 @@ const listenExecutionEvent = beginContext((clientId, fn) => {
15438
15690
  return swarm$1.busService.subscribe(clientId, "execution-bus", functoolsKit.queued(async (e) => await fn(e)));
15439
15691
  });
15440
15692
 
15441
- const METHOD_NAME$18 = "cli.dumpClientPerformance";
15693
+ const METHOD_NAME$13 = "cli.dumpClientPerformance";
15442
15694
  const METHOD_NAME_INTERNAL = "cli.dumpClientPerformance.internal";
15443
15695
  const METHOD_NAME_EXECUTE = "cli.dumpClientPerformance.execute";
15444
15696
  /**
@@ -15462,7 +15714,7 @@ const dumpClientPerformanceInternal = beginContext(async (clientId, dirName = ".
15462
15714
  * @returns {Promise<void>} A promise that resolves when the performance data has been dumped.
15463
15715
  */
15464
15716
  const dumpClientPerformance = async (clientId, dirName = "./logs/client") => {
15465
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$18);
15717
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$13);
15466
15718
  await dumpClientPerformanceInternal(clientId, dirName);
15467
15719
  };
15468
15720
  /**
@@ -15483,7 +15735,7 @@ dumpClientPerformance.runAfterExecute = beginContext(async (dirName = "./logs/cl
15483
15735
  });
15484
15736
 
15485
15737
  /** @private Constant defining the method name for logging and validation context */
15486
- const METHOD_NAME$17 = "function.commit.commitFlushForce";
15738
+ const METHOD_NAME$12 = "function.commit.commitFlushForce";
15487
15739
  /**
15488
15740
  * Forcefully commits a flush of agent history for a specific client in the swarm system, without checking the active agent.
15489
15741
  * Validates the session and swarm, then proceeds with flushing the history regardless of the current agent state.
@@ -15501,20 +15753,20 @@ const METHOD_NAME$17 = "function.commit.commitFlushForce";
15501
15753
  const commitFlushForce = beginContext(async (clientId) => {
15502
15754
  // Log the flush attempt if enabled
15503
15755
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15504
- swarm$1.loggerService.log(METHOD_NAME$17, {
15756
+ swarm$1.loggerService.log(METHOD_NAME$12, {
15505
15757
  clientId,
15506
- METHOD_NAME: METHOD_NAME$17,
15758
+ METHOD_NAME: METHOD_NAME$12,
15507
15759
  });
15508
15760
  // Validate the session exists and retrieve the associated swarm
15509
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$17);
15761
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$12);
15510
15762
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
15511
15763
  // Validate the swarm configuration
15512
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$17);
15764
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$12);
15513
15765
  // Commit the flush of agent history via SessionPublicService without agent checks
15514
- await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$17, clientId, swarmName);
15766
+ await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$12, clientId, swarmName);
15515
15767
  });
15516
15768
 
15517
- const METHOD_NAME$16 = "function.commit.commitToolOutputForce";
15769
+ const METHOD_NAME$11 = "function.commit.commitToolOutputForce";
15518
15770
  /**
15519
15771
  * Commits the output of a tool execution to the active agent in a swarm session without checking the active agent.
15520
15772
  *
@@ -15533,24 +15785,24 @@ const METHOD_NAME$16 = "function.commit.commitToolOutputForce";
15533
15785
  const commitToolOutputForce = beginContext(async (toolId, content, clientId) => {
15534
15786
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
15535
15787
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15536
- swarm$1.loggerService.log(METHOD_NAME$16, {
15788
+ swarm$1.loggerService.log(METHOD_NAME$11, {
15537
15789
  toolId,
15538
15790
  content,
15539
15791
  clientId,
15540
15792
  });
15541
15793
  // Validate the session and swarm to ensure they exist and are accessible
15542
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$16);
15794
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$11);
15543
15795
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
15544
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$16);
15796
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$11);
15545
15797
  // Commit the tool output to the session via the session public service without checking the active agent
15546
- await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$16, clientId, swarmName);
15798
+ await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$11, clientId, swarmName);
15547
15799
  });
15548
15800
 
15549
15801
  /**
15550
15802
  * @private Constant defining the method name for logging and validation purposes.
15551
15803
  * Used as an identifier in log messages and validation checks to track calls to `hasNavigation`.
15552
15804
  */
15553
- const METHOD_NAME$15 = "function.common.hasNavigation";
15805
+ const METHOD_NAME$10 = "function.common.hasNavigation";
15554
15806
  /**
15555
15807
  * Checks if a specific agent is part of the navigation route for a given client.
15556
15808
  * Validates the agent and client session, retrieves the associated swarm, and queries the navigation route.
@@ -15561,16 +15813,16 @@ const METHOD_NAME$15 = "function.common.hasNavigation";
15561
15813
  */
15562
15814
  const hasNavigation = async (clientId, agentName) => {
15563
15815
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15564
- swarm$1.loggerService.log(METHOD_NAME$15, { clientId });
15565
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$15);
15566
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$15);
15816
+ swarm$1.loggerService.log(METHOD_NAME$10, { clientId });
15817
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$10);
15818
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$10);
15567
15819
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
15568
15820
  return swarm$1.navigationValidationService
15569
15821
  .getNavigationRoute(clientId, swarmName)
15570
15822
  .has(agentName);
15571
15823
  };
15572
15824
 
15573
- const METHOD_NAME$14 = "function.history.getRawHistory";
15825
+ const METHOD_NAME$$ = "function.history.getRawHistory";
15574
15826
  /**
15575
15827
  * Retrieves the raw, unmodified history for a given client session.
15576
15828
  *
@@ -15587,10 +15839,10 @@ const METHOD_NAME$14 = "function.history.getRawHistory";
15587
15839
  * const rawHistory = await getRawHistory("client-123");
15588
15840
  * console.log(rawHistory); // Outputs the full raw history array
15589
15841
  */
15590
- const getRawHistory = beginContext(async (clientId, methodName = METHOD_NAME$14) => {
15842
+ const getRawHistory = beginContext(async (clientId, methodName = METHOD_NAME$$) => {
15591
15843
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
15592
15844
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15593
- swarm$1.loggerService.log(METHOD_NAME$14, {
15845
+ swarm$1.loggerService.log(METHOD_NAME$$, {
15594
15846
  clientId,
15595
15847
  });
15596
15848
  // Validate the session and swarm
@@ -15603,7 +15855,7 @@ const getRawHistory = beginContext(async (clientId, methodName = METHOD_NAME$14)
15603
15855
  return [...history];
15604
15856
  });
15605
15857
 
15606
- const METHOD_NAME$13 = "function.history.getLastUserMessage";
15858
+ const METHOD_NAME$_ = "function.history.getLastUserMessage";
15607
15859
  /**
15608
15860
  * Retrieves the content of the most recent user message from a client's session history.
15609
15861
  *
@@ -15621,16 +15873,16 @@ const METHOD_NAME$13 = "function.history.getLastUserMessage";
15621
15873
  const getLastUserMessage = beginContext(async (clientId) => {
15622
15874
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
15623
15875
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15624
- swarm$1.loggerService.log(METHOD_NAME$13, {
15876
+ swarm$1.loggerService.log(METHOD_NAME$_, {
15625
15877
  clientId,
15626
15878
  });
15627
15879
  // Fetch raw history and find the last user message
15628
- const history = await getRawHistory(clientId, METHOD_NAME$13);
15880
+ const history = await getRawHistory(clientId, METHOD_NAME$_);
15629
15881
  const last = history.findLast(({ role, mode }) => role === "user" && mode === "user");
15630
15882
  return last ? last.content : null;
15631
15883
  });
15632
15884
 
15633
- const METHOD_NAME$12 = "function.navigate.changeToDefaultAgent";
15885
+ const METHOD_NAME$Z = "function.navigate.changeToDefaultAgent";
15634
15886
  /**
15635
15887
  * Time-to-live for the change agent function in milliseconds.
15636
15888
  * Defines how long the cached change agent function remains valid before expiring.
@@ -15665,7 +15917,7 @@ const createChangeToDefaultAgent = functoolsKit.ttl((clientId) => functoolsKit.q
15665
15917
  }));
15666
15918
  {
15667
15919
  // Dispose of the current agent's resources and set up the new default agent
15668
- const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$12, clientId, swarmName);
15920
+ const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$Z, clientId, swarmName);
15669
15921
  await swarm$1.agentPublicService.dispose(methodName, clientId, agentName);
15670
15922
  await swarm$1.historyPublicService.dispose(methodName, clientId, agentName);
15671
15923
  await swarm$1.swarmPublicService.setAgentRef(methodName, clientId, swarmName, agentName, await swarm$1.agentPublicService.createAgentRef(methodName, clientId, agentName));
@@ -15704,23 +15956,23 @@ const createGc$3 = functoolsKit.singleshot(async () => {
15704
15956
  const changeToDefaultAgent = beginContext(async (clientId) => {
15705
15957
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
15706
15958
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15707
- swarm$1.loggerService.log(METHOD_NAME$12, {
15959
+ swarm$1.loggerService.log(METHOD_NAME$Z, {
15708
15960
  clientId,
15709
15961
  });
15710
15962
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
15711
15963
  const { defaultAgent: agentName } = swarm$1.swarmSchemaService.get(swarmName);
15712
15964
  {
15713
15965
  // Validate session and default agent
15714
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$12);
15715
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$12);
15966
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$Z);
15967
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$Z);
15716
15968
  }
15717
15969
  // Execute the agent change with TTL and queuing
15718
15970
  const run = await createChangeToDefaultAgent(clientId);
15719
15971
  createGc$3();
15720
- return await run(METHOD_NAME$12, agentName, swarmName);
15972
+ return await run(METHOD_NAME$Z, agentName, swarmName);
15721
15973
  });
15722
15974
 
15723
- const METHOD_NAME$11 = "function.target.emitForce";
15975
+ const METHOD_NAME$Y = "function.target.emitForce";
15724
15976
  /**
15725
15977
  * Emits a string as model output without executing an incoming message or checking the active agent.
15726
15978
  *
@@ -15739,19 +15991,19 @@ const METHOD_NAME$11 = "function.target.emitForce";
15739
15991
  const emitForce = beginContext(async (content, clientId) => {
15740
15992
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
15741
15993
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15742
- swarm$1.loggerService.log(METHOD_NAME$11, {
15994
+ swarm$1.loggerService.log(METHOD_NAME$Y, {
15743
15995
  content,
15744
15996
  clientId,
15745
15997
  });
15746
15998
  // Validate the session and swarm
15747
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$11);
15999
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$Y);
15748
16000
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
15749
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$11);
16001
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$Y);
15750
16002
  // Emit the content directly via the session public service
15751
- return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$11, clientId, swarmName);
16003
+ return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$Y, clientId, swarmName);
15752
16004
  });
15753
16005
 
15754
- const METHOD_NAME$10 = "function.target.executeForce";
16006
+ const METHOD_NAME$X = "function.target.executeForce";
15755
16007
  /**
15756
16008
  * Sends a message to the active agent in a swarm session as if it originated from the client side, forcing execution regardless of agent activity.
15757
16009
  *
@@ -15772,22 +16024,22 @@ const executeForce = beginContext(async (content, clientId) => {
15772
16024
  const executionId = functoolsKit.randomString();
15773
16025
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
15774
16026
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15775
- swarm$1.loggerService.log(METHOD_NAME$10, {
16027
+ swarm$1.loggerService.log(METHOD_NAME$X, {
15776
16028
  content,
15777
16029
  clientId,
15778
16030
  executionId,
15779
16031
  });
15780
16032
  // Validate the session and swarm
15781
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$10);
16033
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$X);
15782
16034
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
15783
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$10);
16035
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$X);
15784
16036
  // Execute the command within an execution context with performance tracking
15785
16037
  return ExecutionContextService.runInContext(async () => {
15786
16038
  let isFinished = false;
15787
16039
  swarm$1.perfService.startExecution(executionId, clientId, content.length);
15788
16040
  try {
15789
16041
  swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
15790
- const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$10, clientId, swarmName);
16042
+ const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$X, clientId, swarmName);
15791
16043
  isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
15792
16044
  swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
15793
16045
  return result;
@@ -15804,7 +16056,7 @@ const executeForce = beginContext(async (content, clientId) => {
15804
16056
  });
15805
16057
  });
15806
16058
 
15807
- const METHOD_NAME$$ = "function.template.navigateToTriageAgent";
16059
+ const METHOD_NAME$W = "function.template.navigateToTriageAgent";
15808
16060
  const DEFAULT_ACCEPT_FN = (_, defaultAgent) => `Successfully navigated to ${defaultAgent}`;
15809
16061
  const DEFAULT_REJECT_FN = (_, defaultAgent) => `Already on ${defaultAgent}`;
15810
16062
  /**
@@ -15853,7 +16105,7 @@ const createNavigateToTriageAgent = async ({ flushMessage, executeMessage, toolO
15853
16105
  */
15854
16106
  return beginContext(async (toolId, clientId) => {
15855
16107
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15856
- swarm$1.loggerService.log(METHOD_NAME$$, {
16108
+ swarm$1.loggerService.log(METHOD_NAME$W, {
15857
16109
  clientId,
15858
16110
  toolId,
15859
16111
  });
@@ -15883,7 +16135,7 @@ const createNavigateToTriageAgent = async ({ flushMessage, executeMessage, toolO
15883
16135
  });
15884
16136
  };
15885
16137
 
15886
- const METHOD_NAME$_ = "function.navigate.changeToAgent";
16138
+ const METHOD_NAME$V = "function.navigate.changeToAgent";
15887
16139
  /**
15888
16140
  * Time-to-live for the change agent function in milliseconds.
15889
16141
  * Defines how long the cached change agent function remains valid before expiring.
@@ -15919,7 +16171,7 @@ const createChangeToAgent = functoolsKit.ttl((clientId) => functoolsKit.queued(a
15919
16171
  }));
15920
16172
  {
15921
16173
  // Dispose of the current agent's resources and set up the new agent
15922
- const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$_, clientId, swarmName);
16174
+ const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$V, clientId, swarmName);
15923
16175
  await swarm$1.agentPublicService.dispose(methodName, clientId, agentName);
15924
16176
  await swarm$1.historyPublicService.dispose(methodName, clientId, agentName);
15925
16177
  await swarm$1.swarmPublicService.setAgentRef(methodName, clientId, swarmName, agentName, await swarm$1.agentPublicService.createAgentRef(methodName, clientId, agentName));
@@ -15959,16 +16211,16 @@ const createGc$2 = functoolsKit.singleshot(async () => {
15959
16211
  const changeToAgent = beginContext(async (agentName, clientId) => {
15960
16212
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
15961
16213
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
15962
- swarm$1.loggerService.log(METHOD_NAME$_, {
16214
+ swarm$1.loggerService.log(METHOD_NAME$V, {
15963
16215
  agentName,
15964
16216
  clientId,
15965
16217
  });
15966
16218
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
15967
16219
  {
15968
16220
  // Validate session, agent, and dependencies
15969
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$_);
15970
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$_);
15971
- const activeAgent = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$_, clientId, swarmName);
16221
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$V);
16222
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$V);
16223
+ const activeAgent = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$V, clientId, swarmName);
15972
16224
  if (!swarm$1.agentValidationService.hasDependency(activeAgent, agentName)) {
15973
16225
  console.error(`agent-swarm missing dependency detected for activeAgent=${activeAgent} dependencyAgent=${agentName}`);
15974
16226
  }
@@ -15986,10 +16238,10 @@ const changeToAgent = beginContext(async (agentName, clientId) => {
15986
16238
  // Execute the agent change with TTL and queuing
15987
16239
  const run = await createChangeToAgent(clientId);
15988
16240
  createGc$2();
15989
- return await run(METHOD_NAME$_, agentName, swarmName);
16241
+ return await run(METHOD_NAME$V, agentName, swarmName);
15990
16242
  });
15991
16243
 
15992
- const METHOD_NAME$Z = "function.template.navigateToAgent";
16244
+ const METHOD_NAME$U = "function.template.navigateToAgent";
15993
16245
  /**
15994
16246
  * Default tool output message indicating successful navigation to the specified agent.
15995
16247
  *
@@ -16054,7 +16306,7 @@ const createNavigateToAgent = async ({ executeMessage, emitMessage, flushMessage
16054
16306
  */
16055
16307
  return beginContext(async (toolId, clientId, agentName) => {
16056
16308
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16057
- swarm$1.loggerService.log(METHOD_NAME$Z, {
16309
+ swarm$1.loggerService.log(METHOD_NAME$U, {
16058
16310
  clientId,
16059
16311
  toolId,
16060
16312
  });
@@ -16087,7 +16339,7 @@ const createNavigateToAgent = async ({ executeMessage, emitMessage, flushMessage
16087
16339
  };
16088
16340
 
16089
16341
  /** @constant {string} METHOD_NAME - The name of the method used for logging */
16090
- const METHOD_NAME$Y = "function.setup.addWiki";
16342
+ const METHOD_NAME$T = "function.setup.addWiki";
16091
16343
  /**
16092
16344
  * Adds a wiki schema to the system
16093
16345
  * @function addWiki
@@ -16096,7 +16348,7 @@ const METHOD_NAME$Y = "function.setup.addWiki";
16096
16348
  */
16097
16349
  const addWiki = beginContext((wikiSchema) => {
16098
16350
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16099
- swarm$1.loggerService.log(METHOD_NAME$Y, {
16351
+ swarm$1.loggerService.log(METHOD_NAME$T, {
16100
16352
  wikiSchema,
16101
16353
  });
16102
16354
  swarm$1.wikiValidationService.addWiki(wikiSchema.wikiName, wikiSchema);
@@ -16104,7 +16356,7 @@ const addWiki = beginContext((wikiSchema) => {
16104
16356
  return wikiSchema.wikiName;
16105
16357
  });
16106
16358
 
16107
- const METHOD_NAME$X = "function.setup.addAgent";
16359
+ const METHOD_NAME$S = "function.setup.addAgent";
16108
16360
  /**
16109
16361
  * Adds a new agent to the agent registry for use within the swarm system.
16110
16362
  *
@@ -16124,7 +16376,7 @@ const METHOD_NAME$X = "function.setup.addAgent";
16124
16376
  const addAgent = beginContext((agentSchema) => {
16125
16377
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
16126
16378
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16127
- swarm$1.loggerService.log(METHOD_NAME$X, {
16379
+ swarm$1.loggerService.log(METHOD_NAME$S, {
16128
16380
  agentSchema,
16129
16381
  });
16130
16382
  // Register the agent in the validation and schema services
@@ -16134,7 +16386,7 @@ const addAgent = beginContext((agentSchema) => {
16134
16386
  return agentSchema.agentName;
16135
16387
  });
16136
16388
 
16137
- const METHOD_NAME$W = "function.setup.addCompletion";
16389
+ const METHOD_NAME$R = "function.setup.addCompletion";
16138
16390
  /**
16139
16391
  * Adds a completion engine to the registry for use by agents in the swarm system.
16140
16392
  *
@@ -16154,7 +16406,7 @@ const METHOD_NAME$W = "function.setup.addCompletion";
16154
16406
  const addCompletion = beginContext((completionSchema) => {
16155
16407
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
16156
16408
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16157
- swarm$1.loggerService.log(METHOD_NAME$W, {
16409
+ swarm$1.loggerService.log(METHOD_NAME$R, {
16158
16410
  completionSchema,
16159
16411
  });
16160
16412
  // Register the completion in the validation and schema services
@@ -16164,7 +16416,7 @@ const addCompletion = beginContext((completionSchema) => {
16164
16416
  return completionSchema.completionName;
16165
16417
  });
16166
16418
 
16167
- const METHOD_NAME$V = "function.setup.addSwarm";
16419
+ const METHOD_NAME$Q = "function.setup.addSwarm";
16168
16420
  /**
16169
16421
  * Adds a new swarm to the system for managing client sessions.
16170
16422
  *
@@ -16184,7 +16436,7 @@ const METHOD_NAME$V = "function.setup.addSwarm";
16184
16436
  const addSwarm = beginContext((swarmSchema) => {
16185
16437
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
16186
16438
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16187
- swarm$1.loggerService.log(METHOD_NAME$V, {
16439
+ swarm$1.loggerService.log(METHOD_NAME$Q, {
16188
16440
  swarmSchema,
16189
16441
  });
16190
16442
  // Register the swarm in the validation and schema services
@@ -16194,7 +16446,7 @@ const addSwarm = beginContext((swarmSchema) => {
16194
16446
  return swarmSchema.swarmName;
16195
16447
  });
16196
16448
 
16197
- const METHOD_NAME$U = "function.setup.addTool";
16449
+ const METHOD_NAME$P = "function.setup.addTool";
16198
16450
  /**
16199
16451
  * Adds a new tool to the tool registry for use by agents in the swarm system.
16200
16452
  *
@@ -16216,7 +16468,7 @@ const METHOD_NAME$U = "function.setup.addTool";
16216
16468
  const addTool = beginContext((toolSchema) => {
16217
16469
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
16218
16470
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16219
- swarm$1.loggerService.log(METHOD_NAME$U, {
16471
+ swarm$1.loggerService.log(METHOD_NAME$P, {
16220
16472
  toolSchema,
16221
16473
  });
16222
16474
  // Register the tool in the validation and schema services
@@ -16226,7 +16478,7 @@ const addTool = beginContext((toolSchema) => {
16226
16478
  return toolSchema.toolName;
16227
16479
  });
16228
16480
 
16229
- const METHOD_NAME$T = "function.setup.addMCP";
16481
+ const METHOD_NAME$O = "function.setup.addMCP";
16230
16482
  /**
16231
16483
  * Registers a new MCP (Model Context Protocol) schema in the system.
16232
16484
  * @param mcpSchema - The MCP schema to register.
@@ -16234,7 +16486,7 @@ const METHOD_NAME$T = "function.setup.addMCP";
16234
16486
  */
16235
16487
  const addMCP = beginContext((mcpSchema) => {
16236
16488
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16237
- swarm$1.loggerService.log(METHOD_NAME$T, {
16489
+ swarm$1.loggerService.log(METHOD_NAME$O, {
16238
16490
  mcpSchema,
16239
16491
  });
16240
16492
  swarm$1.mcpValidationService.addMCP(mcpSchema.mcpName, mcpSchema);
@@ -16242,7 +16494,7 @@ const addMCP = beginContext((mcpSchema) => {
16242
16494
  return mcpSchema.mcpName;
16243
16495
  });
16244
16496
 
16245
- const METHOD_NAME$S = "function.setup.addState";
16497
+ const METHOD_NAME$N = "function.setup.addState";
16246
16498
  /**
16247
16499
  * Adds a new state to the state registry for use within the swarm system.
16248
16500
  *
@@ -16264,7 +16516,7 @@ const METHOD_NAME$S = "function.setup.addState";
16264
16516
  const addState = beginContext((stateSchema) => {
16265
16517
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
16266
16518
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16267
- swarm$1.loggerService.log(METHOD_NAME$S, {
16519
+ swarm$1.loggerService.log(METHOD_NAME$N, {
16268
16520
  stateSchema,
16269
16521
  });
16270
16522
  // Register the state in the schema service
@@ -16279,7 +16531,7 @@ const addState = beginContext((stateSchema) => {
16279
16531
  return stateSchema.stateName;
16280
16532
  });
16281
16533
 
16282
- const METHOD_NAME$R = "function.setup.addEmbedding";
16534
+ const METHOD_NAME$M = "function.setup.addEmbedding";
16283
16535
  /**
16284
16536
  * Adds a new embedding engine to the embedding registry for use within the swarm system.
16285
16537
  *
@@ -16299,7 +16551,7 @@ const METHOD_NAME$R = "function.setup.addEmbedding";
16299
16551
  const addEmbedding = beginContext((embeddingSchema) => {
16300
16552
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
16301
16553
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16302
- swarm$1.loggerService.log(METHOD_NAME$R, {
16554
+ swarm$1.loggerService.log(METHOD_NAME$M, {
16303
16555
  embeddingSchema,
16304
16556
  });
16305
16557
  // Register the embedding in the validation and schema services
@@ -16309,7 +16561,7 @@ const addEmbedding = beginContext((embeddingSchema) => {
16309
16561
  return embeddingSchema.embeddingName;
16310
16562
  });
16311
16563
 
16312
- const METHOD_NAME$Q = "function.setup.addStorage";
16564
+ const METHOD_NAME$L = "function.setup.addStorage";
16313
16565
  /**
16314
16566
  * Adds a new storage engine to the storage registry for use within the swarm system.
16315
16567
  *
@@ -16331,7 +16583,7 @@ const METHOD_NAME$Q = "function.setup.addStorage";
16331
16583
  const addStorage = beginContext((storageSchema) => {
16332
16584
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
16333
16585
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16334
- swarm$1.loggerService.log(METHOD_NAME$Q, {
16586
+ swarm$1.loggerService.log(METHOD_NAME$L, {
16335
16587
  storageSchema,
16336
16588
  });
16337
16589
  // Register the storage in the validation and schema services
@@ -16348,7 +16600,7 @@ const addStorage = beginContext((storageSchema) => {
16348
16600
  });
16349
16601
 
16350
16602
  /** @private Constant defining the method name for logging and validation context */
16351
- const METHOD_NAME$P = "function.setup.addPolicy";
16603
+ const METHOD_NAME$K = "function.setup.addPolicy";
16352
16604
  /**
16353
16605
  * Adds a new policy for agents in the swarm system by registering it with validation and schema services.
16354
16606
  * Registers the policy with PolicyValidationService for runtime validation and PolicySchemaService for schema management.
@@ -16364,7 +16616,7 @@ const METHOD_NAME$P = "function.setup.addPolicy";
16364
16616
  const addPolicy = beginContext((policySchema) => {
16365
16617
  // Log the policy addition attempt if enabled
16366
16618
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16367
- swarm$1.loggerService.log(METHOD_NAME$P, {
16619
+ swarm$1.loggerService.log(METHOD_NAME$K, {
16368
16620
  policySchema,
16369
16621
  });
16370
16622
  // Register the policy with PolicyValidationService for runtime validation
@@ -16375,7 +16627,7 @@ const addPolicy = beginContext((policySchema) => {
16375
16627
  return policySchema.policyName;
16376
16628
  });
16377
16629
 
16378
- const METHOD_NAME$O = "function.test.overrideAgent";
16630
+ const METHOD_NAME$J = "function.test.overrideAgent";
16379
16631
  /**
16380
16632
  * Overrides an existing agent schema in the swarm system with a new or partial schema.
16381
16633
  * This function updates the configuration of an agent identified by its `agentName`, applying the provided schema properties.
@@ -16399,13 +16651,13 @@ const METHOD_NAME$O = "function.test.overrideAgent";
16399
16651
  */
16400
16652
  const overrideAgent = beginContext((agentSchema) => {
16401
16653
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16402
- swarm$1.loggerService.log(METHOD_NAME$O, {
16654
+ swarm$1.loggerService.log(METHOD_NAME$J, {
16403
16655
  agentSchema,
16404
16656
  });
16405
16657
  return swarm$1.agentSchemaService.override(agentSchema.agentName, agentSchema);
16406
16658
  });
16407
16659
 
16408
- const METHOD_NAME$N = "function.test.overrideCompletion";
16660
+ const METHOD_NAME$I = "function.test.overrideCompletion";
16409
16661
  /**
16410
16662
  * Overrides an existing completion schema in the swarm system with a new or partial schema.
16411
16663
  * This function updates the configuration of a completion mechanism identified by its `completionName`, applying the provided schema properties.
@@ -16429,13 +16681,13 @@ const METHOD_NAME$N = "function.test.overrideCompletion";
16429
16681
  */
16430
16682
  const overrideCompletion = beginContext((completionSchema) => {
16431
16683
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16432
- swarm$1.loggerService.log(METHOD_NAME$N, {
16684
+ swarm$1.loggerService.log(METHOD_NAME$I, {
16433
16685
  completionSchema,
16434
16686
  });
16435
16687
  return swarm$1.completionSchemaService.override(completionSchema.completionName, completionSchema);
16436
16688
  });
16437
16689
 
16438
- const METHOD_NAME$M = "function.test.overrideEmbeding";
16690
+ const METHOD_NAME$H = "function.test.overrideEmbeding";
16439
16691
  /**
16440
16692
  * Overrides an existing embedding schema in the swarm system with a new or partial schema.
16441
16693
  * This function updates the configuration of an embedding mechanism identified by its `embeddingName`, applying the provided schema properties.
@@ -16461,13 +16713,13 @@ const METHOD_NAME$M = "function.test.overrideEmbeding";
16461
16713
  */
16462
16714
  const overrideEmbeding = beginContext((embeddingSchema) => {
16463
16715
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16464
- swarm$1.loggerService.log(METHOD_NAME$M, {
16716
+ swarm$1.loggerService.log(METHOD_NAME$H, {
16465
16717
  embeddingSchema,
16466
16718
  });
16467
16719
  return swarm$1.embeddingSchemaService.override(embeddingSchema.embeddingName, embeddingSchema);
16468
16720
  });
16469
16721
 
16470
- const METHOD_NAME$L = "function.test.overridePolicy";
16722
+ const METHOD_NAME$G = "function.test.overridePolicy";
16471
16723
  /**
16472
16724
  * Overrides an existing policy schema in the swarm system with a new or partial schema.
16473
16725
  * This function updates the configuration of a policy identified by its `policyName`, applying the provided schema properties.
@@ -16491,13 +16743,13 @@ const METHOD_NAME$L = "function.test.overridePolicy";
16491
16743
  */
16492
16744
  const overridePolicy = beginContext((policySchema) => {
16493
16745
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16494
- swarm$1.loggerService.log(METHOD_NAME$L, {
16746
+ swarm$1.loggerService.log(METHOD_NAME$G, {
16495
16747
  policySchema,
16496
16748
  });
16497
16749
  return swarm$1.policySchemaService.override(policySchema.policyName, policySchema);
16498
16750
  });
16499
16751
 
16500
- const METHOD_NAME$K = "function.test.overrideState";
16752
+ const METHOD_NAME$F = "function.test.overrideState";
16501
16753
  /**
16502
16754
  * Overrides an existing state schema in the swarm system with a new or partial schema.
16503
16755
  * This function updates the configuration of a state identified by its `stateName`, applying the provided schema properties.
@@ -16522,13 +16774,13 @@ const METHOD_NAME$K = "function.test.overrideState";
16522
16774
  */
16523
16775
  const overrideState = beginContext((stateSchema) => {
16524
16776
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16525
- swarm$1.loggerService.log(METHOD_NAME$K, {
16777
+ swarm$1.loggerService.log(METHOD_NAME$F, {
16526
16778
  stateSchema,
16527
16779
  });
16528
16780
  return swarm$1.stateSchemaService.override(stateSchema.stateName, stateSchema);
16529
16781
  });
16530
16782
 
16531
- const METHOD_NAME$J = "function.test.overrideStorage";
16783
+ const METHOD_NAME$E = "function.test.overrideStorage";
16532
16784
  /**
16533
16785
  * Overrides an existing storage schema in the swarm system with a new or partial schema.
16534
16786
  * This function updates the configuration of a storage identified by its `storageName`, applying the provided schema properties.
@@ -16554,13 +16806,13 @@ const METHOD_NAME$J = "function.test.overrideStorage";
16554
16806
  */
16555
16807
  const overrideStorage = beginContext((storageSchema) => {
16556
16808
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16557
- swarm$1.loggerService.log(METHOD_NAME$J, {
16809
+ swarm$1.loggerService.log(METHOD_NAME$E, {
16558
16810
  storageSchema,
16559
16811
  });
16560
16812
  return swarm$1.storageSchemaService.override(storageSchema.storageName, storageSchema);
16561
16813
  });
16562
16814
 
16563
- const METHOD_NAME$I = "function.test.overrideSwarm";
16815
+ const METHOD_NAME$D = "function.test.overrideSwarm";
16564
16816
  /**
16565
16817
  * Overrides an existing swarm schema in the swarm system with a new or partial schema.
16566
16818
  * This function updates the configuration of a swarm identified by its `swarmName`, applying the provided schema properties.
@@ -16584,13 +16836,13 @@ const METHOD_NAME$I = "function.test.overrideSwarm";
16584
16836
  */
16585
16837
  const overrideSwarm = beginContext((swarmSchema) => {
16586
16838
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16587
- swarm$1.loggerService.log(METHOD_NAME$I, {
16839
+ swarm$1.loggerService.log(METHOD_NAME$D, {
16588
16840
  swarmSchema,
16589
16841
  });
16590
16842
  return swarm$1.swarmSchemaService.override(swarmSchema.swarmName, swarmSchema);
16591
16843
  });
16592
16844
 
16593
- const METHOD_NAME$H = "function.test.overrideTool";
16845
+ const METHOD_NAME$C = "function.test.overrideTool";
16594
16846
  /**
16595
16847
  * Overrides an existing tool schema in the swarm system with a new or partial schema.
16596
16848
  * This function updates the configuration of a tool identified by its `toolName`, applying the provided schema properties.
@@ -16614,13 +16866,13 @@ const METHOD_NAME$H = "function.test.overrideTool";
16614
16866
  */
16615
16867
  const overrideTool = beginContext((toolSchema) => {
16616
16868
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16617
- swarm$1.loggerService.log(METHOD_NAME$H, {
16869
+ swarm$1.loggerService.log(METHOD_NAME$C, {
16618
16870
  toolSchema,
16619
16871
  });
16620
16872
  return swarm$1.toolSchemaService.override(toolSchema.toolName, toolSchema);
16621
16873
  });
16622
16874
 
16623
- const METHOD_NAME$G = "function.test.overrideMCP";
16875
+ const METHOD_NAME$B = "function.test.overrideMCP";
16624
16876
  /**
16625
16877
  * Overrides an existing MCP (Model Context Protocol) schema with a new or partial schema.
16626
16878
  * @param mcpSchema - The MCP schema containing the name and optional properties to override.
@@ -16628,13 +16880,13 @@ const METHOD_NAME$G = "function.test.overrideMCP";
16628
16880
  */
16629
16881
  const overrideMCP = beginContext((mcpSchema) => {
16630
16882
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16631
- swarm$1.loggerService.log(METHOD_NAME$G, {
16883
+ swarm$1.loggerService.log(METHOD_NAME$B, {
16632
16884
  mcpSchema,
16633
16885
  });
16634
16886
  return swarm$1.mcpSchemaService.override(mcpSchema.mcpName, mcpSchema);
16635
16887
  });
16636
16888
 
16637
- const METHOD_NAME$F = "function.test.overrideWiki";
16889
+ const METHOD_NAME$A = "function.test.overrideWiki";
16638
16890
  /**
16639
16891
  * Overrides an existing wiki schema in the swarm system with a new or partial schema.
16640
16892
  * This function updates the configuration of a wiki identified by its `wikiName`, applying the provided schema properties.
@@ -16658,13 +16910,13 @@ const METHOD_NAME$F = "function.test.overrideWiki";
16658
16910
  */
16659
16911
  const overrideWiki = beginContext((wikiSchema) => {
16660
16912
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16661
- swarm$1.loggerService.log(METHOD_NAME$F, {
16913
+ swarm$1.loggerService.log(METHOD_NAME$A, {
16662
16914
  wikiSchema,
16663
16915
  });
16664
16916
  return swarm$1.wikiSchemaService.override(wikiSchema.wikiName, wikiSchema);
16665
16917
  });
16666
16918
 
16667
- const METHOD_NAME$E = "function.other.markOnline";
16919
+ const METHOD_NAME$z = "function.other.markOnline";
16668
16920
  /**
16669
16921
  * Marks a client as online in the specified swarm.
16670
16922
  *
@@ -16676,16 +16928,16 @@ const METHOD_NAME$E = "function.other.markOnline";
16676
16928
  const markOnline = async (clientId, swarmName) => {
16677
16929
  // Log the operation if logging is enabled in the global configuration
16678
16930
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16679
- swarm.loggerService.log(METHOD_NAME$E, {
16931
+ swarm.loggerService.log(METHOD_NAME$z, {
16680
16932
  clientId,
16681
16933
  });
16682
16934
  // Validate the swarm name
16683
- swarm.swarmValidationService.validate(swarmName, METHOD_NAME$E);
16935
+ swarm.swarmValidationService.validate(swarmName, METHOD_NAME$z);
16684
16936
  // Run the operation in the method context
16685
16937
  return await MethodContextService.runInContext(async () => {
16686
- await swarm.aliveService.markOnline(clientId, swarmName, METHOD_NAME$E);
16938
+ await swarm.aliveService.markOnline(clientId, swarmName, METHOD_NAME$z);
16687
16939
  }, {
16688
- methodName: METHOD_NAME$E,
16940
+ methodName: METHOD_NAME$z,
16689
16941
  agentName: "",
16690
16942
  policyName: "",
16691
16943
  stateName: "",
@@ -16696,7 +16948,7 @@ const markOnline = async (clientId, swarmName) => {
16696
16948
  });
16697
16949
  };
16698
16950
 
16699
- const METHOD_NAME$D = "function.other.markOffline";
16951
+ const METHOD_NAME$y = "function.other.markOffline";
16700
16952
  /**
16701
16953
  * Marks a client as offline in the specified swarm.
16702
16954
  *
@@ -16711,14 +16963,14 @@ const METHOD_NAME$D = "function.other.markOffline";
16711
16963
  */
16712
16964
  const markOffline = async (clientId, swarmName) => {
16713
16965
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16714
- swarm.loggerService.log(METHOD_NAME$D, {
16966
+ swarm.loggerService.log(METHOD_NAME$y, {
16715
16967
  clientId,
16716
16968
  });
16717
- swarm.swarmValidationService.validate(swarmName, METHOD_NAME$D);
16969
+ swarm.swarmValidationService.validate(swarmName, METHOD_NAME$y);
16718
16970
  return await MethodContextService.runInContext(async () => {
16719
- await swarm.aliveService.markOffline(clientId, swarmName, METHOD_NAME$D);
16971
+ await swarm.aliveService.markOffline(clientId, swarmName, METHOD_NAME$y);
16720
16972
  }, {
16721
- methodName: METHOD_NAME$D,
16973
+ methodName: METHOD_NAME$y,
16722
16974
  agentName: "",
16723
16975
  policyName: "",
16724
16976
  stateName: "",
@@ -16729,56 +16981,8 @@ const markOffline = async (clientId, swarmName) => {
16729
16981
  });
16730
16982
  };
16731
16983
 
16732
- const METHOD_NAME$C = "function.commit.commitToolOutput";
16733
- /**
16734
- * Commits the output of a tool execution to the active agent in a swarm session.
16735
- *
16736
- * This function ensures that the tool output is committed only if the specified agent is still the active agent in the swarm session.
16737
- * It performs validation checks on the agent, session, and swarm, logs the operation if enabled, and delegates the commit operation to the session public service.
16738
- * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
16739
- *
16740
- * @param {string} toolId - The unique identifier of the tool whose output is being committed.
16741
- * @param {string} content - The content or result of the tool execution to be committed.
16742
- * @param {string} clientId - The unique identifier of the client session associated with the operation.
16743
- * @param {AgentName} agentName - The name of the agent committing the tool output.
16744
- * @returns {Promise<void>} A promise that resolves when the tool output is successfully committed, or immediately if the operation is skipped due to an agent change.
16745
- * @throws {Error} If validation fails (e.g., invalid agent, session, or swarm) or if the session public service encounters an error during the commit operation.
16746
- * @example
16747
- * await commitToolOutput("tool-123", "Tool execution result", "client-456", "AgentX");
16748
- */
16749
- const commitToolOutput = beginContext(async (toolId, content, clientId, agentName) => {
16750
- // Log the operation details if logging is enabled in GLOBAL_CONFIG
16751
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16752
- swarm$1.loggerService.log(METHOD_NAME$C, {
16753
- toolId,
16754
- content,
16755
- clientId,
16756
- agentName,
16757
- });
16758
- // Validate the agent, session, and swarm to ensure they exist and are accessible
16759
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$C);
16760
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$C);
16761
- const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
16762
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$C);
16763
- // Check if the specified agent is still the active agent in the swarm session
16764
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$C, clientId, swarmName);
16765
- if (currentAgentName !== agentName) {
16766
- // Log a skip message if the agent has changed during the operation
16767
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16768
- swarm$1.loggerService.log('function "commitToolOutput" skipped due to the agent change', {
16769
- toolId,
16770
- currentAgentName,
16771
- agentName,
16772
- clientId,
16773
- });
16774
- return;
16775
- }
16776
- // Commit the tool output to the session via the session public service
16777
- await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$C, clientId, swarmName);
16778
- });
16779
-
16780
16984
  /** @private Constant defining the method name for logging and validation context */
16781
- const METHOD_NAME$B = "function.commit.commitSystemMessage";
16985
+ const METHOD_NAME$x = "function.commit.commitSystemMessage";
16782
16986
  /**
16783
16987
  * Commits a system-generated message to the active agent in the swarm system.
16784
16988
  * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before committing the message.
@@ -16797,20 +17001,20 @@ const METHOD_NAME$B = "function.commit.commitSystemMessage";
16797
17001
  const commitSystemMessage = beginContext(async (content, clientId, agentName) => {
16798
17002
  // Log the commit attempt if enabled
16799
17003
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16800
- swarm$1.loggerService.log(METHOD_NAME$B, {
17004
+ swarm$1.loggerService.log(METHOD_NAME$x, {
16801
17005
  content,
16802
17006
  clientId,
16803
17007
  agentName,
16804
17008
  });
16805
17009
  // Validate the agent exists
16806
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$B);
17010
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$x);
16807
17011
  // Validate the session exists and retrieve the associated swarm
16808
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$B);
17012
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$x);
16809
17013
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
16810
17014
  // Validate the swarm configuration
16811
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$B);
17015
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$x);
16812
17016
  // Check if the current agent matches the provided agent
16813
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$B, clientId, swarmName);
17017
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$x, clientId, swarmName);
16814
17018
  if (currentAgentName !== agentName) {
16815
17019
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16816
17020
  swarm$1.loggerService.log('function "commitSystemMessage" skipped due to the agent change', {
@@ -16821,54 +17025,10 @@ const commitSystemMessage = beginContext(async (content, clientId, agentName) =>
16821
17025
  return;
16822
17026
  }
16823
17027
  // Commit the system message via SessionPublicService
16824
- await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$B, clientId, swarmName);
17028
+ await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$x, clientId, swarmName);
16825
17029
  });
16826
17030
 
16827
- /** @private Constant defining the method name for logging and validation context */
16828
- const METHOD_NAME$A = "function.commit.commitFlush";
16829
- /**
16830
- * Commits a flush of agent history for a specific client and agent in the swarm system.
16831
- * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before flushing the history.
16832
- * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
16833
- * Integrates with AgentValidationService (agent validation), SessionValidationService (session and swarm retrieval),
16834
- * SwarmValidationService (swarm validation), SwarmPublicService (agent retrieval), SessionPublicService (history flush),
16835
- * and LoggerService (logging). Complements functions like commitAssistantMessage by clearing agent history rather than adding messages.
16836
- *
16837
- * @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
16838
- * @param {string} agentName - The name of the agent whose history is to be flushed, validated against registered agents.
16839
- * @returns {Promise<void>} A promise that resolves when the history flush is committed or skipped (e.g., agent mismatch).
16840
- * @throws {Error} If agent, session, or swarm validation fails, propagated from respective validation services.
16841
- */
16842
- const commitFlush = beginContext(async (clientId, agentName) => {
16843
- // Log the flush attempt if enabled
16844
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16845
- swarm$1.loggerService.log(METHOD_NAME$A, {
16846
- clientId,
16847
- agentName,
16848
- });
16849
- // Validate the agent exists
16850
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$A);
16851
- // Validate the session exists and retrieve the associated swarm
16852
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$A);
16853
- const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
16854
- // Validate the swarm configuration
16855
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$A);
16856
- // Check if the current agent matches the provided agent
16857
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$A, clientId, swarmName);
16858
- if (currentAgentName !== agentName) {
16859
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16860
- swarm$1.loggerService.log('function "commitFlush" skipped due to the agent change', {
16861
- currentAgentName,
16862
- agentName,
16863
- clientId,
16864
- });
16865
- return;
16866
- }
16867
- // Commit the flush of agent history via SessionPublicService
16868
- await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$A, clientId, swarmName);
16869
- });
16870
-
16871
- const METHOD_NAME$z = "function.commit.commitSystemMessage";
17031
+ const METHOD_NAME$w = "function.commit.commitSystemMessage";
16872
17032
  /**
16873
17033
  * Commits a user message to the active agent's history in a swarm session without triggering a response.
16874
17034
  *
@@ -16887,19 +17047,19 @@ const METHOD_NAME$z = "function.commit.commitSystemMessage";
16887
17047
  const commitUserMessage = beginContext(async (content, mode, clientId, agentName, payload) => {
16888
17048
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
16889
17049
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16890
- swarm$1.loggerService.log(METHOD_NAME$z, {
17050
+ swarm$1.loggerService.log(METHOD_NAME$w, {
16891
17051
  content,
16892
17052
  clientId,
16893
17053
  agentName,
16894
17054
  mode,
16895
17055
  });
16896
17056
  // Validate the agent, session, and swarm to ensure they exist and are accessible
16897
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$z);
16898
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$z);
17057
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$w);
17058
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$w);
16899
17059
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
16900
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$z);
17060
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$w);
16901
17061
  // Check if the specified agent is still the active agent in the swarm session
16902
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$z, clientId, swarmName);
17062
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$w, clientId, swarmName);
16903
17063
  if (currentAgentName !== agentName) {
16904
17064
  // Log a skip message if the agent has changed during the operation
16905
17065
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
@@ -16912,18 +17072,18 @@ const commitUserMessage = beginContext(async (content, mode, clientId, agentName
16912
17072
  }
16913
17073
  if (payload) {
16914
17074
  return await PayloadContextService.runInContext(async () => {
16915
- await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$z, clientId, swarmName);
17075
+ await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$w, clientId, swarmName);
16916
17076
  }, {
16917
17077
  clientId,
16918
17078
  payload,
16919
17079
  });
16920
17080
  }
16921
17081
  // Commit the user message to the agent's history via the session public service
16922
- return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$z, clientId, swarmName);
17082
+ return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$w, clientId, swarmName);
16923
17083
  });
16924
17084
 
16925
17085
  /** @private Constant defining the method name for logging and validation context */
16926
- const METHOD_NAME$y = "function.commit.commitSystemMessageForce";
17086
+ const METHOD_NAME$v = "function.commit.commitSystemMessageForce";
16927
17087
  /**
16928
17088
  * Forcefully commits a system-generated message to a session in the swarm system, without checking the active agent.
16929
17089
  * Validates the session and swarm, then proceeds with committing the message regardless of the current agent state.
@@ -16942,20 +17102,20 @@ const METHOD_NAME$y = "function.commit.commitSystemMessageForce";
16942
17102
  const commitSystemMessageForce = beginContext(async (content, clientId) => {
16943
17103
  // Log the commit attempt if enabled
16944
17104
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16945
- swarm$1.loggerService.log(METHOD_NAME$y, {
17105
+ swarm$1.loggerService.log(METHOD_NAME$v, {
16946
17106
  content,
16947
17107
  clientId,
16948
17108
  });
16949
17109
  // Validate the session exists and retrieve the associated swarm
16950
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$y);
17110
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$v);
16951
17111
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
16952
17112
  // Validate the swarm configuration
16953
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$y);
17113
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$v);
16954
17114
  // Commit the system message via SessionPublicService without agent checks
16955
- await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$y, clientId, swarmName);
17115
+ await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$v, clientId, swarmName);
16956
17116
  });
16957
17117
 
16958
- const METHOD_NAME$x = "function.commit.commitSystemMessage";
17118
+ const METHOD_NAME$u = "function.commit.commitSystemMessage";
16959
17119
  /**
16960
17120
  * Commits a user message to the active agent's history in a swarm session without triggering a response and without checking the active agent.
16961
17121
  *
@@ -16973,29 +17133,29 @@ const METHOD_NAME$x = "function.commit.commitSystemMessage";
16973
17133
  const commitUserMessageForce = beginContext(async (content, mode, clientId, payload) => {
16974
17134
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
16975
17135
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
16976
- swarm$1.loggerService.log(METHOD_NAME$x, {
17136
+ swarm$1.loggerService.log(METHOD_NAME$u, {
16977
17137
  content,
16978
17138
  clientId,
16979
17139
  mode,
16980
17140
  });
16981
17141
  // Validate the session and swarm to ensure they exist and are accessible
16982
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$x);
17142
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$u);
16983
17143
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
16984
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$x);
17144
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$u);
16985
17145
  if (payload) {
16986
17146
  return await PayloadContextService.runInContext(async () => {
16987
- await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$x, clientId, swarmName);
17147
+ await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$u, clientId, swarmName);
16988
17148
  }, {
16989
17149
  clientId,
16990
17150
  payload,
16991
17151
  });
16992
17152
  }
16993
17153
  // Commit the user message to the agent's history via the session public service without checking the active agent
16994
- return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$x, clientId, swarmName);
17154
+ return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$u, clientId, swarmName);
16995
17155
  });
16996
17156
 
16997
17157
  /** @private Constant defining the method name for logging and validation context */
16998
- const METHOD_NAME$w = "function.commit.commitAssistantMessage";
17158
+ const METHOD_NAME$t = "function.commit.commitAssistantMessage";
16999
17159
  /**
17000
17160
  * Commits an assistant-generated message to the active agent in the swarm system.
17001
17161
  * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before committing the message.
@@ -17013,20 +17173,20 @@ const METHOD_NAME$w = "function.commit.commitAssistantMessage";
17013
17173
  const commitAssistantMessage = beginContext(async (content, clientId, agentName) => {
17014
17174
  // Log the commit attempt if enabled
17015
17175
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17016
- swarm$1.loggerService.log(METHOD_NAME$w, {
17176
+ swarm$1.loggerService.log(METHOD_NAME$t, {
17017
17177
  content,
17018
17178
  clientId,
17019
17179
  agentName,
17020
17180
  });
17021
17181
  // Validate the agent exists
17022
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$w);
17182
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$t);
17023
17183
  // Validate the session exists and retrieve the associated swarm
17024
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$w);
17184
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$t);
17025
17185
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
17026
17186
  // Validate the swarm configuration
17027
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$w);
17187
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$t);
17028
17188
  // Check if the current agent matches the provided agent
17029
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$w, clientId, swarmName);
17189
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$t, clientId, swarmName);
17030
17190
  if (currentAgentName !== agentName) {
17031
17191
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17032
17192
  swarm$1.loggerService.log('function "commitAssistantMessage" skipped due to the agent change', {
@@ -17037,11 +17197,11 @@ const commitAssistantMessage = beginContext(async (content, clientId, agentName)
17037
17197
  return;
17038
17198
  }
17039
17199
  // Commit the assistant message via SessionPublicService
17040
- await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$w, clientId, swarmName);
17200
+ await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$t, clientId, swarmName);
17041
17201
  });
17042
17202
 
17043
17203
  /** @private Constant defining the method name for logging and validation context */
17044
- const METHOD_NAME$v = "function.commit.commitAssistantMessageForce";
17204
+ const METHOD_NAME$s = "function.commit.commitAssistantMessageForce";
17045
17205
  /**
17046
17206
  * Forcefully commits an assistant-generated message to a session in the swarm system, without checking the active agent.
17047
17207
  * Validates the session and swarm, then proceeds with committing the message regardless of the current agent state.
@@ -17060,21 +17220,21 @@ const METHOD_NAME$v = "function.commit.commitAssistantMessageForce";
17060
17220
  const commitAssistantMessageForce = beginContext(async (content, clientId) => {
17061
17221
  // Log the commit attempt if enabled
17062
17222
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17063
- swarm$1.loggerService.log(METHOD_NAME$v, {
17223
+ swarm$1.loggerService.log(METHOD_NAME$s, {
17064
17224
  content,
17065
17225
  clientId,
17066
17226
  });
17067
17227
  // Validate the session exists and retrieve the associated swarm
17068
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$v);
17228
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$s);
17069
17229
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
17070
17230
  // Validate the swarm configuration
17071
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$v);
17231
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$s);
17072
17232
  // Commit the assistant message via SessionPublicService without agent checks
17073
- await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$v, clientId, swarmName);
17233
+ await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$s, clientId, swarmName);
17074
17234
  });
17075
17235
 
17076
17236
  /** @private Constant defining the method name for logging and validation context */
17077
- const METHOD_NAME$u = "function.commit.cancelOutput";
17237
+ const METHOD_NAME$r = "function.commit.cancelOutput";
17078
17238
  /**
17079
17239
  * Cancels the awaited output for a specific client and agent by emitting an empty string.
17080
17240
  * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before cancellation.
@@ -17090,19 +17250,19 @@ const METHOD_NAME$u = "function.commit.cancelOutput";
17090
17250
  const cancelOutput = beginContext(async (clientId, agentName) => {
17091
17251
  // Log the cancellation attempt if enabled
17092
17252
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17093
- swarm$1.loggerService.log(METHOD_NAME$u, {
17253
+ swarm$1.loggerService.log(METHOD_NAME$r, {
17094
17254
  clientId,
17095
17255
  agentName,
17096
17256
  });
17097
17257
  // Validate the agent exists
17098
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$u);
17258
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$r);
17099
17259
  // Validate the session exists and retrieve the associated swarm
17100
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$u);
17260
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$r);
17101
17261
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
17102
17262
  // Validate the swarm configuration
17103
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$u);
17263
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$r);
17104
17264
  // Check if the current agent matches the provided agent
17105
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$u, clientId, swarmName);
17265
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$r, clientId, swarmName);
17106
17266
  if (currentAgentName !== agentName) {
17107
17267
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17108
17268
  swarm$1.loggerService.log('function "cancelOutput" skipped due to the agent change', {
@@ -17113,11 +17273,11 @@ const cancelOutput = beginContext(async (clientId, agentName) => {
17113
17273
  return;
17114
17274
  }
17115
17275
  // Perform the output cancellation via SwarmPublicService
17116
- await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$u, clientId, swarmName);
17276
+ await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$r, clientId, swarmName);
17117
17277
  });
17118
17278
 
17119
17279
  /** @private Constant defining the method name for logging and validation context */
17120
- const METHOD_NAME$t = "function.commit.cancelOutputForce";
17280
+ const METHOD_NAME$q = "function.commit.cancelOutputForce";
17121
17281
  /**
17122
17282
  * Forcefully cancels the awaited output for a specific client by emitting an empty string, without checking the active agent.
17123
17283
  * Validates the session and swarm, then proceeds with cancellation regardless of the current agent state.
@@ -17134,20 +17294,20 @@ const METHOD_NAME$t = "function.commit.cancelOutputForce";
17134
17294
  const cancelOutputForce = beginContext(async (clientId) => {
17135
17295
  // Log the cancellation attempt if enabled
17136
17296
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17137
- swarm$1.loggerService.log(METHOD_NAME$t, {
17297
+ swarm$1.loggerService.log(METHOD_NAME$q, {
17138
17298
  clientId,
17139
17299
  });
17140
17300
  // Validate the session exists and retrieve the associated swarm
17141
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$t);
17301
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$q);
17142
17302
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
17143
17303
  // Validate the swarm configuration
17144
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$t);
17304
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$q);
17145
17305
  // Perform the output cancellation via SwarmPublicService without agent checks
17146
- await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$t, clientId, swarmName);
17306
+ await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$q, clientId, swarmName);
17147
17307
  });
17148
17308
 
17149
17309
  /** @private Constant defining the method name for logging and validation context */
17150
- const METHOD_NAME$s = "function.commit.commitStopTools";
17310
+ const METHOD_NAME$p = "function.commit.commitStopTools";
17151
17311
  /**
17152
17312
  * Prevents the next tool from being executed for a specific client and agent in the swarm system.
17153
17313
  * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before stopping tool execution.
@@ -17164,19 +17324,19 @@ const METHOD_NAME$s = "function.commit.commitStopTools";
17164
17324
  const commitStopTools = beginContext(async (clientId, agentName) => {
17165
17325
  // Log the stop tools attempt if enabled
17166
17326
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17167
- swarm$1.loggerService.log(METHOD_NAME$s, {
17327
+ swarm$1.loggerService.log(METHOD_NAME$p, {
17168
17328
  clientId,
17169
17329
  agentName,
17170
17330
  });
17171
17331
  // Validate the agent exists
17172
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$s);
17332
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$p);
17173
17333
  // Validate the session exists and retrieve the associated swarm
17174
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$s);
17334
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$p);
17175
17335
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
17176
17336
  // Validate the swarm configuration
17177
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$s);
17337
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$p);
17178
17338
  // Check if the current agent matches the provided agent
17179
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$s, clientId, swarmName);
17339
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$p, clientId, swarmName);
17180
17340
  if (currentAgentName !== agentName) {
17181
17341
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17182
17342
  swarm$1.loggerService.log('function "commitStopTools" skipped due to the agent change', {
@@ -17187,11 +17347,11 @@ const commitStopTools = beginContext(async (clientId, agentName) => {
17187
17347
  return;
17188
17348
  }
17189
17349
  // Commit the stop of the next tool execution via SessionPublicService
17190
- await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$s, clientId, swarmName);
17350
+ await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$p, clientId, swarmName);
17191
17351
  });
17192
17352
 
17193
17353
  /** @private Constant defining the method name for logging and validation context */
17194
- const METHOD_NAME$r = "function.commit.commitStopToolsForce";
17354
+ const METHOD_NAME$o = "function.commit.commitStopToolsForce";
17195
17355
  /**
17196
17356
  * Forcefully prevents the next tool from being executed for a specific client in the swarm system, without checking the active agent.
17197
17357
  * Validates the session and swarm, then proceeds with stopping tool execution regardless of the current agent state.
@@ -17209,21 +17369,21 @@ const METHOD_NAME$r = "function.commit.commitStopToolsForce";
17209
17369
  const commitStopToolsForce = beginContext(async (clientId) => {
17210
17370
  // Log the stop tools attempt if enabled
17211
17371
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17212
- swarm$1.loggerService.log(METHOD_NAME$r, {
17372
+ swarm$1.loggerService.log(METHOD_NAME$o, {
17213
17373
  clientId,
17214
- METHOD_NAME: METHOD_NAME$r,
17374
+ METHOD_NAME: METHOD_NAME$o,
17215
17375
  });
17216
17376
  // Validate the session exists and retrieve the associated swarm
17217
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$r);
17377
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$o);
17218
17378
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
17219
17379
  // Validate the swarm configuration
17220
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$r);
17380
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$o);
17221
17381
  // Commit the stop of the next tool execution via SessionPublicService without agent checks
17222
- await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$r, clientId, swarmName);
17382
+ await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$o, clientId, swarmName);
17223
17383
  });
17224
17384
 
17225
17385
  /** @constant {string} METHOD_NAME - The name of the method used for logging and validation */
17226
- const METHOD_NAME$q = "function.target.question";
17386
+ const METHOD_NAME$n = "function.target.question";
17227
17387
  /**
17228
17388
  * Initiates a question process within a chat context
17229
17389
  * @function question
@@ -17235,21 +17395,21 @@ const METHOD_NAME$q = "function.target.question";
17235
17395
  */
17236
17396
  const question = beginContext(async (message, clientId, agentName, wikiName) => {
17237
17397
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17238
- swarm$1.loggerService.log(METHOD_NAME$q, {
17398
+ swarm$1.loggerService.log(METHOD_NAME$n, {
17239
17399
  message,
17240
17400
  clientId,
17241
17401
  agentName,
17242
17402
  wikiName,
17243
17403
  });
17244
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$q);
17245
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$q);
17404
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$n);
17405
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$n);
17246
17406
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
17247
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$q);
17248
- swarm$1.wikiValidationService.validate(wikiName, METHOD_NAME$q);
17407
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$n);
17408
+ swarm$1.wikiValidationService.validate(wikiName, METHOD_NAME$n);
17249
17409
  if (!swarm$1.agentValidationService.hasWiki(agentName, wikiName)) {
17250
- throw new Error(`agent-swarm ${METHOD_NAME$q} ${wikiName} not registered in ${agentName}`);
17410
+ throw new Error(`agent-swarm ${METHOD_NAME$n} ${wikiName} not registered in ${agentName}`);
17251
17411
  }
17252
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$q, clientId, swarmName);
17412
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$n, clientId, swarmName);
17253
17413
  if (currentAgentName !== agentName) {
17254
17414
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17255
17415
  swarm$1.loggerService.log('function "question" skipped due to the agent change', {
@@ -17272,7 +17432,7 @@ const question = beginContext(async (message, clientId, agentName, wikiName) =>
17272
17432
  });
17273
17433
 
17274
17434
  /** @constant {string} METHOD_NAME - The name of the method used for logging and validation */
17275
- const METHOD_NAME$p = "function.target.questionForce";
17435
+ const METHOD_NAME$m = "function.target.questionForce";
17276
17436
  /**
17277
17437
  * Initiates a forced question process within a chat context
17278
17438
  * @function questionForce
@@ -17283,17 +17443,17 @@ const METHOD_NAME$p = "function.target.questionForce";
17283
17443
  */
17284
17444
  const questionForce = beginContext(async (message, clientId, wikiName) => {
17285
17445
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17286
- swarm$1.loggerService.log(METHOD_NAME$p, {
17446
+ swarm$1.loggerService.log(METHOD_NAME$m, {
17287
17447
  message,
17288
17448
  clientId,
17289
17449
  wikiName,
17290
17450
  });
17291
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$p);
17451
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$m);
17292
17452
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
17293
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$p);
17294
- swarm$1.wikiValidationService.validate(wikiName, METHOD_NAME$p);
17453
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$m);
17454
+ swarm$1.wikiValidationService.validate(wikiName, METHOD_NAME$m);
17295
17455
  const { getChat, callbacks } = swarm$1.wikiSchemaService.get(wikiName);
17296
- const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$p, clientId, swarmName);
17456
+ const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$m, clientId, swarmName);
17297
17457
  const args = {
17298
17458
  clientId,
17299
17459
  message,
@@ -17305,7 +17465,7 @@ const questionForce = beginContext(async (message, clientId, wikiName) => {
17305
17465
  return await getChat(args);
17306
17466
  });
17307
17467
 
17308
- const METHOD_NAME$o = "function.target.disposeConnection";
17468
+ const METHOD_NAME$l = "function.target.disposeConnection";
17309
17469
  /**
17310
17470
  * Disposes of a client session and all related resources within a swarm.
17311
17471
  *
@@ -17322,10 +17482,10 @@ const METHOD_NAME$o = "function.target.disposeConnection";
17322
17482
  * @example
17323
17483
  * await disposeConnection("client-123", "TaskSwarm");
17324
17484
  */
17325
- const disposeConnection = beginContext(async (clientId, swarmName, methodName = METHOD_NAME$o) => {
17485
+ const disposeConnection = beginContext(async (clientId, swarmName, methodName = METHOD_NAME$l) => {
17326
17486
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
17327
17487
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17328
- swarm$1.loggerService.log(METHOD_NAME$o, {
17488
+ swarm$1.loggerService.log(METHOD_NAME$l, {
17329
17489
  clientId,
17330
17490
  swarmName,
17331
17491
  });
@@ -17412,7 +17572,7 @@ const disposeConnection = beginContext(async (clientId, swarmName, methodName =
17412
17572
  PersistMemoryAdapter.dispose(clientId);
17413
17573
  });
17414
17574
 
17415
- const METHOD_NAME$n = "function.target.makeAutoDispose";
17575
+ const METHOD_NAME$k = "function.target.makeAutoDispose";
17416
17576
  /**
17417
17577
  * Default timeout in seconds before auto-dispose is triggered.
17418
17578
  * @constant {number}
@@ -17443,7 +17603,7 @@ const DEFAULT_TIMEOUT = 15 * 60;
17443
17603
  const makeAutoDispose = beginContext((clientId, swarmName, { timeoutSeconds = DEFAULT_TIMEOUT, onDestroy, } = {}) => {
17444
17604
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
17445
17605
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17446
- swarm$1.loggerService.log(METHOD_NAME$n, {
17606
+ swarm$1.loggerService.log(METHOD_NAME$k, {
17447
17607
  clientId,
17448
17608
  swarmName,
17449
17609
  });
@@ -17476,125 +17636,7 @@ const makeAutoDispose = beginContext((clientId, swarmName, { timeoutSeconds = DE
17476
17636
  };
17477
17637
  });
17478
17638
 
17479
- const METHOD_NAME$m = "function.target.execute";
17480
- /**
17481
- * Sends a message to the active agent in a swarm session as if it originated from the client side.
17482
- *
17483
- * This function executes a command or message on behalf of the specified agent within a swarm session, designed for scenarios like reviewing tool output
17484
- * or initiating a model-to-client conversation. It validates the agent and session, checks if the specified agent is still active, and executes the content
17485
- * with performance tracking and event bus notifications. The execution is wrapped in `beginContext` for a clean environment and runs within an
17486
- * `ExecutionContextService` context for metadata tracking. If the active agent has changed, the operation is skipped.
17487
- *
17488
- * @param {string} content - The content or command to be executed by the agent.
17489
- * @param {string} clientId - The unique identifier of the client session requesting the execution.
17490
- * @param {AgentName} agentName - The name of the agent intended to execute the command.
17491
- * @returns {Promise<string>} A promise that resolves to the result of the execution, or an empty string if skipped due to an agent change.
17492
- * @throws {Error} If agent, session, or swarm validation fails, or if the execution process encounters an error.
17493
- * @example
17494
- * const result = await execute("Review this output", "client-123", "AgentX");
17495
- * console.log(result); // Outputs the agent's response or "" if skipped
17496
- */
17497
- const execute = beginContext(async (content, clientId, agentName) => {
17498
- const executionId = functoolsKit.randomString();
17499
- // Log the operation details if logging is enabled in GLOBAL_CONFIG
17500
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17501
- swarm$1.loggerService.log(METHOD_NAME$m, {
17502
- content,
17503
- clientId,
17504
- agentName,
17505
- executionId,
17506
- });
17507
- // Validate the agent, session, and swarm
17508
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$m);
17509
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$m);
17510
- const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
17511
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$m);
17512
- // Check if the specified agent is still the active agent
17513
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$m, clientId, swarmName);
17514
- if (currentAgentName !== agentName) {
17515
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17516
- swarm$1.loggerService.log('function "execute" skipped due to the agent change', {
17517
- currentAgentName,
17518
- agentName,
17519
- clientId,
17520
- });
17521
- return "";
17522
- }
17523
- // Execute the command within an execution context with performance tracking
17524
- return ExecutionContextService.runInContext(async () => {
17525
- let isFinished = false;
17526
- swarm$1.perfService.startExecution(executionId, clientId, content.length);
17527
- try {
17528
- swarm$1.busService.commitExecutionBegin(clientId, {
17529
- agentName,
17530
- swarmName,
17531
- });
17532
- const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$m, clientId, swarmName);
17533
- isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
17534
- swarm$1.busService.commitExecutionEnd(clientId, {
17535
- agentName,
17536
- swarmName,
17537
- });
17538
- return result;
17539
- }
17540
- finally {
17541
- if (!isFinished) {
17542
- swarm$1.perfService.endExecution(executionId, clientId, 0);
17543
- }
17544
- }
17545
- }, {
17546
- clientId,
17547
- executionId,
17548
- processId: GLOBAL_CONFIG.CC_PROCESS_UUID,
17549
- });
17550
- });
17551
-
17552
- const METHOD_NAME$l = "function.target.emit";
17553
- /**
17554
- * Emits a string as model output without executing an incoming message, with agent activity validation.
17555
- *
17556
- * This function directly emits a provided string as output from the swarm session, bypassing message execution, and is designed exclusively
17557
- * for sessions established via `makeConnection`. It validates the session, swarm, and specified agent, ensuring the agent is still active
17558
- * before emitting. If the active agent has changed, the operation is skipped. The execution is wrapped in `beginContext` for a clean environment,
17559
- * logs the operation if enabled, and throws an error if the session mode is not "makeConnection".
17560
- *
17561
- * @param {string} content - The content to be emitted as the model output.
17562
- * @param {string} clientId - The unique identifier of the client session emitting the content.
17563
- * @param {AgentName} agentName - The name of the agent intended to emit the content.
17564
- * @returns {Promise<void>} A promise that resolves when the content is emitted, or resolves early if skipped due to an agent change.
17565
- * @throws {Error} If the session mode is not "makeConnection", or if agent, session, or swarm validation fails.
17566
- * @example
17567
- * await emit("Direct output", "client-123", "AgentX"); // Emits "Direct output" if AgentX is active
17568
- */
17569
- const emit = beginContext(async (content, clientId, agentName) => {
17570
- // Log the operation details if logging is enabled in GLOBAL_CONFIG
17571
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17572
- swarm$1.loggerService.log(METHOD_NAME$l, {
17573
- content,
17574
- clientId,
17575
- agentName,
17576
- });
17577
- // Validate the agent, session, and swarm
17578
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$l);
17579
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$l);
17580
- const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
17581
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$l);
17582
- // Check if the specified agent is still the active agent
17583
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$l, clientId, swarmName);
17584
- if (currentAgentName !== agentName) {
17585
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17586
- swarm$1.loggerService.log('function "emit" skipped due to the agent change', {
17587
- currentAgentName,
17588
- agentName,
17589
- clientId,
17590
- });
17591
- return;
17592
- }
17593
- // Emit the content directly via the session public service
17594
- return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$l, clientId, swarmName);
17595
- });
17596
-
17597
- const METHOD_NAME$k = "function.target.notify";
17639
+ const METHOD_NAME$j = "function.target.notify";
17598
17640
  /**
17599
17641
  * Sends a notification message as output from the swarm session without executing an incoming message.
17600
17642
  *
@@ -17614,23 +17656,23 @@ const METHOD_NAME$k = "function.target.notify";
17614
17656
  const notify = beginContext(async (content, clientId, agentName) => {
17615
17657
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
17616
17658
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17617
- swarm$1.loggerService.log(METHOD_NAME$k, {
17659
+ swarm$1.loggerService.log(METHOD_NAME$j, {
17618
17660
  content,
17619
17661
  clientId,
17620
17662
  agentName,
17621
17663
  });
17622
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$k);
17664
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$j);
17623
17665
  // Check if the session mode is "makeConnection"
17624
17666
  if (swarm$1.sessionValidationService.getSessionMode(clientId) !==
17625
17667
  "makeConnection") {
17626
17668
  throw new Error(`agent-swarm-kit notify session is not makeConnection clientId=${clientId}`);
17627
17669
  }
17628
17670
  // Validate the agent, session, and swarm
17629
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$k);
17671
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$j);
17630
17672
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
17631
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$k);
17673
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$j);
17632
17674
  // Check if the specified agent is still the active agent
17633
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$k, clientId, swarmName);
17675
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$j, clientId, swarmName);
17634
17676
  if (currentAgentName !== agentName) {
17635
17677
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17636
17678
  swarm$1.loggerService.log('function "notify" skipped due to the agent change', {
@@ -17641,10 +17683,10 @@ const notify = beginContext(async (content, clientId, agentName) => {
17641
17683
  return;
17642
17684
  }
17643
17685
  // Notify the content directly via the session public service
17644
- return await swarm$1.sessionPublicService.notify(content, METHOD_NAME$k, clientId, swarmName);
17686
+ return await swarm$1.sessionPublicService.notify(content, METHOD_NAME$j, clientId, swarmName);
17645
17687
  });
17646
17688
 
17647
- const METHOD_NAME$j = "function.target.notifyForce";
17689
+ const METHOD_NAME$i = "function.target.notifyForce";
17648
17690
  /**
17649
17691
  * Sends a notification message as output from the swarm session without executing an incoming message.
17650
17692
  *
@@ -17663,11 +17705,11 @@ const METHOD_NAME$j = "function.target.notifyForce";
17663
17705
  const notifyForce = beginContext(async (content, clientId) => {
17664
17706
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
17665
17707
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17666
- swarm$1.loggerService.log(METHOD_NAME$j, {
17708
+ swarm$1.loggerService.log(METHOD_NAME$i, {
17667
17709
  content,
17668
17710
  clientId,
17669
17711
  });
17670
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$j);
17712
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$i);
17671
17713
  // Check if the session mode is "makeConnection"
17672
17714
  if (swarm$1.sessionValidationService.getSessionMode(clientId) !==
17673
17715
  "makeConnection") {
@@ -17675,12 +17717,12 @@ const notifyForce = beginContext(async (content, clientId) => {
17675
17717
  }
17676
17718
  // Validate the agent, session, and swarm
17677
17719
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
17678
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$j);
17720
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$i);
17679
17721
  // Notify the content directly via the session public service
17680
- return await swarm$1.sessionPublicService.notify(content, METHOD_NAME$j, clientId, swarmName);
17722
+ return await swarm$1.sessionPublicService.notify(content, METHOD_NAME$i, clientId, swarmName);
17681
17723
  });
17682
17724
 
17683
- const METHOD_NAME$i = "function.target.runStateless";
17725
+ const METHOD_NAME$h = "function.target.runStateless";
17684
17726
  /**
17685
17727
  * Executes a message statelessly with an agent in a swarm session, bypassing chat history.
17686
17728
  *
@@ -17703,19 +17745,19 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
17703
17745
  const executionId = functoolsKit.randomString();
17704
17746
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
17705
17747
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17706
- swarm$1.loggerService.log(METHOD_NAME$i, {
17748
+ swarm$1.loggerService.log(METHOD_NAME$h, {
17707
17749
  content,
17708
17750
  clientId,
17709
17751
  agentName,
17710
17752
  executionId,
17711
17753
  });
17712
17754
  // Validate the agent, session, and swarm
17713
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$i);
17714
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$i);
17755
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$h);
17756
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$h);
17715
17757
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
17716
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$i);
17758
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$h);
17717
17759
  // Check if the specified agent is still the active agent
17718
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$i, clientId, swarmName);
17760
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$h, clientId, swarmName);
17719
17761
  if (currentAgentName !== agentName) {
17720
17762
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17721
17763
  swarm$1.loggerService.log('function "runStateless" skipped due to the agent change', {
@@ -17734,7 +17776,7 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
17734
17776
  agentName,
17735
17777
  swarmName,
17736
17778
  });
17737
- const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$i, clientId, swarmName);
17779
+ const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$h, clientId, swarmName);
17738
17780
  isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
17739
17781
  swarm$1.busService.commitExecutionEnd(clientId, {
17740
17782
  agentName,
@@ -17754,7 +17796,7 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
17754
17796
  });
17755
17797
  });
17756
17798
 
17757
- const METHOD_NAME$h = "function.target.runStatelessForce";
17799
+ const METHOD_NAME$g = "function.target.runStatelessForce";
17758
17800
  /**
17759
17801
  * Executes a message statelessly with the active agent in a swarm session, bypassing chat history and forcing execution regardless of agent activity.
17760
17802
  *
@@ -17775,22 +17817,22 @@ const runStatelessForce = beginContext(async (content, clientId) => {
17775
17817
  const executionId = functoolsKit.randomString();
17776
17818
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
17777
17819
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17778
- swarm$1.loggerService.log(METHOD_NAME$h, {
17820
+ swarm$1.loggerService.log(METHOD_NAME$g, {
17779
17821
  content,
17780
17822
  clientId,
17781
17823
  executionId,
17782
17824
  });
17783
17825
  // Validate the session and swarm
17784
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$h);
17826
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$g);
17785
17827
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
17786
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$h);
17828
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$g);
17787
17829
  // Execute the command statelessly within an execution context with performance tracking
17788
17830
  return ExecutionContextService.runInContext(async () => {
17789
17831
  let isFinished = false;
17790
17832
  swarm$1.perfService.startExecution(executionId, clientId, content.length);
17791
17833
  try {
17792
17834
  swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
17793
- const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$h, clientId, swarmName);
17835
+ const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$g, clientId, swarmName);
17794
17836
  isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
17795
17837
  swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
17796
17838
  return result;
@@ -17817,7 +17859,7 @@ const SCHEDULED_DELAY$1 = 1000;
17817
17859
  * @constant {number}
17818
17860
  */
17819
17861
  const RATE_DELAY = 10000;
17820
- const METHOD_NAME$g = "function.target.makeConnection";
17862
+ const METHOD_NAME$f = "function.target.makeConnection";
17821
17863
  /**
17822
17864
  * Internal implementation of the connection factory for a client to a swarm.
17823
17865
  *
@@ -17832,21 +17874,21 @@ const METHOD_NAME$g = "function.target.makeConnection";
17832
17874
  const makeConnectionInternal = (connector, clientId, swarmName) => {
17833
17875
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
17834
17876
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17835
- swarm$1.loggerService.log(METHOD_NAME$g, {
17877
+ swarm$1.loggerService.log(METHOD_NAME$f, {
17836
17878
  clientId,
17837
17879
  swarmName,
17838
17880
  });
17839
17881
  // Validate the swarm and initialize the session
17840
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$g);
17882
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$f);
17841
17883
  swarm$1.sessionValidationService.addSession(clientId, swarmName, "makeConnection");
17842
17884
  // Create a queued send function using the session public service
17843
- const send = functoolsKit.queued(swarm$1.sessionPublicService.connect(connector, METHOD_NAME$g, clientId, swarmName));
17885
+ const send = functoolsKit.queued(swarm$1.sessionPublicService.connect(connector, METHOD_NAME$f, clientId, swarmName));
17844
17886
  // Return a wrapped send function with validation and agent context
17845
17887
  return (async (outgoing) => {
17846
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$g);
17888
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$f);
17847
17889
  return await send({
17848
17890
  data: outgoing,
17849
- agentName: await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$g, clientId, swarmName),
17891
+ agentName: await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$f, clientId, swarmName),
17850
17892
  clientId,
17851
17893
  });
17852
17894
  });
@@ -17929,13 +17971,13 @@ makeConnection.scheduled = (connector, clientId, swarmName, { delay = SCHEDULED_
17929
17971
  await online();
17930
17972
  if (payload) {
17931
17973
  return await PayloadContextService.runInContext(async () => {
17932
- await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$g, clientId, swarmName);
17974
+ await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$f, clientId, swarmName);
17933
17975
  }, {
17934
17976
  clientId,
17935
17977
  payload,
17936
17978
  });
17937
17979
  }
17938
- await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$g, clientId, swarmName);
17980
+ await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$f, clientId, swarmName);
17939
17981
  }),
17940
17982
  delay,
17941
17983
  });
@@ -17998,7 +18040,7 @@ makeConnection.rate = (connector, clientId, swarmName, { delay = RATE_DELAY } =
17998
18040
  };
17999
18041
  };
18000
18042
 
18001
- const METHOD_NAME$f = "function.target.complete";
18043
+ const METHOD_NAME$e = "function.target.complete";
18002
18044
  /**
18003
18045
  * Time-to-live for the complete function in milliseconds.
18004
18046
  * Defines how long the cached complete function remains valid before expiring.
@@ -18064,7 +18106,7 @@ const complete = beginContext(async (content, clientId, swarmName, payload = nul
18064
18106
  const executionId = functoolsKit.randomString();
18065
18107
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
18066
18108
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18067
- swarm$1.loggerService.log(METHOD_NAME$f, {
18109
+ swarm$1.loggerService.log(METHOD_NAME$e, {
18068
18110
  content,
18069
18111
  clientId,
18070
18112
  executionId,
@@ -18082,7 +18124,7 @@ const complete = beginContext(async (content, clientId, swarmName, payload = nul
18082
18124
  swarm$1.navigationValidationService.beginMonit(clientId, swarmName);
18083
18125
  try {
18084
18126
  swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
18085
- const result = await run(METHOD_NAME$f, content);
18127
+ const result = await run(METHOD_NAME$e, content);
18086
18128
  isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
18087
18129
  swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
18088
18130
  return result;
@@ -18112,7 +18154,7 @@ const complete = beginContext(async (content, clientId, swarmName, payload = nul
18112
18154
  * @constant {number}
18113
18155
  */
18114
18156
  const SCHEDULED_DELAY = 1000;
18115
- const METHOD_NAME$e = "function.target.session";
18157
+ const METHOD_NAME$d = "function.target.session";
18116
18158
  /**
18117
18159
  * Internal implementation of the session factory for a client and swarm.
18118
18160
  *
@@ -18127,23 +18169,23 @@ const sessionInternal = (clientId, swarmName, { onDispose = () => { } } = {}) =>
18127
18169
  const executionId = functoolsKit.randomString();
18128
18170
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
18129
18171
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18130
- swarm$1.loggerService.log(METHOD_NAME$e, {
18172
+ swarm$1.loggerService.log(METHOD_NAME$d, {
18131
18173
  clientId,
18132
18174
  swarmName,
18133
18175
  executionId,
18134
18176
  });
18135
18177
  // Validate the swarm and initialize the session
18136
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$e);
18178
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$d);
18137
18179
  swarm$1.sessionValidationService.addSession(clientId, swarmName, "session");
18138
18180
  const complete = functoolsKit.queued(async (content) => {
18139
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$e);
18181
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$d);
18140
18182
  return ExecutionContextService.runInContext(async () => {
18141
18183
  let isFinished = false;
18142
18184
  swarm$1.perfService.startExecution(executionId, clientId, content.length);
18143
18185
  swarm$1.navigationValidationService.beginMonit(clientId, swarmName);
18144
18186
  try {
18145
18187
  swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
18146
- const result = await swarm$1.sessionPublicService.execute(content, "user", METHOD_NAME$e, clientId, swarmName);
18188
+ const result = await swarm$1.sessionPublicService.execute(content, "user", METHOD_NAME$d, clientId, swarmName);
18147
18189
  isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
18148
18190
  swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
18149
18191
  return result;
@@ -18164,7 +18206,7 @@ const sessionInternal = (clientId, swarmName, { onDispose = () => { } } = {}) =>
18164
18206
  return await complete(content);
18165
18207
  }),
18166
18208
  dispose: async () => {
18167
- await disposeConnection(clientId, swarmName, METHOD_NAME$e);
18209
+ await disposeConnection(clientId, swarmName, METHOD_NAME$d);
18168
18210
  await onDispose();
18169
18211
  },
18170
18212
  };
@@ -18264,13 +18306,13 @@ session.scheduled = (clientId, swarmName, { delay = SCHEDULED_DELAY, onDispose }
18264
18306
  await online();
18265
18307
  if (payload) {
18266
18308
  return await PayloadContextService.runInContext(async () => {
18267
- return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$e, clientId, swarmName);
18309
+ return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$d, clientId, swarmName);
18268
18310
  }, {
18269
18311
  clientId,
18270
18312
  payload,
18271
18313
  });
18272
18314
  }
18273
- return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$e, clientId, swarmName);
18315
+ return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$d, clientId, swarmName);
18274
18316
  }),
18275
18317
  delay,
18276
18318
  });
@@ -18350,7 +18392,7 @@ session.rate = (clientId, swarmName, { delay = SCHEDULED_DELAY, onDispose } = {}
18350
18392
  };
18351
18393
 
18352
18394
  /** @private Constant defining the method name for logging purposes */
18353
- const METHOD_NAME$d = "function.common.hasSession";
18395
+ const METHOD_NAME$c = "function.common.hasSession";
18354
18396
  /**
18355
18397
  * Checks if a session exists for the given client ID.
18356
18398
  *
@@ -18362,39 +18404,10 @@ const METHOD_NAME$d = "function.common.hasSession";
18362
18404
  */
18363
18405
  const hasSession = (clientId) => {
18364
18406
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18365
- swarm$1.loggerService.log(METHOD_NAME$d, { clientId });
18407
+ swarm$1.loggerService.log(METHOD_NAME$c, { clientId });
18366
18408
  return swarm$1.sessionValidationService.hasSession(clientId);
18367
18409
  };
18368
18410
 
18369
- const METHOD_NAME$c = "function.common.getAgentName";
18370
- /**
18371
- * Retrieves the name of the active agent for a given client session in a swarm.
18372
- *
18373
- * This function fetches the name of the currently active agent associated with the specified client session within a swarm.
18374
- * It validates the client session and swarm, logs the operation if enabled, and delegates the retrieval to the swarm public service.
18375
- * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
18376
- *
18377
- * @param {string} clientId - The unique identifier of the client session whose active agent name is being retrieved.
18378
- * @returns {Promise<string>} A promise that resolves to the name of the active agent (`AgentName`) associated with the client session.
18379
- * @throws {Error} If the client session is invalid, the swarm validation fails, or the swarm public service encounters an error during retrieval.
18380
- * @example
18381
- * const agentName = await getAgentName("client-123");
18382
- * console.log(agentName); // Outputs "AgentX"
18383
- */
18384
- const getAgentName = beginContext(async (clientId) => {
18385
- // Log the operation details if logging is enabled in GLOBAL_CONFIG
18386
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18387
- swarm$1.loggerService.log(METHOD_NAME$c, {
18388
- clientId,
18389
- });
18390
- // Validate the session and swarm to ensure they exist and are accessible
18391
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$c);
18392
- const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
18393
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$c);
18394
- // Retrieve the active agent name via the swarm public service
18395
- return await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$c, clientId, swarmName);
18396
- });
18397
-
18398
18411
  const METHOD_NAME$b = "function.common.getAgentHistory";
18399
18412
  /**
18400
18413
  * Retrieves the history prepared for a specific agent, incorporating rescue algorithm tweaks.