agent-swarm-kit 1.1.46 → 1.1.48

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.
Files changed (4) hide show
  1. package/build/index.cjs +1249 -802
  2. package/build/index.mjs +1249 -802
  3. package/package.json +1 -1
  4. package/types.d.ts +120 -104
package/build/index.cjs CHANGED
@@ -4835,22 +4835,9 @@ class ClientOperator {
4835
4835
 
4836
4836
  const METHOD_NAME$1n = "function.commit.commitToolOutput";
4837
4837
  /**
4838
- * Commits the output of a tool execution to the active agent in a swarm session.
4839
- *
4840
- * This function ensures that the tool output is committed only if the specified agent is still the active agent in the swarm session.
4841
- * 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.
4842
- * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
4843
- *
4844
- * @param {string} toolId - The unique identifier of the tool whose output is being committed.
4845
- * @param {string} content - The content or result of the tool execution to be committed.
4846
- * @param {string} clientId - The unique identifier of the client session associated with the operation.
4847
- * @param {AgentName} agentName - The name of the agent committing the tool output.
4848
- * @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.
4849
- * @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.
4850
- * @example
4851
- * await commitToolOutput("tool-123", "Tool execution result", "client-456", "AgentX");
4838
+ * Function implementation
4852
4839
  */
4853
- const commitToolOutput = beginContext(async (toolId, content, clientId, agentName) => {
4840
+ const commitToolOutputInternal = beginContext(async (toolId, content, clientId, agentName) => {
4854
4841
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
4855
4842
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
4856
4843
  swarm$1.loggerService.log(METHOD_NAME$1n, {
@@ -4880,26 +4867,31 @@ const commitToolOutput = beginContext(async (toolId, content, clientId, agentNam
4880
4867
  // Commit the tool output to the session via the session public service
4881
4868
  await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$1n, clientId, swarmName);
4882
4869
  });
4883
-
4884
- const METHOD_NAME$1m = "function.target.execute";
4885
4870
  /**
4886
- * Sends a message to the active agent in a swarm session as if it originated from the client side.
4871
+ * Commits the output of a tool execution to the active agent in a swarm session.
4887
4872
  *
4888
- * This function executes a command or message on behalf of the specified agent within a swarm session, designed for scenarios like reviewing tool output
4889
- * 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
4890
- * with performance tracking and event bus notifications. The execution is wrapped in `beginContext` for a clean environment and runs within an
4891
- * `ExecutionContextService` context for metadata tracking. If the active agent has changed, the operation is skipped.
4873
+ * This function ensures that the tool output is committed only if the specified agent is still the active agent in the swarm session.
4874
+ * 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.
4875
+ * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
4892
4876
  *
4893
- * @param {string} content - The content or command to be executed by the agent.
4894
- * @param {string} clientId - The unique identifier of the client session requesting the execution.
4895
- * @param {AgentName} agentName - The name of the agent intended to execute the command.
4896
- * @returns {Promise<string>} A promise that resolves to the result of the execution, or an empty string if skipped due to an agent change.
4897
- * @throws {Error} If agent, session, or swarm validation fails, or if the execution process encounters an error.
4877
+ * @param {string} toolId - The unique identifier of the tool whose output is being committed.
4878
+ * @param {string} content - The content or result of the tool execution to be committed.
4879
+ * @param {string} clientId - The unique identifier of the client session associated with the operation.
4880
+ * @param {AgentName} agentName - The name of the agent committing the tool output.
4881
+ * @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.
4882
+ * @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.
4898
4883
  * @example
4899
- * const result = await execute("Review this output", "client-123", "AgentX");
4900
- * console.log(result); // Outputs the agent's response or "" if skipped
4884
+ * await commitToolOutput("tool-123", "Tool execution result", "client-456", "AgentX");
4885
+ */
4886
+ function commitToolOutput(toolId, content, clientId, agentName) {
4887
+ return commitToolOutputInternal(toolId, content, clientId, agentName);
4888
+ }
4889
+
4890
+ const METHOD_NAME$1m = "function.target.execute";
4891
+ /**
4892
+ * Function implementation
4901
4893
  */
4902
- const execute = beginContext(async (content, clientId, agentName) => {
4894
+ const executeInternal = beginContext(async (content, clientId, agentName) => {
4903
4895
  const executionId = functoolsKit.randomString();
4904
4896
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
4905
4897
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
@@ -4953,23 +4945,33 @@ const execute = beginContext(async (content, clientId, agentName) => {
4953
4945
  processId: GLOBAL_CONFIG.CC_PROCESS_UUID,
4954
4946
  });
4955
4947
  });
4948
+ /**
4949
+ * Sends a message to the active agent in a swarm session as if it originated from the client side.
4950
+ *
4951
+ * This function executes a command or message on behalf of the specified agent within a swarm session, designed for scenarios like reviewing tool output
4952
+ * 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
4953
+ * with performance tracking and event bus notifications. The execution is wrapped in `beginContext` for a clean environment and runs within an
4954
+ * `ExecutionContextService` context for metadata tracking. If the active agent has changed, the operation is skipped.
4955
+ *
4956
+ * @param {string} content - The content or command to be executed by the agent.
4957
+ * @param {string} clientId - The unique identifier of the client session requesting the execution.
4958
+ * @param {AgentName} agentName - The name of the agent intended to execute the command.
4959
+ * @returns {Promise<string>} A promise that resolves to the result of the execution, or an empty string if skipped due to an agent change.
4960
+ * @throws {Error} If agent, session, or swarm validation fails, or if the execution process encounters an error.
4961
+ * @example
4962
+ * const result = await execute("Review this output", "client-123", "AgentX");
4963
+ * console.log(result); // Outputs the agent's response or "" if skipped
4964
+ */
4965
+ function execute(content, clientId, agentName) {
4966
+ return executeInternal(content, clientId, agentName);
4967
+ }
4956
4968
 
4957
4969
  /** @private Constant defining the method name for logging and validation context */
4958
4970
  const METHOD_NAME$1l = "function.commit.commitFlush";
4959
4971
  /**
4960
- * Commits a flush of agent history for a specific client and agent in the swarm system.
4961
- * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before flushing the history.
4962
- * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
4963
- * Integrates with AgentValidationService (agent validation), SessionValidationService (session and swarm retrieval),
4964
- * SwarmValidationService (swarm validation), SwarmPublicService (agent retrieval), SessionPublicService (history flush),
4965
- * and LoggerService (logging). Complements functions like commitAssistantMessage by clearing agent history rather than adding messages.
4966
- *
4967
- * @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
4968
- * @param {string} agentName - The name of the agent whose history is to be flushed, validated against registered agents.
4969
- * @returns {Promise<void>} A promise that resolves when the history flush is committed or skipped (e.g., agent mismatch).
4970
- * @throws {Error} If agent, session, or swarm validation fails, propagated from respective validation services.
4972
+ * Function implementation
4971
4973
  */
4972
- const commitFlush = beginContext(async (clientId, agentName) => {
4974
+ const commitFlushInternal = beginContext(async (clientId, agentName) => {
4973
4975
  // Log the flush attempt if enabled
4974
4976
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
4975
4977
  swarm$1.loggerService.log(METHOD_NAME$1l, {
@@ -4997,25 +4999,28 @@ const commitFlush = beginContext(async (clientId, agentName) => {
4997
4999
  // Commit the flush of agent history via SessionPublicService
4998
5000
  await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$1l, clientId, swarmName);
4999
5001
  });
5002
+ /**
5003
+ * Commits a flush of agent history for a specific client and agent in the swarm system.
5004
+ * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before flushing the history.
5005
+ * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
5006
+ * Integrates with AgentValidationService (agent validation), SessionValidationService (session and swarm retrieval),
5007
+ * SwarmValidationService (swarm validation), SwarmPublicService (agent retrieval), SessionPublicService (history flush),
5008
+ * and LoggerService (logging). Complements functions like commitAssistantMessage by clearing agent history rather than adding messages.
5009
+ *
5010
+ * @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
5011
+ * @param {string} agentName - The name of the agent whose history is to be flushed, validated against registered agents.
5012
+ * @returns {Promise<void>} A promise that resolves when the history flush is committed or skipped (e.g., agent mismatch).
5013
+ * @throws {Error} If agent, session, or swarm validation fails, propagated from respective validation services.
5014
+ */
5015
+ function commitFlush(clientId, agentName) {
5016
+ return commitFlushInternal(clientId, agentName);
5017
+ }
5000
5018
 
5001
5019
  const METHOD_NAME$1k = "function.target.emit";
5002
5020
  /**
5003
- * Emits a string as model output without executing an incoming message, with agent activity validation.
5004
- *
5005
- * This function directly emits a provided string as output from the swarm session, bypassing message execution, and is designed exclusively
5006
- * for sessions established via `makeConnection`. It validates the session, swarm, and specified agent, ensuring the agent is still active
5007
- * before emitting. If the active agent has changed, the operation is skipped. The execution is wrapped in `beginContext` for a clean environment,
5008
- * logs the operation if enabled, and throws an error if the session mode is not "makeConnection".
5009
- *
5010
- * @param {string} content - The content to be emitted as the model output.
5011
- * @param {string} clientId - The unique identifier of the client session emitting the content.
5012
- * @param {AgentName} agentName - The name of the agent intended to emit the content.
5013
- * @returns {Promise<void>} A promise that resolves when the content is emitted, or resolves early if skipped due to an agent change.
5014
- * @throws {Error} If the session mode is not "makeConnection", or if agent, session, or swarm validation fails.
5015
- * @example
5016
- * await emit("Direct output", "client-123", "AgentX"); // Emits "Direct output" if AgentX is active
5021
+ * Function implementation
5017
5022
  */
5018
- const emit = beginContext(async (content, clientId, agentName) => {
5023
+ const emitInternal = beginContext(async (content, clientId, agentName) => {
5019
5024
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
5020
5025
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
5021
5026
  swarm$1.loggerService.log(METHOD_NAME$1k, {
@@ -5042,23 +5047,31 @@ const emit = beginContext(async (content, clientId, agentName) => {
5042
5047
  // Emit the content directly via the session public service
5043
5048
  return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$1k, clientId, swarmName);
5044
5049
  });
5045
-
5046
- const METHOD_NAME$1j = "function.common.getAgentName";
5047
5050
  /**
5048
- * Retrieves the name of the active agent for a given client session in a swarm.
5051
+ * Emits a string as model output without executing an incoming message, with agent activity validation.
5049
5052
  *
5050
- * This function fetches the name of the currently active agent associated with the specified client session within a swarm.
5051
- * It validates the client session and swarm, logs the operation if enabled, and delegates the retrieval to the swarm public service.
5052
- * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
5053
+ * This function directly emits a provided string as output from the swarm session, bypassing message execution, and is designed exclusively
5054
+ * for sessions established via `makeConnection`. It validates the session, swarm, and specified agent, ensuring the agent is still active
5055
+ * before emitting. If the active agent has changed, the operation is skipped. The execution is wrapped in `beginContext` for a clean environment,
5056
+ * logs the operation if enabled, and throws an error if the session mode is not "makeConnection".
5053
5057
  *
5054
- * @param {string} clientId - The unique identifier of the client session whose active agent name is being retrieved.
5055
- * @returns {Promise<string>} A promise that resolves to the name of the active agent (`AgentName`) associated with the client session.
5056
- * @throws {Error} If the client session is invalid, the swarm validation fails, or the swarm public service encounters an error during retrieval.
5058
+ * @param {string} content - The content to be emitted as the model output.
5059
+ * @param {string} clientId - The unique identifier of the client session emitting the content.
5060
+ * @param {AgentName} agentName - The name of the agent intended to emit the content.
5061
+ * @returns {Promise<void>} A promise that resolves when the content is emitted, or resolves early if skipped due to an agent change.
5062
+ * @throws {Error} If the session mode is not "makeConnection", or if agent, session, or swarm validation fails.
5057
5063
  * @example
5058
- * const agentName = await getAgentName("client-123");
5059
- * console.log(agentName); // Outputs "AgentX"
5064
+ * await emit("Direct output", "client-123", "AgentX"); // Emits "Direct output" if AgentX is active
5065
+ */
5066
+ function emit(content, clientId, agentName) {
5067
+ return emitInternal(content, clientId, agentName);
5068
+ }
5069
+
5070
+ const METHOD_NAME$1j = "function.common.getAgentName";
5071
+ /**
5072
+ * Function implementation
5060
5073
  */
5061
- const getAgentName = beginContext(async (clientId) => {
5074
+ const getAgentNameInternal = beginContext(async (clientId) => {
5062
5075
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
5063
5076
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
5064
5077
  swarm$1.loggerService.log(METHOD_NAME$1j, {
@@ -5071,23 +5084,30 @@ const getAgentName = beginContext(async (clientId) => {
5071
5084
  // Retrieve the active agent name via the swarm public service
5072
5085
  return await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$1j, clientId, swarmName);
5073
5086
  });
5087
+ /**
5088
+ * Retrieves the name of the active agent for a given client session in a swarm.
5089
+ *
5090
+ * This function fetches the name of the currently active agent associated with the specified client session within a swarm.
5091
+ * It validates the client session and swarm, logs the operation if enabled, and delegates the retrieval to the swarm public service.
5092
+ * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
5093
+ *
5094
+ * @param {string} clientId - The unique identifier of the client session whose active agent name is being retrieved.
5095
+ * @returns {Promise<string>} A promise that resolves to the name of the active agent (`AgentName`) associated with the client session.
5096
+ * @throws {Error} If the client session is invalid, the swarm validation fails, or the swarm public service encounters an error during retrieval.
5097
+ * @example
5098
+ * const agentName = await getAgentName("client-123");
5099
+ * console.log(agentName); // Outputs "AgentX"
5100
+ */
5101
+ function getAgentName(clientId) {
5102
+ return getAgentNameInternal(clientId);
5103
+ }
5074
5104
 
5075
5105
  /** @private Constant defining the method name for logging and validation context */
5076
5106
  const METHOD_NAME$1i = "function.commit.commitStopTools";
5077
5107
  /**
5078
- * Prevents the next tool from being executed for a specific client and agent in the swarm system.
5079
- * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before stopping tool execution.
5080
- * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
5081
- * Integrates with AgentValidationService (agent validation), SessionValidationService (session and swarm retrieval),
5082
- * SwarmValidationService (swarm validation), SwarmPublicService (agent retrieval), SessionPublicService (tool execution stop),
5083
- * ToolValidationService (tool context), and LoggerService (logging). Complements functions like commitFlush by controlling tool flow rather than clearing history.
5084
- *
5085
- * @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
5086
- * @param {string} agentName - The name of the agent whose next tool execution is to be stopped, validated against registered agents.
5087
- * @returns {Promise<void>} A promise that resolves when the tool stop is committed or skipped (e.g., agent mismatch).
5088
- * @throws {Error} If agent, session, or swarm validation fails, propagated from respective validation services.
5108
+ * Function implementation
5089
5109
  */
5090
- const commitStopTools = beginContext(async (clientId, agentName) => {
5110
+ const commitStopToolsInternal = beginContext(async (clientId, agentName) => {
5091
5111
  // Log the stop tools attempt if enabled
5092
5112
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
5093
5113
  swarm$1.loggerService.log(METHOD_NAME$1i, {
@@ -5115,6 +5135,22 @@ const commitStopTools = beginContext(async (clientId, agentName) => {
5115
5135
  // Commit the stop of the next tool execution via SessionPublicService
5116
5136
  await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$1i, clientId, swarmName);
5117
5137
  });
5138
+ /**
5139
+ * Prevents the next tool from being executed for a specific client and agent in the swarm system.
5140
+ * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before stopping tool execution.
5141
+ * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
5142
+ * Integrates with AgentValidationService (agent validation), SessionValidationService (session and swarm retrieval),
5143
+ * SwarmValidationService (swarm validation), SwarmPublicService (agent retrieval), SessionPublicService (tool execution stop),
5144
+ * ToolValidationService (tool context), and LoggerService (logging). Complements functions like commitFlush by controlling tool flow rather than clearing history.
5145
+ *
5146
+ * @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
5147
+ * @param {string} agentName - The name of the agent whose next tool execution is to be stopped, validated against registered agents.
5148
+ * @returns {Promise<void>} A promise that resolves when the tool stop is committed or skipped (e.g., agent mismatch).
5149
+ * @throws {Error} If agent, session, or swarm validation fails, propagated from respective validation services.
5150
+ */
5151
+ function commitStopTools(clientId, agentName) {
5152
+ return commitStopToolsInternal(clientId, agentName);
5153
+ }
5118
5154
 
5119
5155
  const METHOD_NAME_UPDATE$2 = "McpUtils.update";
5120
5156
  /**
@@ -5642,15 +5678,9 @@ class AgentConnectionService {
5642
5678
  /** @private Constant defining the method name for logging purposes */
5643
5679
  const METHOD_NAME$1h = "function.common.getPayload";
5644
5680
  /**
5645
- * Retrieves the payload from the current PayloadContextService context.
5646
- * Returns null if no context is available. Logs the operation if logging is enabled.
5647
- * @template Payload - The type of the payload object, defaults to a generic object.
5648
- * @returns the payload data from the context, or null if no context exists.
5649
- * @example
5650
- * const payload = await getPayload<{ id: number }>();
5651
- * console.log(payload); // { id: number } or null
5681
+ * Function implementation
5652
5682
  */
5653
- const getPayload = () => {
5683
+ const getPayloadInternal = () => {
5654
5684
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$1h);
5655
5685
  if (PayloadContextService.hasContext()) {
5656
5686
  const { payload } = swarm$1.payloadContextService.context;
@@ -5658,6 +5688,18 @@ const getPayload = () => {
5658
5688
  }
5659
5689
  return null;
5660
5690
  };
5691
+ /**
5692
+ * Retrieves the payload from the current PayloadContextService context.
5693
+ * Returns null if no context is available. Logs the operation if logging is enabled.
5694
+ * @template Payload - The type of the payload object, defaults to a generic object.
5695
+ * @returns the payload data from the context, or null if no context exists.
5696
+ * @example
5697
+ * const payload = await getPayload<{ id: number }>();
5698
+ * console.log(payload); // { id: number } or null
5699
+ */
5700
+ function getPayload() {
5701
+ return getPayloadInternal();
5702
+ }
5661
5703
 
5662
5704
  /**
5663
5705
  * Class representing the history of client messages in the swarm system, implementing the IHistory interface.
@@ -17859,20 +17901,9 @@ dumpClientPerformance.runAfterExecute = beginContext(async (dirName = "./logs/cl
17859
17901
  /** @private Constant defining the method name for logging and validation context */
17860
17902
  const METHOD_NAME$1b = "function.commit.commitFlushForce";
17861
17903
  /**
17862
- * Forcefully commits a flush of agent history for a specific client in the swarm system, without checking the active agent.
17863
- * Validates the session and swarm, then proceeds with flushing the history regardless of the current agent state.
17864
- * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
17865
- * Integrates with SessionValidationService (session and swarm retrieval), SwarmValidationService (swarm validation),
17866
- * SessionPublicService (history flush), and LoggerService (logging).
17867
- * Unlike commitFlush, this function skips agent validation and active agent checks, providing a more aggressive flush mechanism,
17868
- * analogous to commitAssistantMessageForce vs. commitAssistantMessage.
17869
- *
17870
- * @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
17871
- * @param {string} agentName - The name of the agent (unused in this implementation, included for interface consistency with commitFlush).
17872
- * @returns {Promise<void>} A promise that resolves when the history flush is committed.
17873
- * @throws {Error} If session or swarm validation fails, propagated from respective validation services.
17904
+ * Function implementation
17874
17905
  */
17875
- const commitFlushForce = beginContext(async (clientId) => {
17906
+ const commitFlushForceInternal = beginContext(async (clientId) => {
17876
17907
  // Log the flush attempt if enabled
17877
17908
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17878
17909
  swarm$1.loggerService.log(METHOD_NAME$1b, {
@@ -17887,24 +17918,29 @@ const commitFlushForce = beginContext(async (clientId) => {
17887
17918
  // Commit the flush of agent history via SessionPublicService without agent checks
17888
17919
  await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$1b, clientId, swarmName);
17889
17920
  });
17921
+ /**
17922
+ * Forcefully commits a flush of agent history for a specific client in the swarm system, without checking the active agent.
17923
+ * Validates the session and swarm, then proceeds with flushing the history regardless of the current agent state.
17924
+ * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
17925
+ * Integrates with SessionValidationService (session and swarm retrieval), SwarmValidationService (swarm validation),
17926
+ * SessionPublicService (history flush), and LoggerService (logging).
17927
+ * Unlike commitFlush, this function skips agent validation and active agent checks, providing a more aggressive flush mechanism,
17928
+ * analogous to commitAssistantMessageForce vs. commitAssistantMessage.
17929
+ *
17930
+ * @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
17931
+ * @param {string} agentName - The name of the agent (unused in this implementation, included for interface consistency with commitFlush).
17932
+ * @returns {Promise<void>} A promise that resolves when the history flush is committed.
17933
+ * @throws {Error} If session or swarm validation fails, propagated from respective validation services.
17934
+ */
17935
+ function commitFlushForce(clientId) {
17936
+ return commitFlushForceInternal(clientId);
17937
+ }
17890
17938
 
17891
17939
  const METHOD_NAME$1a = "function.commit.commitToolOutputForce";
17892
17940
  /**
17893
- * Commits the output of a tool execution to the active agent in a swarm session without checking the active agent.
17894
- *
17895
- * This function forcefully commits the tool output to the session, bypassing the check for whether the agent is still active in the swarm session.
17896
- * It performs validation on the session and swarm, logs the operation if enabled, and delegates the commit operation to the session public service.
17897
- * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
17898
- *
17899
- * @param {string} toolId - The unique identifier of the tool whose output is being committed.
17900
- * @param {string} content - The content or result of the tool execution to be committed.
17901
- * @param {string} clientId - The unique identifier of the client session associated with the operation.
17902
- * @returns {Promise<void>} A promise that resolves when the tool output is successfully committed.
17903
- * @throws {Error} If validation fails (e.g., invalid session or swarm) or if the session public service encounters an error during the commit operation.
17904
- * @example
17905
- * await commitToolOutputForce("tool-123", "Tool execution result", "client-456");
17941
+ * Function implementation
17906
17942
  */
17907
- const commitToolOutputForce = beginContext(async (toolId, content, clientId) => {
17943
+ const commitToolOutputForceInternal = beginContext(async (toolId, content, clientId) => {
17908
17944
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
17909
17945
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17910
17946
  swarm$1.loggerService.log(METHOD_NAME$1a, {
@@ -17919,6 +17955,24 @@ const commitToolOutputForce = beginContext(async (toolId, content, clientId) =>
17919
17955
  // Commit the tool output to the session via the session public service without checking the active agent
17920
17956
  await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$1a, clientId, swarmName);
17921
17957
  });
17958
+ /**
17959
+ * Commits the output of a tool execution to the active agent in a swarm session without checking the active agent.
17960
+ *
17961
+ * This function forcefully commits the tool output to the session, bypassing the check for whether the agent is still active in the swarm session.
17962
+ * It performs validation on the session and swarm, logs the operation if enabled, and delegates the commit operation to the session public service.
17963
+ * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
17964
+ *
17965
+ * @param {string} toolId - The unique identifier of the tool whose output is being committed.
17966
+ * @param {string} content - The content or result of the tool execution to be committed.
17967
+ * @param {string} clientId - The unique identifier of the client session associated with the operation.
17968
+ * @returns {Promise<void>} A promise that resolves when the tool output is successfully committed.
17969
+ * @throws {Error} If validation fails (e.g., invalid session or swarm) or if the session public service encounters an error during the commit operation.
17970
+ * @example
17971
+ * await commitToolOutputForce("tool-123", "Tool execution result", "client-456");
17972
+ */
17973
+ function commitToolOutputForce(toolId, content, clientId) {
17974
+ return commitToolOutputForceInternal(toolId, content, clientId);
17975
+ }
17922
17976
 
17923
17977
  /**
17924
17978
  * @private Constant defining the method name for logging and validation purposes.
@@ -17926,14 +17980,9 @@ const commitToolOutputForce = beginContext(async (toolId, content, clientId) =>
17926
17980
  */
17927
17981
  const METHOD_NAME$19 = "function.common.hasNavigation";
17928
17982
  /**
17929
- * Checks if a specific agent is part of the navigation route for a given client.
17930
- * Validates the agent and client session, retrieves the associated swarm, and queries the navigation route.
17931
- * Logs the operation if enabled by global configuration.
17932
- * @param {string} clientId - The unique identifier of the client whose navigation route is being checked.
17933
- * @param {AgentName} agentName - The name of the agent to check within the navigation route.
17934
- * @returns {Promise<boolean>} A promise resolving to true if the agent is in the navigation route, false otherwise.
17983
+ * Function implementation
17935
17984
  */
17936
- const hasNavigation = async (clientId, agentName) => {
17985
+ const hasNavigationInternal = async (clientId, agentName) => {
17937
17986
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17938
17987
  swarm$1.loggerService.log(METHOD_NAME$19, { clientId });
17939
17988
  swarm$1.agentValidationService.validate(agentName, METHOD_NAME$19);
@@ -17943,8 +17992,37 @@ const hasNavigation = async (clientId, agentName) => {
17943
17992
  .getNavigationRoute(clientId, swarmName)
17944
17993
  .has(agentName);
17945
17994
  };
17995
+ /**
17996
+ * Checks if a specific agent is part of the navigation route for a given client.
17997
+ * Validates the agent and client session, retrieves the associated swarm, and queries the navigation route.
17998
+ * Logs the operation if enabled by global configuration.
17999
+ * @param {string} clientId - The unique identifier of the client whose navigation route is being checked.
18000
+ * @param {AgentName} agentName - The name of the agent to check within the navigation route.
18001
+ * @returns {Promise<boolean>} A promise resolving to true if the agent is in the navigation route, false otherwise.
18002
+ */
18003
+ function hasNavigation(clientId, agentName) {
18004
+ return hasNavigationInternal(clientId, agentName);
18005
+ }
17946
18006
 
17947
18007
  const METHOD_NAME$18 = "function.history.getRawHistory";
18008
+ /**
18009
+ * Function implementation
18010
+ */
18011
+ const getRawHistoryInternal = beginContext(async (clientId, methodName) => {
18012
+ // Log the operation details if logging is enabled in GLOBAL_CONFIG
18013
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18014
+ swarm$1.loggerService.log(METHOD_NAME$18, {
18015
+ clientId,
18016
+ });
18017
+ // Validate the session and swarm
18018
+ swarm$1.sessionValidationService.validate(clientId, methodName);
18019
+ const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
18020
+ swarm$1.swarmValidationService.validate(swarmName, methodName);
18021
+ // Get the current agent and fetch raw history
18022
+ const agentName = await swarm$1.swarmPublicService.getAgentName(methodName, clientId, swarmName);
18023
+ const history = await swarm$1.historyPublicService.toArrayForRaw(methodName, clientId, agentName);
18024
+ return [...history];
18025
+ });
17948
18026
  /**
17949
18027
  * Retrieves the raw, unmodified history for a given client session.
17950
18028
  *
@@ -17961,23 +18039,25 @@ const METHOD_NAME$18 = "function.history.getRawHistory";
17961
18039
  * const rawHistory = await getRawHistory("client-123");
17962
18040
  * console.log(rawHistory); // Outputs the full raw history array
17963
18041
  */
17964
- const getRawHistory = beginContext(async (clientId, methodName = METHOD_NAME$18) => {
18042
+ function getRawHistory(clientId) {
18043
+ return getRawHistoryInternal(clientId, METHOD_NAME$18);
18044
+ }
18045
+
18046
+ const METHOD_NAME$17 = "function.history.getLastUserMessage";
18047
+ /**
18048
+ * Function implementation
18049
+ */
18050
+ const getLastUserMessageInternal = beginContext(async (clientId) => {
17965
18051
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
17966
18052
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17967
- swarm$1.loggerService.log(METHOD_NAME$18, {
18053
+ swarm$1.loggerService.log(METHOD_NAME$17, {
17968
18054
  clientId,
17969
18055
  });
17970
- // Validate the session and swarm
17971
- swarm$1.sessionValidationService.validate(clientId, methodName);
17972
- const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
17973
- swarm$1.swarmValidationService.validate(swarmName, methodName);
17974
- // Get the current agent and fetch raw history
17975
- const agentName = await swarm$1.swarmPublicService.getAgentName(methodName, clientId, swarmName);
17976
- const history = await swarm$1.historyPublicService.toArrayForRaw(methodName, clientId, agentName);
17977
- return [...history];
18056
+ // Fetch raw history and find the last user message
18057
+ const history = await getRawHistoryInternal(clientId, METHOD_NAME$17);
18058
+ const last = history.findLast(({ role, mode }) => role === "user" && mode === "user");
18059
+ return last?.content ? last.content : null;
17978
18060
  });
17979
-
17980
- const METHOD_NAME$17 = "function.history.getLastUserMessage";
17981
18061
  /**
17982
18062
  * Retrieves the content of the most recent user message from a client's session history.
17983
18063
  *
@@ -17992,17 +18072,9 @@ const METHOD_NAME$17 = "function.history.getLastUserMessage";
17992
18072
  * const lastMessage = await getLastUserMessage("client-123");
17993
18073
  * console.log(lastMessage); // Outputs the last user message or null
17994
18074
  */
17995
- const getLastUserMessage = beginContext(async (clientId) => {
17996
- // Log the operation details if logging is enabled in GLOBAL_CONFIG
17997
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
17998
- swarm$1.loggerService.log(METHOD_NAME$17, {
17999
- clientId,
18000
- });
18001
- // Fetch raw history and find the last user message
18002
- const history = await getRawHistory(clientId, METHOD_NAME$17);
18003
- const last = history.findLast(({ role, mode }) => role === "user" && mode === "user");
18004
- return last?.content ? last.content : null;
18005
- });
18075
+ function getLastUserMessage(clientId) {
18076
+ return getLastUserMessageInternal(clientId);
18077
+ }
18006
18078
 
18007
18079
  const disposeSubject = new functoolsKit.Subject();
18008
18080
 
@@ -18052,19 +18124,9 @@ const createGc$3 = functoolsKit.singleshot(async () => {
18052
18124
  });
18053
18125
  });
18054
18126
  /**
18055
- * Navigates back to the default agent for a given client session in a swarm.
18056
- *
18057
- * This function switches the active agent to the default agent defined in the swarm schema for the specified client session.
18058
- * It validates the session and default agent, logs the operation if enabled, and executes the change using a TTL-limited, queued runner.
18059
- * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts.
18060
- *
18061
- * @param {string} clientId - The unique identifier of the client session.
18062
- * @returns {Promise<boolean>} A promise that resolves when the default agent change is complete. If navigation stack contains recursion being canceled
18063
- * @throws {Error} If session or agent validation fails, or if the agent change process encounters an error.
18064
- * @example
18065
- * await changeToDefaultAgent("client-123");
18127
+ * Function implementation
18066
18128
  */
18067
- const changeToDefaultAgent = beginContext(async (clientId) => {
18129
+ const changeToDefaultAgentInternal = beginContext(async (clientId) => {
18068
18130
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
18069
18131
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18070
18132
  swarm$1.loggerService.log(METHOD_NAME$16, {
@@ -18082,24 +18144,28 @@ const changeToDefaultAgent = beginContext(async (clientId) => {
18082
18144
  createGc$3();
18083
18145
  return await run(METHOD_NAME$16, agentName, swarmName);
18084
18146
  });
18085
-
18086
- const METHOD_NAME$15 = "function.target.emitForce";
18087
18147
  /**
18088
- * Emits a string as model output without executing an incoming message or checking the active agent.
18148
+ * Navigates back to the default agent for a given client session in a swarm.
18089
18149
  *
18090
- * This function directly emits a provided string as output from the swarm session, bypassing message execution and agent activity checks.
18091
- * It is designed exclusively for sessions established via `makeConnection`, ensuring compatibility with its connection model.
18092
- * The execution is wrapped in `beginContext` for a clean environment, validates the session and swarm, and throws an error if the session mode
18093
- * is not "makeConnection". The operation is logged if enabled, and resolves when the content is successfully emitted.
18150
+ * This function switches the active agent to the default agent defined in the swarm schema for the specified client session.
18151
+ * It validates the session and default agent, logs the operation if enabled, and executes the change using a TTL-limited, queued runner.
18152
+ * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts.
18094
18153
  *
18095
- * @param {string} content - The content to be emitted as the model output.
18096
- * @param {string} clientId - The unique identifier of the client session emitting the content.
18097
- * @returns {Promise<void>} A promise that resolves when the content is emitted.
18098
- * @throws {Error} If the session mode is not "makeConnection", or if session or swarm validation fails.
18154
+ * @param {string} clientId - The unique identifier of the client session.
18155
+ * @returns {Promise<boolean>} A promise that resolves when the default agent change is complete. If navigation stack contains recursion being canceled
18156
+ * @throws {Error} If session or agent validation fails, or if the agent change process encounters an error.
18099
18157
  * @example
18100
- * await emitForce("Direct output", "client-123"); // Emits "Direct output" in a makeConnection session
18158
+ * await changeToDefaultAgent("client-123");
18159
+ */
18160
+ function changeToDefaultAgent(clientId) {
18161
+ return changeToDefaultAgentInternal(clientId);
18162
+ }
18163
+
18164
+ const METHOD_NAME$15 = "function.target.emitForce";
18165
+ /**
18166
+ * Function implementation
18101
18167
  */
18102
- const emitForce = beginContext(async (content, clientId) => {
18168
+ const emitForceInternal = beginContext(async (content, clientId) => {
18103
18169
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
18104
18170
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18105
18171
  swarm$1.loggerService.log(METHOD_NAME$15, {
@@ -18113,25 +18179,30 @@ const emitForce = beginContext(async (content, clientId) => {
18113
18179
  // Emit the content directly via the session public service
18114
18180
  return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$15, clientId, swarmName);
18115
18181
  });
18116
-
18117
- const METHOD_NAME$14 = "function.target.executeForce";
18118
18182
  /**
18119
- * 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.
18183
+ * Emits a string as model output without executing an incoming message or checking the active agent.
18120
18184
  *
18121
- * This function executes a command or message on behalf of the active agent within a swarm session, designed for scenarios like reviewing tool output
18122
- * or initiating a model-to-client conversation. Unlike `execute`, it does not check if the agent is currently active, ensuring execution even if the
18123
- * agent has changed or is inactive. It validates the session and swarm, executes the content with performance tracking and event bus notifications,
18124
- * and is wrapped in `beginContext` for a clean environment and `ExecutionContextService` for metadata tracking.
18185
+ * This function directly emits a provided string as output from the swarm session, bypassing message execution and agent activity checks.
18186
+ * It is designed exclusively for sessions established via `makeConnection`, ensuring compatibility with its connection model.
18187
+ * The execution is wrapped in `beginContext` for a clean environment, validates the session and swarm, and throws an error if the session mode
18188
+ * is not "makeConnection". The operation is logged if enabled, and resolves when the content is successfully emitted.
18125
18189
  *
18126
- * @param {string} content - The content or command to be executed by the active agent.
18127
- * @param {string} clientId - The unique identifier of the client session requesting the execution.
18128
- * @returns {Promise<string>} A promise that resolves to the result of the execution.
18129
- * @throws {Error} If session or swarm validation fails, or if the execution process encounters an error.
18190
+ * @param {string} content - The content to be emitted as the model output.
18191
+ * @param {string} clientId - The unique identifier of the client session emitting the content.
18192
+ * @returns {Promise<void>} A promise that resolves when the content is emitted.
18193
+ * @throws {Error} If the session mode is not "makeConnection", or if session or swarm validation fails.
18130
18194
  * @example
18131
- * const result = await executeForce("Force this execution", "client-123");
18132
- * console.log(result); // Outputs the agent's response regardless of its active state
18195
+ * await emitForce("Direct output", "client-123"); // Emits "Direct output" in a makeConnection session
18196
+ */
18197
+ function emitForce(content, clientId) {
18198
+ return emitForceInternal(content, clientId);
18199
+ }
18200
+
18201
+ const METHOD_NAME$14 = "function.target.executeForce";
18202
+ /**
18203
+ * Function implementation
18133
18204
  */
18134
- const executeForce = beginContext(async (content, clientId) => {
18205
+ const executeForceInternal = beginContext(async (content, clientId) => {
18135
18206
  const executionId = functoolsKit.randomString();
18136
18207
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
18137
18208
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
@@ -18166,6 +18237,25 @@ const executeForce = beginContext(async (content, clientId) => {
18166
18237
  processId: GLOBAL_CONFIG.CC_PROCESS_UUID,
18167
18238
  });
18168
18239
  });
18240
+ /**
18241
+ * 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.
18242
+ *
18243
+ * This function executes a command or message on behalf of the active agent within a swarm session, designed for scenarios like reviewing tool output
18244
+ * or initiating a model-to-client conversation. Unlike `execute`, it does not check if the agent is currently active, ensuring execution even if the
18245
+ * agent has changed or is inactive. It validates the session and swarm, executes the content with performance tracking and event bus notifications,
18246
+ * and is wrapped in `beginContext` for a clean environment and `ExecutionContextService` for metadata tracking.
18247
+ *
18248
+ * @param {string} content - The content or command to be executed by the active agent.
18249
+ * @param {string} clientId - The unique identifier of the client session requesting the execution.
18250
+ * @returns {Promise<string>} A promise that resolves to the result of the execution.
18251
+ * @throws {Error} If session or swarm validation fails, or if the execution process encounters an error.
18252
+ * @example
18253
+ * const result = await executeForce("Force this execution", "client-123");
18254
+ * console.log(result); // Outputs the agent's response regardless of its active state
18255
+ */
18256
+ function executeForce(content, clientId) {
18257
+ return executeForceInternal(content, clientId);
18258
+ }
18169
18259
 
18170
18260
  const METHOD_NAME$13 = "function.template.navigateToTriageAgent";
18171
18261
  /**
@@ -18297,20 +18387,9 @@ const createGc$2 = functoolsKit.singleshot(async () => {
18297
18387
  });
18298
18388
  });
18299
18389
  /**
18300
- * Changes the active agent for a given client session in a swarm.
18301
- *
18302
- * This function facilitates switching the active agent in a swarm session, validating the session and agent dependencies,
18303
- * logging the operation if enabled, and executing the change using a TTL-limited, queued runner.
18304
- * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts.
18305
- *
18306
- * @param {AgentName} agentName - The name of the agent to switch to.
18307
- * @param {string} clientId - The unique identifier of the client session.
18308
- * @returns {Promise<boolean>} A promise that resolves when the agent change is complete. If it resolved false, the navigation is canceled due to recursion
18309
- * @throws {Error} If session or agent validation fails, or if the agent change process encounters an error.
18310
- * @example
18311
- * await changeToAgent("AgentX", "client-123");
18390
+ * Function implementation
18312
18391
  */
18313
- const changeToAgent = beginContext(async (agentName, clientId) => {
18392
+ const changeToAgentInternal = beginContext(async (agentName, clientId) => {
18314
18393
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
18315
18394
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18316
18395
  swarm$1.loggerService.log(METHOD_NAME$12, {
@@ -18342,6 +18421,23 @@ const changeToAgent = beginContext(async (agentName, clientId) => {
18342
18421
  createGc$2();
18343
18422
  return await run(METHOD_NAME$12, agentName, swarmName);
18344
18423
  });
18424
+ /**
18425
+ * Changes the active agent for a given client session in a swarm.
18426
+ *
18427
+ * This function facilitates switching the active agent in a swarm session, validating the session and agent dependencies,
18428
+ * logging the operation if enabled, and executing the change using a TTL-limited, queued runner.
18429
+ * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts.
18430
+ *
18431
+ * @param {AgentName} agentName - The name of the agent to switch to.
18432
+ * @param {string} clientId - The unique identifier of the client session.
18433
+ * @returns {Promise<boolean>} A promise that resolves when the agent change is complete. If it resolved false, the navigation is canceled due to recursion
18434
+ * @throws {Error} If session or agent validation fails, or if the agent change process encounters an error.
18435
+ * @example
18436
+ * await changeToAgent("AgentX", "client-123");
18437
+ */
18438
+ function changeToAgent(agentName, clientId) {
18439
+ return changeToAgentInternal(agentName, clientId);
18440
+ }
18345
18441
 
18346
18442
  const METHOD_NAME$11 = "function.template.navigateToAgent";
18347
18443
  /**
@@ -18443,6 +18539,21 @@ const createNavigateToAgent = ({ executeMessage = DEFAULT_EXECUTE_MESSAGE, emitM
18443
18539
  };
18444
18540
 
18445
18541
  const METHOD_NAME$10 = "function.setup.addTool";
18542
+ /**
18543
+ * Function implementation
18544
+ */
18545
+ const addToolInternal = beginContext((toolSchema) => {
18546
+ // Log the operation details if logging is enabled in GLOBAL_CONFIG
18547
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18548
+ swarm$1.loggerService.log(METHOD_NAME$10, {
18549
+ toolSchema,
18550
+ });
18551
+ // Register the tool in the validation and schema services
18552
+ swarm$1.toolValidationService.addTool(toolSchema.toolName, toolSchema);
18553
+ swarm$1.toolSchemaService.register(toolSchema.toolName, toolSchema);
18554
+ // Return the tool's name as confirmation of registration
18555
+ return toolSchema.toolName;
18556
+ });
18446
18557
  /**
18447
18558
  * Adds a new tool to the tool registry for use by agents in the swarm system.
18448
18559
  *
@@ -18461,18 +18572,9 @@ const METHOD_NAME$10 = "function.setup.addTool";
18461
18572
  * const toolName = addTool(toolSchema);
18462
18573
  * console.log(toolName); // Outputs "Calculator"
18463
18574
  */
18464
- const addTool = beginContext((toolSchema) => {
18465
- // Log the operation details if logging is enabled in GLOBAL_CONFIG
18466
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18467
- swarm$1.loggerService.log(METHOD_NAME$10, {
18468
- toolSchema,
18469
- });
18470
- // Register the tool in the validation and schema services
18471
- swarm$1.toolValidationService.addTool(toolSchema.toolName, toolSchema);
18472
- swarm$1.toolSchemaService.register(toolSchema.toolName, toolSchema);
18473
- // Return the tool's name as confirmation of registration
18474
- return toolSchema.toolName;
18475
- });
18575
+ function addTool(toolSchema) {
18576
+ return addToolInternal(toolSchema);
18577
+ }
18476
18578
 
18477
18579
  /**
18478
18580
  * Adds navigation functionality to an agent by creating a tool that allows navigation to a specified agent.
@@ -18481,17 +18583,9 @@ const addTool = beginContext((toolSchema) => {
18481
18583
  const METHOD_NAME$$ = "function.alias.addAgentNavigation";
18482
18584
  const DEFAULT_SKIP_PLACEHOLDER$1 = "Navigation canceled";
18483
18585
  /**
18484
- * Creates and registers a navigation tool for an agent to navigate to another specified agent.
18485
- * @function addAgentNavigation
18486
- * @param {IAgentNavigationParams} params - The parameters for configuring the navigation tool.
18487
- * @param {ToolName} params.toolName - The name of the tool.
18488
- * @param {string} params.description - Description of the tool's purpose.
18489
- * @param {AgentName} params.navigateTo - The target agent to navigate to.
18490
- * @param {string} [params.docNote] - Optional documentation note.
18491
- * @param {...INavigateToAgentParams} params.navigateProps - Additional navigation properties.
18492
- * @returns {ReturnType<typeof addTool>} The result of adding the navigation tool.
18586
+ * Function implementation
18493
18587
  */
18494
- const addAgentNavigation = beginContext(({ toolName, docNote, description, navigateTo, skipPlaceholder = DEFAULT_SKIP_PLACEHOLDER$1, ...navigateProps }) => {
18588
+ const addAgentNavigationInternal = beginContext(({ toolName, docNote, description, navigateTo, skipPlaceholder = DEFAULT_SKIP_PLACEHOLDER$1, ...navigateProps }) => {
18495
18589
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$$);
18496
18590
  const navigate = createNavigateToAgent(navigateProps);
18497
18591
  return addTool({
@@ -18516,6 +18610,20 @@ const addAgentNavigation = beginContext(({ toolName, docNote, description, navig
18516
18610
  },
18517
18611
  });
18518
18612
  });
18613
+ /**
18614
+ * Creates and registers a navigation tool for an agent to navigate to another specified agent.
18615
+ * @function addAgentNavigation
18616
+ * @param {IAgentNavigationParams} params - The parameters for configuring the navigation tool.
18617
+ * @param {ToolName} params.toolName - The name of the tool.
18618
+ * @param {string} params.description - Description of the tool's purpose.
18619
+ * @param {AgentName} params.navigateTo - The target agent to navigate to.
18620
+ * @param {string} [params.docNote] - Optional documentation note.
18621
+ * @param {...INavigateToAgentParams} params.navigateProps - Additional navigation properties.
18622
+ * @returns {ReturnType<typeof addTool>} The result of adding the navigation tool.
18623
+ */
18624
+ function addAgentNavigation(params) {
18625
+ return addAgentNavigationInternal(params);
18626
+ }
18519
18627
 
18520
18628
  /**
18521
18629
  * Adds triage navigation functionality to an agent by creating a tool that facilitates navigation to a triage agent.
@@ -18524,16 +18632,9 @@ const addAgentNavigation = beginContext(({ toolName, docNote, description, navig
18524
18632
  const METHOD_NAME$_ = "function.alias.addTriageNavigation";
18525
18633
  const DEFAULT_SKIP_PLACEHOLDER = "Navigation canceled";
18526
18634
  /**
18527
- * Creates and registers a triage navigation tool for an agent to navigate to a triage agent.
18528
- * @function addTriageNavigation
18529
- * @param {ITriageNavigationParams} params - The parameters for configuring the triage navigation tool.
18530
- * @param {ToolName} params.toolName - The name of the tool.
18531
- * @param {string} params.description - Description of the tool's purpose.
18532
- * @param {string} [params.docNote] - Optional documentation note.
18533
- * @param {...INavigateToTriageParams} params.navigateProps - Additional triage navigation properties.
18534
- * @returns {ReturnType<typeof addTool>} The result of adding the triage navigation tool.
18635
+ * Function implementation
18535
18636
  */
18536
- const addTriageNavigation = beginContext(({ toolName, docNote, description, skipPlaceholder = DEFAULT_SKIP_PLACEHOLDER, ...navigateProps }) => {
18637
+ const addTriageNavigationInternal = beginContext(({ toolName, docNote, description, skipPlaceholder = DEFAULT_SKIP_PLACEHOLDER, ...navigateProps }) => {
18537
18638
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$_);
18538
18639
  const navigate = createNavigateToTriageAgent(navigateProps);
18539
18640
  return addTool({
@@ -18558,16 +18659,26 @@ const addTriageNavigation = beginContext(({ toolName, docNote, description, skip
18558
18659
  },
18559
18660
  });
18560
18661
  });
18662
+ /**
18663
+ * Creates and registers a triage navigation tool for an agent to navigate to a triage agent.
18664
+ * @function addTriageNavigation
18665
+ * @param {ITriageNavigationParams} params - The parameters for configuring the triage navigation tool.
18666
+ * @param {ToolName} params.toolName - The name of the tool.
18667
+ * @param {string} params.description - Description of the tool's purpose.
18668
+ * @param {string} [params.docNote] - Optional documentation note.
18669
+ * @param {...INavigateToTriageParams} params.navigateProps - Additional triage navigation properties.
18670
+ * @returns {ReturnType<typeof addTool>} The result of adding the triage navigation tool.
18671
+ */
18672
+ function addTriageNavigation(params) {
18673
+ return addTriageNavigationInternal(params);
18674
+ }
18561
18675
 
18562
18676
  /** @constant {string} METHOD_NAME - The name of the method used for logging */
18563
18677
  const METHOD_NAME$Z = "function.setup.addWiki";
18564
18678
  /**
18565
- * Adds a wiki schema to the system
18566
- * @function addWiki
18567
- * @param {IWikiSchema} wikiSchema - The wiki schema to add
18568
- * @returns {string} The name of the added wiki
18679
+ * Function implementation
18569
18680
  */
18570
- const addWiki = beginContext((wikiSchema) => {
18681
+ const addWikiInternal = beginContext((wikiSchema) => {
18571
18682
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18572
18683
  swarm$1.loggerService.log(METHOD_NAME$Z, {
18573
18684
  wikiSchema,
@@ -18576,8 +18687,32 @@ const addWiki = beginContext((wikiSchema) => {
18576
18687
  swarm$1.wikiSchemaService.register(wikiSchema.wikiName, wikiSchema);
18577
18688
  return wikiSchema.wikiName;
18578
18689
  });
18690
+ /**
18691
+ * Adds a wiki schema to the system
18692
+ * @function addWiki
18693
+ * @param {IWikiSchema} wikiSchema - The wiki schema to add
18694
+ * @returns {string} The name of the added wiki
18695
+ */
18696
+ function addWiki(wikiSchema) {
18697
+ return addWikiInternal(wikiSchema);
18698
+ }
18579
18699
 
18580
18700
  const METHOD_NAME$Y = "function.setup.addAgent";
18701
+ /**
18702
+ * Function implementation
18703
+ */
18704
+ const addAgentInternal = beginContext((agentSchema) => {
18705
+ // Log the operation details if logging is enabled in GLOBAL_CONFIG
18706
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18707
+ swarm$1.loggerService.log(METHOD_NAME$Y, {
18708
+ agentSchema,
18709
+ });
18710
+ // Register the agent in the validation and schema services
18711
+ swarm$1.agentValidationService.addAgent(agentSchema.agentName, agentSchema);
18712
+ swarm$1.agentSchemaService.register(agentSchema.agentName, agentSchema);
18713
+ // Return the agent's name as confirmation of registration
18714
+ return agentSchema.agentName;
18715
+ });
18581
18716
  /**
18582
18717
  * Adds a new agent to the agent registry for use within the swarm system.
18583
18718
  *
@@ -18594,22 +18729,28 @@ const METHOD_NAME$Y = "function.setup.addAgent";
18594
18729
  * const agentName = addAgent(agentSchema);
18595
18730
  * console.log(agentName); // Outputs "AgentX"
18596
18731
  */
18597
- const addAgent = beginContext((agentSchema) => {
18598
- // Log the operation details if logging is enabled in GLOBAL_CONFIG
18599
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18600
- swarm$1.loggerService.log(METHOD_NAME$Y, {
18601
- agentSchema,
18602
- });
18603
- // Register the agent in the validation and schema services
18604
- swarm$1.agentValidationService.addAgent(agentSchema.agentName, agentSchema);
18605
- swarm$1.agentSchemaService.register(agentSchema.agentName, agentSchema);
18606
- // Return the agent's name as confirmation of registration
18607
- return agentSchema.agentName;
18608
- });
18732
+ function addAgent(agentSchema) {
18733
+ return addAgentInternal(agentSchema);
18734
+ }
18609
18735
 
18610
18736
  const METHOD_NAME$X = "function.setup.addCompletion";
18611
18737
  /**
18612
- * Adds a completion engine to the registry for use by agents in the swarm system.
18738
+ * Function implementation
18739
+ */
18740
+ const addCompletionInternal = beginContext((completionSchema) => {
18741
+ // Log the operation details if logging is enabled in GLOBAL_CONFIG
18742
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18743
+ swarm$1.loggerService.log(METHOD_NAME$X, {
18744
+ completionSchema,
18745
+ });
18746
+ // Register the completion in the validation and schema services
18747
+ swarm$1.completionValidationService.addCompletion(completionSchema.completionName);
18748
+ swarm$1.completionSchemaService.register(completionSchema.completionName, completionSchema);
18749
+ // Return the completion's name as confirmation of registration
18750
+ return completionSchema.completionName;
18751
+ });
18752
+ /**
18753
+ * Adds a completion engine to the registry for use by agents in the swarm system.
18613
18754
  *
18614
18755
  * This function registers a completion engine, enabling agents to utilize various models and frameworks (e.g., mock, GPT4All, Ollama, OpenAI)
18615
18756
  * for generating completions. The completion schema is added to the validation and schema services, making it available for agent operations.
@@ -18624,20 +18765,26 @@ const METHOD_NAME$X = "function.setup.addCompletion";
18624
18765
  * const completionName = addCompletion(completionSchema);
18625
18766
  * console.log(completionName); // Outputs "OpenAI"
18626
18767
  */
18627
- const addCompletion = beginContext((completionSchema) => {
18768
+ function addCompletion(completionSchema) {
18769
+ return addCompletionInternal(completionSchema);
18770
+ }
18771
+
18772
+ const METHOD_NAME$W = "function.setup.addSwarm";
18773
+ /**
18774
+ * Function implementation
18775
+ */
18776
+ const addSwarmInternal = beginContext((swarmSchema) => {
18628
18777
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
18629
18778
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18630
- swarm$1.loggerService.log(METHOD_NAME$X, {
18631
- completionSchema,
18779
+ swarm$1.loggerService.log(METHOD_NAME$W, {
18780
+ swarmSchema,
18632
18781
  });
18633
- // Register the completion in the validation and schema services
18634
- swarm$1.completionValidationService.addCompletion(completionSchema.completionName);
18635
- swarm$1.completionSchemaService.register(completionSchema.completionName, completionSchema);
18636
- // Return the completion's name as confirmation of registration
18637
- return completionSchema.completionName;
18782
+ // Register the swarm in the validation and schema services
18783
+ swarm$1.swarmValidationService.addSwarm(swarmSchema.swarmName, swarmSchema);
18784
+ swarm$1.swarmSchemaService.register(swarmSchema.swarmName, swarmSchema);
18785
+ // Return the swarm's name as confirmation of registration
18786
+ return swarmSchema.swarmName;
18638
18787
  });
18639
-
18640
- const METHOD_NAME$W = "function.setup.addSwarm";
18641
18788
  /**
18642
18789
  * Adds a new swarm to the system for managing client sessions.
18643
18790
  *
@@ -18654,26 +18801,15 @@ const METHOD_NAME$W = "function.setup.addSwarm";
18654
18801
  * const swarmName = addSwarm(swarmSchema);
18655
18802
  * console.log(swarmName); // Outputs "TaskSwarm"
18656
18803
  */
18657
- const addSwarm = beginContext((swarmSchema) => {
18658
- // Log the operation details if logging is enabled in GLOBAL_CONFIG
18659
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18660
- swarm$1.loggerService.log(METHOD_NAME$W, {
18661
- swarmSchema,
18662
- });
18663
- // Register the swarm in the validation and schema services
18664
- swarm$1.swarmValidationService.addSwarm(swarmSchema.swarmName, swarmSchema);
18665
- swarm$1.swarmSchemaService.register(swarmSchema.swarmName, swarmSchema);
18666
- // Return the swarm's name as confirmation of registration
18667
- return swarmSchema.swarmName;
18668
- });
18804
+ function addSwarm(swarmSchema) {
18805
+ return addSwarmInternal(swarmSchema);
18806
+ }
18669
18807
 
18670
18808
  const METHOD_NAME$V = "function.setup.addMCP";
18671
18809
  /**
18672
- * Registers a new MCP (Model Context Protocol) schema in the system.
18673
- * @param mcpSchema - The MCP schema to register.
18674
- * @returns The name of the registered MCP.
18810
+ * Function implementation
18675
18811
  */
18676
- const addMCP = beginContext((mcpSchema) => {
18812
+ const addMCPInternal = beginContext((mcpSchema) => {
18677
18813
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18678
18814
  swarm$1.loggerService.log(METHOD_NAME$V, {
18679
18815
  mcpSchema,
@@ -18682,27 +18818,20 @@ const addMCP = beginContext((mcpSchema) => {
18682
18818
  swarm$1.mcpSchemaService.register(mcpSchema.mcpName, mcpSchema);
18683
18819
  return mcpSchema.mcpName;
18684
18820
  });
18821
+ /**
18822
+ * Registers a new MCP (Model Context Protocol) schema in the system.
18823
+ * @param mcpSchema - The MCP schema to register.
18824
+ * @returns The name of the registered MCP.
18825
+ */
18826
+ function addMCP(mcpSchema) {
18827
+ return addMCPInternal(mcpSchema);
18828
+ }
18685
18829
 
18686
18830
  const METHOD_NAME$U = "function.setup.addState";
18687
18831
  /**
18688
- * Adds a new state to the state registry for use within the swarm system.
18689
- *
18690
- * This function registers a new state, enabling the swarm to manage and utilize it for agent operations or shared data persistence.
18691
- * Only states registered through this function are recognized by the swarm. If the state is marked as shared, it initializes a connection
18692
- * to the shared state service and waits for its initialization. The execution is wrapped in `beginContext` to ensure it runs outside of
18693
- * existing method and execution contexts, providing a clean execution environment. The function logs the operation if enabled and returns
18694
- * the state's name upon successful registration.
18695
- *
18696
- * @template T - The type of data stored in the state (defaults to `any` if unspecified).
18697
- * @param {IStateSchema<T>} stateSchema - The schema defining the state's properties, including its name (`stateName`), shared status (`shared`), and other configuration details.
18698
- * @returns {string} The name of the newly added state (`stateSchema.stateName`), confirming its registration.
18699
- * @throws {Error} If the state schema is invalid, registration fails (e.g., duplicate state name), or shared state initialization encounters an error.
18700
- * @example
18701
- * const stateSchema = { stateName: "UserPrefs", shared: true, initialValue: { theme: "dark" } };
18702
- * const stateName = addState(stateSchema);
18703
- * console.log(stateName); // Outputs "UserPrefs"
18832
+ * Function implementation
18704
18833
  */
18705
- const addState = beginContext((stateSchema) => {
18834
+ const addStateInternal = beginContext((stateSchema) => {
18706
18835
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
18707
18836
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18708
18837
  swarm$1.loggerService.log(METHOD_NAME$U, {
@@ -18721,8 +18850,44 @@ const addState = beginContext((stateSchema) => {
18721
18850
  // Return the state's name as confirmation of registration
18722
18851
  return stateSchema.stateName;
18723
18852
  });
18853
+ /**
18854
+ * Adds a new state to the state registry for use within the swarm system.
18855
+ *
18856
+ * This function registers a new state, enabling the swarm to manage and utilize it for agent operations or shared data persistence.
18857
+ * Only states registered through this function are recognized by the swarm. If the state is marked as shared, it initializes a connection
18858
+ * to the shared state service and waits for its initialization. The execution is wrapped in `beginContext` to ensure it runs outside of
18859
+ * existing method and execution contexts, providing a clean execution environment. The function logs the operation if enabled and returns
18860
+ * the state's name upon successful registration.
18861
+ *
18862
+ * @template T - The type of data stored in the state (defaults to `any` if unspecified).
18863
+ * @param {IStateSchema<T>} stateSchema - The schema defining the state's properties, including its name (`stateName`), shared status (`shared`), and other configuration details.
18864
+ * @returns {string} The name of the newly added state (`stateSchema.stateName`), confirming its registration.
18865
+ * @throws {Error} If the state schema is invalid, registration fails (e.g., duplicate state name), or shared state initialization encounters an error.
18866
+ * @example
18867
+ * const stateSchema = { stateName: "UserPrefs", shared: true, initialValue: { theme: "dark" } };
18868
+ * const stateName = addState(stateSchema);
18869
+ * console.log(stateName); // Outputs "UserPrefs"
18870
+ */
18871
+ function addState(stateSchema) {
18872
+ return addStateInternal(stateSchema);
18873
+ }
18724
18874
 
18725
18875
  const METHOD_NAME$T = "function.setup.addEmbedding";
18876
+ /**
18877
+ * Function implementation
18878
+ */
18879
+ const addEmbeddingInternal = beginContext((embeddingSchema) => {
18880
+ // Log the operation details if logging is enabled in GLOBAL_CONFIG
18881
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18882
+ swarm$1.loggerService.log(METHOD_NAME$T, {
18883
+ embeddingSchema,
18884
+ });
18885
+ // Register the embedding in the validation and schema services
18886
+ swarm$1.embeddingValidationService.addEmbedding(embeddingSchema.embeddingName, embeddingSchema);
18887
+ swarm$1.embeddingSchemaService.register(embeddingSchema.embeddingName, embeddingSchema);
18888
+ // Return the embedding's name as confirmation of registration
18889
+ return embeddingSchema.embeddingName;
18890
+ });
18726
18891
  /**
18727
18892
  * Adds a new embedding engine to the embedding registry for use within the swarm system.
18728
18893
  *
@@ -18739,20 +18904,32 @@ const METHOD_NAME$T = "function.setup.addEmbedding";
18739
18904
  * const embeddingName = addEmbedding(embeddingSchema);
18740
18905
  * console.log(embeddingName); // Outputs "TextEmbedder"
18741
18906
  */
18742
- const addEmbedding = beginContext((embeddingSchema) => {
18907
+ function addEmbedding(embeddingSchema) {
18908
+ return addEmbeddingInternal(embeddingSchema);
18909
+ }
18910
+
18911
+ const METHOD_NAME$S = "function.setup.addStorage";
18912
+ /**
18913
+ * Function implementation
18914
+ */
18915
+ const addStorageInternal = beginContext((storageSchema) => {
18743
18916
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
18744
18917
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18745
- swarm$1.loggerService.log(METHOD_NAME$T, {
18746
- embeddingSchema,
18918
+ swarm$1.loggerService.log(METHOD_NAME$S, {
18919
+ storageSchema,
18747
18920
  });
18748
- // Register the embedding in the validation and schema services
18749
- swarm$1.embeddingValidationService.addEmbedding(embeddingSchema.embeddingName, embeddingSchema);
18750
- swarm$1.embeddingSchemaService.register(embeddingSchema.embeddingName, embeddingSchema);
18751
- // Return the embedding's name as confirmation of registration
18752
- return embeddingSchema.embeddingName;
18921
+ // Register the storage in the validation and schema services
18922
+ swarm$1.storageValidationService.addStorage(storageSchema.storageName, storageSchema);
18923
+ swarm$1.storageSchemaService.register(storageSchema.storageName, storageSchema);
18924
+ // If the storage is shared, initialize and wait for the shared storage connection
18925
+ if (storageSchema.shared) {
18926
+ swarm$1.sharedStorageConnectionService
18927
+ .getStorage(storageSchema.storageName)
18928
+ .waitForInit();
18929
+ }
18930
+ // Return the storage's name as confirmation of registration
18931
+ return storageSchema.storageName;
18753
18932
  });
18754
-
18755
- const METHOD_NAME$S = "function.setup.addStorage";
18756
18933
  /**
18757
18934
  * Adds a new storage engine to the storage registry for use within the swarm system.
18758
18935
  *
@@ -18771,40 +18948,16 @@ const METHOD_NAME$S = "function.setup.addStorage";
18771
18948
  * const storageName = addStorage(storageSchema);
18772
18949
  * console.log(storageName); // Outputs "UserData"
18773
18950
  */
18774
- const addStorage = beginContext((storageSchema) => {
18775
- // Log the operation details if logging is enabled in GLOBAL_CONFIG
18776
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18777
- swarm$1.loggerService.log(METHOD_NAME$S, {
18778
- storageSchema,
18779
- });
18780
- // Register the storage in the validation and schema services
18781
- swarm$1.storageValidationService.addStorage(storageSchema.storageName, storageSchema);
18782
- swarm$1.storageSchemaService.register(storageSchema.storageName, storageSchema);
18783
- // If the storage is shared, initialize and wait for the shared storage connection
18784
- if (storageSchema.shared) {
18785
- swarm$1.sharedStorageConnectionService
18786
- .getStorage(storageSchema.storageName)
18787
- .waitForInit();
18788
- }
18789
- // Return the storage's name as confirmation of registration
18790
- return storageSchema.storageName;
18791
- });
18951
+ function addStorage(storageSchema) {
18952
+ return addStorageInternal(storageSchema);
18953
+ }
18792
18954
 
18793
18955
  /** @private Constant defining the method name for logging and validation context */
18794
18956
  const METHOD_NAME$R = "function.setup.addPolicy";
18795
18957
  /**
18796
- * Adds a new policy for agents in the swarm system by registering it with validation and schema services.
18797
- * Registers the policy with PolicyValidationService for runtime validation and PolicySchemaService for schema management.
18798
- * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
18799
- * Integrates with PolicyValidationService (policy registration and validation), PolicySchemaService (schema registration),
18800
- * and LoggerService (logging). Part of the swarm setup process, enabling policies to govern agent behavior,
18801
- * complementing runtime functions like commitAssistantMessage by defining operational rules upfront.
18802
- *
18803
- * @param {IPolicySchema} policySchema - The schema of the policy to be added, including policyName and other configuration details.
18804
- * @returns {string} The name of the policy that was added, as specified in policySchema.policyName.
18805
- * @throws {Error} If policy registration fails due to validation errors in PolicyValidationService or PolicySchemaService.
18958
+ * Function implementation
18806
18959
  */
18807
- const addPolicy = beginContext((policySchema) => {
18960
+ const addPolicyInternal = beginContext((policySchema) => {
18808
18961
  // Log the policy addition attempt if enabled
18809
18962
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18810
18963
  swarm$1.loggerService.log(METHOD_NAME$R, {
@@ -18817,19 +18970,30 @@ const addPolicy = beginContext((policySchema) => {
18817
18970
  // Return the policy name as confirmation of successful addition
18818
18971
  return policySchema.policyName;
18819
18972
  });
18973
+ /**
18974
+ * Adds a new policy for agents in the swarm system by registering it with validation and schema services.
18975
+ * Registers the policy with PolicyValidationService for runtime validation and PolicySchemaService for schema management.
18976
+ * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
18977
+ * Integrates with PolicyValidationService (policy registration and validation), PolicySchemaService (schema registration),
18978
+ * and LoggerService (logging). Part of the swarm setup process, enabling policies to govern agent behavior,
18979
+ * complementing runtime functions like commitAssistantMessage by defining operational rules upfront.
18980
+ *
18981
+ * @param {IPolicySchema} policySchema - The schema of the policy to be added, including policyName and other configuration details.
18982
+ * @returns {string} The name of the policy that was added, as specified in policySchema.policyName.
18983
+ * @throws {Error} If policy registration fails due to validation errors in PolicyValidationService or PolicySchemaService.
18984
+ */
18985
+ function addPolicy(policySchema) {
18986
+ return addPolicyInternal(policySchema);
18987
+ }
18820
18988
 
18821
18989
  /**
18822
18990
  * @module addCompute
18823
18991
  * @description Provides a function to register a compute schema with validation and logging.
18824
18992
  */
18825
18993
  /**
18826
- * @function addCompute
18827
- * @description Registers a compute schema, validates it, and adds it to the compute schema service.
18828
- * @template T - Type extending IComputeData.
18829
- * @param {IComputeSchema<T>} computeSchema - The compute schema to register.
18830
- * @returns {string} The name of the registered compute.
18994
+ * Function implementation
18831
18995
  */
18832
- const addCompute = beginContext((computeSchema) => {
18996
+ const addComputeInternal = beginContext((computeSchema) => {
18833
18997
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18834
18998
  swarm$1.loggerService.log("function.setup.addCompute", {
18835
18999
  computeSchema,
@@ -18838,6 +19002,15 @@ const addCompute = beginContext((computeSchema) => {
18838
19002
  swarm$1.computeSchemaService.register(computeSchema.computeName, computeSchema);
18839
19003
  return computeSchema.computeName;
18840
19004
  });
19005
+ /**
19006
+ * Registers a compute schema, validates it, and adds it to the compute schema service.
19007
+ * @template T - Type extending IComputeData.
19008
+ * @param {IComputeSchema<T>} computeSchema - The compute schema to register.
19009
+ * @returns {string} The name of the registered compute.
19010
+ */
19011
+ function addCompute(computeSchema) {
19012
+ return addComputeInternal(computeSchema);
19013
+ }
18841
19014
 
18842
19015
  /**
18843
19016
  * @module addPipeline
@@ -18850,13 +19023,9 @@ const addCompute = beginContext((computeSchema) => {
18850
19023
  */
18851
19024
  const METHOD_NAME$Q = "function.setup.addPipeline";
18852
19025
  /**
18853
- * @function addPipeline
18854
- * @description Registers a pipeline schema, validates it, and adds it to the pipeline schema service.
18855
- * @template Payload - Type extending object for the pipeline payload.
18856
- * @param {IPipelineSchema<Payload>} pipelineSchema - The pipeline schema to register.
18857
- * @returns {string} The name of the registered pipeline.
19026
+ * Function implementation
18858
19027
  */
18859
- const addPipeline = beginContext((pipelineSchema) => {
19028
+ const addPipelineInternal = beginContext((pipelineSchema) => {
18860
19029
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18861
19030
  swarm$1.loggerService.log(METHOD_NAME$Q, {
18862
19031
  pipelineSchema,
@@ -18865,8 +19034,28 @@ const addPipeline = beginContext((pipelineSchema) => {
18865
19034
  swarm$1.pipelineSchemaService.register(pipelineSchema.pipelineName, pipelineSchema);
18866
19035
  return pipelineSchema.pipelineName;
18867
19036
  });
19037
+ /**
19038
+ * Registers a pipeline schema, validates it, and adds it to the pipeline schema service.
19039
+ * @template Payload - Type extending object for the pipeline payload.
19040
+ * @param {IPipelineSchema<Payload>} pipelineSchema - The pipeline schema to register.
19041
+ * @returns {string} The name of the registered pipeline.
19042
+ */
19043
+ function addPipeline(pipelineSchema) {
19044
+ return addPipelineInternal(pipelineSchema);
19045
+ }
18868
19046
 
18869
19047
  const METHOD_NAME$P = "function.test.overrideAgent";
19048
+ /**
19049
+ * Function implementation
19050
+ */
19051
+ const overrideAgentInternal = beginContext((agentSchema) => {
19052
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19053
+ swarm$1.loggerService.log(METHOD_NAME$P, {
19054
+ agentSchema,
19055
+ });
19056
+ swarm$1.agentSchemaService.get(agentSchema.agentName);
19057
+ return swarm$1.agentSchemaService.override(agentSchema.agentName, agentSchema);
19058
+ });
18870
19059
  /**
18871
19060
  * Overrides an existing agent schema in the swarm system with a new or partial schema.
18872
19061
  * This function updates the configuration of an agent identified by its `agentName`, applying the provided schema properties.
@@ -18888,16 +19077,21 @@ const METHOD_NAME$P = "function.test.overrideAgent";
18888
19077
  * });
18889
19078
  * // Logs the operation (if enabled) and updates the agent schema in the swarm.
18890
19079
  */
18891
- const overrideAgent = beginContext((agentSchema) => {
19080
+ function overrideAgent(agentSchema) {
19081
+ return overrideAgentInternal(agentSchema);
19082
+ }
19083
+
19084
+ const METHOD_NAME$O = "function.test.overrideCompletion";
19085
+ /**
19086
+ * Function implementation
19087
+ */
19088
+ const overrideCompletionInternal = beginContext((completionSchema) => {
18892
19089
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18893
- swarm$1.loggerService.log(METHOD_NAME$P, {
18894
- agentSchema,
19090
+ swarm$1.loggerService.log(METHOD_NAME$O, {
19091
+ completionSchema,
18895
19092
  });
18896
- swarm$1.agentSchemaService.get(agentSchema.agentName);
18897
- return swarm$1.agentSchemaService.override(agentSchema.agentName, agentSchema);
19093
+ return swarm$1.completionSchemaService.override(completionSchema.completionName, completionSchema);
18898
19094
  });
18899
-
18900
- const METHOD_NAME$O = "function.test.overrideCompletion";
18901
19095
  /**
18902
19096
  * Overrides an existing completion schema in the swarm system with a new or partial schema.
18903
19097
  * This function updates the configuration of a completion mechanism identified by its `completionName`, applying the provided schema properties.
@@ -18919,15 +19113,21 @@ const METHOD_NAME$O = "function.test.overrideCompletion";
18919
19113
  * });
18920
19114
  * // Logs the operation (if enabled) and updates the completion schema in the swarm.
18921
19115
  */
18922
- const overrideCompletion = beginContext((completionSchema) => {
19116
+ function overrideCompletion(completionSchema) {
19117
+ return overrideCompletionInternal(completionSchema);
19118
+ }
19119
+
19120
+ const METHOD_NAME$N = "function.test.overrideEmbeding";
19121
+ /**
19122
+ * Function implementation
19123
+ */
19124
+ const overrideEmbedingInternal = beginContext((embeddingSchema) => {
18923
19125
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18924
- swarm$1.loggerService.log(METHOD_NAME$O, {
18925
- completionSchema,
19126
+ swarm$1.loggerService.log(METHOD_NAME$N, {
19127
+ embeddingSchema,
18926
19128
  });
18927
- return swarm$1.completionSchemaService.override(completionSchema.completionName, completionSchema);
19129
+ return swarm$1.embeddingSchemaService.override(embeddingSchema.embeddingName, embeddingSchema);
18928
19130
  });
18929
-
18930
- const METHOD_NAME$N = "function.test.overrideEmbeding";
18931
19131
  /**
18932
19132
  * Overrides an existing embedding schema in the swarm system with a new or partial schema.
18933
19133
  * This function updates the configuration of an embedding mechanism identified by its `embeddingName`, applying the provided schema properties.
@@ -18951,15 +19151,21 @@ const METHOD_NAME$N = "function.test.overrideEmbeding";
18951
19151
  * });
18952
19152
  * // Logs the operation (if enabled) and updates the embedding schema in the swarm.
18953
19153
  */
18954
- const overrideEmbeding = beginContext((embeddingSchema) => {
19154
+ function overrideEmbeding(embeddingSchema) {
19155
+ return overrideEmbedingInternal(embeddingSchema);
19156
+ }
19157
+
19158
+ const METHOD_NAME$M = "function.test.overridePolicy";
19159
+ /**
19160
+ * Function implementation
19161
+ */
19162
+ const overridePolicyInternal = beginContext((policySchema) => {
18955
19163
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18956
- swarm$1.loggerService.log(METHOD_NAME$N, {
18957
- embeddingSchema,
19164
+ swarm$1.loggerService.log(METHOD_NAME$M, {
19165
+ policySchema,
18958
19166
  });
18959
- return swarm$1.embeddingSchemaService.override(embeddingSchema.embeddingName, embeddingSchema);
19167
+ return swarm$1.policySchemaService.override(policySchema.policyName, policySchema);
18960
19168
  });
18961
-
18962
- const METHOD_NAME$M = "function.test.overridePolicy";
18963
19169
  /**
18964
19170
  * Overrides an existing policy schema in the swarm system with a new or partial schema.
18965
19171
  * This function updates the configuration of a policy identified by its `policyName`, applying the provided schema properties.
@@ -18981,15 +19187,21 @@ const METHOD_NAME$M = "function.test.overridePolicy";
18981
19187
  * });
18982
19188
  * // Logs the operation (if enabled) and updates the policy schema in the swarm.
18983
19189
  */
18984
- const overridePolicy = beginContext((policySchema) => {
19190
+ function overridePolicy(policySchema) {
19191
+ return overridePolicyInternal(policySchema);
19192
+ }
19193
+
19194
+ const METHOD_NAME$L = "function.test.overrideState";
19195
+ /**
19196
+ * Function implementation
19197
+ */
19198
+ const overrideStateInternal = beginContext((stateSchema) => {
18985
19199
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
18986
- swarm$1.loggerService.log(METHOD_NAME$M, {
18987
- policySchema,
19200
+ swarm$1.loggerService.log(METHOD_NAME$L, {
19201
+ stateSchema,
18988
19202
  });
18989
- return swarm$1.policySchemaService.override(policySchema.policyName, policySchema);
19203
+ return swarm$1.stateSchemaService.override(stateSchema.stateName, stateSchema);
18990
19204
  });
18991
-
18992
- const METHOD_NAME$L = "function.test.overrideState";
18993
19205
  /**
18994
19206
  * Overrides an existing state schema in the swarm system with a new or partial schema.
18995
19207
  * This function updates the configuration of a state identified by its `stateName`, applying the provided schema properties.
@@ -19012,15 +19224,21 @@ const METHOD_NAME$L = "function.test.overrideState";
19012
19224
  * });
19013
19225
  * // Logs the operation (if enabled) and updates the state schema in the swarm.
19014
19226
  */
19015
- const overrideState = beginContext((stateSchema) => {
19016
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19017
- swarm$1.loggerService.log(METHOD_NAME$L, {
19018
- stateSchema,
19019
- });
19020
- return swarm$1.stateSchemaService.override(stateSchema.stateName, stateSchema);
19021
- });
19227
+ function overrideState(stateSchema) {
19228
+ return overrideStateInternal(stateSchema);
19229
+ }
19022
19230
 
19023
19231
  const METHOD_NAME$K = "function.test.overrideStorage";
19232
+ /**
19233
+ * Function implementation
19234
+ */
19235
+ const overrideStorageInternal = beginContext((storageSchema) => {
19236
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19237
+ swarm$1.loggerService.log(METHOD_NAME$K, {
19238
+ storageSchema,
19239
+ });
19240
+ return swarm$1.storageSchemaService.override(storageSchema.storageName, storageSchema);
19241
+ });
19024
19242
  /**
19025
19243
  * Overrides an existing storage schema in the swarm system with a new or partial schema.
19026
19244
  * This function updates the configuration of a storage identified by its `storageName`, applying the provided schema properties.
@@ -19044,15 +19262,21 @@ const METHOD_NAME$K = "function.test.overrideStorage";
19044
19262
  * });
19045
19263
  * // Logs the operation (if enabled) and updates the storage schema in the swarm.
19046
19264
  */
19047
- const overrideStorage = beginContext((storageSchema) => {
19265
+ function overrideStorage(storageSchema) {
19266
+ return overrideStorageInternal(storageSchema);
19267
+ }
19268
+
19269
+ const METHOD_NAME$J = "function.test.overrideSwarm";
19270
+ /**
19271
+ * Function implementation
19272
+ */
19273
+ const overrideSwarmInternal = beginContext((swarmSchema) => {
19048
19274
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19049
- swarm$1.loggerService.log(METHOD_NAME$K, {
19050
- storageSchema,
19275
+ swarm$1.loggerService.log(METHOD_NAME$J, {
19276
+ swarmSchema,
19051
19277
  });
19052
- return swarm$1.storageSchemaService.override(storageSchema.storageName, storageSchema);
19278
+ return swarm$1.swarmSchemaService.override(swarmSchema.swarmName, swarmSchema);
19053
19279
  });
19054
-
19055
- const METHOD_NAME$J = "function.test.overrideSwarm";
19056
19280
  /**
19057
19281
  * Overrides an existing swarm schema in the swarm system with a new or partial schema.
19058
19282
  * This function updates the configuration of a swarm identified by its `swarmName`, applying the provided schema properties.
@@ -19074,15 +19298,21 @@ const METHOD_NAME$J = "function.test.overrideSwarm";
19074
19298
  * });
19075
19299
  * // Logs the operation (if enabled) and updates the swarm schema in the swarm system.
19076
19300
  */
19077
- const overrideSwarm = beginContext((swarmSchema) => {
19301
+ function overrideSwarm(swarmSchema) {
19302
+ return overrideSwarmInternal(swarmSchema);
19303
+ }
19304
+
19305
+ const METHOD_NAME$I = "function.test.overrideTool";
19306
+ /**
19307
+ * Function implementation
19308
+ */
19309
+ const overrideToolInternal = beginContext((toolSchema) => {
19078
19310
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19079
- swarm$1.loggerService.log(METHOD_NAME$J, {
19080
- swarmSchema,
19311
+ swarm$1.loggerService.log(METHOD_NAME$I, {
19312
+ toolSchema,
19081
19313
  });
19082
- return swarm$1.swarmSchemaService.override(swarmSchema.swarmName, swarmSchema);
19314
+ return swarm$1.toolSchemaService.override(toolSchema.toolName, toolSchema);
19083
19315
  });
19084
-
19085
- const METHOD_NAME$I = "function.test.overrideTool";
19086
19316
  /**
19087
19317
  * Overrides an existing tool schema in the swarm system with a new or partial schema.
19088
19318
  * This function updates the configuration of a tool identified by its `toolName`, applying the provided schema properties.
@@ -19104,29 +19334,41 @@ const METHOD_NAME$I = "function.test.overrideTool";
19104
19334
  * });
19105
19335
  * // Logs the operation (if enabled) and updates the tool schema in the swarm.
19106
19336
  */
19107
- const overrideTool = beginContext((toolSchema) => {
19108
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19109
- swarm$1.loggerService.log(METHOD_NAME$I, {
19110
- toolSchema,
19111
- });
19112
- return swarm$1.toolSchemaService.override(toolSchema.toolName, toolSchema);
19113
- });
19337
+ function overrideTool(toolSchema) {
19338
+ return overrideToolInternal(toolSchema);
19339
+ }
19114
19340
 
19115
19341
  const METHOD_NAME$H = "function.test.overrideMCP";
19116
19342
  /**
19117
- * Overrides an existing MCP (Model Context Protocol) schema with a new or partial schema.
19118
- * @param mcpSchema - The MCP schema containing the name and optional properties to override.
19119
- * @returns The result of the override operation from the MCP schema service.
19343
+ * Function implementation
19120
19344
  */
19121
- const overrideMCP = beginContext((mcpSchema) => {
19345
+ const overrideMCPInternal = beginContext((mcpSchema) => {
19122
19346
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19123
19347
  swarm$1.loggerService.log(METHOD_NAME$H, {
19124
19348
  mcpSchema,
19125
19349
  });
19126
19350
  return swarm$1.mcpSchemaService.override(mcpSchema.mcpName, mcpSchema);
19127
19351
  });
19352
+ /**
19353
+ * Overrides an existing MCP (Model Context Protocol) schema with a new or partial schema.
19354
+ * @param mcpSchema - The MCP schema containing the name and optional properties to override.
19355
+ * @returns The result of the override operation from the MCP schema service.
19356
+ */
19357
+ function overrideMCP(mcpSchema) {
19358
+ return overrideMCPInternal(mcpSchema);
19359
+ }
19128
19360
 
19129
19361
  const METHOD_NAME$G = "function.test.overrideWiki";
19362
+ /**
19363
+ * Function implementation
19364
+ */
19365
+ const overrideWikiInternal = beginContext((wikiSchema) => {
19366
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19367
+ swarm$1.loggerService.log(METHOD_NAME$G, {
19368
+ wikiSchema,
19369
+ });
19370
+ return swarm$1.wikiSchemaService.override(wikiSchema.wikiName, wikiSchema);
19371
+ });
19130
19372
  /**
19131
19373
  * Overrides an existing wiki schema in the swarm system with a new or partial schema.
19132
19374
  * This function updates the configuration of a wiki identified by its `wikiName`, applying the provided schema properties.
@@ -19148,13 +19390,9 @@ const METHOD_NAME$G = "function.test.overrideWiki";
19148
19390
  * });
19149
19391
  * // Logs the operation (if enabled) and updates the wiki schema in the swarm.
19150
19392
  */
19151
- const overrideWiki = beginContext((wikiSchema) => {
19152
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19153
- swarm$1.loggerService.log(METHOD_NAME$G, {
19154
- wikiSchema,
19155
- });
19156
- return swarm$1.wikiSchemaService.override(wikiSchema.wikiName, wikiSchema);
19157
- });
19393
+ function overrideWiki(wikiSchema) {
19394
+ return overrideWikiInternal(wikiSchema);
19395
+ }
19158
19396
 
19159
19397
  /**
19160
19398
  * @module overrideCompute
@@ -19167,18 +19405,23 @@ const overrideWiki = beginContext((wikiSchema) => {
19167
19405
  */
19168
19406
  const METHOD_NAME$F = "function.test.overrideCompute";
19169
19407
  /**
19170
- * @function overrideCompute
19171
- * @description Overrides an existing compute schema with provided partial updates.
19172
- * @param {TComputeSchema} computeSchema - The partial compute schema with updates.
19173
- * @returns {IComputeSchema} The updated compute schema.
19408
+ * Function implementation
19174
19409
  */
19175
- const overrideCompute = beginContext((computeSchema) => {
19410
+ const overrideComputeInternal = beginContext((computeSchema) => {
19176
19411
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19177
19412
  swarm$1.loggerService.log(METHOD_NAME$F, {
19178
19413
  computeSchema,
19179
19414
  });
19180
19415
  return swarm$1.computeSchemaService.override(computeSchema.computeName, computeSchema);
19181
19416
  });
19417
+ /**
19418
+ * Overrides an existing compute schema with provided partial updates.
19419
+ * @param {TComputeSchema} computeSchema - The partial compute schema with updates.
19420
+ * @returns {IComputeSchema} The updated compute schema.
19421
+ */
19422
+ function overrideCompute(computeSchema) {
19423
+ return overrideComputeInternal(computeSchema);
19424
+ }
19182
19425
 
19183
19426
  /**
19184
19427
  * @module overridePipeline
@@ -19191,30 +19434,30 @@ const overrideCompute = beginContext((computeSchema) => {
19191
19434
  */
19192
19435
  const METHOD_NAME$E = "function.test.overridePipeline";
19193
19436
  /**
19194
- * @function overridePipeline
19195
- * @description Overrides an existing pipeline schema with provided partial updates.
19196
- * @template Payload - Type extending object for the pipeline payload.
19197
- * @param {IPipelineSchema<Payload>} pipelineSchema - The partial pipeline schema with updates.
19198
- * @returns {IPipelineSchema<Payload>} The updated pipeline schema.
19437
+ * Function implementation
19199
19438
  */
19200
- const overridePipeline = beginContext((pipelineSchema) => {
19439
+ const overridePipelineInternal = beginContext((pipelineSchema) => {
19201
19440
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19202
19441
  swarm$1.loggerService.log(METHOD_NAME$E, {
19203
19442
  pipelineSchema,
19204
19443
  });
19205
19444
  return swarm$1.pipelineSchemaService.override(pipelineSchema.pipelineName, pipelineSchema);
19206
19445
  });
19446
+ /**
19447
+ * Overrides an existing pipeline schema with provided partial updates.
19448
+ * @template Payload - Type extending object for the pipeline payload.
19449
+ * @param {IPipelineSchema<Payload>} pipelineSchema - The partial pipeline schema with updates.
19450
+ * @returns {IPipelineSchema<Payload>} The updated pipeline schema.
19451
+ */
19452
+ function overridePipeline(pipelineSchema) {
19453
+ return overridePipelineInternal(pipelineSchema);
19454
+ }
19207
19455
 
19208
19456
  const METHOD_NAME$D = "function.other.markOnline";
19209
19457
  /**
19210
- * Marks a client as online in the specified swarm.
19211
- *
19212
- * @param {string} clientId - The unique identifier of the client to mark as online.
19213
- * @param {SwarmName} swarmName - The name of the swarm where the client is being marked online.
19214
- * @returns {Promise<void>} A promise that resolves when the client is successfully marked online.
19215
- * @throws {Error} Throws an error if the swarm validation fails or if the operation fails.
19458
+ * Function implementation
19216
19459
  */
19217
- const markOnline = async (clientId, swarmName) => {
19460
+ const markOnlineInternal = async (clientId, swarmName) => {
19218
19461
  // Log the operation if logging is enabled in the global configuration
19219
19462
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19220
19463
  swarm.loggerService.log(METHOD_NAME$D, {
@@ -19237,21 +19480,23 @@ const markOnline = async (clientId, swarmName) => {
19237
19480
  clientId,
19238
19481
  });
19239
19482
  };
19483
+ /**
19484
+ * Marks a client as online in the specified swarm.
19485
+ *
19486
+ * @param {string} clientId - The unique identifier of the client to mark as online.
19487
+ * @param {SwarmName} swarmName - The name of the swarm where the client is being marked online.
19488
+ * @returns {Promise<void>} A promise that resolves when the client is successfully marked online.
19489
+ * @throws {Error} Throws an error if the swarm validation fails or if the operation fails.
19490
+ */
19491
+ function markOnline(clientId, swarmName) {
19492
+ return markOnlineInternal(clientId, swarmName);
19493
+ }
19240
19494
 
19241
19495
  const METHOD_NAME$C = "function.other.markOffline";
19242
19496
  /**
19243
- * Marks a client as offline in the specified swarm.
19244
- *
19245
- * @param {string} clientId - The unique identifier of the client to mark as offline.
19246
- * @param {SwarmName} swarmName - The name of the swarm where the client belongs.
19247
- * @returns {Promise<void>} A promise that resolves when the client is successfully marked as offline.
19248
- *
19249
- * @throws {Error} If the swarm validation fails or the operation encounters an issue.
19250
- *
19251
- * @example
19252
- * await markOffline("client123", "exampleSwarm");
19497
+ * Function implementation
19253
19498
  */
19254
- const markOffline = async (clientId, swarmName) => {
19499
+ const markOfflineInternal = async (clientId, swarmName) => {
19255
19500
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19256
19501
  swarm.loggerService.log(METHOD_NAME$C, {
19257
19502
  clientId,
@@ -19271,25 +19516,28 @@ const markOffline = async (clientId, swarmName) => {
19271
19516
  clientId,
19272
19517
  });
19273
19518
  };
19519
+ /**
19520
+ * Marks a client as offline in the specified swarm.
19521
+ *
19522
+ * @param {string} clientId - The unique identifier of the client to mark as offline.
19523
+ * @param {SwarmName} swarmName - The name of the swarm where the client belongs.
19524
+ * @returns {Promise<void>} A promise that resolves when the client is successfully marked as offline.
19525
+ *
19526
+ * @throws {Error} If the swarm validation fails or the operation encounters an issue.
19527
+ *
19528
+ * @example
19529
+ * await markOffline("client123", "exampleSwarm");
19530
+ */
19531
+ function markOffline(clientId, swarmName) {
19532
+ return markOfflineInternal(clientId, swarmName);
19533
+ }
19274
19534
 
19275
19535
  /** @private Constant defining the method name for logging and validation context */
19276
19536
  const METHOD_NAME$B = "function.commit.commitSystemMessage";
19277
19537
  /**
19278
- * Commits a system-generated message to the active agent in the swarm system.
19279
- * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before committing the message.
19280
- * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
19281
- * Integrates with AgentValidationService (agent validation), SessionValidationService (session and swarm retrieval),
19282
- * SwarmValidationService (swarm validation), SwarmPublicService (agent retrieval), SessionPublicService (message committing),
19283
- * and LoggerService (logging). Complements functions like commitAssistantMessage by handling system messages (e.g., configuration or control messages)
19284
- * rather than assistant-generated responses.
19285
- *
19286
- * @param {string} content - The content of the system message to commit, typically related to system state or control instructions.
19287
- * @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
19288
- * @param {string} agentName - The name of the agent to commit the message for, validated against registered agents.
19289
- * @returns {Promise<void>} A promise that resolves when the message is committed or skipped (e.g., agent mismatch).
19290
- * @throws {Error} If agent, session, or swarm validation fails, propagated from respective validation services.
19538
+ * Function implementation
19291
19539
  */
19292
- const commitSystemMessage = beginContext(async (content, clientId, agentName) => {
19540
+ const commitSystemMessageInternal = beginContext(async (content, clientId, agentName) => {
19293
19541
  // Log the commit attempt if enabled
19294
19542
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19295
19543
  swarm$1.loggerService.log(METHOD_NAME$B, {
@@ -19318,24 +19566,30 @@ const commitSystemMessage = beginContext(async (content, clientId, agentName) =>
19318
19566
  // Commit the system message via SessionPublicService
19319
19567
  await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$B, clientId, swarmName);
19320
19568
  });
19569
+ /**
19570
+ * Commits a system-generated message to the active agent in the swarm system.
19571
+ * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before committing the message.
19572
+ * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
19573
+ * Integrates with AgentValidationService (agent validation), SessionValidationService (session and swarm retrieval),
19574
+ * SwarmValidationService (swarm validation), SwarmPublicService (agent retrieval), SessionPublicService (message committing),
19575
+ * and LoggerService (logging). Complements functions like commitAssistantMessage by handling system messages (e.g., configuration or control messages)
19576
+ * rather than assistant-generated responses.
19577
+ *
19578
+ * @param {string} content - The content of the system message to commit, typically related to system state or control instructions.
19579
+ * @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
19580
+ * @param {string} agentName - The name of the agent to commit the message for, validated against registered agents.
19581
+ * @returns {Promise<void>} A promise that resolves when the message is committed or skipped (e.g., agent mismatch).
19582
+ * @throws {Error} If agent, session, or swarm validation fails, propagated from respective validation services.
19583
+ */
19584
+ function commitSystemMessage(content, clientId, agentName) {
19585
+ return commitSystemMessageInternal(content, clientId, agentName);
19586
+ }
19321
19587
 
19322
19588
  const METHOD_NAME$A = "function.commit.commitSystemMessage";
19323
19589
  /**
19324
- * Commits a user message to the active agent's history in a swarm session without triggering a response.
19325
- *
19326
- * This function commits a user message to the history of the specified agent, ensuring the agent is still active in the swarm session.
19327
- * 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.
19328
- * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
19329
- *
19330
- * @param {string} content - The content of the user message to be committed.
19331
- * @param {string} clientId - The unique identifier of the client session associated with the operation.
19332
- * @param {string} agentName - The name of the agent to whose history the message will be committed.
19333
- * @returns {Promise<void>} A promise that resolves when the message is successfully committed, or immediately if the operation is skipped due to an agent change.
19334
- * @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.
19335
- * @example
19336
- * await commitUserMessage("User input message", "client-123", "AgentX");
19590
+ * Function implementation
19337
19591
  */
19338
- const commitUserMessage = beginContext(async (content, mode, clientId, agentName, payload) => {
19592
+ const commitUserMessageInternal = beginContext(async (content, mode, clientId, agentName, payload) => {
19339
19593
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
19340
19594
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19341
19595
  swarm$1.loggerService.log(METHOD_NAME$A, {
@@ -19372,25 +19626,31 @@ const commitUserMessage = beginContext(async (content, mode, clientId, agentName
19372
19626
  // Commit the user message to the agent's history via the session public service
19373
19627
  return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$A, clientId, swarmName);
19374
19628
  });
19629
+ /**
19630
+ * Commits a user message to the active agent's history in a swarm session without triggering a response.
19631
+ *
19632
+ * This function commits a user message to the history of the specified agent, ensuring the agent is still active in the swarm session.
19633
+ * 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.
19634
+ * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
19635
+ *
19636
+ * @param {string} content - The content of the user message to be committed.
19637
+ * @param {string} clientId - The unique identifier of the client session associated with the operation.
19638
+ * @param {string} agentName - The name of the agent to whose history the message will be committed.
19639
+ * @returns {Promise<void>} A promise that resolves when the message is successfully committed, or immediately if the operation is skipped due to an agent change.
19640
+ * @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.
19641
+ * @example
19642
+ * await commitUserMessage("User input message", "client-123", "AgentX");
19643
+ */
19644
+ function commitUserMessage(content, mode, clientId, agentName, payload) {
19645
+ return commitUserMessageInternal(content, mode, clientId, agentName, payload);
19646
+ }
19375
19647
 
19376
19648
  /** @private Constant defining the method name for logging and validation context */
19377
19649
  const METHOD_NAME$z = "function.commit.commitSystemMessageForce";
19378
19650
  /**
19379
- * Forcefully commits a system-generated message to a session in the swarm system, without checking the active agent.
19380
- * Validates the session and swarm, then proceeds with committing the message regardless of the current agent state.
19381
- * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
19382
- * Integrates with SessionValidationService (session and swarm retrieval), SwarmValidationService (swarm validation),
19383
- * SessionPublicService (message committing), and LoggerService (logging).
19384
- * Unlike commitSystemMessage, this function skips agent validation and active agent checks, providing a more aggressive commit mechanism,
19385
- * analogous to commitAssistantMessageForce vs. commitAssistantMessage.
19386
- *
19387
- * @param {string} content - The content of the system message to commit, typically related to system state or control instructions.
19388
- * @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
19389
- * @param {string} agentName - The name of the agent (unused in this implementation, included for interface consistency with commitSystemMessage).
19390
- * @returns {Promise<void>} A promise that resolves when the message is committed.
19391
- * @throws {Error} If session or swarm validation fails, propagated from respective validation services.
19651
+ * Function implementation
19392
19652
  */
19393
- const commitSystemMessageForce = beginContext(async (content, clientId) => {
19653
+ const commitSystemMessageForceInternal = beginContext(async (content, clientId) => {
19394
19654
  // Log the commit attempt if enabled
19395
19655
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19396
19656
  swarm$1.loggerService.log(METHOD_NAME$z, {
@@ -19405,23 +19665,30 @@ const commitSystemMessageForce = beginContext(async (content, clientId) => {
19405
19665
  // Commit the system message via SessionPublicService without agent checks
19406
19666
  await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$z, clientId, swarmName);
19407
19667
  });
19668
+ /**
19669
+ * Forcefully commits a system-generated message to a session in the swarm system, without checking the active agent.
19670
+ * Validates the session and swarm, then proceeds with committing the message regardless of the current agent state.
19671
+ * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
19672
+ * Integrates with SessionValidationService (session and swarm retrieval), SwarmValidationService (swarm validation),
19673
+ * SessionPublicService (message committing), and LoggerService (logging).
19674
+ * Unlike commitSystemMessage, this function skips agent validation and active agent checks, providing a more aggressive commit mechanism,
19675
+ * analogous to commitAssistantMessageForce vs. commitAssistantMessage.
19676
+ *
19677
+ * @param {string} content - The content of the system message to commit, typically related to system state or control instructions.
19678
+ * @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
19679
+ * @param {string} agentName - The name of the agent (unused in this implementation, included for interface consistency with commitSystemMessage).
19680
+ * @returns {Promise<void>} A promise that resolves when the message is committed.
19681
+ * @throws {Error} If session or swarm validation fails, propagated from respective validation services.
19682
+ */
19683
+ function commitSystemMessageForce(content, clientId) {
19684
+ return commitSystemMessageForceInternal(content, clientId);
19685
+ }
19408
19686
 
19409
19687
  const METHOD_NAME$y = "function.commit.commitSystemMessage";
19410
19688
  /**
19411
- * Commits a user message to the active agent's history in a swarm session without triggering a response and without checking the active agent.
19412
- *
19413
- * This function forcefully commits a user message to the history of the active agent in the specified swarm session, bypassing the check for whether the agent is still active.
19414
- * It performs validation on the session and swarm, logs the operation if enabled, and delegates the commit operation to the session public service.
19415
- * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
19416
- *
19417
- * @param {string} content - The content of the user message to be committed.
19418
- * @param {string} clientId - The unique identifier of the client session associated with the operation.
19419
- * @returns {Promise<void>} A promise that resolves when the message is successfully committed.
19420
- * @throws {Error} If validation fails (e.g., invalid session or swarm) or if the session public service encounters an error during the commit operation.
19421
- * @example
19422
- * await commitUserMessageForce("User input message", "client-123");
19689
+ * Function implementation
19423
19690
  */
19424
- const commitUserMessageForce = beginContext(async (content, mode, clientId, payload) => {
19691
+ const commitUserMessageForceInternal = beginContext(async (content, mode, clientId, payload) => {
19425
19692
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
19426
19693
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19427
19694
  swarm$1.loggerService.log(METHOD_NAME$y, {
@@ -19444,24 +19711,30 @@ const commitUserMessageForce = beginContext(async (content, mode, clientId, payl
19444
19711
  // Commit the user message to the agent's history via the session public service without checking the active agent
19445
19712
  return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$y, clientId, swarmName);
19446
19713
  });
19714
+ /**
19715
+ * Commits a user message to the active agent's history in a swarm session without triggering a response and without checking the active agent.
19716
+ *
19717
+ * This function forcefully commits a user message to the history of the active agent in the specified swarm session, bypassing the check for whether the agent is still active.
19718
+ * It performs validation on the session and swarm, logs the operation if enabled, and delegates the commit operation to the session public service.
19719
+ * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
19720
+ *
19721
+ * @param {string} content - The content of the user message to be committed.
19722
+ * @param {string} clientId - The unique identifier of the client session associated with the operation.
19723
+ * @returns {Promise<void>} A promise that resolves when the message is successfully committed.
19724
+ * @throws {Error} If validation fails (e.g., invalid session or swarm) or if the session public service encounters an error during the commit operation.
19725
+ * @example
19726
+ * await commitUserMessageForce("User input message", "client-123");
19727
+ */
19728
+ function commitUserMessageForce(content, mode, clientId, payload) {
19729
+ return commitUserMessageForceInternal(content, mode, clientId, payload);
19730
+ }
19447
19731
 
19448
19732
  /** @private Constant defining the method name for logging and validation context */
19449
19733
  const METHOD_NAME$x = "function.commit.commitAssistantMessage";
19450
19734
  /**
19451
- * Commits an assistant-generated message to the active agent in the swarm system.
19452
- * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before committing the message.
19453
- * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
19454
- * Integrates with AgentValidationService (agent validation), SessionValidationService (session and swarm retrieval),
19455
- * SwarmValidationService (swarm validation), SwarmPublicService (agent retrieval), SessionPublicService (message committing),
19456
- * and LoggerService (logging). Complements functions like cancelOutput by persisting assistant messages rather than canceling output.
19457
- *
19458
- * @param {string} content - The content of the assistant message to commit, typically generated by the agent.
19459
- * @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
19460
- * @param {string} agentName - The name of the agent to commit the message for, validated against registered agents.
19461
- * @returns {Promise<void>} A promise that resolves when the message is committed or skipped (e.g., agent mismatch).
19462
- * @throws {Error} If agent, session, or swarm validation fails, propagated from respective validation services.
19735
+ * Function implementation
19463
19736
  */
19464
- const commitAssistantMessage = beginContext(async (content, clientId, agentName) => {
19737
+ const commitAssistantMessageInternal = beginContext(async (content, clientId, agentName) => {
19465
19738
  // Log the commit attempt if enabled
19466
19739
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19467
19740
  swarm$1.loggerService.log(METHOD_NAME$x, {
@@ -19490,25 +19763,30 @@ const commitAssistantMessage = beginContext(async (content, clientId, agentName)
19490
19763
  // Commit the assistant message via SessionPublicService
19491
19764
  await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$x, clientId, swarmName);
19492
19765
  });
19493
-
19494
- /** @private Constant defining the method name for logging and validation context */
19495
- const METHOD_NAME$w = "function.commit.commitAssistantMessageForce";
19496
19766
  /**
19497
- * Forcefully commits an assistant-generated message to a session in the swarm system, without checking the active agent.
19498
- * Validates the session and swarm, then proceeds with committing the message regardless of the current agent state.
19767
+ * Commits an assistant-generated message to the active agent in the swarm system.
19768
+ * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before committing the message.
19499
19769
  * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
19500
- * Integrates with SessionValidationService (session and swarm retrieval), SwarmValidationService (swarm validation),
19501
- * SessionPublicService (message committing), and LoggerService (logging).
19502
- * Unlike commitAssistantMessage, this function skips agent validation and active agent checks, providing a more aggressive commit mechanism,
19503
- * analogous to cancelOutputForce vs. cancelOutput.
19770
+ * Integrates with AgentValidationService (agent validation), SessionValidationService (session and swarm retrieval),
19771
+ * SwarmValidationService (swarm validation), SwarmPublicService (agent retrieval), SessionPublicService (message committing),
19772
+ * and LoggerService (logging). Complements functions like cancelOutput by persisting assistant messages rather than canceling output.
19504
19773
  *
19505
- * @param {string} content - The content of the assistant message to commit, typically generated by an agent.
19774
+ * @param {string} content - The content of the assistant message to commit, typically generated by the agent.
19506
19775
  * @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
19507
- * @param {string} agentName - The name of the agent (unused in this implementation, included for interface consistency with commitAssistantMessage).
19508
- * @returns {Promise<void>} A promise that resolves when the message is committed.
19509
- * @throws {Error} If session or swarm validation fails, propagated from respective validation services.
19776
+ * @param {string} agentName - The name of the agent to commit the message for, validated against registered agents.
19777
+ * @returns {Promise<void>} A promise that resolves when the message is committed or skipped (e.g., agent mismatch).
19778
+ * @throws {Error} If agent, session, or swarm validation fails, propagated from respective validation services.
19510
19779
  */
19511
- const commitAssistantMessageForce = beginContext(async (content, clientId) => {
19780
+ function commitAssistantMessage(content, clientId, agentName) {
19781
+ return commitAssistantMessageInternal(content, clientId, agentName);
19782
+ }
19783
+
19784
+ /** @private Constant defining the method name for logging and validation context */
19785
+ const METHOD_NAME$w = "function.commit.commitAssistantMessageForce";
19786
+ /**
19787
+ * Function implementation
19788
+ */
19789
+ const commitAssistantMessageForceInternal = beginContext(async (content, clientId) => {
19512
19790
  // Log the commit attempt if enabled
19513
19791
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19514
19792
  swarm$1.loggerService.log(METHOD_NAME$w, {
@@ -19523,22 +19801,31 @@ const commitAssistantMessageForce = beginContext(async (content, clientId) => {
19523
19801
  // Commit the assistant message via SessionPublicService without agent checks
19524
19802
  await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$w, clientId, swarmName);
19525
19803
  });
19804
+ /**
19805
+ * Forcefully commits an assistant-generated message to a session in the swarm system, without checking the active agent.
19806
+ * Validates the session and swarm, then proceeds with committing the message regardless of the current agent state.
19807
+ * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
19808
+ * Integrates with SessionValidationService (session and swarm retrieval), SwarmValidationService (swarm validation),
19809
+ * SessionPublicService (message committing), and LoggerService (logging).
19810
+ * Unlike commitAssistantMessage, this function skips agent validation and active agent checks, providing a more aggressive commit mechanism,
19811
+ * analogous to cancelOutputForce vs. cancelOutput.
19812
+ *
19813
+ * @param {string} content - The content of the assistant message to commit, typically generated by an agent.
19814
+ * @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
19815
+ * @param {string} agentName - The name of the agent (unused in this implementation, included for interface consistency with commitAssistantMessage).
19816
+ * @returns {Promise<void>} A promise that resolves when the message is committed.
19817
+ * @throws {Error} If session or swarm validation fails, propagated from respective validation services.
19818
+ */
19819
+ function commitAssistantMessageForce(content, clientId) {
19820
+ return commitAssistantMessageForceInternal(content, clientId);
19821
+ }
19526
19822
 
19527
19823
  /** @private Constant defining the method name for logging and validation context */
19528
19824
  const METHOD_NAME$v = "function.commit.cancelOutput";
19529
19825
  /**
19530
- * Cancels the awaited output for a specific client and agent by emitting an empty string.
19531
- * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before cancellation.
19532
- * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
19533
- * Integrates with AgentValidationService (agent validation), SessionValidationService (session and swarm retrieval),
19534
- * SwarmValidationService (swarm validation), and SwarmPublicService (agent retrieval and output cancellation).
19535
- *
19536
- * @param {string} clientId - The ID of the client whose output is to be canceled, validated against active sessions.
19537
- * @param {string} agentName - The name of the agent for which the output is canceled, validated against registered agents.
19538
- * @returns {Promise<void>} A promise that resolves when the output cancellation is complete or skipped (e.g., agent mismatch).
19539
- * @throws {Error} If agent, session, or swarm validation fails, propagated from respective validation services.
19826
+ * Function implementation
19540
19827
  */
19541
- const cancelOutput = beginContext(async (clientId, agentName) => {
19828
+ const cancelOutputInternal = beginContext(async (clientId, agentName) => {
19542
19829
  // Log the cancellation attempt if enabled
19543
19830
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19544
19831
  swarm$1.loggerService.log(METHOD_NAME$v, {
@@ -19566,23 +19853,28 @@ const cancelOutput = beginContext(async (clientId, agentName) => {
19566
19853
  // Perform the output cancellation via SwarmPublicService
19567
19854
  await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$v, clientId, swarmName);
19568
19855
  });
19569
-
19570
- /** @private Constant defining the method name for logging and validation context */
19571
- const METHOD_NAME$u = "function.commit.cancelOutputForce";
19572
19856
  /**
19573
- * Forcefully cancels the awaited output for a specific client by emitting an empty string, without checking the active agent.
19574
- * Validates the session and swarm, then proceeds with cancellation regardless of the current agent state.
19857
+ * Cancels the awaited output for a specific client and agent by emitting an empty string.
19858
+ * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before cancellation.
19575
19859
  * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
19576
- * Integrates with SessionValidationService (session and swarm retrieval), SwarmValidationService (swarm validation),
19577
- * SwarmPublicService (output cancellation), and LoggerService (logging).
19578
- * Unlike cancelOutput, this function skips agent validation and active agent checks, providing a more aggressive cancellation mechanism.
19860
+ * Integrates with AgentValidationService (agent validation), SessionValidationService (session and swarm retrieval),
19861
+ * SwarmValidationService (swarm validation), and SwarmPublicService (agent retrieval and output cancellation).
19579
19862
  *
19580
19863
  * @param {string} clientId - The ID of the client whose output is to be canceled, validated against active sessions.
19581
- * @param {string} agentName - The name of the agent (unused in this implementation, included for interface consistency with cancelOutput).
19582
- * @returns {Promise<void>} A promise that resolves when the output cancellation is complete.
19583
- * @throws {Error} If session or swarm validation fails, propagated from respective validation services.
19864
+ * @param {string} agentName - The name of the agent for which the output is canceled, validated against registered agents.
19865
+ * @returns {Promise<void>} A promise that resolves when the output cancellation is complete or skipped (e.g., agent mismatch).
19866
+ * @throws {Error} If agent, session, or swarm validation fails, propagated from respective validation services.
19584
19867
  */
19585
- const cancelOutputForce = beginContext(async (clientId) => {
19868
+ function cancelOutput(clientId, agentName) {
19869
+ return cancelOutputInternal(clientId, agentName);
19870
+ }
19871
+
19872
+ /** @private Constant defining the method name for logging and validation context */
19873
+ const METHOD_NAME$u = "function.commit.cancelOutputForce";
19874
+ /**
19875
+ * Function implementation
19876
+ */
19877
+ const cancelOutputForceInternal = beginContext(async (clientId) => {
19586
19878
  // Log the cancellation attempt if enabled
19587
19879
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19588
19880
  swarm$1.loggerService.log(METHOD_NAME$u, {
@@ -19596,24 +19888,29 @@ const cancelOutputForce = beginContext(async (clientId) => {
19596
19888
  // Perform the output cancellation via SwarmPublicService without agent checks
19597
19889
  await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$u, clientId, swarmName);
19598
19890
  });
19599
-
19600
- /** @private Constant defining the method name for logging and validation context */
19601
- const METHOD_NAME$t = "function.commit.commitStopToolsForce";
19602
19891
  /**
19603
- * Forcefully prevents the next tool from being executed for a specific client in the swarm system, without checking the active agent.
19604
- * Validates the session and swarm, then proceeds with stopping tool execution regardless of the current agent state.
19892
+ * Forcefully cancels the awaited output for a specific client by emitting an empty string, without checking the active agent.
19893
+ * Validates the session and swarm, then proceeds with cancellation regardless of the current agent state.
19605
19894
  * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
19606
19895
  * Integrates with SessionValidationService (session and swarm retrieval), SwarmValidationService (swarm validation),
19607
- * SessionPublicService (tool execution stop), ToolValidationService (tool context), and LoggerService (logging).
19608
- * Unlike commitStopTools, this function skips agent validation and active agent checks, providing a more aggressive stop mechanism,
19609
- * analogous to commitFlushForce vs. commitFlush.
19896
+ * SwarmPublicService (output cancellation), and LoggerService (logging).
19897
+ * Unlike cancelOutput, this function skips agent validation and active agent checks, providing a more aggressive cancellation mechanism.
19610
19898
  *
19611
- * @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
19612
- * @param {string} agentName - The name of the agent (unused in this implementation, included for interface consistency with commitStopTools).
19613
- * @returns {Promise<void>} A promise that resolves when the tool stop is committed.
19899
+ * @param {string} clientId - The ID of the client whose output is to be canceled, validated against active sessions.
19900
+ * @param {string} agentName - The name of the agent (unused in this implementation, included for interface consistency with cancelOutput).
19901
+ * @returns {Promise<void>} A promise that resolves when the output cancellation is complete.
19614
19902
  * @throws {Error} If session or swarm validation fails, propagated from respective validation services.
19615
19903
  */
19616
- const commitStopToolsForce = beginContext(async (clientId) => {
19904
+ function cancelOutputForce(clientId) {
19905
+ return cancelOutputForceInternal(clientId);
19906
+ }
19907
+
19908
+ /** @private Constant defining the method name for logging and validation context */
19909
+ const METHOD_NAME$t = "function.commit.commitStopToolsForce";
19910
+ /**
19911
+ * Function implementation
19912
+ */
19913
+ const commitStopToolsForceInternal = beginContext(async (clientId) => {
19617
19914
  // Log the stop tools attempt if enabled
19618
19915
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19619
19916
  swarm$1.loggerService.log(METHOD_NAME$t, {
@@ -19628,23 +19925,29 @@ const commitStopToolsForce = beginContext(async (clientId) => {
19628
19925
  // Commit the stop of the next tool execution via SessionPublicService without agent checks
19629
19926
  await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$t, clientId, swarmName);
19630
19927
  });
19631
-
19632
- const METHOD_NAME$s = "function.commit.commitToolRequest";
19633
19928
  /**
19634
- * Commits a tool request to the active agent in the swarm system.
19635
- * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before committing the request.
19929
+ * Forcefully prevents the next tool from being executed for a specific client in the swarm system, without checking the active agent.
19930
+ * Validates the session and swarm, then proceeds with stopping tool execution regardless of the current agent state.
19636
19931
  * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
19637
- * Integrates with AgentValidationService (agent validation), SessionValidationService (session and swarm retrieval),
19638
- * SwarmValidationService (swarm validation), SwarmPublicService (agent retrieval), SessionPublicService (tool request committing),
19639
- * and LoggerService (logging). Complements functions like commitSystemMessage by handling tool requests rather than system messages.
19932
+ * Integrates with SessionValidationService (session and swarm retrieval), SwarmValidationService (swarm validation),
19933
+ * SessionPublicService (tool execution stop), ToolValidationService (tool context), and LoggerService (logging).
19934
+ * Unlike commitStopTools, this function skips agent validation and active agent checks, providing a more aggressive stop mechanism,
19935
+ * analogous to commitFlushForce vs. commitFlush.
19640
19936
  *
19641
- * @param {IToolRequest | IToolRequest[]} request - The tool request(s) to commit, either as a single request or an array of requests.
19642
19937
  * @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
19643
- * @param {string} agentName - The name of the agent to commit the request for, validated against registered agents.
19644
- * @returns {Promise<string[] | null>} A promise that resolves with an array of results if the request is committed, or `null` if skipped (e.g., agent mismatch).
19645
- * @throws {Error} If agent, session, or swarm validation fails, propagated from respective validation services.
19938
+ * @param {string} agentName - The name of the agent (unused in this implementation, included for interface consistency with commitStopTools).
19939
+ * @returns {Promise<void>} A promise that resolves when the tool stop is committed.
19940
+ * @throws {Error} If session or swarm validation fails, propagated from respective validation services.
19646
19941
  */
19647
- const commitToolRequest = beginContext(async (request, clientId, agentName) => {
19942
+ function commitStopToolsForce(clientId) {
19943
+ return commitStopToolsForceInternal(clientId);
19944
+ }
19945
+
19946
+ const METHOD_NAME$s = "function.commit.commitToolRequest";
19947
+ /**
19948
+ * Function implementation
19949
+ */
19950
+ const commitToolRequestInternal = beginContext(async (request, clientId, agentName) => {
19648
19951
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19649
19952
  swarm$1.loggerService.log(METHOD_NAME$s, {
19650
19953
  request,
@@ -19667,22 +19970,25 @@ const commitToolRequest = beginContext(async (request, clientId, agentName) => {
19667
19970
  }
19668
19971
  return await swarm$1.sessionPublicService.commitToolRequest(Array.isArray(request) ? request : [request], METHOD_NAME$s, clientId, swarmName);
19669
19972
  });
19670
-
19671
- const METHOD_NAME$r = "function.commit.commitToolRequestForce";
19672
19973
  /**
19673
- * Forcefully commits a tool request to the active agent in the swarm system.
19674
- * Validates the session and swarm, bypassing agent validation to directly commit the request.
19974
+ * Commits a tool request to the active agent in the swarm system.
19975
+ * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before committing the request.
19675
19976
  * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
19676
- * Integrates with SessionValidationService (session and swarm retrieval), SwarmValidationService (swarm validation),
19677
- * SessionPublicService (tool request committing), and LoggerService (logging).
19678
- * Complements functions like commitToolRequest by skipping agent validation for direct tool request commits.
19679
19977
  *
19680
- * @param {IToolRequest | IToolRequest[]} request - The tool request(s) to commit, either as a single request or an array of requests.
19681
- * @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
19682
- * @returns {Promise<string[]>} A promise that resolves with an array of results if the request is committed.
19683
- * @throws {Error} If session or swarm validation fails, propagated from respective validation services.
19978
+ * @param {IToolRequest | IToolRequest[]} request - The tool request(s) to commit.
19979
+ * @param {string} clientId - The client ID associated with the session.
19980
+ * @param {string} agentName - The agent name to commit the request for.
19981
+ * @returns {Promise<string[] | null>} A promise resolving with an array of result strings, or null if skipped due to agent mismatch.
19982
+ */
19983
+ function commitToolRequest(request, clientId, agentName) {
19984
+ return commitToolRequestInternal(request, clientId, agentName);
19985
+ }
19986
+
19987
+ const METHOD_NAME$r = "function.commit.commitToolRequestForce";
19988
+ /**
19989
+ * Function implementation
19684
19990
  */
19685
- const commitToolRequestForce = beginContext(async (request, clientId) => {
19991
+ const commitToolRequestForceInternal = beginContext(async (request, clientId) => {
19686
19992
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19687
19993
  swarm$1.loggerService.log(METHOD_NAME$r, {
19688
19994
  request,
@@ -19691,21 +19997,29 @@ const commitToolRequestForce = beginContext(async (request, clientId) => {
19691
19997
  swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$r);
19692
19998
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
19693
19999
  swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$r);
19694
- return await swarm$1.sessionPublicService.commitToolRequest(Array.isArray(request) ? request : [request], METHOD_NAME$r, clientId, swarmName);
20000
+ const requests = Array.isArray(request) ? request : [request];
20001
+ return await swarm$1.sessionPublicService.commitToolRequest(requests, METHOD_NAME$r, clientId, swarmName);
19695
20002
  });
20003
+ /**
20004
+ * Forcefully commits a tool request to the active agent in the swarm system.
20005
+ * Validates the session and swarm, bypassing agent validation to directly commit the request.
20006
+ * Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
20007
+ *
20008
+ * @param {IToolRequest | IToolRequest[]} request - The tool request(s) to commit.
20009
+ * @param {string} clientId - The ID of the client associated with the session.
20010
+ * @returns {Promise<string[]>} A promise that resolves with an array of results if the request is committed.
20011
+ * @throws {Error} If session or swarm validation fails.
20012
+ */
20013
+ function commitToolRequestForce(request, clientId) {
20014
+ return commitToolRequestForceInternal(request, clientId);
20015
+ }
19696
20016
 
19697
20017
  /** @constant {string} METHOD_NAME - The name of the method used for logging and validation */
19698
20018
  const METHOD_NAME$q = "function.target.question";
19699
20019
  /**
19700
- * Initiates a question process within a chat context
19701
- * @function question
19702
- * @param {string} message - The message/question to be processed
19703
- * @param {string} clientId - Unique identifier for the client
19704
- * @param {AgentName} agentName - Name of the agent handling the question
19705
- * @param {WikiName} wikiName - Name of the wiki context
19706
- * @returns {Promise<string>} The response from the chat process
20020
+ * Function implementation
19707
20021
  */
19708
- const question = beginContext(async (message, clientId, agentName, wikiName) => {
20022
+ const questionInternal = beginContext(async (message, clientId, agentName, wikiName) => {
19709
20023
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19710
20024
  swarm$1.loggerService.log(METHOD_NAME$q, {
19711
20025
  message,
@@ -19742,18 +20056,25 @@ const question = beginContext(async (message, clientId, agentName, wikiName) =>
19742
20056
  }
19743
20057
  return await getChat(args);
19744
20058
  });
19745
-
19746
- /** @constant {string} METHOD_NAME - The name of the method used for logging and validation */
19747
- const METHOD_NAME$p = "function.target.questionForce";
19748
20059
  /**
19749
- * Initiates a forced question process within a chat context
19750
- * @function questionForce
20060
+ * Initiates a question process within a chat context
20061
+ * @function question
19751
20062
  * @param {string} message - The message/question to be processed
19752
20063
  * @param {string} clientId - Unique identifier for the client
20064
+ * @param {AgentName} agentName - Name of the agent handling the question
19753
20065
  * @param {WikiName} wikiName - Name of the wiki context
19754
20066
  * @returns {Promise<string>} The response from the chat process
19755
20067
  */
19756
- const questionForce = beginContext(async (message, clientId, wikiName) => {
20068
+ function question(message, clientId, agentName, wikiName) {
20069
+ return questionInternal(message, clientId, agentName, wikiName);
20070
+ }
20071
+
20072
+ /** @constant {string} METHOD_NAME - The name of the method used for logging and validation */
20073
+ const METHOD_NAME$p = "function.target.questionForce";
20074
+ /**
20075
+ * Function implementation
20076
+ */
20077
+ const questionForceInternal = beginContext(async (message, clientId, wikiName) => {
19757
20078
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19758
20079
  swarm$1.loggerService.log(METHOD_NAME$p, {
19759
20080
  message,
@@ -19776,6 +20097,17 @@ const questionForce = beginContext(async (message, clientId, wikiName) => {
19776
20097
  }
19777
20098
  return await getChat(args);
19778
20099
  });
20100
+ /**
20101
+ * Initiates a forced question process within a chat context
20102
+ * @function questionForce
20103
+ * @param {string} message - The message/question to be processed
20104
+ * @param {string} clientId - Unique identifier for the client
20105
+ * @param {WikiName} wikiName - Name of the wiki context
20106
+ * @returns {Promise<string>} The response from the chat process
20107
+ */
20108
+ function questionForce(message, clientId, wikiName) {
20109
+ return questionForceInternal(message, clientId, wikiName);
20110
+ }
19779
20111
 
19780
20112
  const METHOD_NAME$o = "function.target.disposeConnection";
19781
20113
  /**
@@ -19968,22 +20300,9 @@ const makeAutoDispose = beginContext((clientId, swarmName, { timeoutSeconds = DE
19968
20300
 
19969
20301
  const METHOD_NAME$m = "function.target.notify";
19970
20302
  /**
19971
- * Sends a notification message as output from the swarm session without executing an incoming message.
19972
- *
19973
- * This function directly sends a provided string as output from the swarm session, bypassing message execution. It is designed exclusively
19974
- * for sessions established via the "makeConnection" mode. The function validates the session, swarm, and specified agent, ensuring the agent
19975
- * is still active before sending the notification. If the active agent has changed, the operation is skipped. The execution is wrapped in
19976
- * `beginContext` for a clean environment, logs the operation if enabled, and throws an error if the session mode is not "makeConnection".
19977
- *
19978
- * @param {string} content - The content to be sent as the notification output.
19979
- * @param {string} clientId - The unique identifier of the client session sending the notification.
19980
- * @param {AgentName} agentName - The name of the agent intended to send the notification.
19981
- * @returns {Promise<void>} A promise that resolves when the notification is sent, or resolves early if skipped due to an agent change.
19982
- * @throws {Error} If the session mode is not "makeConnection", or if agent, session, or swarm validation fails.
19983
- * @example
19984
- * await notify("Direct output", "client-123", "AgentX"); // Sends "Direct output" if AgentX is active
20303
+ * Function implementation
19985
20304
  */
19986
- const notify = beginContext(async (content, clientId, agentName) => {
20305
+ const notifyInternal = beginContext(async (content, clientId, agentName) => {
19987
20306
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
19988
20307
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
19989
20308
  swarm$1.loggerService.log(METHOD_NAME$m, {
@@ -20015,24 +20334,31 @@ const notify = beginContext(async (content, clientId, agentName) => {
20015
20334
  // Notify the content directly via the session public service
20016
20335
  return await swarm$1.sessionPublicService.notify(content, METHOD_NAME$m, clientId, swarmName);
20017
20336
  });
20018
-
20019
- const METHOD_NAME$l = "function.target.notifyForce";
20020
20337
  /**
20021
20338
  * Sends a notification message as output from the swarm session without executing an incoming message.
20022
20339
  *
20023
20340
  * This function directly sends a provided string as output from the swarm session, bypassing message execution. It is designed exclusively
20024
20341
  * for sessions established via the "makeConnection" mode. The function validates the session, swarm, and specified agent, ensuring the agent
20025
- * is still active before sending the notification. Will notify even if the agent was changed. The execution is wrapped in
20342
+ * is still active before sending the notification. If the active agent has changed, the operation is skipped. The execution is wrapped in
20026
20343
  * `beginContext` for a clean environment, logs the operation if enabled, and throws an error if the session mode is not "makeConnection".
20027
20344
  *
20028
20345
  * @param {string} content - The content to be sent as the notification output.
20029
20346
  * @param {string} clientId - The unique identifier of the client session sending the notification.
20030
- * @returns {Promise<void>} A promise that resolves when the notification is sent
20347
+ * @param {AgentName} agentName - The name of the agent intended to send the notification.
20348
+ * @returns {Promise<void>} A promise that resolves when the notification is sent, or resolves early if skipped due to an agent change.
20031
20349
  * @throws {Error} If the session mode is not "makeConnection", or if agent, session, or swarm validation fails.
20032
20350
  * @example
20033
- * await notifyForce("Direct output", "client-123", "AgentX"); // Sends "Direct output" if AgentX is active
20351
+ * await notify("Direct output", "client-123", "AgentX"); // Sends "Direct output" if AgentX is active
20352
+ */
20353
+ function notify(content, clientId, agentName) {
20354
+ return notifyInternal(content, clientId, agentName);
20355
+ }
20356
+
20357
+ const METHOD_NAME$l = "function.target.notifyForce";
20358
+ /**
20359
+ * Function implementation
20034
20360
  */
20035
- const notifyForce = beginContext(async (content, clientId) => {
20361
+ const notifyForceInternal = beginContext(async (content, clientId) => {
20036
20362
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
20037
20363
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
20038
20364
  swarm$1.loggerService.log(METHOD_NAME$l, {
@@ -20051,27 +20377,30 @@ const notifyForce = beginContext(async (content, clientId) => {
20051
20377
  // Notify the content directly via the session public service
20052
20378
  return await swarm$1.sessionPublicService.notify(content, METHOD_NAME$l, clientId, swarmName);
20053
20379
  });
20054
-
20055
- const METHOD_NAME$k = "function.target.runStateless";
20056
20380
  /**
20057
- * Executes a message statelessly with an agent in a swarm session, bypassing chat history.
20381
+ * Sends a notification message as output from the swarm session without executing an incoming message.
20058
20382
  *
20059
- * This function processes a command or message using the specified agent without appending it to the chat history, designed to prevent
20060
- * model history overflow when handling storage output or one-off tasks. It validates the agent, session, and swarm, checks if the specified
20061
- * agent is still active, and executes the content with performance tracking and event bus notifications. The execution is wrapped in
20062
- * `beginContext` for a clean environment and `ExecutionContextService` for metadata tracking. If the active agent has changed, the operation
20063
- * is skipped, returning an empty string.
20383
+ * This function directly sends a provided string as output from the swarm session, bypassing message execution. It is designed exclusively
20384
+ * for sessions established via the "makeConnection" mode. The function validates the session, swarm, and specified agent, ensuring the agent
20385
+ * is still active before sending the notification. Will notify even if the agent was changed. The execution is wrapped in
20386
+ * `beginContext` for a clean environment, logs the operation if enabled, and throws an error if the session mode is not "makeConnection".
20064
20387
  *
20065
- * @param {string} content - The content or command to be executed statelessly by the agent.
20066
- * @param {string} clientId - The unique identifier of the client session requesting the execution.
20067
- * @param {AgentName} agentName - The name of the agent intended to execute the command.
20068
- * @returns {Promise<string>} A promise that resolves to the result of the execution, or an empty string if skipped due to an agent change.
20069
- * @throws {Error} If agent, session, or swarm validation fails, or if the execution process encounters an error.
20388
+ * @param {string} content - The content to be sent as the notification output.
20389
+ * @param {string} clientId - The unique identifier of the client session sending the notification.
20390
+ * @returns {Promise<void>} A promise that resolves when the notification is sent
20391
+ * @throws {Error} If the session mode is not "makeConnection", or if agent, session, or swarm validation fails.
20070
20392
  * @example
20071
- * const result = await runStateless("Process this data", "client-123", "AgentX");
20072
- * console.log(result); // Outputs the agent's response without affecting history
20393
+ * await notifyForce("Direct output", "client-123", "AgentX"); // Sends "Direct output" if AgentX is active
20394
+ */
20395
+ function notifyForce(content, clientId) {
20396
+ return notifyForceInternal(content, clientId);
20397
+ }
20398
+
20399
+ const METHOD_NAME$k = "function.target.runStateless";
20400
+ /**
20401
+ * Function implementation
20073
20402
  */
20074
- const runStateless = beginContext(async (content, clientId, agentName) => {
20403
+ const runStatelessInternal = beginContext(async (content, clientId, agentName) => {
20075
20404
  const executionId = functoolsKit.randomString();
20076
20405
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
20077
20406
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
@@ -20125,25 +20454,33 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
20125
20454
  processId: GLOBAL_CONFIG.CC_PROCESS_UUID,
20126
20455
  });
20127
20456
  });
20128
-
20129
- const METHOD_NAME$j = "function.target.runStatelessForce";
20130
20457
  /**
20131
- * Executes a message statelessly with the active agent in a swarm session, bypassing chat history and forcing execution regardless of agent activity.
20458
+ * Executes a message statelessly with an agent in a swarm session, bypassing chat history.
20132
20459
  *
20133
- * This function processes a command or message using the active agent without appending it to the chat history, designed to prevent model history
20134
- * overflow when handling storage output or one-off tasks. Unlike `runStateless`, it does not check if the agent is currently active, ensuring execution
20135
- * even if the agent has changed or is inactive. It validates the session and swarm, executes the content with performance tracking and event bus
20136
- * notifications, and is wrapped in `beginContext` for a clean environment and `ExecutionContextService` for metadata tracking.
20460
+ * This function processes a command or message using the specified agent without appending it to the chat history, designed to prevent
20461
+ * model history overflow when handling storage output or one-off tasks. It validates the agent, session, and swarm, checks if the specified
20462
+ * agent is still active, and executes the content with performance tracking and event bus notifications. The execution is wrapped in
20463
+ * `beginContext` for a clean environment and `ExecutionContextService` for metadata tracking. If the active agent has changed, the operation
20464
+ * is skipped, returning an empty string.
20137
20465
  *
20138
- * @param {string} content - The content or command to be executed statelessly by the active agent.
20466
+ * @param {string} content - The content or command to be executed statelessly by the agent.
20139
20467
  * @param {string} clientId - The unique identifier of the client session requesting the execution.
20140
- * @returns {Promise<string>} A promise that resolves to the result of the execution.
20141
- * @throws {Error} If session or swarm validation fails, or if the execution process encounters an error.
20468
+ * @param {AgentName} agentName - The name of the agent intended to execute the command.
20469
+ * @returns {Promise<string>} A promise that resolves to the result of the execution, or an empty string if skipped due to an agent change.
20470
+ * @throws {Error} If agent, session, or swarm validation fails, or if the execution process encounters an error.
20142
20471
  * @example
20143
- * const result = await runStatelessForce("Process this data forcefully", "client-123");
20472
+ * const result = await runStateless("Process this data", "client-123", "AgentX");
20144
20473
  * console.log(result); // Outputs the agent's response without affecting history
20145
20474
  */
20146
- const runStatelessForce = beginContext(async (content, clientId) => {
20475
+ function runStateless(content, clientId, agentName) {
20476
+ return runStatelessInternal(content, clientId, agentName);
20477
+ }
20478
+
20479
+ const METHOD_NAME$j = "function.target.runStatelessForce";
20480
+ /**
20481
+ * Function implementation
20482
+ */
20483
+ const runStatelessForceInternal = beginContext(async (content, clientId) => {
20147
20484
  const executionId = functoolsKit.randomString();
20148
20485
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
20149
20486
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
@@ -20178,6 +20515,25 @@ const runStatelessForce = beginContext(async (content, clientId) => {
20178
20515
  processId: GLOBAL_CONFIG.CC_PROCESS_UUID,
20179
20516
  });
20180
20517
  });
20518
+ /**
20519
+ * Executes a message statelessly with the active agent in a swarm session, bypassing chat history and forcing execution regardless of agent activity.
20520
+ *
20521
+ * This function processes a command or message using the active agent without appending it to the chat history, designed to prevent model history
20522
+ * overflow when handling storage output or one-off tasks. Unlike `runStateless`, it does not check if the agent is currently active, ensuring execution
20523
+ * even if the agent has changed or is inactive. It validates the session and swarm, executes the content with performance tracking and event bus
20524
+ * notifications, and is wrapped in `beginContext` for a clean environment and `ExecutionContextService` for metadata tracking.
20525
+ *
20526
+ * @param {string} content - The content or command to be executed statelessly by the active agent.
20527
+ * @param {string} clientId - The unique identifier of the client session requesting the execution.
20528
+ * @returns {Promise<string>} A promise that resolves to the result of the execution.
20529
+ * @throws {Error} If session or swarm validation fails, or if the execution process encounters an error.
20530
+ * @example
20531
+ * const result = await runStatelessForce("Process this data forcefully", "client-123");
20532
+ * console.log(result); // Outputs the agent's response without affecting history
20533
+ */
20534
+ function runStatelessForce(content, clientId) {
20535
+ return runStatelessForceInternal(content, clientId);
20536
+ }
20181
20537
 
20182
20538
  /**
20183
20539
  * Delay in milliseconds for scheduled message sending.
@@ -20719,15 +21075,9 @@ session.rate = (clientId, swarmName, { delay = SCHEDULED_DELAY, onDispose } = {}
20719
21075
  */
20720
21076
  const METHOD_NAME$f = "function.target.fork";
20721
21077
  /**
20722
- * @function fork
20723
- * @description Executes a provided function within a managed scope, handling session creation, validation, and cleanup.
20724
- * @template T - Type of the result returned by the run function.
20725
- * @param {Function} runFn - The function to execute, receiving clientId and agentName as arguments.
20726
- * @param {IScopeOptions} options - Configuration options for the scope operation.
20727
- * @returns {Promise<T | void>} The result of the run function or void if no result is returned.
20728
- * @throws {Error} If a session already exists for the clientId.
21078
+ * Function implementation
20729
21079
  */
20730
- const fork = beginContext(async (runFn, { clientId, swarmName, onError }) => {
21080
+ const forkInternal = beginContext(async (runFn, { clientId, swarmName, onError }) => {
20731
21081
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
20732
21082
  swarm$1.loggerService.log(METHOD_NAME$f, {
20733
21083
  clientId,
@@ -20753,6 +21103,17 @@ const fork = beginContext(async (runFn, { clientId, swarmName, onError }) => {
20753
21103
  }
20754
21104
  return result;
20755
21105
  });
21106
+ /**
21107
+ * Executes a provided function within a managed scope, handling session creation, validation, and cleanup.
21108
+ * @template T - Type of the result returned by the run function.
21109
+ * @param {Function} runFn - The function to execute, receiving clientId and agentName as arguments.
21110
+ * @param {IScopeOptions} options - Configuration options for the scope operation.
21111
+ * @returns {Promise<T | void>} The result of the run function or void if no result is returned.
21112
+ * @throws {Error} If a session already exists for the clientId.
21113
+ */
21114
+ function fork(runFn, options) {
21115
+ return forkInternal(runFn, options);
21116
+ }
20756
21117
 
20757
21118
  /**
20758
21119
  * @module scope
@@ -20765,14 +21126,9 @@ const fork = beginContext(async (runFn, { clientId, swarmName, onError }) => {
20765
21126
  */
20766
21127
  const METHOD_NAME$e = "function.target.scope";
20767
21128
  /**
20768
- * @function scope
20769
- * @description Executes a provided function within a schema context, with optional overrides for schema services such as agents, completions, and pipelines.
20770
- * @template T - Type of the result returned by the run function.
20771
- * @param {Function} runFn - The function to execute within the schema context.
20772
- * @param {Partial<ISchemaContext["registry"]>} [options] - Optional overrides for schema services, with defaults from the swarm's schema services.
20773
- * @returns {Promise<T>} The result of the executed function.
21129
+ * Function implementation
20774
21130
  */
20775
- const scope = beginContext(async (runFn, { agentSchemaService = swarm$1.agentSchemaService.registry, completionSchemaService = swarm$1.completionSchemaService.registry, computeSchemaService = swarm$1.computeSchemaService.registry, embeddingSchemaService = swarm$1.embeddingSchemaService.registry, mcpSchemaService = swarm$1.mcpSchemaService.registry, pipelineSchemaService = swarm$1.pipelineSchemaService.registry, policySchemaService = swarm$1.policySchemaService.registry, stateSchemaService = swarm$1.stateSchemaService.registry, storageSchemaService = swarm$1.storageSchemaService.registry, swarmSchemaService = swarm$1.swarmSchemaService.registry, toolSchemaService = swarm$1.toolSchemaService.registry, wikiSchemaService = swarm$1.wikiSchemaService.registry, } = {}) => {
21131
+ const scopeInternal = beginContext(async (runFn, { agentSchemaService = swarm$1.agentSchemaService.registry, completionSchemaService = swarm$1.completionSchemaService.registry, computeSchemaService = swarm$1.computeSchemaService.registry, embeddingSchemaService = swarm$1.embeddingSchemaService.registry, mcpSchemaService = swarm$1.mcpSchemaService.registry, pipelineSchemaService = swarm$1.pipelineSchemaService.registry, policySchemaService = swarm$1.policySchemaService.registry, stateSchemaService = swarm$1.stateSchemaService.registry, storageSchemaService = swarm$1.storageSchemaService.registry, swarmSchemaService = swarm$1.swarmSchemaService.registry, toolSchemaService = swarm$1.toolSchemaService.registry, wikiSchemaService = swarm$1.wikiSchemaService.registry, } = {}) => {
20776
21132
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$e);
20777
21133
  return await SchemaContextService.runInContext(runFn, {
20778
21134
  registry: {
@@ -20791,6 +21147,16 @@ const scope = beginContext(async (runFn, { agentSchemaService = swarm$1.agentSch
20791
21147
  },
20792
21148
  });
20793
21149
  });
21150
+ /**
21151
+ * Executes a provided function within a schema context, with optional overrides for schema services such as agents, completions, and pipelines.
21152
+ * @template T - Type of the result returned by the run function.
21153
+ * @param {Function} runFn - The function to execute within the schema context.
21154
+ * @param {Partial<ISchemaContext["registry"]>} [options] - Optional overrides for schema services, with defaults from the swarm's schema services.
21155
+ * @returns {Promise<T>} The result of the executed function.
21156
+ */
21157
+ function scope(runFn, options) {
21158
+ return scopeInternal(runFn, options);
21159
+ }
20794
21160
 
20795
21161
  /**
20796
21162
  * @module startPipeline
@@ -20803,17 +21169,9 @@ const scope = beginContext(async (runFn, { agentSchemaService = swarm$1.agentSch
20803
21169
  */
20804
21170
  const METHOD_NAME$d = "function.target.startPipeline";
20805
21171
  /**
20806
- * @function startPipeline
20807
- * @description Executes a pipeline with the specified name, handling session creation, validation, and lifecycle callbacks.
20808
- * @template Payload - Type extending object for the pipeline payload.
20809
- * @template T - Type of the result returned by the pipeline execution.
20810
- * @param {string} clientId - The client identifier.
20811
- * @param {PipelineName} pipelineName - The name of the pipeline to execute.
20812
- * @param {AgentName} agentName - The name of the agent associated with the pipeline.
20813
- * @param {Payload} [payload={}] - Optional payload data for the pipeline.
20814
- * @returns {Promise<T>} The result of the pipeline execution.
21172
+ * Function implementation
20815
21173
  */
20816
- const startPipeline = beginContext(async (clientId, pipelineName, agentName, payload = {}) => {
21174
+ const startPipelineInternal = beginContext(async (clientId, pipelineName, agentName, payload = {}) => {
20817
21175
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
20818
21176
  swarm$1.loggerService.log(METHOD_NAME$d, {
20819
21177
  clientId,
@@ -20851,9 +21209,31 @@ const startPipeline = beginContext(async (clientId, pipelineName, agentName, pay
20851
21209
  }
20852
21210
  return result;
20853
21211
  });
21212
+ /**
21213
+ * @function startPipeline
21214
+ * @description Executes a pipeline with the specified name, handling session creation, validation, and lifecycle callbacks.
21215
+ * @template Payload - Type extending object for the pipeline payload.
21216
+ * @template T - Type of the result returned by the pipeline execution.
21217
+ * @param {string} clientId - The client identifier.
21218
+ * @param {PipelineName} pipelineName - The name of the pipeline to execute.
21219
+ * @param {AgentName} agentName - The name of the agent associated with the pipeline.
21220
+ * @param {Payload} [payload={}] - Optional payload data for the pipeline.
21221
+ * @returns {Promise<T>} The result of the pipeline execution.
21222
+ */
21223
+ function startPipeline(clientId, pipelineName, agentName, payload) {
21224
+ return startPipelineInternal(clientId, pipelineName, agentName, payload);
21225
+ }
20854
21226
 
20855
21227
  /** @private Constant defining the method name for logging purposes */
20856
21228
  const METHOD_NAME$c = "function.common.hasSession";
21229
+ /**
21230
+ * Function implementation
21231
+ */
21232
+ const hasSessionInternal = (clientId) => {
21233
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
21234
+ swarm$1.loggerService.log(METHOD_NAME$c, { clientId });
21235
+ return swarm$1.sessionValidationService.hasSession(clientId);
21236
+ };
20857
21237
  /**
20858
21238
  * Checks if a session exists for the given client ID.
20859
21239
  *
@@ -20863,29 +21243,15 @@ const METHOD_NAME$c = "function.common.hasSession";
20863
21243
  * @param {string} clientId - The unique identifier of the client whose session is being validated.
20864
21244
  * @returns {boolean} `true` if the session exists, otherwise `false`.
20865
21245
  */
20866
- const hasSession = (clientId) => {
20867
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
20868
- swarm$1.loggerService.log(METHOD_NAME$c, { clientId });
20869
- return swarm$1.sessionValidationService.hasSession(clientId);
20870
- };
21246
+ function hasSession(clientId) {
21247
+ return hasSessionInternal(clientId);
21248
+ }
20871
21249
 
20872
21250
  const METHOD_NAME$b = "function.common.getAgentHistory";
20873
21251
  /**
20874
- * Retrieves the history prepared for a specific agent, incorporating rescue algorithm tweaks.
20875
- *
20876
- * This function fetches the history tailored for a specified agent within a swarm session, applying any rescue strategies defined in the system (e.g., `CC_RESQUE_STRATEGY` from `GLOBAL_CONFIG`).
20877
- * It validates the client session and agent, logs the operation if enabled, and retrieves the history using the agent's prompt configuration via the history public service.
20878
- * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
20879
- *
20880
- * @param {string} clientId - The unique identifier of the client session requesting the history.
20881
- * @param {AgentName} agentName - The name of the agent whose history is being retrieved.
20882
- * @returns {Promise<IModelMessage[]>} A promise that resolves to an array of history messages (`IModelMessage[]`) prepared for the agent, including any rescue algorithm adjustments.
20883
- * @throws {Error} If validation fails (e.g., invalid session or agent) or if the history public service encounters an error during retrieval.
20884
- * @example
20885
- * const history = await getAgentHistory("client-123", "AgentX");
20886
- * console.log(history); // Outputs array of IModelMessage objects
21252
+ * Function implementation
20887
21253
  */
20888
- const getAgentHistory = beginContext(async (clientId, agentName) => {
21254
+ const getAgentHistoryInternal = beginContext(async (clientId, agentName) => {
20889
21255
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
20890
21256
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
20891
21257
  swarm$1.loggerService.log(METHOD_NAME$b, {
@@ -20902,23 +21268,27 @@ const getAgentHistory = beginContext(async (clientId, agentName) => {
20902
21268
  // Return a shallow copy of the history array
20903
21269
  return [...history];
20904
21270
  });
20905
-
20906
- const METHOD_NAME$a = "function.common.getSessionMode";
20907
21271
  /**
20908
- * Retrieves the session mode for a given client session in a swarm.
21272
+ * Retrieves the history prepared for a specific agent, incorporating rescue algorithm tweaks.
20909
21273
  *
20910
- * This function returns the current mode of the specified client session, which can be one of `"session"`, `"makeConnection"`, or `"complete"`.
20911
- * It validates the client session and associated swarm, logs the operation if enabled, and fetches the session mode using the session validation service.
21274
+ * This function fetches the history tailored for a specified agent within a swarm session, applying any rescue strategies defined in the system (e.g., `CC_RESQUE_STRATEGY` from `GLOBAL_CONFIG`).
21275
+ * It validates the client session and agent, logs the operation if enabled, and retrieves the history using the agent's prompt configuration via the history public service.
20912
21276
  * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
20913
21277
  *
20914
- * @param {string} clientId - The unique identifier of the client session whose mode is being retrieved.
20915
- * @returns {Promise<"session" | "makeConnection" | "complete">} A promise that resolves to the session mode, indicating the current state of the session.
20916
- * @throws {Error} If the client session is invalid, the swarm validation fails, or the session validation service encounters an error during mode retrieval.
21278
+ * @param {string} clientId - The unique identifier of the client session requesting the history.
21279
+ * @param {AgentName} agentName - The name of the agent whose history is being retrieved.
21280
+ * @returns {Promise<IModelMessage[]>} A promise that resolves to an array of history messages (`IModelMessage[]`) prepared for the agent, including any rescue algorithm adjustments.
21281
+ * @throws {Error} If validation fails (e.g., invalid session or agent) or if the history public service encounters an error during retrieval.
20917
21282
  * @example
20918
- * const mode = await getSessionMode("client-123");
20919
- * console.log(mode); // Outputs "session", "makeConnection", or "complete"
21283
+ * const history = await getAgentHistory("client-123", "AgentX");
21284
+ * console.log(history); // Outputs array of IModelMessage objects
20920
21285
  */
20921
- const getSessionMode = beginContext(async (clientId) => {
21286
+ function getAgentHistory(clientId, agentName) {
21287
+ return getAgentHistoryInternal(clientId, agentName);
21288
+ }
21289
+
21290
+ const METHOD_NAME$a = "function.common.getSessionMode";
21291
+ const getSessionModeInternal = beginContext(async (clientId) => {
20922
21292
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
20923
21293
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
20924
21294
  swarm$1.loggerService.log(METHOD_NAME$a, {
@@ -20931,22 +21301,29 @@ const getSessionMode = beginContext(async (clientId) => {
20931
21301
  // Retrieve the session mode from the session validation service
20932
21302
  return swarm$1.sessionValidationService.getSessionMode(clientId);
20933
21303
  });
20934
-
20935
- const METHOD_NAME$9 = "function.common.getSessionContext";
20936
21304
  /**
20937
- * Retrieves the session context for the current execution environment.
21305
+ * Retrieves the session mode for a given client session in a swarm.
20938
21306
  *
20939
- * This function constructs and returns the session context, including the client ID, process ID, and available method and execution contexts.
20940
- * It logs the operation if enabled, checks for active contexts using the `MethodContextService` and `ExecutionContextService`, and derives the client ID from either context if available.
20941
- * Unlike other functions, it does not perform explicit validation or require a `clientId` parameter, as it relies on the current execution environment's state.
21307
+ * This function returns the current mode of the specified client session, which can be one of `"session"`, `"makeConnection"`, or `"complete"`.
21308
+ * It validates the client session and associated swarm, logs the operation if enabled, and fetches the session mode using the session validation service.
21309
+ * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
20942
21310
  *
20943
- * @returns {Promise<ISessionContext>} A promise that resolves to an object containing the session context, including `clientId`, `processId`, `methodContext`, and `executionContext`.
20944
- * @throws {Error} If an unexpected error occurs while accessing the method or execution context services (though typically none are thrown in this implementation).
21311
+ * @param {string} clientId - The unique identifier of the client session whose mode is being retrieved.
21312
+ * @returns {Promise<"session" | "makeConnection" | "complete">} A promise that resolves to the session mode, indicating the current state of the session.
21313
+ * @throws {Error} If the client session is invalid, the swarm validation fails, or the session validation service encounters an error during mode retrieval.
20945
21314
  * @example
20946
- * const context = await getSessionContext();
20947
- * console.log(context); // Outputs { clientId: "client-123", processId: "uuid-xyz", methodContext: {...}, executionContext: {...} }
21315
+ * const mode = await getSessionMode("client-123");
21316
+ * console.log(mode); // Outputs "session", "makeConnection", or "complete"
21317
+ */
21318
+ function getSessionMode(clientId) {
21319
+ return getSessionModeInternal(clientId);
21320
+ }
21321
+
21322
+ const METHOD_NAME$9 = "function.common.getSessionContext";
21323
+ /**
21324
+ * Function implementation
20948
21325
  */
20949
- const getSessionContext = async () => {
21326
+ const getSessionContextInternal = async () => {
20950
21327
  // Log the operation if logging is enabled in GLOBAL_CONFIG
20951
21328
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
20952
21329
  swarm$1.loggerService.log(METHOD_NAME$9);
@@ -20968,6 +21345,22 @@ const getSessionContext = async () => {
20968
21345
  executionContext,
20969
21346
  };
20970
21347
  };
21348
+ /**
21349
+ * Retrieves the session context for the current execution environment.
21350
+ *
21351
+ * This function constructs and returns the session context, including the client ID, process ID, and available method and execution contexts.
21352
+ * It logs the operation if enabled, checks for active contexts using the `MethodContextService` and `ExecutionContextService`, and derives the client ID from either context if available.
21353
+ * Unlike other functions, it does not perform explicit validation or require a `clientId` parameter, as it relies on the current execution environment's state.
21354
+ *
21355
+ * @returns {Promise<ISessionContext>} A promise that resolves to an object containing the session context, including `clientId`, `processId`, `methodContext`, and `executionContext`.
21356
+ * @throws {Error} If an unexpected error occurs while accessing the method or execution context services (though typically none are thrown in this implementation).
21357
+ * @example
21358
+ * const context = await getSessionContext();
21359
+ * console.log(context); // Outputs { clientId: "client-123", processId: "uuid-xyz", methodContext: {...}, executionContext: {...} }
21360
+ */
21361
+ function getSessionContext() {
21362
+ return getSessionContextInternal();
21363
+ }
20971
21364
 
20972
21365
  /**
20973
21366
  * @private Constant defining the method name for logging purposes.
@@ -20975,14 +21368,9 @@ const getSessionContext = async () => {
20975
21368
  */
20976
21369
  const METHOD_NAME$8 = "function.common.getNavigationRoute";
20977
21370
  /**
20978
- * Retrieves the navigation route for a given client and swarm.
20979
- * Delegates to `NavigationValidationService.getNavigationRoute` to obtain a `Set` of visited agent names,
20980
- * with optional logging based on global configuration.
20981
- * @param {string} clientId - The unique identifier of the client requesting the navigation route.
20982
- * @param {SwarmName} swarmName - The name of the swarm context for which the route is retrieved.
20983
- * @returns {Set<string>} A set of `AgentName`s representing the visited agents in the navigation route.
21371
+ * Function implementation
20984
21372
  */
20985
- const getNavigationRoute = (clientId, swarmName) => {
21373
+ const getNavigationRouteInternal = (clientId, swarmName) => {
20986
21374
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
20987
21375
  swarm$1.loggerService.log(METHOD_NAME$8, {
20988
21376
  clientId,
@@ -20991,8 +21379,32 @@ const getNavigationRoute = (clientId, swarmName) => {
20991
21379
  swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$8);
20992
21380
  return swarm$1.navigationValidationService.getNavigationRoute(clientId, swarmName);
20993
21381
  };
21382
+ /**
21383
+ * Retrieves the navigation route for a given client and swarm.
21384
+ * Delegates to `NavigationValidationService.getNavigationRoute` to obtain a `Set` of visited agent names,
21385
+ * with optional logging based on global configuration.
21386
+ * @param {string} clientId - The unique identifier of the client requesting the navigation route.
21387
+ * @param {SwarmName} swarmName - The name of the swarm context for which the route is retrieved.
21388
+ * @returns {Set<string>} A set of `AgentName`s representing the visited agents in the navigation route.
21389
+ */
21390
+ function getNavigationRoute(clientId, swarmName) {
21391
+ return getNavigationRouteInternal(clientId, swarmName);
21392
+ }
20994
21393
 
20995
21394
  const METHOD_NAME$7 = "function.history.getUserHistory";
21395
+ /**
21396
+ * Function implementation
21397
+ */
21398
+ const getUserHistoryInternal = beginContext(async (clientId) => {
21399
+ // Log the operation details if logging is enabled in GLOBAL_CONFIG
21400
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
21401
+ swarm$1.loggerService.log(METHOD_NAME$7, {
21402
+ clientId,
21403
+ });
21404
+ // Fetch raw history and filter for user role and mode
21405
+ const history = await getRawHistoryInternal(clientId, METHOD_NAME$7);
21406
+ return history.filter(({ role, mode }) => role === "user" && mode === "user");
21407
+ });
20996
21408
  /**
20997
21409
  * Retrieves the user-specific history entries for a given client session.
20998
21410
  *
@@ -21007,18 +21419,24 @@ const METHOD_NAME$7 = "function.history.getUserHistory";
21007
21419
  * const userHistory = await getUserHistory("client-123");
21008
21420
  * console.log(userHistory); // Outputs array of user history entries
21009
21421
  */
21010
- const getUserHistory = beginContext(async (clientId) => {
21422
+ function getUserHistory(clientId) {
21423
+ return getUserHistoryInternal(clientId);
21424
+ }
21425
+
21426
+ const METHOD_NAME$6 = "function.history.getAssistantHistory";
21427
+ /**
21428
+ * Function implementation
21429
+ */
21430
+ const getAssistantHistoryInternal = beginContext(async (clientId) => {
21011
21431
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
21012
21432
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
21013
- swarm$1.loggerService.log(METHOD_NAME$7, {
21433
+ swarm$1.loggerService.log(METHOD_NAME$6, {
21014
21434
  clientId,
21015
21435
  });
21016
- // Fetch raw history and filter for user role and mode
21017
- const history = await getRawHistory(clientId, METHOD_NAME$7);
21018
- return history.filter(({ role, mode }) => role === "user" && mode === "user");
21436
+ // Fetch raw history and filter for assistant role
21437
+ const history = await getRawHistoryInternal(clientId, METHOD_NAME$6);
21438
+ return history.filter(({ role }) => role === "assistant");
21019
21439
  });
21020
-
21021
- const METHOD_NAME$6 = "function.history.getAssistantHistory";
21022
21440
  /**
21023
21441
  * Retrieves the assistant's history entries for a given client session.
21024
21442
  *
@@ -21033,18 +21451,25 @@ const METHOD_NAME$6 = "function.history.getAssistantHistory";
21033
21451
  * const assistantHistory = await getAssistantHistory("client-123");
21034
21452
  * console.log(assistantHistory); // Outputs array of assistant history entries
21035
21453
  */
21036
- const getAssistantHistory = beginContext(async (clientId) => {
21454
+ function getAssistantHistory(clientId) {
21455
+ return getAssistantHistoryInternal(clientId);
21456
+ }
21457
+
21458
+ const METHOD_NAME$5 = "function.history.getLastAssistantMessage";
21459
+ /**
21460
+ * Function implementation
21461
+ */
21462
+ const getLastAssistantMessageInternal = beginContext(async (clientId) => {
21037
21463
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
21038
21464
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
21039
- swarm$1.loggerService.log(METHOD_NAME$6, {
21465
+ swarm$1.loggerService.log(METHOD_NAME$5, {
21040
21466
  clientId,
21041
21467
  });
21042
- // Fetch raw history and filter for assistant role
21043
- const history = await getRawHistory(clientId, METHOD_NAME$6);
21044
- return history.filter(({ role }) => role === "assistant");
21468
+ // Fetch raw history and find the last assistant message
21469
+ const history = await getRawHistoryInternal(clientId, METHOD_NAME$5);
21470
+ const last = history.findLast(({ role }) => role === "assistant");
21471
+ return last?.content ? last.content : null;
21045
21472
  });
21046
-
21047
- const METHOD_NAME$5 = "function.history.getLastAssistantMessage";
21048
21473
  /**
21049
21474
  * Retrieves the content of the most recent assistant message from a client's session history.
21050
21475
  *
@@ -21059,19 +21484,25 @@ const METHOD_NAME$5 = "function.history.getLastAssistantMessage";
21059
21484
  * const lastMessage = await getLastAssistantMessage("client-123");
21060
21485
  * console.log(lastMessage); // Outputs the last assistant message or null
21061
21486
  */
21062
- const getLastAssistantMessage = beginContext(async (clientId) => {
21487
+ function getLastAssistantMessage(clientId) {
21488
+ return getLastAssistantMessageInternal(clientId);
21489
+ }
21490
+
21491
+ const METHOD_NAME$4 = "function.history.getLastSystemMessage";
21492
+ /**
21493
+ * Function implementation
21494
+ */
21495
+ const getLastSystemMessageInternal = beginContext(async (clientId) => {
21063
21496
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
21064
21497
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
21065
- swarm$1.loggerService.log(METHOD_NAME$5, {
21498
+ swarm$1.loggerService.log(METHOD_NAME$4, {
21066
21499
  clientId,
21067
21500
  });
21068
- // Fetch raw history and find the last assistant message
21069
- const history = await getRawHistory(clientId, METHOD_NAME$5);
21070
- const last = history.findLast(({ role }) => role === "assistant");
21071
- return last?.content ? last.content : null;
21501
+ // Fetch raw history and find the last system message
21502
+ const history = await getRawHistoryInternal(clientId, METHOD_NAME$4);
21503
+ const last = history.findLast(({ role }) => role === "system");
21504
+ return last ? last.content : null;
21072
21505
  });
21073
-
21074
- const METHOD_NAME$4 = "function.history.getLastSystemMessage";
21075
21506
  /**
21076
21507
  * Retrieves the content of the most recent system message from a client's session history.
21077
21508
  *
@@ -21086,17 +21517,9 @@ const METHOD_NAME$4 = "function.history.getLastSystemMessage";
21086
21517
  * const lastMessage = await getLastSystemMessage("client-123");
21087
21518
  * console.log(lastMessage); // Outputs the last system message or null
21088
21519
  */
21089
- const getLastSystemMessage = beginContext(async (clientId) => {
21090
- // Log the operation details if logging is enabled in GLOBAL_CONFIG
21091
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
21092
- swarm$1.loggerService.log(METHOD_NAME$4, {
21093
- clientId,
21094
- });
21095
- // Fetch raw history and find the last system message
21096
- const history = await getRawHistory(clientId, METHOD_NAME$4);
21097
- const last = history.findLast(({ role }) => role === "system");
21098
- return last ? last.content : null;
21099
- });
21520
+ function getLastSystemMessage(clientId) {
21521
+ return getLastSystemMessageInternal(clientId);
21522
+ }
21100
21523
 
21101
21524
  const METHOD_NAME$3 = "function.event.listenEvent";
21102
21525
  /**
@@ -21114,24 +21537,9 @@ const DISALLOWED_EVENT_SOURCE_LIST$2 = new Set([
21114
21537
  "policy-bus",
21115
21538
  ]);
21116
21539
  /**
21117
- * Emits a custom event to the swarm bus service.
21118
- *
21119
- * This function sends a custom event with a specified topic and payload to the swarm's bus service, allowing clients to broadcast messages
21120
- * for other components to listen to. It is wrapped in `beginContext` for a clean execution environment and logs the operation if enabled.
21121
- * The function enforces a restriction on reserved topic names (defined in `DISALLOWED_EVENT_SOURCE_LIST`), throwing an error if a reserved
21122
- * topic is used. The event is structured as an `ICustomEvent` with the provided `clientId`, `topicName` as the source, and `payload`.
21123
- *
21124
- * @template T - The type of the payload, defaulting to `any` if unspecified.
21125
- * @param {string} clientId - The unique identifier of the client emitting the event.
21126
- * @param {string} topicName - The name of the event topic (must not be a reserved source).
21127
- * @param {T} payload - The payload data to be included in the event.
21128
- * @returns {Promise<void>} A promise that resolves when the event is successfully emitted.
21129
- * @throws {Error} If the `topicName` is a reserved event source (e.g., "agent-bus", "session-bus").
21130
- * @example
21131
- * await event("client-123", "custom-topic", { message: "Hello, swarm!" });
21132
- * // Emits an event with topic "custom-topic" and payload { message: "Hello, swarm!" }
21540
+ * Function implementation
21133
21541
  */
21134
- const event = beginContext((clientId, topicName, payload) => {
21542
+ const eventInternal = beginContext((clientId, topicName, payload) => {
21135
21543
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
21136
21544
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
21137
21545
  swarm$1.loggerService.log(METHOD_NAME$3, {
@@ -21148,6 +21556,27 @@ const event = beginContext((clientId, topicName, payload) => {
21148
21556
  clientId,
21149
21557
  });
21150
21558
  });
21559
+ /**
21560
+ * Emits a custom event to the swarm bus service.
21561
+ *
21562
+ * This function sends a custom event with a specified topic and payload to the swarm's bus service, allowing clients to broadcast messages
21563
+ * for other components to listen to. It is wrapped in `beginContext` for a clean execution environment and logs the operation if enabled.
21564
+ * The function enforces a restriction on reserved topic names (defined in `DISALLOWED_EVENT_SOURCE_LIST`), throwing an error if a reserved
21565
+ * topic is used. The event is structured as an `ICustomEvent` with the provided `clientId`, `topicName` as the source, and `payload`.
21566
+ *
21567
+ * @template T - The type of the payload, defaulting to `any` if unspecified.
21568
+ * @param {string} clientId - The unique identifier of the client emitting the event.
21569
+ * @param {string} topicName - The name of the event topic (must not be a reserved source).
21570
+ * @param {T} payload - The payload data to be included in the event.
21571
+ * @returns {Promise<void>} A promise that resolves when the event is successfully emitted.
21572
+ * @throws {Error} If the `topicName` is a reserved event source (e.g., "agent-bus", "session-bus").
21573
+ * @example
21574
+ * await event("client-123", "custom-topic", { message: "Hello, swarm!" });
21575
+ * // Emits an event with topic "custom-topic" and payload { message: "Hello, swarm!" }
21576
+ */
21577
+ function event(clientId, topicName, payload) {
21578
+ return eventInternal(clientId, topicName, payload);
21579
+ }
21151
21580
 
21152
21581
  const METHOD_NAME$2 = "function.event.listenEvent";
21153
21582
  /**
@@ -21178,6 +21607,24 @@ const validateClientId$g = (clientId) => {
21178
21607
  throw new Error(`agent-swarm listenEvent session not found for clientId=${clientId}`);
21179
21608
  }
21180
21609
  };
21610
+ /**
21611
+ * Function implementation
21612
+ */
21613
+ const listenEventInternal = beginContext((clientId, topicName, fn) => {
21614
+ // Log the operation details if logging is enabled in GLOBAL_CONFIG
21615
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
21616
+ swarm$1.loggerService.log(METHOD_NAME$2, {
21617
+ clientId,
21618
+ });
21619
+ // Check if the topic name is reserved
21620
+ if (DISALLOWED_EVENT_SOURCE_LIST$1.has(topicName)) {
21621
+ throw new Error(`agent-swarm listenEvent topic is reserved topicName=${topicName}`);
21622
+ }
21623
+ // Validate the client ID
21624
+ validateClientId$g(clientId);
21625
+ // Subscribe to the event with a queued callback
21626
+ return swarm$1.busService.subscribe(clientId, topicName, functoolsKit.queued(async ({ payload }) => await fn(payload)));
21627
+ });
21181
21628
  /**
21182
21629
  * Subscribes to a custom event on the swarm bus service and executes a callback when the event is received.
21183
21630
  *
@@ -21198,21 +21645,9 @@ const validateClientId$g = (clientId) => {
21198
21645
  * // Logs payload when "custom-topic" event is received for "client-123"
21199
21646
  * unsubscribe(); // Stops listening
21200
21647
  */
21201
- const listenEvent = beginContext((clientId, topicName, fn) => {
21202
- // Log the operation details if logging is enabled in GLOBAL_CONFIG
21203
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
21204
- swarm$1.loggerService.log(METHOD_NAME$2, {
21205
- clientId,
21206
- });
21207
- // Check if the topic name is reserved
21208
- if (DISALLOWED_EVENT_SOURCE_LIST$1.has(topicName)) {
21209
- throw new Error(`agent-swarm listenEvent topic is reserved topicName=${topicName}`);
21210
- }
21211
- // Validate the client ID
21212
- validateClientId$g(clientId);
21213
- // Subscribe to the event with a queued callback
21214
- return swarm$1.busService.subscribe(clientId, topicName, functoolsKit.queued(async ({ payload }) => await fn(payload)));
21215
- });
21648
+ function listenEvent(clientId, topicName, fn) {
21649
+ return listenEventInternal(clientId, topicName, fn);
21650
+ }
21216
21651
 
21217
21652
  const METHOD_NAME$1 = "function.event.listenEventOnce";
21218
21653
  /**
@@ -21243,6 +21678,24 @@ const validateClientId$f = (clientId) => {
21243
21678
  throw new Error(`agent-swarm listenEventOnce session not found for clientId=${clientId}`);
21244
21679
  }
21245
21680
  };
21681
+ /**
21682
+ * Function implementation
21683
+ */
21684
+ const listenEventOnceInternal = beginContext((clientId, topicName, filterFn, fn) => {
21685
+ // Log the operation details if logging is enabled in GLOBAL_CONFIG
21686
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
21687
+ swarm$1.loggerService.log(METHOD_NAME$1, {
21688
+ clientId,
21689
+ });
21690
+ // Check if the topic name is reserved
21691
+ if (DISALLOWED_EVENT_SOURCE_LIST.has(topicName)) {
21692
+ throw new Error(`agent-swarm listenEventOnce topic is reserved topicName=${topicName}`);
21693
+ }
21694
+ // Validate the client ID
21695
+ validateClientId$f(clientId);
21696
+ // Subscribe to the event for one occurrence with a filter and queued callback
21697
+ return swarm$1.busService.once(clientId, topicName, ({ payload }) => filterFn(payload), functoolsKit.queued(async ({ payload }) => await fn(payload)));
21698
+ });
21246
21699
  /**
21247
21700
  * Subscribes to a custom event on the swarm bus service for a single occurrence, executing a callback when the event matches a filter.
21248
21701
  *
@@ -21269,21 +21722,9 @@ const validateClientId$f = (clientId) => {
21269
21722
  * // Logs payload once when "custom-topic" event with value > 0 is received
21270
21723
  * unsubscribe(); // Cancels listener if not yet triggered
21271
21724
  */
21272
- const listenEventOnce = beginContext((clientId, topicName, filterFn, fn) => {
21273
- // Log the operation details if logging is enabled in GLOBAL_CONFIG
21274
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
21275
- swarm$1.loggerService.log(METHOD_NAME$1, {
21276
- clientId,
21277
- });
21278
- // Check if the topic name is reserved
21279
- if (DISALLOWED_EVENT_SOURCE_LIST.has(topicName)) {
21280
- throw new Error(`agent-swarm listenEventOnce topic is reserved topicName=${topicName}`);
21281
- }
21282
- // Validate the client ID
21283
- validateClientId$f(clientId);
21284
- // Subscribe to the event for one occurrence with a filter and queued callback
21285
- return swarm$1.busService.once(clientId, topicName, ({ payload }) => filterFn(payload), functoolsKit.queued(async ({ payload }) => await fn(payload)));
21286
- });
21725
+ function listenEventOnce(clientId, topicName, filterFn, fn) {
21726
+ return listenEventOnceInternal(clientId, topicName, filterFn, fn);
21727
+ }
21287
21728
 
21288
21729
  const METHOD_NAME = "function.navigate.changeToPrevAgent";
21289
21730
  /**
@@ -21331,19 +21772,9 @@ const createGc = functoolsKit.singleshot(async () => {
21331
21772
  });
21332
21773
  });
21333
21774
  /**
21334
- * Navigates back to the previous or default agent for a given client session in a swarm.
21335
- *
21336
- * This function switches the active agent to the previous agent in the navigation stack, or the default agent if no previous agent exists,
21337
- * as determined by the `navigationPop` method. It validates the session and agent, logs the operation if enabled, and executes the change using a TTL-limited, queued runner.
21338
- * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts.
21339
- *
21340
- * @param {string} clientId - The unique identifier of the client session.
21341
- * @returns {Promise<boolean>} A promise that resolves when the agent change is complete. If navigation stack contains recursion does nothing
21342
- * @throws {Error} If session or agent validation fails, or if the agent change process encounters an error.
21343
- * @example
21344
- * await changeToPrevAgent("client-123");
21775
+ * Function implementation
21345
21776
  */
21346
- const changeToPrevAgent = beginContext(async (clientId) => {
21777
+ const changeToPrevAgentInternal = beginContext(async (clientId) => {
21347
21778
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
21348
21779
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
21349
21780
  swarm$1.loggerService.log(METHOD_NAME, {
@@ -21361,6 +21792,22 @@ const changeToPrevAgent = beginContext(async (clientId) => {
21361
21792
  createGc();
21362
21793
  return await run(METHOD_NAME, agentName, swarmName);
21363
21794
  });
21795
+ /**
21796
+ * Navigates back to the previous or default agent for a given client session in a swarm.
21797
+ *
21798
+ * This function switches the active agent to the previous agent in the navigation stack, or the default agent if no previous agent exists,
21799
+ * as determined by the `navigationPop` method. It validates the session and agent, logs the operation if enabled, and executes the change using a TTL-limited, queued runner.
21800
+ * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts.
21801
+ *
21802
+ * @param {string} clientId - The unique identifier of the client session.
21803
+ * @returns {Promise<boolean>} A promise that resolves when the agent change is complete. If navigation stack contains recursion does nothing
21804
+ * @throws {Error} If session or agent validation fails, or if the agent change process encounters an error.
21805
+ * @example
21806
+ * await changeToPrevAgent("client-123");
21807
+ */
21808
+ function changeToPrevAgent(clientId) {
21809
+ return changeToPrevAgentInternal(clientId);
21810
+ }
21364
21811
 
21365
21812
  /**
21366
21813
  * Validates the client ID for agent event listening, allowing wildcard "*" or checking for an active session.