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