agent-swarm-kit 1.1.13 → 1.1.15

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