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