agent-swarm-kit 1.1.5 → 1.1.7
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 +1042 -420
- package/build/index.mjs +1041 -422
- package/package.json +1 -1
- package/types.d.ts +242 -22
package/build/index.cjs
CHANGED
|
@@ -53,6 +53,7 @@ const connectionServices$1 = {
|
|
|
53
53
|
stateConnectionService: Symbol('stateConnectionService'),
|
|
54
54
|
sharedStateConnectionService: Symbol('sharedStateConnectionService'),
|
|
55
55
|
policyConnectionService: Symbol('policyConnectionService'),
|
|
56
|
+
mcpConnectionService: Symbol('mcpConnectionService'),
|
|
56
57
|
};
|
|
57
58
|
const schemaServices$1 = {
|
|
58
59
|
completionSchemaService: Symbol('completionSchemaService'),
|
|
@@ -65,6 +66,7 @@ const schemaServices$1 = {
|
|
|
65
66
|
memorySchemaService: Symbol('memorySchemaService'),
|
|
66
67
|
policySchemaService: Symbol('policySchemaService'),
|
|
67
68
|
wikiSchemaService: Symbol('wikiSchemaService'),
|
|
69
|
+
mcpSchemaService: Symbol('mcpSchemaService'),
|
|
68
70
|
};
|
|
69
71
|
const metaServices$1 = {
|
|
70
72
|
agentMetaService: Symbol('agentMetaService'),
|
|
@@ -80,6 +82,7 @@ const publicServices$1 = {
|
|
|
80
82
|
statePublicService: Symbol('statePublicService'),
|
|
81
83
|
sharedStatePublicService: Symbol('sharedStatePublicService'),
|
|
82
84
|
policyPublicService: Symbol('policyPublicService'),
|
|
85
|
+
mcpPublicService: Symbol('mcpPublicService'),
|
|
83
86
|
};
|
|
84
87
|
const validationServices$1 = {
|
|
85
88
|
agentValidationService: Symbol('agentValidationService'),
|
|
@@ -92,6 +95,7 @@ const validationServices$1 = {
|
|
|
92
95
|
policyValidationService: Symbol('policyValidationService'),
|
|
93
96
|
navigationValidationService: Symbol('navigationValidationService'),
|
|
94
97
|
wikiValidationService: Symbol('wikiValidationService'),
|
|
98
|
+
mcpValidationService: Symbol('mcpValidationService'),
|
|
95
99
|
};
|
|
96
100
|
const TYPES = {
|
|
97
101
|
...baseServices$1,
|
|
@@ -2611,6 +2615,7 @@ class LoggerUtils {
|
|
|
2611
2615
|
stateName: "",
|
|
2612
2616
|
storageName: "",
|
|
2613
2617
|
swarmName: "",
|
|
2618
|
+
mcpName: "",
|
|
2614
2619
|
});
|
|
2615
2620
|
});
|
|
2616
2621
|
/**
|
|
@@ -2639,6 +2644,7 @@ class LoggerUtils {
|
|
|
2639
2644
|
stateName: "",
|
|
2640
2645
|
storageName: "",
|
|
2641
2646
|
swarmName: "",
|
|
2647
|
+
mcpName: "",
|
|
2642
2648
|
});
|
|
2643
2649
|
});
|
|
2644
2650
|
/**
|
|
@@ -2667,6 +2673,7 @@ class LoggerUtils {
|
|
|
2667
2673
|
stateName: "",
|
|
2668
2674
|
storageName: "",
|
|
2669
2675
|
swarmName: "",
|
|
2676
|
+
mcpName: "",
|
|
2670
2677
|
});
|
|
2671
2678
|
});
|
|
2672
2679
|
/**
|
|
@@ -3434,6 +3441,16 @@ class AgentSchemaService {
|
|
|
3434
3441
|
if (agentSchema.tools?.some((value) => typeof value !== "string")) {
|
|
3435
3442
|
throw new Error(`agent-swarm agent schema validation failed: invalid tools for agentName=${agentSchema.agentName} tools=[${agentSchema.tools}]`);
|
|
3436
3443
|
}
|
|
3444
|
+
if (agentSchema.mcp && !Array.isArray(agentSchema.mcp)) {
|
|
3445
|
+
throw new Error(`agent-swarm agent schema validation failed: invalid mcp for agentName=${agentSchema.agentName} mcp=${agentSchema.mcp}`);
|
|
3446
|
+
}
|
|
3447
|
+
if (agentSchema.mcp &&
|
|
3448
|
+
agentSchema.mcp.length !== new Set(agentSchema.mcp).size) {
|
|
3449
|
+
throw new Error(`agent-swarm agent schema validation failed: found duplicate mcp for agentName=${agentSchema.agentName} mcp=[${agentSchema.mcp}]`);
|
|
3450
|
+
}
|
|
3451
|
+
if (agentSchema.mcp?.some((value) => typeof value !== "string")) {
|
|
3452
|
+
throw new Error(`agent-swarm agent schema validation failed: invalid mcp for agentName=${agentSchema.agentName} mcp=[${agentSchema.mcp}]`);
|
|
3453
|
+
}
|
|
3437
3454
|
};
|
|
3438
3455
|
/**
|
|
3439
3456
|
* Registers a new agent schema in the registry after validation.
|
|
@@ -3579,6 +3596,51 @@ const createToolCall = async (idx, tool, toolCalls, targetFn, self) => {
|
|
|
3579
3596
|
self._toolErrorSubject.next(TOOL_ERROR_SYMBOL);
|
|
3580
3597
|
}
|
|
3581
3598
|
};
|
|
3599
|
+
/**
|
|
3600
|
+
* Maps an MCP (Model-Context-Protocol) tool definition to an `IAgentTool` object.
|
|
3601
|
+
* This function transforms the MCP tool's schema and properties into a format compatible with the agent's tool system.
|
|
3602
|
+
* It also defines the tool's behavior, including its call method and parameter validation.
|
|
3603
|
+
*
|
|
3604
|
+
* @param {Object} tool - The MCP tool definition containing its name, description, and input schema.
|
|
3605
|
+
* @param {string} tool.name - The name of the MCP tool.
|
|
3606
|
+
* @param {string} [tool.description=tool.name] - A description of the MCP tool. Defaults to the tool's name if not provided.
|
|
3607
|
+
* @param {Object} [tool.inputSchema] - The input schema for the MCP tool, defining its parameters and validation rules.
|
|
3608
|
+
* @param {Object} [tool.inputSchema.properties] - The properties of the input schema, where each key represents a parameter.
|
|
3609
|
+
* @param {string[]} [tool.inputSchema.required] - An array of required parameter names for the tool.
|
|
3610
|
+
* @param {ClientAgent} self - The `ClientAgent` instance, providing context such as the agent's name, client ID, and logger.
|
|
3611
|
+
*
|
|
3612
|
+
* @returns {IAgentTool} An object representing the mapped tool, including its name, type, function definition, and call behavior.
|
|
3613
|
+
*/
|
|
3614
|
+
const mapMcpToolCall = ({ name, description = name, inputSchema }, self) => {
|
|
3615
|
+
const mcpProperties = inputSchema
|
|
3616
|
+
? inputSchema.properties ?? {}
|
|
3617
|
+
: {};
|
|
3618
|
+
return {
|
|
3619
|
+
toolName: `mcp_${name}`,
|
|
3620
|
+
type: "function",
|
|
3621
|
+
function: {
|
|
3622
|
+
name,
|
|
3623
|
+
description,
|
|
3624
|
+
parameters: {
|
|
3625
|
+
type: "object",
|
|
3626
|
+
properties: Object.entries(mcpProperties).reduce((acm, [key, { type, description = type, enum: e }]) => ({
|
|
3627
|
+
...acm,
|
|
3628
|
+
[key]: {
|
|
3629
|
+
type,
|
|
3630
|
+
description,
|
|
3631
|
+
enum: e,
|
|
3632
|
+
},
|
|
3633
|
+
}), {}),
|
|
3634
|
+
required: inputSchema.required,
|
|
3635
|
+
},
|
|
3636
|
+
},
|
|
3637
|
+
call: async (dto) => {
|
|
3638
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
3639
|
+
self.params.logger.debug(`ClientAgent agentName=${self.params.agentName} clientId=${self.params.clientId} calling MCP tool toolName=${name}`);
|
|
3640
|
+
await self.params.mcp.callTool(name, dto);
|
|
3641
|
+
},
|
|
3642
|
+
};
|
|
3643
|
+
};
|
|
3582
3644
|
/**
|
|
3583
3645
|
* Runs a stateless completion for the incoming message, returning the transformed result.
|
|
3584
3646
|
* Returns an empty string if tool calls are present or validation fails, avoiding further processing.
|
|
@@ -3604,7 +3666,7 @@ const RUN_FN = async (incoming, self) => {
|
|
|
3604
3666
|
agentName: self.params.agentName,
|
|
3605
3667
|
messages,
|
|
3606
3668
|
mode: "user",
|
|
3607
|
-
tools:
|
|
3669
|
+
tools: [],
|
|
3608
3670
|
};
|
|
3609
3671
|
const rawMessage = await self.params.completion.getCompletion(args);
|
|
3610
3672
|
self.params.completion.callbacks?.onComplete &&
|
|
@@ -3660,7 +3722,8 @@ const EXECUTE_FN = async (incoming, mode, self) => {
|
|
|
3660
3722
|
agentName: self.params.agentName,
|
|
3661
3723
|
content: incoming.trim(),
|
|
3662
3724
|
});
|
|
3663
|
-
const
|
|
3725
|
+
const toolList = await self._resolveTools();
|
|
3726
|
+
const rawMessage = await self.getCompletion(mode, toolList);
|
|
3664
3727
|
const message = await self.params.map(rawMessage, self.params.clientId, self.params.agentName);
|
|
3665
3728
|
if (message.tool_calls?.length) {
|
|
3666
3729
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
@@ -3679,10 +3742,10 @@ const EXECUTE_FN = async (incoming, mode, self) => {
|
|
|
3679
3742
|
const [runAwaiter, { resolve: run }] = functoolsKit.createAwaiter();
|
|
3680
3743
|
for (let idx = 0; idx !== toolCalls.length; idx++) {
|
|
3681
3744
|
const tool = toolCalls[idx];
|
|
3682
|
-
const targetFn =
|
|
3745
|
+
const targetFn = toolList.find((t) => t.function.name === tool.function.name);
|
|
3683
3746
|
if (!targetFn) {
|
|
3684
3747
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
3685
|
-
self.params.logger.debug(`ClientAgent agentName=${self.params.agentName} clientId=${self.params.clientId} functionName=${tool.function.name} tool function not found`,
|
|
3748
|
+
self.params.logger.debug(`ClientAgent agentName=${self.params.agentName} clientId=${self.params.clientId} functionName=${tool.function.name} tool function not found`, toolList);
|
|
3686
3749
|
const result = await self._resurrectModel(mode, `No target function for ${tool.function.name}`);
|
|
3687
3750
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
3688
3751
|
self.params.logger.debug(`ClientAgent agentName=${self.params.agentName} clientId=${self.params.clientId} execute end result=${result}`);
|
|
@@ -3887,6 +3950,33 @@ class ClientAgent {
|
|
|
3887
3950
|
});
|
|
3888
3951
|
this.params.onInit && this.params.onInit(params.clientId, params.agentName);
|
|
3889
3952
|
}
|
|
3953
|
+
async _resolveTools() {
|
|
3954
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
3955
|
+
this.params.logger.debug(`ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} _resolveTools`);
|
|
3956
|
+
const seen = new Set();
|
|
3957
|
+
const agentToolList = this.params.tools
|
|
3958
|
+
? this.params.tools
|
|
3959
|
+
: [];
|
|
3960
|
+
const mcpToolList = await this.params.mcp.listTools(this.params.clientId);
|
|
3961
|
+
if (mcpToolList.length) {
|
|
3962
|
+
return agentToolList
|
|
3963
|
+
.concat(mcpToolList.map((tool) => mapMcpToolCall(tool, this)))
|
|
3964
|
+
.filter(({ function: { name } }) => {
|
|
3965
|
+
if (!seen.has(name)) {
|
|
3966
|
+
seen.add(name);
|
|
3967
|
+
return true;
|
|
3968
|
+
}
|
|
3969
|
+
return false;
|
|
3970
|
+
});
|
|
3971
|
+
}
|
|
3972
|
+
return agentToolList.filter(({ function: { name } }) => {
|
|
3973
|
+
if (!seen.has(name)) {
|
|
3974
|
+
seen.add(name);
|
|
3975
|
+
return true;
|
|
3976
|
+
}
|
|
3977
|
+
return false;
|
|
3978
|
+
});
|
|
3979
|
+
}
|
|
3890
3980
|
/**
|
|
3891
3981
|
* Resolves the system prompt by combining static and dynamic system messages.
|
|
3892
3982
|
* Static messages are directly included from the `systemStatic` parameter, while dynamic messages
|
|
@@ -4013,7 +4103,7 @@ class ClientAgent {
|
|
|
4013
4103
|
await this._resqueSubject.next(MODEL_RESQUE_SYMBOL);
|
|
4014
4104
|
return placeholder;
|
|
4015
4105
|
}
|
|
4016
|
-
const rawMessage = await this.getCompletion(mode);
|
|
4106
|
+
const rawMessage = await this.getCompletion(mode, []);
|
|
4017
4107
|
if (rawMessage.tool_calls?.length) {
|
|
4018
4108
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4019
4109
|
this.params.logger.debug(`ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} _resurrectModel should not emit tool_calls`);
|
|
@@ -4066,7 +4156,7 @@ class ClientAgent {
|
|
|
4066
4156
|
* @param {ExecutionMode} mode - The execution mode (e.g., "user" or "tool"), determining context.
|
|
4067
4157
|
* @returns {Promise<IModelMessage>} The completion message from the model, with content defaulted to an empty string if null.
|
|
4068
4158
|
*/
|
|
4069
|
-
async getCompletion(mode) {
|
|
4159
|
+
async getCompletion(mode, tools) {
|
|
4070
4160
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4071
4161
|
this.params.logger.debug(`ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} getCompletion`);
|
|
4072
4162
|
const messages = await this.params.history.toArrayForAgent(this.params.prompt ?? "", await this._resolveSystemPrompt());
|
|
@@ -4075,7 +4165,7 @@ class ClientAgent {
|
|
|
4075
4165
|
agentName: this.params.agentName,
|
|
4076
4166
|
messages,
|
|
4077
4167
|
mode,
|
|
4078
|
-
tools:
|
|
4168
|
+
tools: tools.map((t) => lodashEs.omit(t, "toolName", "docNote", "call", "validate", "callbacks")),
|
|
4079
4169
|
};
|
|
4080
4170
|
const output = await this.params.completion.getCompletion(args);
|
|
4081
4171
|
if (GLOBAL_CONFIG.CC_RESQUE_STRATEGY === "flush") {
|
|
@@ -4119,7 +4209,7 @@ class ClientAgent {
|
|
|
4119
4209
|
agentName: this.params.agentName,
|
|
4120
4210
|
messages,
|
|
4121
4211
|
mode,
|
|
4122
|
-
tools:
|
|
4212
|
+
tools: tools.map((t) => lodashEs.omit(t, "toolName", "docNote", "call", "validate", "callbacks")),
|
|
4123
4213
|
};
|
|
4124
4214
|
const output = await this.params.completion.getCompletion(args);
|
|
4125
4215
|
this.params.completion.callbacks?.onComplete &&
|
|
@@ -4557,6 +4647,84 @@ class ClientOperator {
|
|
|
4557
4647
|
}
|
|
4558
4648
|
}
|
|
4559
4649
|
|
|
4650
|
+
class NoopMCP {
|
|
4651
|
+
constructor(agentName) {
|
|
4652
|
+
this.agentName = agentName;
|
|
4653
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4654
|
+
swarm$1.loggerService.debug(`NoopMCP CTOR agentName=${agentName}`);
|
|
4655
|
+
}
|
|
4656
|
+
async listTools(clientId) {
|
|
4657
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4658
|
+
swarm$1.loggerService.debug(`NoopMCP listTools agentName=${this.agentName}`, {
|
|
4659
|
+
clientId,
|
|
4660
|
+
});
|
|
4661
|
+
return [];
|
|
4662
|
+
}
|
|
4663
|
+
hasTool(toolName, clientId) {
|
|
4664
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4665
|
+
swarm$1.loggerService.debug(`NoopMCP hasTool agentName=${this.agentName}`, {
|
|
4666
|
+
toolName,
|
|
4667
|
+
clientId,
|
|
4668
|
+
});
|
|
4669
|
+
return Promise.resolve(false);
|
|
4670
|
+
}
|
|
4671
|
+
async callTool(toolName, dto) {
|
|
4672
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4673
|
+
swarm$1.loggerService.debug(`NoopMCP callTool agentName=${this.agentName}`, {
|
|
4674
|
+
toolName,
|
|
4675
|
+
dto,
|
|
4676
|
+
});
|
|
4677
|
+
throw new Error(`NoopPolicy callTool should not be called agentName=${this.agentName} toolName=${toolName}`);
|
|
4678
|
+
}
|
|
4679
|
+
}
|
|
4680
|
+
class MergeMCP {
|
|
4681
|
+
constructor(mcpList, agentName) {
|
|
4682
|
+
this.mcpList = mcpList;
|
|
4683
|
+
this.agentName = agentName;
|
|
4684
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4685
|
+
swarm$1.loggerService.debug(`MergeMCP CTOR agentName=${agentName}`, {
|
|
4686
|
+
mcpList,
|
|
4687
|
+
});
|
|
4688
|
+
}
|
|
4689
|
+
async listTools(clientId) {
|
|
4690
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4691
|
+
swarm$1.loggerService.debug(`MergeMCP listTools agentName=${this.agentName}`, {
|
|
4692
|
+
clientId,
|
|
4693
|
+
});
|
|
4694
|
+
const toolList = [];
|
|
4695
|
+
for (const mcp of this.mcpList) {
|
|
4696
|
+
toolList.push(await mcp.listTools(clientId));
|
|
4697
|
+
}
|
|
4698
|
+
return toolList.flatMap((tools) => tools);
|
|
4699
|
+
}
|
|
4700
|
+
async hasTool(toolName, clientId) {
|
|
4701
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4702
|
+
swarm$1.loggerService.debug(`MergeMCP hasTool agentName=${this.agentName}`, {
|
|
4703
|
+
toolName,
|
|
4704
|
+
clientId,
|
|
4705
|
+
});
|
|
4706
|
+
for (const mcp of this.mcpList) {
|
|
4707
|
+
if (await mcp.hasTool(toolName, clientId)) {
|
|
4708
|
+
return true;
|
|
4709
|
+
}
|
|
4710
|
+
}
|
|
4711
|
+
return false;
|
|
4712
|
+
}
|
|
4713
|
+
async callTool(toolName, dto) {
|
|
4714
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4715
|
+
swarm$1.loggerService.debug(`MergeMCP callTool agentName=${this.agentName}`, {
|
|
4716
|
+
toolName,
|
|
4717
|
+
dto,
|
|
4718
|
+
});
|
|
4719
|
+
for (const mcp of this.mcpList) {
|
|
4720
|
+
if (await mcp.hasTool(toolName, dto.clientId)) {
|
|
4721
|
+
return await mcp.callTool(toolName, dto);
|
|
4722
|
+
}
|
|
4723
|
+
}
|
|
4724
|
+
throw new Error(`MergeMCP callTool agentName=${this.agentName} tool not found toolName=${toolName}`);
|
|
4725
|
+
}
|
|
4726
|
+
}
|
|
4727
|
+
|
|
4560
4728
|
/**
|
|
4561
4729
|
* Service class for managing agent connections and operations in the swarm system.
|
|
4562
4730
|
* Implements IAgent to provide an interface for agent instantiation, execution, message handling, and lifecycle management.
|
|
@@ -4637,6 +4805,13 @@ class AgentConnectionService {
|
|
|
4637
4805
|
* @private
|
|
4638
4806
|
*/
|
|
4639
4807
|
this.completionSchemaService = inject(TYPES.completionSchemaService);
|
|
4808
|
+
/**
|
|
4809
|
+
* MCP connection service instance, injected via DI, for retrieving external tools
|
|
4810
|
+
* Provides mcp integration logic to ClientAgent in getAgent, supporting agent tool execution.
|
|
4811
|
+
* @type {CompletionSchemaService}
|
|
4812
|
+
* @private
|
|
4813
|
+
*/
|
|
4814
|
+
this.mcpConnectionService = inject(TYPES.mcpConnectionService);
|
|
4640
4815
|
/**
|
|
4641
4816
|
* Retrieves or creates a memoized ClientAgent instance for a given client and agent.
|
|
4642
4817
|
* Uses functools-kit’s memoize to cache instances by a composite key (clientId-agentName), ensuring efficient reuse across calls.
|
|
@@ -4647,7 +4822,7 @@ class AgentConnectionService {
|
|
|
4647
4822
|
* @returns {ClientAgent} The memoized ClientAgent instance configured for the client and agent.
|
|
4648
4823
|
*/
|
|
4649
4824
|
this.getAgent = functoolsKit.memoize(([clientId, agentName]) => `${clientId}-${agentName}`, (clientId, agentName) => {
|
|
4650
|
-
const { prompt, system, operator, systemStatic = system, systemDynamic, tools, transform = GLOBAL_CONFIG.CC_AGENT_OUTPUT_TRANSFORM, map = GLOBAL_CONFIG.CC_AGENT_OUTPUT_MAP, maxToolCalls = GLOBAL_CONFIG.CC_MAX_TOOL_CALLS, mapToolCalls = GLOBAL_CONFIG.CC_AGENT_MAP_TOOLS, callbacks, storages, states, connectOperator = GLOBAL_CONFIG.CC_DEFAULT_CONNECT_OPERATOR, completion: completionName, validate = validateDefault, } = this.agentSchemaService.get(agentName);
|
|
4825
|
+
const { prompt, system, operator, systemStatic = system, systemDynamic, tools, transform = GLOBAL_CONFIG.CC_AGENT_OUTPUT_TRANSFORM, map = GLOBAL_CONFIG.CC_AGENT_OUTPUT_MAP, maxToolCalls = GLOBAL_CONFIG.CC_MAX_TOOL_CALLS, mapToolCalls = GLOBAL_CONFIG.CC_AGENT_MAP_TOOLS, callbacks, storages, states, mcp, connectOperator = GLOBAL_CONFIG.CC_DEFAULT_CONNECT_OPERATOR, completion: completionName, validate = validateDefault, } = this.agentSchemaService.get(agentName);
|
|
4651
4826
|
const history = this.historyConnectionService.getHistory(clientId, agentName);
|
|
4652
4827
|
this.sessionValidationService.addAgentUsage(clientId, agentName);
|
|
4653
4828
|
storages?.forEach((storageName) => this.storageConnectionService
|
|
@@ -4675,6 +4850,9 @@ class AgentConnectionService {
|
|
|
4675
4850
|
mapToolCalls,
|
|
4676
4851
|
logger: this.loggerService,
|
|
4677
4852
|
bus: this.busService,
|
|
4853
|
+
mcp: mcp
|
|
4854
|
+
? new MergeMCP(mcp.map(this.mcpConnectionService.getMCP), agentName)
|
|
4855
|
+
: new NoopMCP(agentName),
|
|
4678
4856
|
history,
|
|
4679
4857
|
prompt,
|
|
4680
4858
|
systemStatic,
|
|
@@ -4840,7 +5018,7 @@ class AgentConnectionService {
|
|
|
4840
5018
|
}
|
|
4841
5019
|
|
|
4842
5020
|
/** @private Constant defining the method name for logging purposes */
|
|
4843
|
-
const METHOD_NAME$
|
|
5021
|
+
const METHOD_NAME$1d = "function.common.getPayload";
|
|
4844
5022
|
/**
|
|
4845
5023
|
* Retrieves the payload from the current PayloadContextService context.
|
|
4846
5024
|
* Returns null if no context is available. Logs the operation if logging is enabled.
|
|
@@ -4851,7 +5029,7 @@ const METHOD_NAME$1a = "function.common.getPayload";
|
|
|
4851
5029
|
* console.log(payload); // { id: number } or null
|
|
4852
5030
|
*/
|
|
4853
5031
|
const getPayload = () => {
|
|
4854
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$
|
|
5032
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$1d);
|
|
4855
5033
|
if (PayloadContextService.hasContext()) {
|
|
4856
5034
|
const { payload } = swarm$1.payloadContextService.context;
|
|
4857
5035
|
return payload;
|
|
@@ -7129,6 +7307,7 @@ class AgentPublicService {
|
|
|
7129
7307
|
swarmName: "",
|
|
7130
7308
|
storageName: "",
|
|
7131
7309
|
stateName: "",
|
|
7310
|
+
mcpName: "",
|
|
7132
7311
|
});
|
|
7133
7312
|
};
|
|
7134
7313
|
/**
|
|
@@ -7161,6 +7340,7 @@ class AgentPublicService {
|
|
|
7161
7340
|
swarmName: "",
|
|
7162
7341
|
storageName: "",
|
|
7163
7342
|
stateName: "",
|
|
7343
|
+
mcpName: "",
|
|
7164
7344
|
});
|
|
7165
7345
|
};
|
|
7166
7346
|
/**
|
|
@@ -7191,6 +7371,7 @@ class AgentPublicService {
|
|
|
7191
7371
|
swarmName: "",
|
|
7192
7372
|
storageName: "",
|
|
7193
7373
|
stateName: "",
|
|
7374
|
+
mcpName: "",
|
|
7194
7375
|
});
|
|
7195
7376
|
};
|
|
7196
7377
|
/**
|
|
@@ -7219,6 +7400,7 @@ class AgentPublicService {
|
|
|
7219
7400
|
swarmName: "",
|
|
7220
7401
|
storageName: "",
|
|
7221
7402
|
stateName: "",
|
|
7403
|
+
mcpName: "",
|
|
7222
7404
|
});
|
|
7223
7405
|
};
|
|
7224
7406
|
/**
|
|
@@ -7251,6 +7433,7 @@ class AgentPublicService {
|
|
|
7251
7433
|
swarmName: "",
|
|
7252
7434
|
storageName: "",
|
|
7253
7435
|
stateName: "",
|
|
7436
|
+
mcpName: "",
|
|
7254
7437
|
});
|
|
7255
7438
|
};
|
|
7256
7439
|
/**
|
|
@@ -7281,6 +7464,7 @@ class AgentPublicService {
|
|
|
7281
7464
|
swarmName: "",
|
|
7282
7465
|
storageName: "",
|
|
7283
7466
|
stateName: "",
|
|
7467
|
+
mcpName: "",
|
|
7284
7468
|
});
|
|
7285
7469
|
};
|
|
7286
7470
|
/**
|
|
@@ -7311,6 +7495,7 @@ class AgentPublicService {
|
|
|
7311
7495
|
swarmName: "",
|
|
7312
7496
|
storageName: "",
|
|
7313
7497
|
stateName: "",
|
|
7498
|
+
mcpName: "",
|
|
7314
7499
|
});
|
|
7315
7500
|
};
|
|
7316
7501
|
/**
|
|
@@ -7342,6 +7527,7 @@ class AgentPublicService {
|
|
|
7342
7527
|
swarmName: "",
|
|
7343
7528
|
storageName: "",
|
|
7344
7529
|
stateName: "",
|
|
7530
|
+
mcpName: "",
|
|
7345
7531
|
});
|
|
7346
7532
|
};
|
|
7347
7533
|
/**
|
|
@@ -7370,6 +7556,7 @@ class AgentPublicService {
|
|
|
7370
7556
|
swarmName: "",
|
|
7371
7557
|
storageName: "",
|
|
7372
7558
|
stateName: "",
|
|
7559
|
+
mcpName: "",
|
|
7373
7560
|
});
|
|
7374
7561
|
};
|
|
7375
7562
|
/**
|
|
@@ -7398,6 +7585,7 @@ class AgentPublicService {
|
|
|
7398
7585
|
swarmName: "",
|
|
7399
7586
|
storageName: "",
|
|
7400
7587
|
stateName: "",
|
|
7588
|
+
mcpName: "",
|
|
7401
7589
|
});
|
|
7402
7590
|
};
|
|
7403
7591
|
/**
|
|
@@ -7426,6 +7614,7 @@ class AgentPublicService {
|
|
|
7426
7614
|
swarmName: "",
|
|
7427
7615
|
storageName: "",
|
|
7428
7616
|
stateName: "",
|
|
7617
|
+
mcpName: "",
|
|
7429
7618
|
});
|
|
7430
7619
|
};
|
|
7431
7620
|
/**
|
|
@@ -7454,6 +7643,7 @@ class AgentPublicService {
|
|
|
7454
7643
|
swarmName: "",
|
|
7455
7644
|
storageName: "",
|
|
7456
7645
|
stateName: "",
|
|
7646
|
+
mcpName: "",
|
|
7457
7647
|
});
|
|
7458
7648
|
};
|
|
7459
7649
|
}
|
|
@@ -7509,6 +7699,7 @@ class HistoryPublicService {
|
|
|
7509
7699
|
swarmName: "",
|
|
7510
7700
|
storageName: "",
|
|
7511
7701
|
stateName: "",
|
|
7702
|
+
mcpName: "",
|
|
7512
7703
|
});
|
|
7513
7704
|
};
|
|
7514
7705
|
/**
|
|
@@ -7537,6 +7728,7 @@ class HistoryPublicService {
|
|
|
7537
7728
|
swarmName: "",
|
|
7538
7729
|
storageName: "",
|
|
7539
7730
|
stateName: "",
|
|
7731
|
+
mcpName: "",
|
|
7540
7732
|
});
|
|
7541
7733
|
};
|
|
7542
7734
|
/**
|
|
@@ -7566,6 +7758,7 @@ class HistoryPublicService {
|
|
|
7566
7758
|
swarmName: "",
|
|
7567
7759
|
storageName: "",
|
|
7568
7760
|
stateName: "",
|
|
7761
|
+
mcpName: "",
|
|
7569
7762
|
});
|
|
7570
7763
|
};
|
|
7571
7764
|
/**
|
|
@@ -7594,6 +7787,7 @@ class HistoryPublicService {
|
|
|
7594
7787
|
swarmName: "",
|
|
7595
7788
|
storageName: "",
|
|
7596
7789
|
stateName: "",
|
|
7790
|
+
mcpName: "",
|
|
7597
7791
|
});
|
|
7598
7792
|
};
|
|
7599
7793
|
/**
|
|
@@ -7621,6 +7815,7 @@ class HistoryPublicService {
|
|
|
7621
7815
|
swarmName: "",
|
|
7622
7816
|
storageName: "",
|
|
7623
7817
|
stateName: "",
|
|
7818
|
+
mcpName: "",
|
|
7624
7819
|
});
|
|
7625
7820
|
};
|
|
7626
7821
|
}
|
|
@@ -7696,6 +7891,7 @@ class SessionPublicService {
|
|
|
7696
7891
|
agentName: "",
|
|
7697
7892
|
storageName: "",
|
|
7698
7893
|
stateName: "",
|
|
7894
|
+
mcpName: "",
|
|
7699
7895
|
});
|
|
7700
7896
|
};
|
|
7701
7897
|
/**
|
|
@@ -7726,6 +7922,7 @@ class SessionPublicService {
|
|
|
7726
7922
|
agentName: "",
|
|
7727
7923
|
storageName: "",
|
|
7728
7924
|
stateName: "",
|
|
7925
|
+
mcpName: "",
|
|
7729
7926
|
});
|
|
7730
7927
|
};
|
|
7731
7928
|
/**
|
|
@@ -7757,6 +7954,7 @@ class SessionPublicService {
|
|
|
7757
7954
|
agentName: "",
|
|
7758
7955
|
storageName: "",
|
|
7759
7956
|
stateName: "",
|
|
7957
|
+
mcpName: "",
|
|
7760
7958
|
});
|
|
7761
7959
|
};
|
|
7762
7960
|
/**
|
|
@@ -7786,6 +7984,7 @@ class SessionPublicService {
|
|
|
7786
7984
|
agentName: "",
|
|
7787
7985
|
storageName: "",
|
|
7788
7986
|
stateName: "",
|
|
7987
|
+
mcpName: "",
|
|
7789
7988
|
});
|
|
7790
7989
|
};
|
|
7791
7990
|
/**
|
|
@@ -7868,6 +8067,7 @@ class SessionPublicService {
|
|
|
7868
8067
|
agentName: "",
|
|
7869
8068
|
storageName: "",
|
|
7870
8069
|
stateName: "",
|
|
8070
|
+
mcpName: "",
|
|
7871
8071
|
});
|
|
7872
8072
|
};
|
|
7873
8073
|
/**
|
|
@@ -7898,6 +8098,7 @@ class SessionPublicService {
|
|
|
7898
8098
|
agentName: "",
|
|
7899
8099
|
storageName: "",
|
|
7900
8100
|
stateName: "",
|
|
8101
|
+
mcpName: "",
|
|
7901
8102
|
});
|
|
7902
8103
|
};
|
|
7903
8104
|
/**
|
|
@@ -7928,6 +8129,7 @@ class SessionPublicService {
|
|
|
7928
8129
|
agentName: "",
|
|
7929
8130
|
storageName: "",
|
|
7930
8131
|
stateName: "",
|
|
8132
|
+
mcpName: "",
|
|
7931
8133
|
});
|
|
7932
8134
|
};
|
|
7933
8135
|
/**
|
|
@@ -7959,6 +8161,7 @@ class SessionPublicService {
|
|
|
7959
8161
|
agentName: "",
|
|
7960
8162
|
storageName: "",
|
|
7961
8163
|
stateName: "",
|
|
8164
|
+
mcpName: "",
|
|
7962
8165
|
});
|
|
7963
8166
|
};
|
|
7964
8167
|
/**
|
|
@@ -7986,6 +8189,7 @@ class SessionPublicService {
|
|
|
7986
8189
|
agentName: "",
|
|
7987
8190
|
storageName: "",
|
|
7988
8191
|
stateName: "",
|
|
8192
|
+
mcpName: "",
|
|
7989
8193
|
});
|
|
7990
8194
|
};
|
|
7991
8195
|
/**
|
|
@@ -8013,6 +8217,7 @@ class SessionPublicService {
|
|
|
8013
8217
|
agentName: "",
|
|
8014
8218
|
storageName: "",
|
|
8015
8219
|
stateName: "",
|
|
8220
|
+
mcpName: "",
|
|
8016
8221
|
});
|
|
8017
8222
|
};
|
|
8018
8223
|
/**
|
|
@@ -8041,6 +8246,7 @@ class SessionPublicService {
|
|
|
8041
8246
|
agentName: "",
|
|
8042
8247
|
storageName: "",
|
|
8043
8248
|
stateName: "",
|
|
8249
|
+
mcpName: "",
|
|
8044
8250
|
});
|
|
8045
8251
|
};
|
|
8046
8252
|
}
|
|
@@ -8096,6 +8302,7 @@ class SwarmPublicService {
|
|
|
8096
8302
|
agentName: "",
|
|
8097
8303
|
storageName: "",
|
|
8098
8304
|
stateName: "",
|
|
8305
|
+
mcpName: "",
|
|
8099
8306
|
});
|
|
8100
8307
|
};
|
|
8101
8308
|
/**
|
|
@@ -8123,6 +8330,7 @@ class SwarmPublicService {
|
|
|
8123
8330
|
agentName: "",
|
|
8124
8331
|
storageName: "",
|
|
8125
8332
|
stateName: "",
|
|
8333
|
+
mcpName: "",
|
|
8126
8334
|
});
|
|
8127
8335
|
};
|
|
8128
8336
|
/**
|
|
@@ -8150,6 +8358,7 @@ class SwarmPublicService {
|
|
|
8150
8358
|
agentName: "",
|
|
8151
8359
|
storageName: "",
|
|
8152
8360
|
stateName: "",
|
|
8361
|
+
mcpName: "",
|
|
8153
8362
|
});
|
|
8154
8363
|
};
|
|
8155
8364
|
/**
|
|
@@ -8178,6 +8387,7 @@ class SwarmPublicService {
|
|
|
8178
8387
|
agentName: "",
|
|
8179
8388
|
storageName: "",
|
|
8180
8389
|
stateName: "",
|
|
8390
|
+
mcpName: "",
|
|
8181
8391
|
});
|
|
8182
8392
|
};
|
|
8183
8393
|
/**
|
|
@@ -8206,6 +8416,7 @@ class SwarmPublicService {
|
|
|
8206
8416
|
agentName: "",
|
|
8207
8417
|
storageName: "",
|
|
8208
8418
|
stateName: "",
|
|
8419
|
+
mcpName: "",
|
|
8209
8420
|
});
|
|
8210
8421
|
};
|
|
8211
8422
|
/**
|
|
@@ -8233,6 +8444,7 @@ class SwarmPublicService {
|
|
|
8233
8444
|
agentName: "",
|
|
8234
8445
|
storageName: "",
|
|
8235
8446
|
stateName: "",
|
|
8447
|
+
mcpName: "",
|
|
8236
8448
|
});
|
|
8237
8449
|
};
|
|
8238
8450
|
/**
|
|
@@ -8265,6 +8477,7 @@ class SwarmPublicService {
|
|
|
8265
8477
|
agentName: "",
|
|
8266
8478
|
storageName: "",
|
|
8267
8479
|
stateName: "",
|
|
8480
|
+
mcpName: "",
|
|
8268
8481
|
});
|
|
8269
8482
|
};
|
|
8270
8483
|
/**
|
|
@@ -8295,6 +8508,7 @@ class SwarmPublicService {
|
|
|
8295
8508
|
agentName: "",
|
|
8296
8509
|
storageName: "",
|
|
8297
8510
|
stateName: "",
|
|
8511
|
+
mcpName: "",
|
|
8298
8512
|
});
|
|
8299
8513
|
};
|
|
8300
8514
|
/**
|
|
@@ -8323,6 +8537,7 @@ class SwarmPublicService {
|
|
|
8323
8537
|
agentName: "",
|
|
8324
8538
|
storageName: "",
|
|
8325
8539
|
stateName: "",
|
|
8540
|
+
mcpName: "",
|
|
8326
8541
|
});
|
|
8327
8542
|
};
|
|
8328
8543
|
}
|
|
@@ -8362,6 +8577,14 @@ class AgentValidationService {
|
|
|
8362
8577
|
* @readonly
|
|
8363
8578
|
*/
|
|
8364
8579
|
this.wikiValidationService = inject(TYPES.wikiValidationService);
|
|
8580
|
+
/**
|
|
8581
|
+
* MCP validation service instance for validating mcp associated with agents.
|
|
8582
|
+
* Injected via DI, used in validate method to check agent mcp list.
|
|
8583
|
+
* @type {WikiValidationService}
|
|
8584
|
+
* @private
|
|
8585
|
+
* @readonly
|
|
8586
|
+
*/
|
|
8587
|
+
this.mcpValidationService = inject(TYPES.mcpValidationService);
|
|
8365
8588
|
/**
|
|
8366
8589
|
* Completion validation service instance for validating completion configurations of agents.
|
|
8367
8590
|
* Injected via DI, used in validate method to check agent completion.
|
|
@@ -8589,6 +8812,12 @@ class AgentValidationService {
|
|
|
8589
8812
|
}
|
|
8590
8813
|
this.wikiValidationService.validate(wikiName, source);
|
|
8591
8814
|
});
|
|
8815
|
+
agent.mcp?.forEach((mcpName) => {
|
|
8816
|
+
if (typeof mcpName !== "string") {
|
|
8817
|
+
throw new Error(`agent-swarm agent ${agentName} mcp list is invalid (mcpName=${String(mcpName)}) source=${source}`);
|
|
8818
|
+
}
|
|
8819
|
+
this.mcpValidationService.validate(mcpName, source);
|
|
8820
|
+
});
|
|
8592
8821
|
});
|
|
8593
8822
|
}
|
|
8594
8823
|
}
|
|
@@ -10195,6 +10424,7 @@ class StoragePublicService {
|
|
|
10195
10424
|
agentName: "",
|
|
10196
10425
|
swarmName: "",
|
|
10197
10426
|
stateName: "",
|
|
10427
|
+
mcpName: "",
|
|
10198
10428
|
});
|
|
10199
10429
|
};
|
|
10200
10430
|
/**
|
|
@@ -10224,6 +10454,7 @@ class StoragePublicService {
|
|
|
10224
10454
|
agentName: "",
|
|
10225
10455
|
swarmName: "",
|
|
10226
10456
|
stateName: "",
|
|
10457
|
+
mcpName: "",
|
|
10227
10458
|
});
|
|
10228
10459
|
};
|
|
10229
10460
|
/**
|
|
@@ -10253,6 +10484,7 @@ class StoragePublicService {
|
|
|
10253
10484
|
agentName: "",
|
|
10254
10485
|
swarmName: "",
|
|
10255
10486
|
stateName: "",
|
|
10487
|
+
mcpName: "",
|
|
10256
10488
|
});
|
|
10257
10489
|
};
|
|
10258
10490
|
/**
|
|
@@ -10283,6 +10515,7 @@ class StoragePublicService {
|
|
|
10283
10515
|
agentName: "",
|
|
10284
10516
|
swarmName: "",
|
|
10285
10517
|
stateName: "",
|
|
10518
|
+
mcpName: "",
|
|
10286
10519
|
});
|
|
10287
10520
|
};
|
|
10288
10521
|
/**
|
|
@@ -10312,6 +10545,7 @@ class StoragePublicService {
|
|
|
10312
10545
|
agentName: "",
|
|
10313
10546
|
swarmName: "",
|
|
10314
10547
|
stateName: "",
|
|
10548
|
+
mcpName: "",
|
|
10315
10549
|
});
|
|
10316
10550
|
};
|
|
10317
10551
|
/**
|
|
@@ -10340,6 +10574,7 @@ class StoragePublicService {
|
|
|
10340
10574
|
agentName: "",
|
|
10341
10575
|
swarmName: "",
|
|
10342
10576
|
stateName: "",
|
|
10577
|
+
mcpName: "",
|
|
10343
10578
|
});
|
|
10344
10579
|
};
|
|
10345
10580
|
/**
|
|
@@ -10367,6 +10602,7 @@ class StoragePublicService {
|
|
|
10367
10602
|
agentName: "",
|
|
10368
10603
|
swarmName: "",
|
|
10369
10604
|
stateName: "",
|
|
10605
|
+
mcpName: "",
|
|
10370
10606
|
});
|
|
10371
10607
|
};
|
|
10372
10608
|
}
|
|
@@ -11008,6 +11244,7 @@ class StatePublicService {
|
|
|
11008
11244
|
agentName: "",
|
|
11009
11245
|
swarmName: "",
|
|
11010
11246
|
storageName: "",
|
|
11247
|
+
mcpName: "",
|
|
11011
11248
|
});
|
|
11012
11249
|
};
|
|
11013
11250
|
/**
|
|
@@ -11036,6 +11273,7 @@ class StatePublicService {
|
|
|
11036
11273
|
agentName: "",
|
|
11037
11274
|
swarmName: "",
|
|
11038
11275
|
storageName: "",
|
|
11276
|
+
mcpName: "",
|
|
11039
11277
|
});
|
|
11040
11278
|
};
|
|
11041
11279
|
/**
|
|
@@ -11063,6 +11301,7 @@ class StatePublicService {
|
|
|
11063
11301
|
agentName: "",
|
|
11064
11302
|
swarmName: "",
|
|
11065
11303
|
storageName: "",
|
|
11304
|
+
mcpName: "",
|
|
11066
11305
|
});
|
|
11067
11306
|
};
|
|
11068
11307
|
/**
|
|
@@ -11091,6 +11330,7 @@ class StatePublicService {
|
|
|
11091
11330
|
agentName: "",
|
|
11092
11331
|
swarmName: "",
|
|
11093
11332
|
storageName: "",
|
|
11333
|
+
mcpName: "",
|
|
11094
11334
|
});
|
|
11095
11335
|
};
|
|
11096
11336
|
}
|
|
@@ -11815,7 +12055,7 @@ class DocService {
|
|
|
11815
12055
|
result.push("```");
|
|
11816
12056
|
result.push("");
|
|
11817
12057
|
}
|
|
11818
|
-
if (agentSchema.
|
|
12058
|
+
if (agentSchema.systemStatic) {
|
|
11819
12059
|
result.push(`## System prompt`);
|
|
11820
12060
|
result.push("");
|
|
11821
12061
|
for (let i = 0; i !== agentSchema.system.length; i++) {
|
|
@@ -11826,6 +12066,10 @@ class DocService {
|
|
|
11826
12066
|
result.push("");
|
|
11827
12067
|
}
|
|
11828
12068
|
}
|
|
12069
|
+
if (agentSchema.systemDynamic) {
|
|
12070
|
+
result.push("***Dynamic system prompt found***");
|
|
12071
|
+
result.push("");
|
|
12072
|
+
}
|
|
11829
12073
|
if (agentSchema.dependsOn) {
|
|
11830
12074
|
result.push(`## Depends on`);
|
|
11831
12075
|
result.push("");
|
|
@@ -12433,6 +12677,7 @@ class SharedStatePublicService {
|
|
|
12433
12677
|
agentName: "",
|
|
12434
12678
|
swarmName: "",
|
|
12435
12679
|
storageName: "",
|
|
12680
|
+
mcpName: "",
|
|
12436
12681
|
});
|
|
12437
12682
|
};
|
|
12438
12683
|
/**
|
|
@@ -12459,6 +12704,7 @@ class SharedStatePublicService {
|
|
|
12459
12704
|
agentName: "",
|
|
12460
12705
|
swarmName: "",
|
|
12461
12706
|
storageName: "",
|
|
12707
|
+
mcpName: "",
|
|
12462
12708
|
});
|
|
12463
12709
|
};
|
|
12464
12710
|
/**
|
|
@@ -12484,6 +12730,7 @@ class SharedStatePublicService {
|
|
|
12484
12730
|
agentName: "",
|
|
12485
12731
|
swarmName: "",
|
|
12486
12732
|
storageName: "",
|
|
12733
|
+
mcpName: "",
|
|
12487
12734
|
});
|
|
12488
12735
|
};
|
|
12489
12736
|
}
|
|
@@ -12541,6 +12788,7 @@ class SharedStoragePublicService {
|
|
|
12541
12788
|
agentName: "",
|
|
12542
12789
|
swarmName: "",
|
|
12543
12790
|
stateName: "",
|
|
12791
|
+
mcpName: "",
|
|
12544
12792
|
});
|
|
12545
12793
|
};
|
|
12546
12794
|
/**
|
|
@@ -12568,6 +12816,7 @@ class SharedStoragePublicService {
|
|
|
12568
12816
|
agentName: "",
|
|
12569
12817
|
swarmName: "",
|
|
12570
12818
|
stateName: "",
|
|
12819
|
+
mcpName: "",
|
|
12571
12820
|
});
|
|
12572
12821
|
};
|
|
12573
12822
|
/**
|
|
@@ -12595,6 +12844,7 @@ class SharedStoragePublicService {
|
|
|
12595
12844
|
agentName: "",
|
|
12596
12845
|
swarmName: "",
|
|
12597
12846
|
stateName: "",
|
|
12847
|
+
mcpName: "",
|
|
12598
12848
|
});
|
|
12599
12849
|
};
|
|
12600
12850
|
/**
|
|
@@ -12623,6 +12873,7 @@ class SharedStoragePublicService {
|
|
|
12623
12873
|
agentName: "",
|
|
12624
12874
|
swarmName: "",
|
|
12625
12875
|
stateName: "",
|
|
12876
|
+
mcpName: "",
|
|
12626
12877
|
});
|
|
12627
12878
|
};
|
|
12628
12879
|
/**
|
|
@@ -12650,6 +12901,7 @@ class SharedStoragePublicService {
|
|
|
12650
12901
|
agentName: "",
|
|
12651
12902
|
swarmName: "",
|
|
12652
12903
|
stateName: "",
|
|
12904
|
+
mcpName: "",
|
|
12653
12905
|
});
|
|
12654
12906
|
};
|
|
12655
12907
|
/**
|
|
@@ -12676,6 +12928,7 @@ class SharedStoragePublicService {
|
|
|
12676
12928
|
agentName: "",
|
|
12677
12929
|
swarmName: "",
|
|
12678
12930
|
stateName: "",
|
|
12931
|
+
mcpName: "",
|
|
12679
12932
|
});
|
|
12680
12933
|
};
|
|
12681
12934
|
}
|
|
@@ -13518,6 +13771,7 @@ class PolicyPublicService {
|
|
|
13518
13771
|
policyName,
|
|
13519
13772
|
storageName: "",
|
|
13520
13773
|
stateName: "",
|
|
13774
|
+
mcpName: "",
|
|
13521
13775
|
});
|
|
13522
13776
|
};
|
|
13523
13777
|
/**
|
|
@@ -13548,6 +13802,7 @@ class PolicyPublicService {
|
|
|
13548
13802
|
policyName,
|
|
13549
13803
|
storageName: "",
|
|
13550
13804
|
stateName: "",
|
|
13805
|
+
mcpName: "",
|
|
13551
13806
|
});
|
|
13552
13807
|
};
|
|
13553
13808
|
/**
|
|
@@ -13580,6 +13835,7 @@ class PolicyPublicService {
|
|
|
13580
13835
|
policyName,
|
|
13581
13836
|
storageName: "",
|
|
13582
13837
|
stateName: "",
|
|
13838
|
+
mcpName: "",
|
|
13583
13839
|
});
|
|
13584
13840
|
};
|
|
13585
13841
|
/**
|
|
@@ -13612,6 +13868,7 @@ class PolicyPublicService {
|
|
|
13612
13868
|
policyName,
|
|
13613
13869
|
storageName: "",
|
|
13614
13870
|
stateName: "",
|
|
13871
|
+
mcpName: "",
|
|
13615
13872
|
});
|
|
13616
13873
|
};
|
|
13617
13874
|
/**
|
|
@@ -13642,6 +13899,7 @@ class PolicyPublicService {
|
|
|
13642
13899
|
policyName,
|
|
13643
13900
|
storageName: "",
|
|
13644
13901
|
stateName: "",
|
|
13902
|
+
mcpName: "",
|
|
13645
13903
|
});
|
|
13646
13904
|
};
|
|
13647
13905
|
/**
|
|
@@ -13672,6 +13930,7 @@ class PolicyPublicService {
|
|
|
13672
13930
|
policyName,
|
|
13673
13931
|
storageName: "",
|
|
13674
13932
|
stateName: "",
|
|
13933
|
+
mcpName: "",
|
|
13675
13934
|
});
|
|
13676
13935
|
};
|
|
13677
13936
|
}
|
|
@@ -14385,6 +14644,239 @@ class WikiValidationService {
|
|
|
14385
14644
|
}
|
|
14386
14645
|
}
|
|
14387
14646
|
|
|
14647
|
+
class ClientMCP {
|
|
14648
|
+
constructor(params) {
|
|
14649
|
+
this.params = params;
|
|
14650
|
+
this.fetchTools = functoolsKit.memoize(([clientId]) => `${clientId}`, async (clientId) => {
|
|
14651
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
14652
|
+
this.params.logger.debug(`ClientMCP mcpName=${this.params.mcpName} fetchTools`, {
|
|
14653
|
+
clientId,
|
|
14654
|
+
});
|
|
14655
|
+
const toolList = await this.params.listTools(clientId);
|
|
14656
|
+
return new Map(toolList.map((tool) => [tool.name, tool]));
|
|
14657
|
+
});
|
|
14658
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
14659
|
+
this.params.logger.debug(`ClientMCP mcpName=${this.params.mcpName} CTOR`, {
|
|
14660
|
+
params,
|
|
14661
|
+
});
|
|
14662
|
+
if (this.params.callbacks?.onInit) {
|
|
14663
|
+
this.params.callbacks.onInit();
|
|
14664
|
+
}
|
|
14665
|
+
}
|
|
14666
|
+
async listTools(clientId) {
|
|
14667
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
14668
|
+
this.params.logger.debug(`ClientMCP mcpName=${this.params.mcpName} listTools`, {
|
|
14669
|
+
clientId,
|
|
14670
|
+
});
|
|
14671
|
+
if (this.params.callbacks?.onList) {
|
|
14672
|
+
this.params.callbacks.onList(clientId);
|
|
14673
|
+
}
|
|
14674
|
+
const toolMap = await this.fetchTools(clientId);
|
|
14675
|
+
return Array.from(toolMap.values());
|
|
14676
|
+
}
|
|
14677
|
+
async hasTool(toolName, clientId) {
|
|
14678
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
14679
|
+
this.params.logger.debug(`ClientMCP mcpName=${this.params.mcpName} hasTool`, {
|
|
14680
|
+
toolName,
|
|
14681
|
+
clientId,
|
|
14682
|
+
});
|
|
14683
|
+
const toolMap = await this.fetchTools(clientId);
|
|
14684
|
+
return toolMap.has(toolName);
|
|
14685
|
+
}
|
|
14686
|
+
async callTool(toolName, dto) {
|
|
14687
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
14688
|
+
this.params.logger.debug(`ClientMCP mcpName=${this.params.mcpName} callTool`, {
|
|
14689
|
+
toolName,
|
|
14690
|
+
dto,
|
|
14691
|
+
});
|
|
14692
|
+
if (this.params.callbacks?.onCall) {
|
|
14693
|
+
this.params.callbacks.onCall(toolName, dto);
|
|
14694
|
+
}
|
|
14695
|
+
return await this.params.callTool(toolName, dto);
|
|
14696
|
+
}
|
|
14697
|
+
dispose(clientId) {
|
|
14698
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
14699
|
+
this.params.logger.debug(`ClientMCP mcpName=${this.params.mcpName} dispose`, {
|
|
14700
|
+
clientId,
|
|
14701
|
+
});
|
|
14702
|
+
this.fetchTools.clear(clientId);
|
|
14703
|
+
if (this.params.callbacks?.onDispose) {
|
|
14704
|
+
this.params.callbacks.onDispose(clientId);
|
|
14705
|
+
}
|
|
14706
|
+
}
|
|
14707
|
+
}
|
|
14708
|
+
|
|
14709
|
+
class MCPConnectionService {
|
|
14710
|
+
constructor() {
|
|
14711
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
14712
|
+
this.busService = inject(TYPES.busService);
|
|
14713
|
+
this.methodContextService = inject(TYPES.methodContextService);
|
|
14714
|
+
this.mcpSchemaService = inject(TYPES.mcpSchemaService);
|
|
14715
|
+
this.getMCP = functoolsKit.memoize(([mcpName]) => `${mcpName}`, (mcpName) => {
|
|
14716
|
+
const schema = this.mcpSchemaService.get(mcpName);
|
|
14717
|
+
return new ClientMCP({
|
|
14718
|
+
mcpName,
|
|
14719
|
+
bus: this.busService,
|
|
14720
|
+
logger: this.loggerService,
|
|
14721
|
+
...schema,
|
|
14722
|
+
});
|
|
14723
|
+
});
|
|
14724
|
+
}
|
|
14725
|
+
async listTools(clientId) {
|
|
14726
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
14727
|
+
this.loggerService.info(`mcpConnectionService listTools`, {
|
|
14728
|
+
clientId,
|
|
14729
|
+
});
|
|
14730
|
+
return await this.getMCP(this.methodContextService.context.mcpName).listTools(clientId);
|
|
14731
|
+
}
|
|
14732
|
+
async hasTool(toolName, clientId) {
|
|
14733
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
14734
|
+
this.loggerService.info(`mcpConnectionService hasTool`, {
|
|
14735
|
+
toolName,
|
|
14736
|
+
clientId,
|
|
14737
|
+
});
|
|
14738
|
+
return await this.getMCP(this.methodContextService.context.mcpName).hasTool(toolName, clientId);
|
|
14739
|
+
}
|
|
14740
|
+
async callTool(toolName, dto) {
|
|
14741
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
14742
|
+
this.loggerService.info(`mcpConnectionService hasTool`, {
|
|
14743
|
+
toolName,
|
|
14744
|
+
dto,
|
|
14745
|
+
});
|
|
14746
|
+
return await this.getMCP(this.methodContextService.context.mcpName).callTool(toolName, dto);
|
|
14747
|
+
}
|
|
14748
|
+
}
|
|
14749
|
+
|
|
14750
|
+
class MCPSchemaService {
|
|
14751
|
+
constructor() {
|
|
14752
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
14753
|
+
this.registry = new functoolsKit.ToolRegistry("mcpSchemaService");
|
|
14754
|
+
this.validateShallow = (mcpSchema) => {
|
|
14755
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
14756
|
+
this.loggerService.info(`mcpSchemaService validateShallow`, {
|
|
14757
|
+
mcpSchema,
|
|
14758
|
+
});
|
|
14759
|
+
if (typeof mcpSchema.mcpName !== "string") {
|
|
14760
|
+
throw new Error(`agent-swarm mcp schema validation failed: missing mcpName`);
|
|
14761
|
+
}
|
|
14762
|
+
if (typeof mcpSchema.callTool !== "function") {
|
|
14763
|
+
throw new Error(`agent-swarm mcp schema validation failed: callTool must be provided mcpName=${mcpSchema.mcpName}`);
|
|
14764
|
+
}
|
|
14765
|
+
if (typeof mcpSchema.listTools !== "function") {
|
|
14766
|
+
throw new Error(`agent-swarm mcp schema validation failed: listTools must be provided mcpName=${mcpSchema.mcpName}`);
|
|
14767
|
+
}
|
|
14768
|
+
};
|
|
14769
|
+
this.register = (key, value) => {
|
|
14770
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
14771
|
+
this.loggerService.info(`mcpSchemaService register`, { key });
|
|
14772
|
+
this.validateShallow(value);
|
|
14773
|
+
this.registry = this.registry.register(key, value);
|
|
14774
|
+
};
|
|
14775
|
+
this.override = (key, value) => {
|
|
14776
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
14777
|
+
this.loggerService.info(`mcpSchemaService override`, { key });
|
|
14778
|
+
this.registry = this.registry.override(key, value);
|
|
14779
|
+
return this.registry.get(key);
|
|
14780
|
+
};
|
|
14781
|
+
this.get = (key) => {
|
|
14782
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
14783
|
+
this.loggerService.info(`mcpSchemaService get`, { key });
|
|
14784
|
+
return this.registry.get(key);
|
|
14785
|
+
};
|
|
14786
|
+
}
|
|
14787
|
+
}
|
|
14788
|
+
|
|
14789
|
+
class MCPPublicService {
|
|
14790
|
+
constructor() {
|
|
14791
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
14792
|
+
this.mcpConnectionService = inject(TYPES.mcpConnectionService);
|
|
14793
|
+
}
|
|
14794
|
+
async listTools(methodName, clientId, mcpName) {
|
|
14795
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
14796
|
+
this.loggerService.info(`mcpPublicService listTools`, {
|
|
14797
|
+
clientId,
|
|
14798
|
+
});
|
|
14799
|
+
return await MethodContextService.runInContext(async () => {
|
|
14800
|
+
return await this.mcpConnectionService.listTools(clientId);
|
|
14801
|
+
}, {
|
|
14802
|
+
methodName,
|
|
14803
|
+
clientId,
|
|
14804
|
+
mcpName,
|
|
14805
|
+
agentName: "",
|
|
14806
|
+
swarmName: "",
|
|
14807
|
+
storageName: "",
|
|
14808
|
+
stateName: "",
|
|
14809
|
+
policyName: "",
|
|
14810
|
+
});
|
|
14811
|
+
}
|
|
14812
|
+
async hasTool(methodName, clientId, mcpName, toolName) {
|
|
14813
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
14814
|
+
this.loggerService.info(`mcpPublicService hasTool`, {
|
|
14815
|
+
toolName,
|
|
14816
|
+
clientId,
|
|
14817
|
+
});
|
|
14818
|
+
return await MethodContextService.runInContext(async () => {
|
|
14819
|
+
return await this.mcpConnectionService.hasTool(toolName, clientId);
|
|
14820
|
+
}, {
|
|
14821
|
+
methodName,
|
|
14822
|
+
clientId,
|
|
14823
|
+
mcpName,
|
|
14824
|
+
agentName: "",
|
|
14825
|
+
swarmName: "",
|
|
14826
|
+
storageName: "",
|
|
14827
|
+
stateName: "",
|
|
14828
|
+
policyName: "",
|
|
14829
|
+
});
|
|
14830
|
+
}
|
|
14831
|
+
async callTool(methodName, clientId, mcpName, toolName, dto) {
|
|
14832
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
14833
|
+
this.loggerService.info(`mcpPublicService callTool`, {
|
|
14834
|
+
toolName,
|
|
14835
|
+
dto,
|
|
14836
|
+
});
|
|
14837
|
+
return await MethodContextService.runInContext(async () => {
|
|
14838
|
+
return await this.mcpConnectionService.callTool(toolName, dto);
|
|
14839
|
+
}, {
|
|
14840
|
+
methodName,
|
|
14841
|
+
clientId,
|
|
14842
|
+
mcpName,
|
|
14843
|
+
agentName: "",
|
|
14844
|
+
swarmName: "",
|
|
14845
|
+
storageName: "",
|
|
14846
|
+
stateName: "",
|
|
14847
|
+
policyName: "",
|
|
14848
|
+
});
|
|
14849
|
+
}
|
|
14850
|
+
}
|
|
14851
|
+
|
|
14852
|
+
class MCPValidationService {
|
|
14853
|
+
constructor() {
|
|
14854
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
14855
|
+
this._mcpMap = new Map();
|
|
14856
|
+
this.addMCP = (mcpName, mcpSchema) => {
|
|
14857
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
14858
|
+
this.loggerService.info("mcpValidationService addMCP", {
|
|
14859
|
+
mcpName,
|
|
14860
|
+
mcpSchema,
|
|
14861
|
+
});
|
|
14862
|
+
if (this._mcpMap.has(mcpName)) {
|
|
14863
|
+
throw new Error(`agent-swarm mcp ${mcpName} already exist`);
|
|
14864
|
+
}
|
|
14865
|
+
this._mcpMap.set(mcpName, mcpSchema);
|
|
14866
|
+
};
|
|
14867
|
+
this.validate = functoolsKit.memoize(([mcpName]) => mcpName, (mcpName, source) => {
|
|
14868
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
14869
|
+
this.loggerService.info("mcpValidationService validate", {
|
|
14870
|
+
mcpName,
|
|
14871
|
+
source,
|
|
14872
|
+
});
|
|
14873
|
+
if (!this._mcpMap.has(mcpName)) {
|
|
14874
|
+
throw new Error(`agent-swarm mcp ${mcpName} not found source=${source}`);
|
|
14875
|
+
}
|
|
14876
|
+
});
|
|
14877
|
+
}
|
|
14878
|
+
}
|
|
14879
|
+
|
|
14388
14880
|
{
|
|
14389
14881
|
provide(TYPES.docService, () => new DocService());
|
|
14390
14882
|
provide(TYPES.busService, () => new BusService());
|
|
@@ -14407,6 +14899,7 @@ class WikiValidationService {
|
|
|
14407
14899
|
provide(TYPES.stateConnectionService, () => new StateConnectionService());
|
|
14408
14900
|
provide(TYPES.sharedStateConnectionService, () => new SharedStateConnectionService());
|
|
14409
14901
|
provide(TYPES.policyConnectionService, () => new PolicyConnectionService());
|
|
14902
|
+
provide(TYPES.mcpConnectionService, () => new MCPConnectionService());
|
|
14410
14903
|
}
|
|
14411
14904
|
{
|
|
14412
14905
|
provide(TYPES.agentSchemaService, () => new AgentSchemaService());
|
|
@@ -14419,6 +14912,7 @@ class WikiValidationService {
|
|
|
14419
14912
|
provide(TYPES.memorySchemaService, () => new MemorySchemaService());
|
|
14420
14913
|
provide(TYPES.policySchemaService, () => new PolicySchemaService());
|
|
14421
14914
|
provide(TYPES.wikiSchemaService, () => new WikiSchemaService());
|
|
14915
|
+
provide(TYPES.mcpSchemaService, () => new MCPSchemaService());
|
|
14422
14916
|
}
|
|
14423
14917
|
{
|
|
14424
14918
|
provide(TYPES.agentPublicService, () => new AgentPublicService());
|
|
@@ -14430,6 +14924,7 @@ class WikiValidationService {
|
|
|
14430
14924
|
provide(TYPES.statePublicService, () => new StatePublicService());
|
|
14431
14925
|
provide(TYPES.sharedStatePublicService, () => new SharedStatePublicService());
|
|
14432
14926
|
provide(TYPES.policyPublicService, () => new PolicyPublicService());
|
|
14927
|
+
provide(TYPES.mcpPublicService, () => new MCPPublicService());
|
|
14433
14928
|
}
|
|
14434
14929
|
{
|
|
14435
14930
|
provide(TYPES.swarmMetaService, () => new SwarmMetaService());
|
|
@@ -14446,6 +14941,7 @@ class WikiValidationService {
|
|
|
14446
14941
|
provide(TYPES.policyValidationService, () => new PolicyValidationService());
|
|
14447
14942
|
provide(TYPES.navigationValidationService, () => new NavigationValidationService());
|
|
14448
14943
|
provide(TYPES.wikiValidationService, () => new WikiValidationService());
|
|
14944
|
+
provide(TYPES.mcpValidationService, () => new MCPValidationService());
|
|
14449
14945
|
}
|
|
14450
14946
|
|
|
14451
14947
|
const baseServices = {
|
|
@@ -14470,6 +14966,7 @@ const connectionServices = {
|
|
|
14470
14966
|
stateConnectionService: inject(TYPES.stateConnectionService),
|
|
14471
14967
|
sharedStateConnectionService: inject(TYPES.sharedStateConnectionService),
|
|
14472
14968
|
policyConnectionService: inject(TYPES.policyConnectionService),
|
|
14969
|
+
mcpConnectionService: inject(TYPES.mcpConnectionService),
|
|
14473
14970
|
};
|
|
14474
14971
|
const schemaServices = {
|
|
14475
14972
|
agentSchemaService: inject(TYPES.agentSchemaService),
|
|
@@ -14482,6 +14979,7 @@ const schemaServices = {
|
|
|
14482
14979
|
memorySchemaService: inject(TYPES.memorySchemaService),
|
|
14483
14980
|
policySchemaService: inject(TYPES.policySchemaService),
|
|
14484
14981
|
wikiSchemaService: inject(TYPES.wikiSchemaService),
|
|
14982
|
+
mcpSchemaService: inject(TYPES.mcpSchemaService),
|
|
14485
14983
|
};
|
|
14486
14984
|
const publicServices = {
|
|
14487
14985
|
agentPublicService: inject(TYPES.agentPublicService),
|
|
@@ -14493,6 +14991,7 @@ const publicServices = {
|
|
|
14493
14991
|
statePublicService: inject(TYPES.statePublicService),
|
|
14494
14992
|
sharedStatePublicService: inject(TYPES.sharedStatePublicService),
|
|
14495
14993
|
policyPublicService: inject(TYPES.policyPublicService),
|
|
14994
|
+
mcpPublicService: inject(TYPES.mcpPublicService),
|
|
14496
14995
|
};
|
|
14497
14996
|
const metaServices = {
|
|
14498
14997
|
agentMetaService: inject(TYPES.agentMetaService),
|
|
@@ -14509,6 +15008,7 @@ const validationServices = {
|
|
|
14509
15008
|
policyValidationService: inject(TYPES.policyValidationService),
|
|
14510
15009
|
navigationValidationService: inject(TYPES.navigationValidationService),
|
|
14511
15010
|
wikiValidationService: inject(TYPES.wikiValidationService),
|
|
15011
|
+
mcpValidationService: inject(TYPES.mcpValidationService),
|
|
14512
15012
|
};
|
|
14513
15013
|
/** @inheritDoc */
|
|
14514
15014
|
const swarm = {
|
|
@@ -14523,7 +15023,7 @@ const swarm = {
|
|
|
14523
15023
|
init();
|
|
14524
15024
|
var swarm$1 = swarm;
|
|
14525
15025
|
|
|
14526
|
-
const METHOD_NAME$
|
|
15026
|
+
const METHOD_NAME$1c = "cli.dumpDocs";
|
|
14527
15027
|
/**
|
|
14528
15028
|
* Dumps the documentation for the agents and swarms.
|
|
14529
15029
|
*
|
|
@@ -14533,7 +15033,7 @@ const METHOD_NAME$19 = "cli.dumpDocs";
|
|
|
14533
15033
|
*/
|
|
14534
15034
|
const dumpDocs = beginContext((prefix = "swarm", dirName = "./docs/chat", PlantUML) => {
|
|
14535
15035
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14536
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15036
|
+
swarm$1.loggerService.log(METHOD_NAME$1c, {
|
|
14537
15037
|
dirName,
|
|
14538
15038
|
});
|
|
14539
15039
|
if (PlantUML) {
|
|
@@ -14543,10 +15043,10 @@ const dumpDocs = beginContext((prefix = "swarm", dirName = "./docs/chat", PlantU
|
|
|
14543
15043
|
}
|
|
14544
15044
|
swarm$1.agentValidationService
|
|
14545
15045
|
.getAgentList()
|
|
14546
|
-
.forEach((agentName) => swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
15046
|
+
.forEach((agentName) => swarm$1.agentValidationService.validate(agentName, METHOD_NAME$1c));
|
|
14547
15047
|
swarm$1.swarmValidationService
|
|
14548
15048
|
.getSwarmList()
|
|
14549
|
-
.forEach((swarmName) => swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15049
|
+
.forEach((swarmName) => swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$1c));
|
|
14550
15050
|
swarm$1.agentValidationService.getAgentList().forEach((agentName) => {
|
|
14551
15051
|
const { dependsOn } = swarm$1.agentSchemaService.get(agentName);
|
|
14552
15052
|
if (!dependsOn) {
|
|
@@ -14556,7 +15056,7 @@ const dumpDocs = beginContext((prefix = "swarm", dirName = "./docs/chat", PlantU
|
|
|
14556
15056
|
return swarm$1.docService.dumpDocs(prefix, dirName);
|
|
14557
15057
|
});
|
|
14558
15058
|
|
|
14559
|
-
const METHOD_NAME$
|
|
15059
|
+
const METHOD_NAME$1b = "cli.dumpAgent";
|
|
14560
15060
|
/**
|
|
14561
15061
|
* Dumps the agent information into PlantUML format.
|
|
14562
15062
|
*
|
|
@@ -14565,14 +15065,14 @@ const METHOD_NAME$18 = "cli.dumpAgent";
|
|
|
14565
15065
|
*/
|
|
14566
15066
|
const dumpAgent = beginContext((agentName, { withSubtree = false } = {}) => {
|
|
14567
15067
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14568
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15068
|
+
swarm$1.loggerService.log(METHOD_NAME$1b, {
|
|
14569
15069
|
agentName,
|
|
14570
15070
|
});
|
|
14571
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
15071
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$1b);
|
|
14572
15072
|
return swarm$1.agentMetaService.toUML(agentName, withSubtree);
|
|
14573
15073
|
});
|
|
14574
15074
|
|
|
14575
|
-
const METHOD_NAME$
|
|
15075
|
+
const METHOD_NAME$1a = "cli.dumpSwarm";
|
|
14576
15076
|
/**
|
|
14577
15077
|
* Dumps the swarm information into PlantUML format.
|
|
14578
15078
|
*
|
|
@@ -14581,14 +15081,14 @@ const METHOD_NAME$17 = "cli.dumpSwarm";
|
|
|
14581
15081
|
*/
|
|
14582
15082
|
const dumpSwarm = beginContext((swarmName) => {
|
|
14583
15083
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14584
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15084
|
+
swarm$1.loggerService.log(METHOD_NAME$1a, {
|
|
14585
15085
|
swarmName,
|
|
14586
15086
|
});
|
|
14587
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15087
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$1a);
|
|
14588
15088
|
return swarm$1.swarmMetaService.toUML(swarmName);
|
|
14589
15089
|
});
|
|
14590
15090
|
|
|
14591
|
-
const METHOD_NAME$
|
|
15091
|
+
const METHOD_NAME$19 = "cli.dumpPerfomance";
|
|
14592
15092
|
const METHOD_NAME_INTERNAL$1 = "cli.dumpPerfomance.internal";
|
|
14593
15093
|
const METHOD_NAME_INTERVAL = "cli.dumpPerfomance.interval";
|
|
14594
15094
|
/**
|
|
@@ -14607,7 +15107,7 @@ const dumpPerfomanceInternal = beginContext(async (dirName = "./logs/meta") => {
|
|
|
14607
15107
|
* @returns {Promise<void>} A promise that resolves when the performance data has been dumped.
|
|
14608
15108
|
*/
|
|
14609
15109
|
const dumpPerfomance = async (dirName = "./logs/meta") => {
|
|
14610
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$
|
|
15110
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$19);
|
|
14611
15111
|
await dumpPerfomanceInternal(dirName);
|
|
14612
15112
|
};
|
|
14613
15113
|
/**
|
|
@@ -14665,7 +15165,7 @@ const listenExecutionEvent = beginContext((clientId, fn) => {
|
|
|
14665
15165
|
return swarm$1.busService.subscribe(clientId, "execution-bus", functoolsKit.queued(async (e) => await fn(e)));
|
|
14666
15166
|
});
|
|
14667
15167
|
|
|
14668
|
-
const METHOD_NAME$
|
|
15168
|
+
const METHOD_NAME$18 = "cli.dumpClientPerformance";
|
|
14669
15169
|
const METHOD_NAME_INTERNAL = "cli.dumpClientPerformance.internal";
|
|
14670
15170
|
const METHOD_NAME_EXECUTE = "cli.dumpClientPerformance.execute";
|
|
14671
15171
|
/**
|
|
@@ -14689,7 +15189,7 @@ const dumpClientPerformanceInternal = beginContext(async (clientId, dirName = ".
|
|
|
14689
15189
|
* @returns {Promise<void>} A promise that resolves when the performance data has been dumped.
|
|
14690
15190
|
*/
|
|
14691
15191
|
const dumpClientPerformance = async (clientId, dirName = "./logs/client") => {
|
|
14692
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$
|
|
15192
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$18);
|
|
14693
15193
|
await dumpClientPerformanceInternal(clientId, dirName);
|
|
14694
15194
|
};
|
|
14695
15195
|
/**
|
|
@@ -14710,7 +15210,7 @@ dumpClientPerformance.runAfterExecute = beginContext(async (dirName = "./logs/cl
|
|
|
14710
15210
|
});
|
|
14711
15211
|
|
|
14712
15212
|
/** @private Constant defining the method name for logging and validation context */
|
|
14713
|
-
const METHOD_NAME$
|
|
15213
|
+
const METHOD_NAME$17 = "function.commit.commitFlushForce";
|
|
14714
15214
|
/**
|
|
14715
15215
|
* Forcefully commits a flush of agent history for a specific client in the swarm system, without checking the active agent.
|
|
14716
15216
|
* Validates the session and swarm, then proceeds with flushing the history regardless of the current agent state.
|
|
@@ -14728,20 +15228,20 @@ const METHOD_NAME$14 = "function.commit.commitFlushForce";
|
|
|
14728
15228
|
const commitFlushForce = beginContext(async (clientId) => {
|
|
14729
15229
|
// Log the flush attempt if enabled
|
|
14730
15230
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14731
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15231
|
+
swarm$1.loggerService.log(METHOD_NAME$17, {
|
|
14732
15232
|
clientId,
|
|
14733
|
-
METHOD_NAME: METHOD_NAME$
|
|
15233
|
+
METHOD_NAME: METHOD_NAME$17,
|
|
14734
15234
|
});
|
|
14735
15235
|
// Validate the session exists and retrieve the associated swarm
|
|
14736
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
15236
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$17);
|
|
14737
15237
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14738
15238
|
// Validate the swarm configuration
|
|
14739
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15239
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$17);
|
|
14740
15240
|
// Commit the flush of agent history via SessionPublicService without agent checks
|
|
14741
|
-
await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$
|
|
15241
|
+
await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$17, clientId, swarmName);
|
|
14742
15242
|
});
|
|
14743
15243
|
|
|
14744
|
-
const METHOD_NAME$
|
|
15244
|
+
const METHOD_NAME$16 = "function.commit.commitToolOutputForce";
|
|
14745
15245
|
/**
|
|
14746
15246
|
* Commits the output of a tool execution to the active agent in a swarm session without checking the active agent.
|
|
14747
15247
|
*
|
|
@@ -14760,24 +15260,24 @@ const METHOD_NAME$13 = "function.commit.commitToolOutputForce";
|
|
|
14760
15260
|
const commitToolOutputForce = beginContext(async (toolId, content, clientId) => {
|
|
14761
15261
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14762
15262
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14763
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15263
|
+
swarm$1.loggerService.log(METHOD_NAME$16, {
|
|
14764
15264
|
toolId,
|
|
14765
15265
|
content,
|
|
14766
15266
|
clientId,
|
|
14767
15267
|
});
|
|
14768
15268
|
// Validate the session and swarm to ensure they exist and are accessible
|
|
14769
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
15269
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$16);
|
|
14770
15270
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14771
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15271
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$16);
|
|
14772
15272
|
// Commit the tool output to the session via the session public service without checking the active agent
|
|
14773
|
-
await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$
|
|
15273
|
+
await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$16, clientId, swarmName);
|
|
14774
15274
|
});
|
|
14775
15275
|
|
|
14776
15276
|
/**
|
|
14777
15277
|
* @private Constant defining the method name for logging and validation purposes.
|
|
14778
15278
|
* Used as an identifier in log messages and validation checks to track calls to `hasNavigation`.
|
|
14779
15279
|
*/
|
|
14780
|
-
const METHOD_NAME$
|
|
15280
|
+
const METHOD_NAME$15 = "function.common.hasNavigation";
|
|
14781
15281
|
/**
|
|
14782
15282
|
* Checks if a specific agent is part of the navigation route for a given client.
|
|
14783
15283
|
* Validates the agent and client session, retrieves the associated swarm, and queries the navigation route.
|
|
@@ -14788,16 +15288,16 @@ const METHOD_NAME$12 = "function.common.hasNavigation";
|
|
|
14788
15288
|
*/
|
|
14789
15289
|
const hasNavigation = async (clientId, agentName) => {
|
|
14790
15290
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14791
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14792
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
14793
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
15291
|
+
swarm$1.loggerService.log(METHOD_NAME$15, { clientId });
|
|
15292
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$15);
|
|
15293
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$15);
|
|
14794
15294
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14795
15295
|
return swarm$1.navigationValidationService
|
|
14796
15296
|
.getNavigationRoute(clientId, swarmName)
|
|
14797
15297
|
.has(agentName);
|
|
14798
15298
|
};
|
|
14799
15299
|
|
|
14800
|
-
const METHOD_NAME$
|
|
15300
|
+
const METHOD_NAME$14 = "function.history.getRawHistory";
|
|
14801
15301
|
/**
|
|
14802
15302
|
* Retrieves the raw, unmodified history for a given client session.
|
|
14803
15303
|
*
|
|
@@ -14814,10 +15314,10 @@ const METHOD_NAME$11 = "function.history.getRawHistory";
|
|
|
14814
15314
|
* const rawHistory = await getRawHistory("client-123");
|
|
14815
15315
|
* console.log(rawHistory); // Outputs the full raw history array
|
|
14816
15316
|
*/
|
|
14817
|
-
const getRawHistory = beginContext(async (clientId, methodName = METHOD_NAME$
|
|
15317
|
+
const getRawHistory = beginContext(async (clientId, methodName = METHOD_NAME$14) => {
|
|
14818
15318
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14819
15319
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14820
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15320
|
+
swarm$1.loggerService.log(METHOD_NAME$14, {
|
|
14821
15321
|
clientId,
|
|
14822
15322
|
});
|
|
14823
15323
|
// Validate the session and swarm
|
|
@@ -14830,7 +15330,7 @@ const getRawHistory = beginContext(async (clientId, methodName = METHOD_NAME$11)
|
|
|
14830
15330
|
return [...history];
|
|
14831
15331
|
});
|
|
14832
15332
|
|
|
14833
|
-
const METHOD_NAME$
|
|
15333
|
+
const METHOD_NAME$13 = "function.history.getLastUserMessage";
|
|
14834
15334
|
/**
|
|
14835
15335
|
* Retrieves the content of the most recent user message from a client's session history.
|
|
14836
15336
|
*
|
|
@@ -14848,16 +15348,16 @@ const METHOD_NAME$10 = "function.history.getLastUserMessage";
|
|
|
14848
15348
|
const getLastUserMessage = beginContext(async (clientId) => {
|
|
14849
15349
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14850
15350
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14851
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15351
|
+
swarm$1.loggerService.log(METHOD_NAME$13, {
|
|
14852
15352
|
clientId,
|
|
14853
15353
|
});
|
|
14854
15354
|
// Fetch raw history and find the last user message
|
|
14855
|
-
const history = await getRawHistory(clientId, METHOD_NAME$
|
|
15355
|
+
const history = await getRawHistory(clientId, METHOD_NAME$13);
|
|
14856
15356
|
const last = history.findLast(({ role, mode }) => role === "user" && mode === "user");
|
|
14857
15357
|
return last ? last.content : null;
|
|
14858
15358
|
});
|
|
14859
15359
|
|
|
14860
|
-
const METHOD_NAME
|
|
15360
|
+
const METHOD_NAME$12 = "function.navigate.changeToDefaultAgent";
|
|
14861
15361
|
/**
|
|
14862
15362
|
* Time-to-live for the change agent function in milliseconds.
|
|
14863
15363
|
* Defines how long the cached change agent function remains valid before expiring.
|
|
@@ -14892,7 +15392,7 @@ const createChangeToDefaultAgent = functoolsKit.ttl((clientId) => functoolsKit.q
|
|
|
14892
15392
|
}));
|
|
14893
15393
|
{
|
|
14894
15394
|
// Dispose of the current agent's resources and set up the new default agent
|
|
14895
|
-
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME
|
|
15395
|
+
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$12, clientId, swarmName);
|
|
14896
15396
|
await swarm$1.agentPublicService.dispose(methodName, clientId, agentName);
|
|
14897
15397
|
await swarm$1.historyPublicService.dispose(methodName, clientId, agentName);
|
|
14898
15398
|
await swarm$1.swarmPublicService.setAgentRef(methodName, clientId, swarmName, agentName, await swarm$1.agentPublicService.createAgentRef(methodName, clientId, agentName));
|
|
@@ -14931,23 +15431,23 @@ const createGc$3 = functoolsKit.singleshot(async () => {
|
|
|
14931
15431
|
const changeToDefaultAgent = beginContext(async (clientId) => {
|
|
14932
15432
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14933
15433
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14934
|
-
swarm$1.loggerService.log(METHOD_NAME
|
|
15434
|
+
swarm$1.loggerService.log(METHOD_NAME$12, {
|
|
14935
15435
|
clientId,
|
|
14936
15436
|
});
|
|
14937
15437
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14938
15438
|
const { defaultAgent: agentName } = swarm$1.swarmSchemaService.get(swarmName);
|
|
14939
15439
|
{
|
|
14940
15440
|
// Validate session and default agent
|
|
14941
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME
|
|
14942
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME
|
|
15441
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$12);
|
|
15442
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$12);
|
|
14943
15443
|
}
|
|
14944
15444
|
// Execute the agent change with TTL and queuing
|
|
14945
15445
|
const run = await createChangeToDefaultAgent(clientId);
|
|
14946
15446
|
createGc$3();
|
|
14947
|
-
return await run(METHOD_NAME
|
|
15447
|
+
return await run(METHOD_NAME$12, agentName, swarmName);
|
|
14948
15448
|
});
|
|
14949
15449
|
|
|
14950
|
-
const METHOD_NAME$
|
|
15450
|
+
const METHOD_NAME$11 = "function.target.emitForce";
|
|
14951
15451
|
/**
|
|
14952
15452
|
* Emits a string as model output without executing an incoming message or checking the active agent.
|
|
14953
15453
|
*
|
|
@@ -14966,19 +15466,19 @@ const METHOD_NAME$_ = "function.target.emitForce";
|
|
|
14966
15466
|
const emitForce = beginContext(async (content, clientId) => {
|
|
14967
15467
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14968
15468
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14969
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15469
|
+
swarm$1.loggerService.log(METHOD_NAME$11, {
|
|
14970
15470
|
content,
|
|
14971
15471
|
clientId,
|
|
14972
15472
|
});
|
|
14973
15473
|
// Validate the session and swarm
|
|
14974
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
15474
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$11);
|
|
14975
15475
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14976
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15476
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$11);
|
|
14977
15477
|
// Emit the content directly via the session public service
|
|
14978
|
-
return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$
|
|
15478
|
+
return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$11, clientId, swarmName);
|
|
14979
15479
|
});
|
|
14980
15480
|
|
|
14981
|
-
const METHOD_NAME$
|
|
15481
|
+
const METHOD_NAME$10 = "function.target.executeForce";
|
|
14982
15482
|
/**
|
|
14983
15483
|
* 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.
|
|
14984
15484
|
*
|
|
@@ -14999,22 +15499,22 @@ const executeForce = beginContext(async (content, clientId) => {
|
|
|
14999
15499
|
const executionId = functoolsKit.randomString();
|
|
15000
15500
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15001
15501
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15002
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15502
|
+
swarm$1.loggerService.log(METHOD_NAME$10, {
|
|
15003
15503
|
content,
|
|
15004
15504
|
clientId,
|
|
15005
15505
|
executionId,
|
|
15006
15506
|
});
|
|
15007
15507
|
// Validate the session and swarm
|
|
15008
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
15508
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$10);
|
|
15009
15509
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15010
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15510
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$10);
|
|
15011
15511
|
// Execute the command within an execution context with performance tracking
|
|
15012
15512
|
return ExecutionContextService.runInContext(async () => {
|
|
15013
15513
|
let isFinished = false;
|
|
15014
15514
|
swarm$1.perfService.startExecution(executionId, clientId, content.length);
|
|
15015
15515
|
try {
|
|
15016
15516
|
swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
|
|
15017
|
-
const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$
|
|
15517
|
+
const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$10, clientId, swarmName);
|
|
15018
15518
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
15019
15519
|
swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
|
|
15020
15520
|
return result;
|
|
@@ -15031,7 +15531,7 @@ const executeForce = beginContext(async (content, clientId) => {
|
|
|
15031
15531
|
});
|
|
15032
15532
|
});
|
|
15033
15533
|
|
|
15034
|
-
const METHOD_NAME
|
|
15534
|
+
const METHOD_NAME$$ = "function.template.navigateToTriageAgent";
|
|
15035
15535
|
const DEFAULT_ACCEPT_FN = (_, defaultAgent) => `Successfully navigated to ${defaultAgent}`;
|
|
15036
15536
|
const DEFAULT_REJECT_FN = (_, defaultAgent) => `Already on ${defaultAgent}`;
|
|
15037
15537
|
/**
|
|
@@ -15080,7 +15580,7 @@ const createNavigateToTriageAgent = async ({ flushMessage, executeMessage, toolO
|
|
|
15080
15580
|
*/
|
|
15081
15581
|
return beginContext(async (toolId, clientId) => {
|
|
15082
15582
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15083
|
-
swarm$1.loggerService.log(METHOD_NAME
|
|
15583
|
+
swarm$1.loggerService.log(METHOD_NAME$$, {
|
|
15084
15584
|
clientId,
|
|
15085
15585
|
toolId,
|
|
15086
15586
|
});
|
|
@@ -15110,55 +15610,258 @@ const createNavigateToTriageAgent = async ({ flushMessage, executeMessage, toolO
|
|
|
15110
15610
|
});
|
|
15111
15611
|
};
|
|
15112
15612
|
|
|
15113
|
-
|
|
15114
|
-
const METHOD_NAME$X = "function.setup.addWiki";
|
|
15613
|
+
const METHOD_NAME$_ = "function.navigate.changeToAgent";
|
|
15115
15614
|
/**
|
|
15116
|
-
*
|
|
15117
|
-
*
|
|
15118
|
-
* @
|
|
15119
|
-
* @returns {string} The name of the added wiki
|
|
15615
|
+
* Time-to-live for the change agent function in milliseconds.
|
|
15616
|
+
* Defines how long the cached change agent function remains valid before expiring.
|
|
15617
|
+
* @constant {number}
|
|
15120
15618
|
*/
|
|
15121
|
-
const
|
|
15122
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15123
|
-
swarm$1.loggerService.log(METHOD_NAME$X, {
|
|
15124
|
-
wikiSchema,
|
|
15125
|
-
});
|
|
15126
|
-
swarm$1.wikiValidationService.addWiki(wikiSchema.wikiName, wikiSchema);
|
|
15127
|
-
swarm$1.wikiSchemaService.register(wikiSchema.wikiName, wikiSchema);
|
|
15128
|
-
return wikiSchema.wikiName;
|
|
15129
|
-
});
|
|
15130
|
-
|
|
15131
|
-
const METHOD_NAME$W = "function.setup.addAgent";
|
|
15619
|
+
const CHANGE_AGENT_TTL$1 = 15 * 60 * 1000;
|
|
15132
15620
|
/**
|
|
15133
|
-
*
|
|
15621
|
+
* Garbage collection interval for the change agent function in milliseconds.
|
|
15622
|
+
* Specifies the frequency at which expired TTL entries are cleaned up.
|
|
15623
|
+
* @constant {number}
|
|
15624
|
+
*/
|
|
15625
|
+
const CHANGE_AGENT_GC$1 = 60 * 1000;
|
|
15626
|
+
/**
|
|
15627
|
+
* Creates a change agent function with time-to-live (TTL) and queuing capabilities.
|
|
15134
15628
|
*
|
|
15135
|
-
* This function
|
|
15136
|
-
*
|
|
15137
|
-
* outside of existing method and execution contexts, providing a clean execution environment. The function logs the operation if enabled
|
|
15138
|
-
* and returns the agent's name upon successful registration.
|
|
15629
|
+
* This factory function generates a queued, TTL-limited function to handle agent changes for a specific client session,
|
|
15630
|
+
* ensuring operations are executed sequentially and cached results are reused within the TTL period.
|
|
15139
15631
|
*
|
|
15140
|
-
* @
|
|
15141
|
-
* @
|
|
15142
|
-
* @
|
|
15143
|
-
* @example
|
|
15144
|
-
* const agentSchema = { agentName: "AgentX", prompt: "Handle tasks" };
|
|
15145
|
-
* const agentName = addAgent(agentSchema);
|
|
15146
|
-
* console.log(agentName); // Outputs "AgentX"
|
|
15632
|
+
* @function
|
|
15633
|
+
* @param {string} clientId - The unique identifier of the client session.
|
|
15634
|
+
* @returns {TChangeToAgentRun} A function that performs the agent change operation with queuing and TTL.
|
|
15147
15635
|
*/
|
|
15148
|
-
const
|
|
15149
|
-
|
|
15150
|
-
|
|
15151
|
-
|
|
15152
|
-
|
|
15153
|
-
|
|
15154
|
-
|
|
15155
|
-
|
|
15636
|
+
const createChangeToAgent = functoolsKit.ttl((clientId) => functoolsKit.queued(async (methodName, agentName, swarmName) => {
|
|
15637
|
+
if (!swarm$1.navigationValidationService.shouldNavigate(agentName, clientId, swarmName)) {
|
|
15638
|
+
console.warn(`function "changeToAgent" skipped due to the circular route found clientId=${clientId} swarmName=${swarmName} agentNameTo=${agentName}`);
|
|
15639
|
+
return false;
|
|
15640
|
+
}
|
|
15641
|
+
// Notify all agents in the swarm of the change
|
|
15642
|
+
await Promise.all(swarm$1.swarmValidationService
|
|
15643
|
+
.getAgentList(swarmName)
|
|
15644
|
+
.map(async (agentName) => {
|
|
15645
|
+
await swarm$1.agentPublicService.commitAgentChange(methodName, clientId, agentName);
|
|
15646
|
+
}));
|
|
15647
|
+
{
|
|
15648
|
+
// Dispose of the current agent's resources and set up the new agent
|
|
15649
|
+
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$_, clientId, swarmName);
|
|
15650
|
+
await swarm$1.agentPublicService.dispose(methodName, clientId, agentName);
|
|
15651
|
+
await swarm$1.historyPublicService.dispose(methodName, clientId, agentName);
|
|
15652
|
+
await swarm$1.swarmPublicService.setAgentRef(methodName, clientId, swarmName, agentName, await swarm$1.agentPublicService.createAgentRef(methodName, clientId, agentName));
|
|
15653
|
+
}
|
|
15654
|
+
// Set the new agent as the active agent
|
|
15655
|
+
await swarm$1.swarmPublicService.setAgentName(agentName, methodName, clientId, swarmName);
|
|
15656
|
+
return true;
|
|
15657
|
+
}), {
|
|
15658
|
+
key: ([clientId]) => `${clientId}`,
|
|
15659
|
+
timeout: CHANGE_AGENT_TTL$1,
|
|
15660
|
+
});
|
|
15661
|
+
/**
|
|
15662
|
+
* Creates a garbage collector for the change agent function.
|
|
15663
|
+
*
|
|
15664
|
+
* This function sets up a singleton interval-based garbage collector to periodically clean up expired TTL entries from `createChangeToAgent`.
|
|
15665
|
+
*
|
|
15666
|
+
* @function
|
|
15667
|
+
* @returns {Promise<void>} A promise that resolves when the garbage collector is initialized.
|
|
15668
|
+
*/
|
|
15669
|
+
const createGc$2 = functoolsKit.singleshot(async () => {
|
|
15670
|
+
setInterval(createChangeToAgent.gc, CHANGE_AGENT_GC$1);
|
|
15671
|
+
});
|
|
15672
|
+
/**
|
|
15673
|
+
* Changes the active agent for a given client session in a swarm.
|
|
15674
|
+
*
|
|
15675
|
+
* This function facilitates switching the active agent in a swarm session, validating the session and agent dependencies,
|
|
15676
|
+
* logging the operation if enabled, and executing the change using a TTL-limited, queued runner.
|
|
15677
|
+
* The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts.
|
|
15678
|
+
*
|
|
15679
|
+
* @param {AgentName} agentName - The name of the agent to switch to.
|
|
15680
|
+
* @param {string} clientId - The unique identifier of the client session.
|
|
15681
|
+
* @returns {Promise<boolean>} A promise that resolves when the agent change is complete. If it resolved false, the navigation is canceled due to recursion
|
|
15682
|
+
* @throws {Error} If session or agent validation fails, or if the agent change process encounters an error.
|
|
15683
|
+
* @example
|
|
15684
|
+
* await changeToAgent("AgentX", "client-123");
|
|
15685
|
+
*/
|
|
15686
|
+
const changeToAgent = beginContext(async (agentName, clientId) => {
|
|
15687
|
+
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15688
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15689
|
+
swarm$1.loggerService.log(METHOD_NAME$_, {
|
|
15690
|
+
agentName,
|
|
15691
|
+
clientId,
|
|
15692
|
+
});
|
|
15693
|
+
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15694
|
+
{
|
|
15695
|
+
// Validate session, agent, and dependencies
|
|
15696
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$_);
|
|
15697
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$_);
|
|
15698
|
+
const activeAgent = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$_, clientId, swarmName);
|
|
15699
|
+
if (!swarm$1.agentValidationService.hasDependency(activeAgent, agentName)) {
|
|
15700
|
+
console.error(`agent-swarm missing dependency detected for activeAgent=${activeAgent} dependencyAgent=${agentName}`);
|
|
15701
|
+
}
|
|
15702
|
+
}
|
|
15703
|
+
if (!swarm$1.swarmValidationService.getAgentSet(swarmName).has(agentName)) {
|
|
15704
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15705
|
+
swarm$1.loggerService.log('function "changeToAgent" skipped due to the agent is not in the swarm', {
|
|
15706
|
+
agentName,
|
|
15707
|
+
clientId,
|
|
15708
|
+
swarmName,
|
|
15709
|
+
});
|
|
15710
|
+
console.warn(`function "changeToAgent" skipped due to the agent is not in the swarm clientId=${clientId} agentName=${agentName} swarmName=${swarmName}`);
|
|
15711
|
+
return false;
|
|
15712
|
+
}
|
|
15713
|
+
// Execute the agent change with TTL and queuing
|
|
15714
|
+
const run = await createChangeToAgent(clientId);
|
|
15715
|
+
createGc$2();
|
|
15716
|
+
return await run(METHOD_NAME$_, agentName, swarmName);
|
|
15717
|
+
});
|
|
15718
|
+
|
|
15719
|
+
const METHOD_NAME$Z = "function.template.navigateToAgent";
|
|
15720
|
+
/**
|
|
15721
|
+
* Default tool output message indicating successful navigation to the specified agent.
|
|
15722
|
+
*
|
|
15723
|
+
* @param {SessionId} _ - The client session ID (unused).
|
|
15724
|
+
* @param {AgentName} agentName - The name of the agent navigated to.
|
|
15725
|
+
* @returns {string} A message confirming navigation to the agent.
|
|
15726
|
+
*/
|
|
15727
|
+
const DEFAULT_TOOL_OUTPUT = (_, agentName) => `Successfully navigated to ${agentName}`;
|
|
15728
|
+
/**
|
|
15729
|
+
* Default flush message prompting the user to repeat their input.
|
|
15730
|
+
*
|
|
15731
|
+
* @param {SessionId} _ - The client session ID (unused).
|
|
15732
|
+
* @param {AgentName} _ - The agent name (unused).
|
|
15733
|
+
* @returns {string} A generic retry message.
|
|
15734
|
+
*/
|
|
15735
|
+
const DEFAULT_FLUSH_MESSAGE = ({}, {}) => `Sorry, I missed that. Could you repeat please`;
|
|
15736
|
+
/**
|
|
15737
|
+
* Creates a function to navigate to a specified agent for a given client, handling navigation, message execution, emission, and tool output.
|
|
15738
|
+
* The factory generates a handler that checks navigation state, retrieves the last user message, commits tool outputs, and triggers execution or emission based on provided parameters.
|
|
15739
|
+
* It validates the presence of either `emitMessage` or `executeMessage` to ensure proper navigation behavior.
|
|
15740
|
+
* Logs the navigation operation if logging is enabled in the global configuration.
|
|
15741
|
+
*
|
|
15742
|
+
* @param {IFactoryParams} params - Configuration parameters for the navigation handler.
|
|
15743
|
+
* @param {string | ((clientId: string, defaultAgent: AgentName) => string | Promise<string>)} [params.flushMessage] - Optional message or function to emit after flushing the session, defaults to `DEFAULT_FLUSH_MESSAGE`.
|
|
15744
|
+
* @param {string | ((clientId: string, agentName: AgentName) => string | Promise<string>)} [params.toolOutput] - Optional message or function for tool output when navigation occurs, defaults to `DEFAULT_TOOL_OUTPUT`.
|
|
15745
|
+
* @param {string | ((clientId: string, lastMessage: string, agentName: AgentName) => string | Promise<string>)} [params.emitMessage] - Optional message or function to emit when navigation occurs without execution.
|
|
15746
|
+
* @param {string | ((clientId: string, lastMessage: string, agentName: AgentName) => string | Promise<string>)} [params.executeMessage] - Optional message or function to execute when navigation occurs with execution.
|
|
15747
|
+
* @returns {Promise<(toolId: string, clientId: string, agentName: AgentName) => Promise<void>>} A promise resolving to a function that handles navigation to the specified agent.
|
|
15748
|
+
* @throws {Error} If neither `emitMessage` nor `executeMessage` is provided, or if any internal operation (e.g., navigation, commit, or execution) fails.
|
|
15749
|
+
*
|
|
15750
|
+
* @example
|
|
15751
|
+
* // Create a navigation handler with static messages
|
|
15752
|
+
* const navigate = await createNavigateToAgent({
|
|
15753
|
+
* flushMessage: "Session reset.",
|
|
15754
|
+
* toolOutput: "Navigation completed.",
|
|
15755
|
+
* emitMessage: "Navigation event triggered.",
|
|
15756
|
+
* });
|
|
15757
|
+
* await navigate("tool-123", "client-456", "WeatherAgent");
|
|
15758
|
+
* // Navigates to WeatherAgent, commits tool output, and emits the message.
|
|
15759
|
+
*
|
|
15760
|
+
* @example
|
|
15761
|
+
* // Create a navigation handler with dynamic messages
|
|
15762
|
+
* const navigate = await createNavigateToAgent({
|
|
15763
|
+
* executeMessage: (clientId, lastMessage, agent) => `Processing ${lastMessage} for ${clientId} on ${agent}`,
|
|
15764
|
+
* toolOutput: (clientId, agent) => `Navigated ${clientId} to ${agent}`,
|
|
15765
|
+
* });
|
|
15766
|
+
* await navigate("tool-789", "client-012", "SupportAgent");
|
|
15767
|
+
* // Navigates to SupportAgent, commits dynamic tool output, and executes the message with the last user message.
|
|
15768
|
+
*/
|
|
15769
|
+
const createNavigateToAgent = async ({ executeMessage, emitMessage, flushMessage = DEFAULT_FLUSH_MESSAGE, toolOutput = DEFAULT_TOOL_OUTPUT, }) => {
|
|
15770
|
+
if (!emitMessage && !executeMessage) {
|
|
15771
|
+
throw new Error("agent-swarm createNavigateToAgent emitMessage or executeMessage required");
|
|
15772
|
+
}
|
|
15773
|
+
/**
|
|
15774
|
+
* Navigates to a specified agent for a given client and tool, handling message commits, execution, or emission using the last user message.
|
|
15775
|
+
*
|
|
15776
|
+
* @param {string} toolId - The identifier of the tool triggering the navigation.
|
|
15777
|
+
* @param {string} clientId - The unique identifier of the client session.
|
|
15778
|
+
* @param {AgentName} agentName - The name of the agent to navigate to.
|
|
15779
|
+
* @returns {Promise<void>} A promise that resolves when the navigation and associated actions are complete.
|
|
15780
|
+
* @throws {Error} If navigation, commit, execution, or emission operations fail (e.g., invalid clientId or agentName).
|
|
15781
|
+
*/
|
|
15782
|
+
return beginContext(async (toolId, clientId, agentName) => {
|
|
15783
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15784
|
+
swarm$1.loggerService.log(METHOD_NAME$Z, {
|
|
15785
|
+
clientId,
|
|
15786
|
+
toolId,
|
|
15787
|
+
});
|
|
15788
|
+
const lastMessage = await getLastUserMessage(clientId);
|
|
15789
|
+
if (await functoolsKit.and(functoolsKit.not(hasNavigation(clientId, agentName)), Promise.resolve(!!executeMessage))) {
|
|
15790
|
+
await commitToolOutputForce(toolId, typeof toolOutput === "string"
|
|
15791
|
+
? toolOutput
|
|
15792
|
+
: await toolOutput(clientId, agentName), clientId);
|
|
15793
|
+
await changeToAgent(agentName, clientId);
|
|
15794
|
+
await executeForce(typeof executeMessage === "string"
|
|
15795
|
+
? executeMessage
|
|
15796
|
+
: await executeMessage(clientId, lastMessage, agentName), clientId);
|
|
15797
|
+
return;
|
|
15798
|
+
}
|
|
15799
|
+
if (await functoolsKit.and(functoolsKit.not(hasNavigation(clientId, agentName)), Promise.resolve(!!emitMessage))) {
|
|
15800
|
+
await commitToolOutputForce(toolId, typeof toolOutput === "string"
|
|
15801
|
+
? toolOutput
|
|
15802
|
+
: await toolOutput(clientId, agentName), clientId);
|
|
15803
|
+
await changeToAgent(agentName, clientId);
|
|
15804
|
+
await emitForce(typeof emitMessage === "string"
|
|
15805
|
+
? emitMessage
|
|
15806
|
+
: await emitMessage(clientId, lastMessage, agentName), clientId);
|
|
15807
|
+
return;
|
|
15808
|
+
}
|
|
15809
|
+
await commitFlushForce(clientId);
|
|
15810
|
+
await emitForce(typeof flushMessage === "string"
|
|
15811
|
+
? flushMessage
|
|
15812
|
+
: await flushMessage(clientId, agentName), clientId);
|
|
15813
|
+
});
|
|
15814
|
+
};
|
|
15815
|
+
|
|
15816
|
+
/** @constant {string} METHOD_NAME - The name of the method used for logging */
|
|
15817
|
+
const METHOD_NAME$Y = "function.setup.addWiki";
|
|
15818
|
+
/**
|
|
15819
|
+
* Adds a wiki schema to the system
|
|
15820
|
+
* @function addWiki
|
|
15821
|
+
* @param {IWikiSchema} wikiSchema - The wiki schema to add
|
|
15822
|
+
* @returns {string} The name of the added wiki
|
|
15823
|
+
*/
|
|
15824
|
+
const addWiki = beginContext((wikiSchema) => {
|
|
15825
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15826
|
+
swarm$1.loggerService.log(METHOD_NAME$Y, {
|
|
15827
|
+
wikiSchema,
|
|
15828
|
+
});
|
|
15829
|
+
swarm$1.wikiValidationService.addWiki(wikiSchema.wikiName, wikiSchema);
|
|
15830
|
+
swarm$1.wikiSchemaService.register(wikiSchema.wikiName, wikiSchema);
|
|
15831
|
+
return wikiSchema.wikiName;
|
|
15832
|
+
});
|
|
15833
|
+
|
|
15834
|
+
const METHOD_NAME$X = "function.setup.addAgent";
|
|
15835
|
+
/**
|
|
15836
|
+
* Adds a new agent to the agent registry for use within the swarm system.
|
|
15837
|
+
*
|
|
15838
|
+
* This function registers a new agent by adding it to the agent validation and schema services, making it available for swarm operations.
|
|
15839
|
+
* Only agents registered through this function can be utilized by the swarm. The execution is wrapped in `beginContext` to ensure it runs
|
|
15840
|
+
* outside of existing method and execution contexts, providing a clean execution environment. The function logs the operation if enabled
|
|
15841
|
+
* and returns the agent's name upon successful registration.
|
|
15842
|
+
*
|
|
15843
|
+
* @param {IAgentSchema} agentSchema - The schema defining the agent's properties, including its name (`agentName`) and other configuration details.
|
|
15844
|
+
* @returns {string} The name of the newly added agent (`agentSchema.agentName`), confirming its registration.
|
|
15845
|
+
* @throws {Error} If the agent schema is invalid or if registration fails due to conflicts or service errors (e.g., duplicate agent name).
|
|
15846
|
+
* @example
|
|
15847
|
+
* const agentSchema = { agentName: "AgentX", prompt: "Handle tasks" };
|
|
15848
|
+
* const agentName = addAgent(agentSchema);
|
|
15849
|
+
* console.log(agentName); // Outputs "AgentX"
|
|
15850
|
+
*/
|
|
15851
|
+
const addAgent = beginContext((agentSchema) => {
|
|
15852
|
+
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15853
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15854
|
+
swarm$1.loggerService.log(METHOD_NAME$X, {
|
|
15855
|
+
agentSchema,
|
|
15856
|
+
});
|
|
15857
|
+
// Register the agent in the validation and schema services
|
|
15858
|
+
swarm$1.agentValidationService.addAgent(agentSchema.agentName, agentSchema);
|
|
15156
15859
|
swarm$1.agentSchemaService.register(agentSchema.agentName, agentSchema);
|
|
15157
15860
|
// Return the agent's name as confirmation of registration
|
|
15158
15861
|
return agentSchema.agentName;
|
|
15159
15862
|
});
|
|
15160
15863
|
|
|
15161
|
-
const METHOD_NAME$
|
|
15864
|
+
const METHOD_NAME$W = "function.setup.addCompletion";
|
|
15162
15865
|
/**
|
|
15163
15866
|
* Adds a completion engine to the registry for use by agents in the swarm system.
|
|
15164
15867
|
*
|
|
@@ -15178,7 +15881,7 @@ const METHOD_NAME$V = "function.setup.addCompletion";
|
|
|
15178
15881
|
const addCompletion = beginContext((completionSchema) => {
|
|
15179
15882
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15180
15883
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15181
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15884
|
+
swarm$1.loggerService.log(METHOD_NAME$W, {
|
|
15182
15885
|
completionSchema,
|
|
15183
15886
|
});
|
|
15184
15887
|
// Register the completion in the validation and schema services
|
|
@@ -15188,7 +15891,7 @@ const addCompletion = beginContext((completionSchema) => {
|
|
|
15188
15891
|
return completionSchema.completionName;
|
|
15189
15892
|
});
|
|
15190
15893
|
|
|
15191
|
-
const METHOD_NAME$
|
|
15894
|
+
const METHOD_NAME$V = "function.setup.addSwarm";
|
|
15192
15895
|
/**
|
|
15193
15896
|
* Adds a new swarm to the system for managing client sessions.
|
|
15194
15897
|
*
|
|
@@ -15208,7 +15911,7 @@ const METHOD_NAME$U = "function.setup.addSwarm";
|
|
|
15208
15911
|
const addSwarm = beginContext((swarmSchema) => {
|
|
15209
15912
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15210
15913
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15211
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15914
|
+
swarm$1.loggerService.log(METHOD_NAME$V, {
|
|
15212
15915
|
swarmSchema,
|
|
15213
15916
|
});
|
|
15214
15917
|
// Register the swarm in the validation and schema services
|
|
@@ -15218,7 +15921,7 @@ const addSwarm = beginContext((swarmSchema) => {
|
|
|
15218
15921
|
return swarmSchema.swarmName;
|
|
15219
15922
|
});
|
|
15220
15923
|
|
|
15221
|
-
const METHOD_NAME$
|
|
15924
|
+
const METHOD_NAME$U = "function.setup.addTool";
|
|
15222
15925
|
/**
|
|
15223
15926
|
* Adds a new tool to the tool registry for use by agents in the swarm system.
|
|
15224
15927
|
*
|
|
@@ -15240,7 +15943,7 @@ const METHOD_NAME$T = "function.setup.addTool";
|
|
|
15240
15943
|
const addTool = beginContext((toolSchema) => {
|
|
15241
15944
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15242
15945
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15243
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15946
|
+
swarm$1.loggerService.log(METHOD_NAME$U, {
|
|
15244
15947
|
toolSchema,
|
|
15245
15948
|
});
|
|
15246
15949
|
// Register the tool in the validation and schema services
|
|
@@ -15250,6 +15953,17 @@ const addTool = beginContext((toolSchema) => {
|
|
|
15250
15953
|
return toolSchema.toolName;
|
|
15251
15954
|
});
|
|
15252
15955
|
|
|
15956
|
+
const METHOD_NAME$T = "function.setup.addMCP";
|
|
15957
|
+
const addMCP = beginContext((mcpSchema) => {
|
|
15958
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15959
|
+
swarm$1.loggerService.log(METHOD_NAME$T, {
|
|
15960
|
+
mcpSchema,
|
|
15961
|
+
});
|
|
15962
|
+
swarm$1.mcpValidationService.addMCP(mcpSchema.mcpName, mcpSchema);
|
|
15963
|
+
swarm$1.mcpSchemaService.register(mcpSchema.mcpName, mcpSchema);
|
|
15964
|
+
return mcpSchema.mcpName;
|
|
15965
|
+
});
|
|
15966
|
+
|
|
15253
15967
|
const METHOD_NAME$S = "function.setup.addState";
|
|
15254
15968
|
/**
|
|
15255
15969
|
* Adds a new state to the state registry for use within the swarm system.
|
|
@@ -15628,7 +16342,16 @@ const overrideTool = beginContext((toolSchema) => {
|
|
|
15628
16342
|
return swarm$1.toolSchemaService.override(toolSchema.toolName, toolSchema);
|
|
15629
16343
|
});
|
|
15630
16344
|
|
|
15631
|
-
const METHOD_NAME$G = "function.test.
|
|
16345
|
+
const METHOD_NAME$G = "function.test.overrideMCP";
|
|
16346
|
+
const overrideMCP = beginContext((mcpSchema) => {
|
|
16347
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16348
|
+
swarm$1.loggerService.log(METHOD_NAME$G, {
|
|
16349
|
+
mcpSchema,
|
|
16350
|
+
});
|
|
16351
|
+
return swarm$1.mcpSchemaService.override(mcpSchema.mcpName, mcpSchema);
|
|
16352
|
+
});
|
|
16353
|
+
|
|
16354
|
+
const METHOD_NAME$F = "function.test.overrideWiki";
|
|
15632
16355
|
/**
|
|
15633
16356
|
* Overrides an existing wiki schema in the swarm system with a new or partial schema.
|
|
15634
16357
|
* This function updates the configuration of a wiki identified by its `wikiName`, applying the provided schema properties.
|
|
@@ -15652,13 +16375,13 @@ const METHOD_NAME$G = "function.test.overrideWiki";
|
|
|
15652
16375
|
*/
|
|
15653
16376
|
const overrideWiki = beginContext((wikiSchema) => {
|
|
15654
16377
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15655
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16378
|
+
swarm$1.loggerService.log(METHOD_NAME$F, {
|
|
15656
16379
|
wikiSchema,
|
|
15657
16380
|
});
|
|
15658
16381
|
return swarm$1.wikiSchemaService.override(wikiSchema.wikiName, wikiSchema);
|
|
15659
16382
|
});
|
|
15660
16383
|
|
|
15661
|
-
const METHOD_NAME$
|
|
16384
|
+
const METHOD_NAME$E = "function.other.markOnline";
|
|
15662
16385
|
/**
|
|
15663
16386
|
* Marks a client as online in the specified swarm.
|
|
15664
16387
|
*
|
|
@@ -15670,26 +16393,27 @@ const METHOD_NAME$F = "function.other.markOnline";
|
|
|
15670
16393
|
const markOnline = async (clientId, swarmName) => {
|
|
15671
16394
|
// Log the operation if logging is enabled in the global configuration
|
|
15672
16395
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15673
|
-
swarm.loggerService.log(METHOD_NAME$
|
|
16396
|
+
swarm.loggerService.log(METHOD_NAME$E, {
|
|
15674
16397
|
clientId,
|
|
15675
16398
|
});
|
|
15676
16399
|
// Validate the swarm name
|
|
15677
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16400
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$E);
|
|
15678
16401
|
// Run the operation in the method context
|
|
15679
16402
|
return await MethodContextService.runInContext(async () => {
|
|
15680
|
-
await swarm.aliveService.markOnline(clientId, swarmName, METHOD_NAME$
|
|
16403
|
+
await swarm.aliveService.markOnline(clientId, swarmName, METHOD_NAME$E);
|
|
15681
16404
|
}, {
|
|
15682
|
-
methodName: METHOD_NAME$
|
|
16405
|
+
methodName: METHOD_NAME$E,
|
|
15683
16406
|
agentName: "",
|
|
15684
16407
|
policyName: "",
|
|
15685
16408
|
stateName: "",
|
|
15686
16409
|
storageName: "",
|
|
16410
|
+
mcpName: "",
|
|
15687
16411
|
swarmName,
|
|
15688
16412
|
clientId,
|
|
15689
16413
|
});
|
|
15690
16414
|
};
|
|
15691
16415
|
|
|
15692
|
-
const METHOD_NAME$
|
|
16416
|
+
const METHOD_NAME$D = "function.other.markOffline";
|
|
15693
16417
|
/**
|
|
15694
16418
|
* Marks a client as offline in the specified swarm.
|
|
15695
16419
|
*
|
|
@@ -15704,24 +16428,25 @@ const METHOD_NAME$E = "function.other.markOffline";
|
|
|
15704
16428
|
*/
|
|
15705
16429
|
const markOffline = async (clientId, swarmName) => {
|
|
15706
16430
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15707
|
-
swarm.loggerService.log(METHOD_NAME$
|
|
16431
|
+
swarm.loggerService.log(METHOD_NAME$D, {
|
|
15708
16432
|
clientId,
|
|
15709
16433
|
});
|
|
15710
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16434
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$D);
|
|
15711
16435
|
return await MethodContextService.runInContext(async () => {
|
|
15712
|
-
await swarm.aliveService.markOffline(clientId, swarmName, METHOD_NAME$
|
|
16436
|
+
await swarm.aliveService.markOffline(clientId, swarmName, METHOD_NAME$D);
|
|
15713
16437
|
}, {
|
|
15714
|
-
methodName: METHOD_NAME$
|
|
16438
|
+
methodName: METHOD_NAME$D,
|
|
15715
16439
|
agentName: "",
|
|
15716
16440
|
policyName: "",
|
|
15717
16441
|
stateName: "",
|
|
15718
16442
|
storageName: "",
|
|
16443
|
+
mcpName: "",
|
|
15719
16444
|
swarmName,
|
|
15720
16445
|
clientId,
|
|
15721
16446
|
});
|
|
15722
16447
|
};
|
|
15723
16448
|
|
|
15724
|
-
const METHOD_NAME$
|
|
16449
|
+
const METHOD_NAME$C = "function.commit.commitToolOutput";
|
|
15725
16450
|
/**
|
|
15726
16451
|
* Commits the output of a tool execution to the active agent in a swarm session.
|
|
15727
16452
|
*
|
|
@@ -15741,19 +16466,19 @@ const METHOD_NAME$D = "function.commit.commitToolOutput";
|
|
|
15741
16466
|
const commitToolOutput = beginContext(async (toolId, content, clientId, agentName) => {
|
|
15742
16467
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15743
16468
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15744
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16469
|
+
swarm$1.loggerService.log(METHOD_NAME$C, {
|
|
15745
16470
|
toolId,
|
|
15746
16471
|
content,
|
|
15747
16472
|
clientId,
|
|
15748
16473
|
agentName,
|
|
15749
16474
|
});
|
|
15750
16475
|
// Validate the agent, session, and swarm to ensure they exist and are accessible
|
|
15751
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
15752
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16476
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$C);
|
|
16477
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$C);
|
|
15753
16478
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15754
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16479
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$C);
|
|
15755
16480
|
// Check if the specified agent is still the active agent in the swarm session
|
|
15756
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16481
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$C, clientId, swarmName);
|
|
15757
16482
|
if (currentAgentName !== agentName) {
|
|
15758
16483
|
// Log a skip message if the agent has changed during the operation
|
|
15759
16484
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
@@ -15766,11 +16491,11 @@ const commitToolOutput = beginContext(async (toolId, content, clientId, agentNam
|
|
|
15766
16491
|
return;
|
|
15767
16492
|
}
|
|
15768
16493
|
// Commit the tool output to the session via the session public service
|
|
15769
|
-
await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$
|
|
16494
|
+
await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$C, clientId, swarmName);
|
|
15770
16495
|
});
|
|
15771
16496
|
|
|
15772
16497
|
/** @private Constant defining the method name for logging and validation context */
|
|
15773
|
-
const METHOD_NAME$
|
|
16498
|
+
const METHOD_NAME$B = "function.commit.commitSystemMessage";
|
|
15774
16499
|
/**
|
|
15775
16500
|
* Commits a system-generated message to the active agent in the swarm system.
|
|
15776
16501
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before committing the message.
|
|
@@ -15789,20 +16514,20 @@ const METHOD_NAME$C = "function.commit.commitSystemMessage";
|
|
|
15789
16514
|
const commitSystemMessage = beginContext(async (content, clientId, agentName) => {
|
|
15790
16515
|
// Log the commit attempt if enabled
|
|
15791
16516
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15792
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16517
|
+
swarm$1.loggerService.log(METHOD_NAME$B, {
|
|
15793
16518
|
content,
|
|
15794
16519
|
clientId,
|
|
15795
16520
|
agentName,
|
|
15796
16521
|
});
|
|
15797
16522
|
// Validate the agent exists
|
|
15798
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16523
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$B);
|
|
15799
16524
|
// Validate the session exists and retrieve the associated swarm
|
|
15800
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16525
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$B);
|
|
15801
16526
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15802
16527
|
// Validate the swarm configuration
|
|
15803
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16528
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$B);
|
|
15804
16529
|
// Check if the current agent matches the provided agent
|
|
15805
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16530
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$B, clientId, swarmName);
|
|
15806
16531
|
if (currentAgentName !== agentName) {
|
|
15807
16532
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15808
16533
|
swarm$1.loggerService.log('function "commitSystemMessage" skipped due to the agent change', {
|
|
@@ -15813,11 +16538,11 @@ const commitSystemMessage = beginContext(async (content, clientId, agentName) =>
|
|
|
15813
16538
|
return;
|
|
15814
16539
|
}
|
|
15815
16540
|
// Commit the system message via SessionPublicService
|
|
15816
|
-
await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$
|
|
16541
|
+
await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$B, clientId, swarmName);
|
|
15817
16542
|
});
|
|
15818
16543
|
|
|
15819
16544
|
/** @private Constant defining the method name for logging and validation context */
|
|
15820
|
-
const METHOD_NAME$
|
|
16545
|
+
const METHOD_NAME$A = "function.commit.commitFlush";
|
|
15821
16546
|
/**
|
|
15822
16547
|
* Commits a flush of agent history for a specific client and agent in the swarm system.
|
|
15823
16548
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before flushing the history.
|
|
@@ -15834,19 +16559,19 @@ const METHOD_NAME$B = "function.commit.commitFlush";
|
|
|
15834
16559
|
const commitFlush = beginContext(async (clientId, agentName) => {
|
|
15835
16560
|
// Log the flush attempt if enabled
|
|
15836
16561
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15837
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16562
|
+
swarm$1.loggerService.log(METHOD_NAME$A, {
|
|
15838
16563
|
clientId,
|
|
15839
16564
|
agentName,
|
|
15840
16565
|
});
|
|
15841
16566
|
// Validate the agent exists
|
|
15842
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16567
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$A);
|
|
15843
16568
|
// Validate the session exists and retrieve the associated swarm
|
|
15844
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16569
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$A);
|
|
15845
16570
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15846
16571
|
// Validate the swarm configuration
|
|
15847
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16572
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$A);
|
|
15848
16573
|
// Check if the current agent matches the provided agent
|
|
15849
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16574
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$A, clientId, swarmName);
|
|
15850
16575
|
if (currentAgentName !== agentName) {
|
|
15851
16576
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15852
16577
|
swarm$1.loggerService.log('function "commitFlush" skipped due to the agent change', {
|
|
@@ -15857,10 +16582,10 @@ const commitFlush = beginContext(async (clientId, agentName) => {
|
|
|
15857
16582
|
return;
|
|
15858
16583
|
}
|
|
15859
16584
|
// Commit the flush of agent history via SessionPublicService
|
|
15860
|
-
await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$
|
|
16585
|
+
await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$A, clientId, swarmName);
|
|
15861
16586
|
});
|
|
15862
16587
|
|
|
15863
|
-
const METHOD_NAME$
|
|
16588
|
+
const METHOD_NAME$z = "function.commit.commitSystemMessage";
|
|
15864
16589
|
/**
|
|
15865
16590
|
* Commits a user message to the active agent's history in a swarm session without triggering a response.
|
|
15866
16591
|
*
|
|
@@ -15879,19 +16604,19 @@ const METHOD_NAME$A = "function.commit.commitSystemMessage";
|
|
|
15879
16604
|
const commitUserMessage = beginContext(async (content, mode, clientId, agentName, payload) => {
|
|
15880
16605
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15881
16606
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15882
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16607
|
+
swarm$1.loggerService.log(METHOD_NAME$z, {
|
|
15883
16608
|
content,
|
|
15884
16609
|
clientId,
|
|
15885
16610
|
agentName,
|
|
15886
16611
|
mode,
|
|
15887
16612
|
});
|
|
15888
16613
|
// Validate the agent, session, and swarm to ensure they exist and are accessible
|
|
15889
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
15890
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16614
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$z);
|
|
16615
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$z);
|
|
15891
16616
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15892
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16617
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$z);
|
|
15893
16618
|
// Check if the specified agent is still the active agent in the swarm session
|
|
15894
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16619
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$z, clientId, swarmName);
|
|
15895
16620
|
if (currentAgentName !== agentName) {
|
|
15896
16621
|
// Log a skip message if the agent has changed during the operation
|
|
15897
16622
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
@@ -15904,18 +16629,18 @@ const commitUserMessage = beginContext(async (content, mode, clientId, agentName
|
|
|
15904
16629
|
}
|
|
15905
16630
|
if (payload) {
|
|
15906
16631
|
return await PayloadContextService.runInContext(async () => {
|
|
15907
|
-
await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$
|
|
16632
|
+
await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$z, clientId, swarmName);
|
|
15908
16633
|
}, {
|
|
15909
16634
|
clientId,
|
|
15910
16635
|
payload,
|
|
15911
16636
|
});
|
|
15912
16637
|
}
|
|
15913
16638
|
// Commit the user message to the agent's history via the session public service
|
|
15914
|
-
return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$
|
|
16639
|
+
return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$z, clientId, swarmName);
|
|
15915
16640
|
});
|
|
15916
16641
|
|
|
15917
16642
|
/** @private Constant defining the method name for logging and validation context */
|
|
15918
|
-
const METHOD_NAME$
|
|
16643
|
+
const METHOD_NAME$y = "function.commit.commitSystemMessageForce";
|
|
15919
16644
|
/**
|
|
15920
16645
|
* Forcefully commits a system-generated message to a session in the swarm system, without checking the active agent.
|
|
15921
16646
|
* Validates the session and swarm, then proceeds with committing the message regardless of the current agent state.
|
|
@@ -15934,20 +16659,20 @@ const METHOD_NAME$z = "function.commit.commitSystemMessageForce";
|
|
|
15934
16659
|
const commitSystemMessageForce = beginContext(async (content, clientId) => {
|
|
15935
16660
|
// Log the commit attempt if enabled
|
|
15936
16661
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15937
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16662
|
+
swarm$1.loggerService.log(METHOD_NAME$y, {
|
|
15938
16663
|
content,
|
|
15939
16664
|
clientId,
|
|
15940
16665
|
});
|
|
15941
16666
|
// Validate the session exists and retrieve the associated swarm
|
|
15942
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16667
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$y);
|
|
15943
16668
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15944
16669
|
// Validate the swarm configuration
|
|
15945
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16670
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$y);
|
|
15946
16671
|
// Commit the system message via SessionPublicService without agent checks
|
|
15947
|
-
await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$
|
|
16672
|
+
await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$y, clientId, swarmName);
|
|
15948
16673
|
});
|
|
15949
16674
|
|
|
15950
|
-
const METHOD_NAME$
|
|
16675
|
+
const METHOD_NAME$x = "function.commit.commitSystemMessage";
|
|
15951
16676
|
/**
|
|
15952
16677
|
* Commits a user message to the active agent's history in a swarm session without triggering a response and without checking the active agent.
|
|
15953
16678
|
*
|
|
@@ -15965,29 +16690,29 @@ const METHOD_NAME$y = "function.commit.commitSystemMessage";
|
|
|
15965
16690
|
const commitUserMessageForce = beginContext(async (content, mode, clientId, payload) => {
|
|
15966
16691
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15967
16692
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15968
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16693
|
+
swarm$1.loggerService.log(METHOD_NAME$x, {
|
|
15969
16694
|
content,
|
|
15970
16695
|
clientId,
|
|
15971
16696
|
mode,
|
|
15972
16697
|
});
|
|
15973
16698
|
// Validate the session and swarm to ensure they exist and are accessible
|
|
15974
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16699
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$x);
|
|
15975
16700
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15976
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16701
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$x);
|
|
15977
16702
|
if (payload) {
|
|
15978
16703
|
return await PayloadContextService.runInContext(async () => {
|
|
15979
|
-
await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$
|
|
16704
|
+
await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$x, clientId, swarmName);
|
|
15980
16705
|
}, {
|
|
15981
16706
|
clientId,
|
|
15982
16707
|
payload,
|
|
15983
16708
|
});
|
|
15984
16709
|
}
|
|
15985
16710
|
// Commit the user message to the agent's history via the session public service without checking the active agent
|
|
15986
|
-
return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$
|
|
16711
|
+
return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$x, clientId, swarmName);
|
|
15987
16712
|
});
|
|
15988
16713
|
|
|
15989
16714
|
/** @private Constant defining the method name for logging and validation context */
|
|
15990
|
-
const METHOD_NAME$
|
|
16715
|
+
const METHOD_NAME$w = "function.commit.commitAssistantMessage";
|
|
15991
16716
|
/**
|
|
15992
16717
|
* Commits an assistant-generated message to the active agent in the swarm system.
|
|
15993
16718
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before committing the message.
|
|
@@ -16005,20 +16730,20 @@ const METHOD_NAME$x = "function.commit.commitAssistantMessage";
|
|
|
16005
16730
|
const commitAssistantMessage = beginContext(async (content, clientId, agentName) => {
|
|
16006
16731
|
// Log the commit attempt if enabled
|
|
16007
16732
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16008
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16733
|
+
swarm$1.loggerService.log(METHOD_NAME$w, {
|
|
16009
16734
|
content,
|
|
16010
16735
|
clientId,
|
|
16011
16736
|
agentName,
|
|
16012
16737
|
});
|
|
16013
16738
|
// Validate the agent exists
|
|
16014
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16739
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$w);
|
|
16015
16740
|
// Validate the session exists and retrieve the associated swarm
|
|
16016
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16741
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$w);
|
|
16017
16742
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16018
16743
|
// Validate the swarm configuration
|
|
16019
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16744
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$w);
|
|
16020
16745
|
// Check if the current agent matches the provided agent
|
|
16021
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16746
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$w, clientId, swarmName);
|
|
16022
16747
|
if (currentAgentName !== agentName) {
|
|
16023
16748
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16024
16749
|
swarm$1.loggerService.log('function "commitAssistantMessage" skipped due to the agent change', {
|
|
@@ -16029,11 +16754,11 @@ const commitAssistantMessage = beginContext(async (content, clientId, agentName)
|
|
|
16029
16754
|
return;
|
|
16030
16755
|
}
|
|
16031
16756
|
// Commit the assistant message via SessionPublicService
|
|
16032
|
-
await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$
|
|
16757
|
+
await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$w, clientId, swarmName);
|
|
16033
16758
|
});
|
|
16034
16759
|
|
|
16035
16760
|
/** @private Constant defining the method name for logging and validation context */
|
|
16036
|
-
const METHOD_NAME$
|
|
16761
|
+
const METHOD_NAME$v = "function.commit.commitAssistantMessageForce";
|
|
16037
16762
|
/**
|
|
16038
16763
|
* Forcefully commits an assistant-generated message to a session in the swarm system, without checking the active agent.
|
|
16039
16764
|
* Validates the session and swarm, then proceeds with committing the message regardless of the current agent state.
|
|
@@ -16052,21 +16777,21 @@ const METHOD_NAME$w = "function.commit.commitAssistantMessageForce";
|
|
|
16052
16777
|
const commitAssistantMessageForce = beginContext(async (content, clientId) => {
|
|
16053
16778
|
// Log the commit attempt if enabled
|
|
16054
16779
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16055
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16780
|
+
swarm$1.loggerService.log(METHOD_NAME$v, {
|
|
16056
16781
|
content,
|
|
16057
16782
|
clientId,
|
|
16058
16783
|
});
|
|
16059
16784
|
// Validate the session exists and retrieve the associated swarm
|
|
16060
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16785
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$v);
|
|
16061
16786
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16062
16787
|
// Validate the swarm configuration
|
|
16063
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16788
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$v);
|
|
16064
16789
|
// Commit the assistant message via SessionPublicService without agent checks
|
|
16065
|
-
await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$
|
|
16790
|
+
await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$v, clientId, swarmName);
|
|
16066
16791
|
});
|
|
16067
16792
|
|
|
16068
16793
|
/** @private Constant defining the method name for logging and validation context */
|
|
16069
|
-
const METHOD_NAME$
|
|
16794
|
+
const METHOD_NAME$u = "function.commit.cancelOutput";
|
|
16070
16795
|
/**
|
|
16071
16796
|
* Cancels the awaited output for a specific client and agent by emitting an empty string.
|
|
16072
16797
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before cancellation.
|
|
@@ -16082,19 +16807,19 @@ const METHOD_NAME$v = "function.commit.cancelOutput";
|
|
|
16082
16807
|
const cancelOutput = beginContext(async (clientId, agentName) => {
|
|
16083
16808
|
// Log the cancellation attempt if enabled
|
|
16084
16809
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16085
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16810
|
+
swarm$1.loggerService.log(METHOD_NAME$u, {
|
|
16086
16811
|
clientId,
|
|
16087
16812
|
agentName,
|
|
16088
16813
|
});
|
|
16089
16814
|
// Validate the agent exists
|
|
16090
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16815
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$u);
|
|
16091
16816
|
// Validate the session exists and retrieve the associated swarm
|
|
16092
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16817
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$u);
|
|
16093
16818
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16094
16819
|
// Validate the swarm configuration
|
|
16095
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16820
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$u);
|
|
16096
16821
|
// Check if the current agent matches the provided agent
|
|
16097
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16822
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$u, clientId, swarmName);
|
|
16098
16823
|
if (currentAgentName !== agentName) {
|
|
16099
16824
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16100
16825
|
swarm$1.loggerService.log('function "cancelOutput" skipped due to the agent change', {
|
|
@@ -16105,11 +16830,11 @@ const cancelOutput = beginContext(async (clientId, agentName) => {
|
|
|
16105
16830
|
return;
|
|
16106
16831
|
}
|
|
16107
16832
|
// Perform the output cancellation via SwarmPublicService
|
|
16108
|
-
await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$
|
|
16833
|
+
await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$u, clientId, swarmName);
|
|
16109
16834
|
});
|
|
16110
16835
|
|
|
16111
16836
|
/** @private Constant defining the method name for logging and validation context */
|
|
16112
|
-
const METHOD_NAME$
|
|
16837
|
+
const METHOD_NAME$t = "function.commit.cancelOutputForce";
|
|
16113
16838
|
/**
|
|
16114
16839
|
* Forcefully cancels the awaited output for a specific client by emitting an empty string, without checking the active agent.
|
|
16115
16840
|
* Validates the session and swarm, then proceeds with cancellation regardless of the current agent state.
|
|
@@ -16126,20 +16851,20 @@ const METHOD_NAME$u = "function.commit.cancelOutputForce";
|
|
|
16126
16851
|
const cancelOutputForce = beginContext(async (clientId) => {
|
|
16127
16852
|
// Log the cancellation attempt if enabled
|
|
16128
16853
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16129
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16854
|
+
swarm$1.loggerService.log(METHOD_NAME$t, {
|
|
16130
16855
|
clientId,
|
|
16131
16856
|
});
|
|
16132
16857
|
// Validate the session exists and retrieve the associated swarm
|
|
16133
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16858
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$t);
|
|
16134
16859
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16135
16860
|
// Validate the swarm configuration
|
|
16136
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16861
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$t);
|
|
16137
16862
|
// Perform the output cancellation via SwarmPublicService without agent checks
|
|
16138
|
-
await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$
|
|
16863
|
+
await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$t, clientId, swarmName);
|
|
16139
16864
|
});
|
|
16140
16865
|
|
|
16141
16866
|
/** @private Constant defining the method name for logging and validation context */
|
|
16142
|
-
const METHOD_NAME$
|
|
16867
|
+
const METHOD_NAME$s = "function.commit.commitStopTools";
|
|
16143
16868
|
/**
|
|
16144
16869
|
* Prevents the next tool from being executed for a specific client and agent in the swarm system.
|
|
16145
16870
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before stopping tool execution.
|
|
@@ -16156,19 +16881,19 @@ const METHOD_NAME$t = "function.commit.commitStopTools";
|
|
|
16156
16881
|
const commitStopTools = beginContext(async (clientId, agentName) => {
|
|
16157
16882
|
// Log the stop tools attempt if enabled
|
|
16158
16883
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16159
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16884
|
+
swarm$1.loggerService.log(METHOD_NAME$s, {
|
|
16160
16885
|
clientId,
|
|
16161
16886
|
agentName,
|
|
16162
16887
|
});
|
|
16163
16888
|
// Validate the agent exists
|
|
16164
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16889
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$s);
|
|
16165
16890
|
// Validate the session exists and retrieve the associated swarm
|
|
16166
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16891
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$s);
|
|
16167
16892
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16168
16893
|
// Validate the swarm configuration
|
|
16169
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16894
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$s);
|
|
16170
16895
|
// Check if the current agent matches the provided agent
|
|
16171
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16896
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$s, clientId, swarmName);
|
|
16172
16897
|
if (currentAgentName !== agentName) {
|
|
16173
16898
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16174
16899
|
swarm$1.loggerService.log('function "commitStopTools" skipped due to the agent change', {
|
|
@@ -16179,11 +16904,11 @@ const commitStopTools = beginContext(async (clientId, agentName) => {
|
|
|
16179
16904
|
return;
|
|
16180
16905
|
}
|
|
16181
16906
|
// Commit the stop of the next tool execution via SessionPublicService
|
|
16182
|
-
await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$
|
|
16907
|
+
await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$s, clientId, swarmName);
|
|
16183
16908
|
});
|
|
16184
16909
|
|
|
16185
16910
|
/** @private Constant defining the method name for logging and validation context */
|
|
16186
|
-
const METHOD_NAME$
|
|
16911
|
+
const METHOD_NAME$r = "function.commit.commitStopToolsForce";
|
|
16187
16912
|
/**
|
|
16188
16913
|
* Forcefully prevents the next tool from being executed for a specific client in the swarm system, without checking the active agent.
|
|
16189
16914
|
* Validates the session and swarm, then proceeds with stopping tool execution regardless of the current agent state.
|
|
@@ -16201,21 +16926,21 @@ const METHOD_NAME$s = "function.commit.commitStopToolsForce";
|
|
|
16201
16926
|
const commitStopToolsForce = beginContext(async (clientId) => {
|
|
16202
16927
|
// Log the stop tools attempt if enabled
|
|
16203
16928
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16204
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16929
|
+
swarm$1.loggerService.log(METHOD_NAME$r, {
|
|
16205
16930
|
clientId,
|
|
16206
|
-
METHOD_NAME: METHOD_NAME$
|
|
16931
|
+
METHOD_NAME: METHOD_NAME$r,
|
|
16207
16932
|
});
|
|
16208
16933
|
// Validate the session exists and retrieve the associated swarm
|
|
16209
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16934
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$r);
|
|
16210
16935
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16211
16936
|
// Validate the swarm configuration
|
|
16212
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16937
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$r);
|
|
16213
16938
|
// Commit the stop of the next tool execution via SessionPublicService without agent checks
|
|
16214
|
-
await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$
|
|
16939
|
+
await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$r, clientId, swarmName);
|
|
16215
16940
|
});
|
|
16216
16941
|
|
|
16217
16942
|
/** @constant {string} METHOD_NAME - The name of the method used for logging and validation */
|
|
16218
|
-
const METHOD_NAME$
|
|
16943
|
+
const METHOD_NAME$q = "function.target.question";
|
|
16219
16944
|
/**
|
|
16220
16945
|
* Initiates a question process within a chat context
|
|
16221
16946
|
* @function question
|
|
@@ -16227,21 +16952,21 @@ const METHOD_NAME$r = "function.target.question";
|
|
|
16227
16952
|
*/
|
|
16228
16953
|
const question = beginContext(async (message, clientId, agentName, wikiName) => {
|
|
16229
16954
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16230
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16955
|
+
swarm$1.loggerService.log(METHOD_NAME$q, {
|
|
16231
16956
|
message,
|
|
16232
16957
|
clientId,
|
|
16233
16958
|
agentName,
|
|
16234
16959
|
wikiName,
|
|
16235
16960
|
});
|
|
16236
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16237
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16961
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$q);
|
|
16962
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$q);
|
|
16238
16963
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16239
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16240
|
-
swarm$1.wikiValidationService.validate(wikiName, METHOD_NAME$
|
|
16964
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$q);
|
|
16965
|
+
swarm$1.wikiValidationService.validate(wikiName, METHOD_NAME$q);
|
|
16241
16966
|
if (!swarm$1.agentValidationService.hasWiki(agentName, wikiName)) {
|
|
16242
|
-
throw new Error(`agent-swarm ${METHOD_NAME$
|
|
16967
|
+
throw new Error(`agent-swarm ${METHOD_NAME$q} ${wikiName} not registered in ${agentName}`);
|
|
16243
16968
|
}
|
|
16244
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16969
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$q, clientId, swarmName);
|
|
16245
16970
|
if (currentAgentName !== agentName) {
|
|
16246
16971
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16247
16972
|
swarm$1.loggerService.log('function "question" skipped due to the agent change', {
|
|
@@ -16264,7 +16989,7 @@ const question = beginContext(async (message, clientId, agentName, wikiName) =>
|
|
|
16264
16989
|
});
|
|
16265
16990
|
|
|
16266
16991
|
/** @constant {string} METHOD_NAME - The name of the method used for logging and validation */
|
|
16267
|
-
const METHOD_NAME$
|
|
16992
|
+
const METHOD_NAME$p = "function.target.questionForce";
|
|
16268
16993
|
/**
|
|
16269
16994
|
* Initiates a forced question process within a chat context
|
|
16270
16995
|
* @function questionForce
|
|
@@ -16275,17 +17000,17 @@ const METHOD_NAME$q = "function.target.questionForce";
|
|
|
16275
17000
|
*/
|
|
16276
17001
|
const questionForce = beginContext(async (message, clientId, wikiName) => {
|
|
16277
17002
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16278
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17003
|
+
swarm$1.loggerService.log(METHOD_NAME$p, {
|
|
16279
17004
|
message,
|
|
16280
17005
|
clientId,
|
|
16281
17006
|
wikiName,
|
|
16282
17007
|
});
|
|
16283
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17008
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$p);
|
|
16284
17009
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16285
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16286
|
-
swarm$1.wikiValidationService.validate(wikiName, METHOD_NAME$
|
|
17010
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$p);
|
|
17011
|
+
swarm$1.wikiValidationService.validate(wikiName, METHOD_NAME$p);
|
|
16287
17012
|
const { getChat, callbacks } = swarm$1.wikiSchemaService.get(wikiName);
|
|
16288
|
-
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
17013
|
+
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$p, clientId, swarmName);
|
|
16289
17014
|
const args = {
|
|
16290
17015
|
clientId,
|
|
16291
17016
|
message,
|
|
@@ -16297,7 +17022,7 @@ const questionForce = beginContext(async (message, clientId, wikiName) => {
|
|
|
16297
17022
|
return await getChat(args);
|
|
16298
17023
|
});
|
|
16299
17024
|
|
|
16300
|
-
const METHOD_NAME$
|
|
17025
|
+
const METHOD_NAME$o = "function.target.disposeConnection";
|
|
16301
17026
|
/**
|
|
16302
17027
|
* Disposes of a client session and all related resources within a swarm.
|
|
16303
17028
|
*
|
|
@@ -16314,10 +17039,10 @@ const METHOD_NAME$p = "function.target.disposeConnection";
|
|
|
16314
17039
|
* @example
|
|
16315
17040
|
* await disposeConnection("client-123", "TaskSwarm");
|
|
16316
17041
|
*/
|
|
16317
|
-
const disposeConnection = beginContext(async (clientId, swarmName, methodName = METHOD_NAME$
|
|
17042
|
+
const disposeConnection = beginContext(async (clientId, swarmName, methodName = METHOD_NAME$o) => {
|
|
16318
17043
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16319
17044
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16320
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17045
|
+
swarm$1.loggerService.log(METHOD_NAME$o, {
|
|
16321
17046
|
clientId,
|
|
16322
17047
|
swarmName,
|
|
16323
17048
|
});
|
|
@@ -16389,7 +17114,7 @@ const disposeConnection = beginContext(async (clientId, swarmName, methodName =
|
|
|
16389
17114
|
PersistMemoryAdapter.dispose(clientId);
|
|
16390
17115
|
});
|
|
16391
17116
|
|
|
16392
|
-
const METHOD_NAME$
|
|
17117
|
+
const METHOD_NAME$n = "function.target.makeAutoDispose";
|
|
16393
17118
|
/**
|
|
16394
17119
|
* Default timeout in seconds before auto-dispose is triggered.
|
|
16395
17120
|
* @constant {number}
|
|
@@ -16420,7 +17145,7 @@ const DEFAULT_TIMEOUT = 15 * 60;
|
|
|
16420
17145
|
const makeAutoDispose = beginContext((clientId, swarmName, { timeoutSeconds = DEFAULT_TIMEOUT, onDestroy, } = {}) => {
|
|
16421
17146
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16422
17147
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16423
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17148
|
+
swarm$1.loggerService.log(METHOD_NAME$n, {
|
|
16424
17149
|
clientId,
|
|
16425
17150
|
swarmName,
|
|
16426
17151
|
});
|
|
@@ -16453,7 +17178,7 @@ const makeAutoDispose = beginContext((clientId, swarmName, { timeoutSeconds = DE
|
|
|
16453
17178
|
};
|
|
16454
17179
|
});
|
|
16455
17180
|
|
|
16456
|
-
const METHOD_NAME$
|
|
17181
|
+
const METHOD_NAME$m = "function.target.execute";
|
|
16457
17182
|
/**
|
|
16458
17183
|
* Sends a message to the active agent in a swarm session as if it originated from the client side.
|
|
16459
17184
|
*
|
|
@@ -16475,19 +17200,19 @@ const execute = beginContext(async (content, clientId, agentName) => {
|
|
|
16475
17200
|
const executionId = functoolsKit.randomString();
|
|
16476
17201
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16477
17202
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16478
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17203
|
+
swarm$1.loggerService.log(METHOD_NAME$m, {
|
|
16479
17204
|
content,
|
|
16480
17205
|
clientId,
|
|
16481
17206
|
agentName,
|
|
16482
17207
|
executionId,
|
|
16483
17208
|
});
|
|
16484
17209
|
// Validate the agent, session, and swarm
|
|
16485
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16486
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17210
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$m);
|
|
17211
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$m);
|
|
16487
17212
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16488
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
17213
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$m);
|
|
16489
17214
|
// Check if the specified agent is still the active agent
|
|
16490
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
17215
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$m, clientId, swarmName);
|
|
16491
17216
|
if (currentAgentName !== agentName) {
|
|
16492
17217
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16493
17218
|
swarm$1.loggerService.log('function "execute" skipped due to the agent change', {
|
|
@@ -16506,7 +17231,7 @@ const execute = beginContext(async (content, clientId, agentName) => {
|
|
|
16506
17231
|
agentName,
|
|
16507
17232
|
swarmName,
|
|
16508
17233
|
});
|
|
16509
|
-
const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$
|
|
17234
|
+
const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$m, clientId, swarmName);
|
|
16510
17235
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
16511
17236
|
swarm$1.busService.commitExecutionEnd(clientId, {
|
|
16512
17237
|
agentName,
|
|
@@ -16526,7 +17251,7 @@ const execute = beginContext(async (content, clientId, agentName) => {
|
|
|
16526
17251
|
});
|
|
16527
17252
|
});
|
|
16528
17253
|
|
|
16529
|
-
const METHOD_NAME$
|
|
17254
|
+
const METHOD_NAME$l = "function.target.emit";
|
|
16530
17255
|
/**
|
|
16531
17256
|
* Emits a string as model output without executing an incoming message, with agent activity validation.
|
|
16532
17257
|
*
|
|
@@ -16546,18 +17271,18 @@ const METHOD_NAME$m = "function.target.emit";
|
|
|
16546
17271
|
const emit = beginContext(async (content, clientId, agentName) => {
|
|
16547
17272
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16548
17273
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16549
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17274
|
+
swarm$1.loggerService.log(METHOD_NAME$l, {
|
|
16550
17275
|
content,
|
|
16551
17276
|
clientId,
|
|
16552
17277
|
agentName,
|
|
16553
17278
|
});
|
|
16554
17279
|
// Validate the agent, session, and swarm
|
|
16555
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16556
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17280
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$l);
|
|
17281
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$l);
|
|
16557
17282
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16558
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
17283
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$l);
|
|
16559
17284
|
// Check if the specified agent is still the active agent
|
|
16560
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
17285
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$l, clientId, swarmName);
|
|
16561
17286
|
if (currentAgentName !== agentName) {
|
|
16562
17287
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16563
17288
|
swarm$1.loggerService.log('function "emit" skipped due to the agent change', {
|
|
@@ -16568,10 +17293,10 @@ const emit = beginContext(async (content, clientId, agentName) => {
|
|
|
16568
17293
|
return;
|
|
16569
17294
|
}
|
|
16570
17295
|
// Emit the content directly via the session public service
|
|
16571
|
-
return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$
|
|
17296
|
+
return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$l, clientId, swarmName);
|
|
16572
17297
|
});
|
|
16573
17298
|
|
|
16574
|
-
const METHOD_NAME$
|
|
17299
|
+
const METHOD_NAME$k = "function.target.notify";
|
|
16575
17300
|
/**
|
|
16576
17301
|
* Sends a notification message as output from the swarm session without executing an incoming message.
|
|
16577
17302
|
*
|
|
@@ -16591,23 +17316,23 @@ const METHOD_NAME$l = "function.target.notify";
|
|
|
16591
17316
|
const notify = beginContext(async (content, clientId, agentName) => {
|
|
16592
17317
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16593
17318
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16594
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17319
|
+
swarm$1.loggerService.log(METHOD_NAME$k, {
|
|
16595
17320
|
content,
|
|
16596
17321
|
clientId,
|
|
16597
17322
|
agentName,
|
|
16598
17323
|
});
|
|
16599
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17324
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$k);
|
|
16600
17325
|
// Check if the session mode is "makeConnection"
|
|
16601
17326
|
if (swarm$1.sessionValidationService.getSessionMode(clientId) !==
|
|
16602
17327
|
"makeConnection") {
|
|
16603
17328
|
throw new Error(`agent-swarm-kit notify session is not makeConnection clientId=${clientId}`);
|
|
16604
17329
|
}
|
|
16605
17330
|
// Validate the agent, session, and swarm
|
|
16606
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
17331
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$k);
|
|
16607
17332
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16608
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
17333
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$k);
|
|
16609
17334
|
// Check if the specified agent is still the active agent
|
|
16610
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
17335
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$k, clientId, swarmName);
|
|
16611
17336
|
if (currentAgentName !== agentName) {
|
|
16612
17337
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16613
17338
|
swarm$1.loggerService.log('function "notify" skipped due to the agent change', {
|
|
@@ -16618,10 +17343,10 @@ const notify = beginContext(async (content, clientId, agentName) => {
|
|
|
16618
17343
|
return;
|
|
16619
17344
|
}
|
|
16620
17345
|
// Notify the content directly via the session public service
|
|
16621
|
-
return await swarm$1.sessionPublicService.notify(content, METHOD_NAME$
|
|
17346
|
+
return await swarm$1.sessionPublicService.notify(content, METHOD_NAME$k, clientId, swarmName);
|
|
16622
17347
|
});
|
|
16623
17348
|
|
|
16624
|
-
const METHOD_NAME$
|
|
17349
|
+
const METHOD_NAME$j = "function.target.notifyForce";
|
|
16625
17350
|
/**
|
|
16626
17351
|
* Sends a notification message as output from the swarm session without executing an incoming message.
|
|
16627
17352
|
*
|
|
@@ -16640,11 +17365,11 @@ const METHOD_NAME$k = "function.target.notifyForce";
|
|
|
16640
17365
|
const notifyForce = beginContext(async (content, clientId) => {
|
|
16641
17366
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16642
17367
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16643
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17368
|
+
swarm$1.loggerService.log(METHOD_NAME$j, {
|
|
16644
17369
|
content,
|
|
16645
17370
|
clientId,
|
|
16646
17371
|
});
|
|
16647
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17372
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$j);
|
|
16648
17373
|
// Check if the session mode is "makeConnection"
|
|
16649
17374
|
if (swarm$1.sessionValidationService.getSessionMode(clientId) !==
|
|
16650
17375
|
"makeConnection") {
|
|
@@ -16652,12 +17377,12 @@ const notifyForce = beginContext(async (content, clientId) => {
|
|
|
16652
17377
|
}
|
|
16653
17378
|
// Validate the agent, session, and swarm
|
|
16654
17379
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16655
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
17380
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$j);
|
|
16656
17381
|
// Notify the content directly via the session public service
|
|
16657
|
-
return await swarm$1.sessionPublicService.notify(content, METHOD_NAME$
|
|
17382
|
+
return await swarm$1.sessionPublicService.notify(content, METHOD_NAME$j, clientId, swarmName);
|
|
16658
17383
|
});
|
|
16659
17384
|
|
|
16660
|
-
const METHOD_NAME$
|
|
17385
|
+
const METHOD_NAME$i = "function.target.runStateless";
|
|
16661
17386
|
/**
|
|
16662
17387
|
* Executes a message statelessly with an agent in a swarm session, bypassing chat history.
|
|
16663
17388
|
*
|
|
@@ -16680,19 +17405,19 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
|
|
|
16680
17405
|
const executionId = functoolsKit.randomString();
|
|
16681
17406
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16682
17407
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16683
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17408
|
+
swarm$1.loggerService.log(METHOD_NAME$i, {
|
|
16684
17409
|
content,
|
|
16685
17410
|
clientId,
|
|
16686
17411
|
agentName,
|
|
16687
17412
|
executionId,
|
|
16688
17413
|
});
|
|
16689
17414
|
// Validate the agent, session, and swarm
|
|
16690
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16691
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17415
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$i);
|
|
17416
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$i);
|
|
16692
17417
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16693
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
17418
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$i);
|
|
16694
17419
|
// Check if the specified agent is still the active agent
|
|
16695
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
17420
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$i, clientId, swarmName);
|
|
16696
17421
|
if (currentAgentName !== agentName) {
|
|
16697
17422
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16698
17423
|
swarm$1.loggerService.log('function "runStateless" skipped due to the agent change', {
|
|
@@ -16711,7 +17436,7 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
|
|
|
16711
17436
|
agentName,
|
|
16712
17437
|
swarmName,
|
|
16713
17438
|
});
|
|
16714
|
-
const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$
|
|
17439
|
+
const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$i, clientId, swarmName);
|
|
16715
17440
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
16716
17441
|
swarm$1.busService.commitExecutionEnd(clientId, {
|
|
16717
17442
|
agentName,
|
|
@@ -16731,7 +17456,7 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
|
|
|
16731
17456
|
});
|
|
16732
17457
|
});
|
|
16733
17458
|
|
|
16734
|
-
const METHOD_NAME$
|
|
17459
|
+
const METHOD_NAME$h = "function.target.runStatelessForce";
|
|
16735
17460
|
/**
|
|
16736
17461
|
* Executes a message statelessly with the active agent in a swarm session, bypassing chat history and forcing execution regardless of agent activity.
|
|
16737
17462
|
*
|
|
@@ -16752,22 +17477,22 @@ const runStatelessForce = beginContext(async (content, clientId) => {
|
|
|
16752
17477
|
const executionId = functoolsKit.randomString();
|
|
16753
17478
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16754
17479
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16755
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17480
|
+
swarm$1.loggerService.log(METHOD_NAME$h, {
|
|
16756
17481
|
content,
|
|
16757
17482
|
clientId,
|
|
16758
17483
|
executionId,
|
|
16759
17484
|
});
|
|
16760
17485
|
// Validate the session and swarm
|
|
16761
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17486
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$h);
|
|
16762
17487
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16763
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
17488
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$h);
|
|
16764
17489
|
// Execute the command statelessly within an execution context with performance tracking
|
|
16765
17490
|
return ExecutionContextService.runInContext(async () => {
|
|
16766
17491
|
let isFinished = false;
|
|
16767
17492
|
swarm$1.perfService.startExecution(executionId, clientId, content.length);
|
|
16768
17493
|
try {
|
|
16769
17494
|
swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
|
|
16770
|
-
const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$
|
|
17495
|
+
const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$h, clientId, swarmName);
|
|
16771
17496
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
16772
17497
|
swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
|
|
16773
17498
|
return result;
|
|
@@ -16794,7 +17519,7 @@ const SCHEDULED_DELAY$1 = 1000;
|
|
|
16794
17519
|
* @constant {number}
|
|
16795
17520
|
*/
|
|
16796
17521
|
const RATE_DELAY = 10000;
|
|
16797
|
-
const METHOD_NAME$
|
|
17522
|
+
const METHOD_NAME$g = "function.target.makeConnection";
|
|
16798
17523
|
/**
|
|
16799
17524
|
* Internal implementation of the connection factory for a client to a swarm.
|
|
16800
17525
|
*
|
|
@@ -16809,21 +17534,21 @@ const METHOD_NAME$h = "function.target.makeConnection";
|
|
|
16809
17534
|
const makeConnectionInternal = (connector, clientId, swarmName) => {
|
|
16810
17535
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16811
17536
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16812
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17537
|
+
swarm$1.loggerService.log(METHOD_NAME$g, {
|
|
16813
17538
|
clientId,
|
|
16814
17539
|
swarmName,
|
|
16815
17540
|
});
|
|
16816
17541
|
// Validate the swarm and initialize the session
|
|
16817
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
17542
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$g);
|
|
16818
17543
|
swarm$1.sessionValidationService.addSession(clientId, swarmName, "makeConnection");
|
|
16819
17544
|
// Create a queued send function using the session public service
|
|
16820
|
-
const send = functoolsKit.queued(swarm$1.sessionPublicService.connect(connector, METHOD_NAME$
|
|
17545
|
+
const send = functoolsKit.queued(swarm$1.sessionPublicService.connect(connector, METHOD_NAME$g, clientId, swarmName));
|
|
16821
17546
|
// Return a wrapped send function with validation and agent context
|
|
16822
17547
|
return (async (outgoing) => {
|
|
16823
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17548
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$g);
|
|
16824
17549
|
return await send({
|
|
16825
17550
|
data: outgoing,
|
|
16826
|
-
agentName: await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
17551
|
+
agentName: await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$g, clientId, swarmName),
|
|
16827
17552
|
clientId,
|
|
16828
17553
|
});
|
|
16829
17554
|
});
|
|
@@ -16906,13 +17631,13 @@ makeConnection.scheduled = (connector, clientId, swarmName, { delay = SCHEDULED_
|
|
|
16906
17631
|
await online();
|
|
16907
17632
|
if (payload) {
|
|
16908
17633
|
return await PayloadContextService.runInContext(async () => {
|
|
16909
|
-
await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$
|
|
17634
|
+
await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$g, clientId, swarmName);
|
|
16910
17635
|
}, {
|
|
16911
17636
|
clientId,
|
|
16912
17637
|
payload,
|
|
16913
17638
|
});
|
|
16914
17639
|
}
|
|
16915
|
-
await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$
|
|
17640
|
+
await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$g, clientId, swarmName);
|
|
16916
17641
|
}),
|
|
16917
17642
|
delay,
|
|
16918
17643
|
});
|
|
@@ -16975,7 +17700,7 @@ makeConnection.rate = (connector, clientId, swarmName, { delay = RATE_DELAY } =
|
|
|
16975
17700
|
};
|
|
16976
17701
|
};
|
|
16977
17702
|
|
|
16978
|
-
const METHOD_NAME$
|
|
17703
|
+
const METHOD_NAME$f = "function.target.complete";
|
|
16979
17704
|
/**
|
|
16980
17705
|
* Time-to-live for the complete function in milliseconds.
|
|
16981
17706
|
* Defines how long the cached complete function remains valid before expiring.
|
|
@@ -17017,7 +17742,7 @@ const createComplete = functoolsKit.ttl((clientId, swarmName) => functoolsKit.qu
|
|
|
17017
17742
|
*
|
|
17018
17743
|
* @returns {Promise<void>} A promise that resolves when the garbage collector is initialized.
|
|
17019
17744
|
*/
|
|
17020
|
-
const createGc$
|
|
17745
|
+
const createGc$1 = functoolsKit.singleshot(async () => {
|
|
17021
17746
|
setInterval(createComplete.gc, COMPLETE_GC);
|
|
17022
17747
|
});
|
|
17023
17748
|
/**
|
|
@@ -17041,7 +17766,7 @@ const complete = beginContext(async (content, clientId, swarmName, payload = nul
|
|
|
17041
17766
|
const executionId = functoolsKit.randomString();
|
|
17042
17767
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17043
17768
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17044
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17769
|
+
swarm$1.loggerService.log(METHOD_NAME$f, {
|
|
17045
17770
|
content,
|
|
17046
17771
|
clientId,
|
|
17047
17772
|
executionId,
|
|
@@ -17050,7 +17775,7 @@ const complete = beginContext(async (content, clientId, swarmName, payload = nul
|
|
|
17050
17775
|
await markOnline(clientId, swarmName);
|
|
17051
17776
|
// Set up the TTL-limited, queued execution function and garbage collector
|
|
17052
17777
|
const run = await createComplete(clientId, swarmName);
|
|
17053
|
-
createGc$
|
|
17778
|
+
createGc$1();
|
|
17054
17779
|
// Execute the command within an execution context with performance tracking
|
|
17055
17780
|
const handleRun = async () => {
|
|
17056
17781
|
return await ExecutionContextService.runInContext(async () => {
|
|
@@ -17059,7 +17784,7 @@ const complete = beginContext(async (content, clientId, swarmName, payload = nul
|
|
|
17059
17784
|
swarm$1.navigationValidationService.beginMonit(clientId, swarmName);
|
|
17060
17785
|
try {
|
|
17061
17786
|
swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
|
|
17062
|
-
const result = await run(METHOD_NAME$
|
|
17787
|
+
const result = await run(METHOD_NAME$f, content);
|
|
17063
17788
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
17064
17789
|
swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
|
|
17065
17790
|
return result;
|
|
@@ -17089,7 +17814,7 @@ const complete = beginContext(async (content, clientId, swarmName, payload = nul
|
|
|
17089
17814
|
* @constant {number}
|
|
17090
17815
|
*/
|
|
17091
17816
|
const SCHEDULED_DELAY = 1000;
|
|
17092
|
-
const METHOD_NAME$
|
|
17817
|
+
const METHOD_NAME$e = "function.target.session";
|
|
17093
17818
|
/**
|
|
17094
17819
|
* Internal implementation of the session factory for a client and swarm.
|
|
17095
17820
|
*
|
|
@@ -17104,23 +17829,23 @@ const sessionInternal = (clientId, swarmName, { onDispose = () => { } } = {}) =>
|
|
|
17104
17829
|
const executionId = functoolsKit.randomString();
|
|
17105
17830
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17106
17831
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17107
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17832
|
+
swarm$1.loggerService.log(METHOD_NAME$e, {
|
|
17108
17833
|
clientId,
|
|
17109
17834
|
swarmName,
|
|
17110
17835
|
executionId,
|
|
17111
17836
|
});
|
|
17112
17837
|
// Validate the swarm and initialize the session
|
|
17113
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
17838
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$e);
|
|
17114
17839
|
swarm$1.sessionValidationService.addSession(clientId, swarmName, "session");
|
|
17115
17840
|
const complete = functoolsKit.queued(async (content) => {
|
|
17116
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17841
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$e);
|
|
17117
17842
|
return ExecutionContextService.runInContext(async () => {
|
|
17118
17843
|
let isFinished = false;
|
|
17119
17844
|
swarm$1.perfService.startExecution(executionId, clientId, content.length);
|
|
17120
17845
|
swarm$1.navigationValidationService.beginMonit(clientId, swarmName);
|
|
17121
17846
|
try {
|
|
17122
17847
|
swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
|
|
17123
|
-
const result = await swarm$1.sessionPublicService.execute(content, "user", METHOD_NAME$
|
|
17848
|
+
const result = await swarm$1.sessionPublicService.execute(content, "user", METHOD_NAME$e, clientId, swarmName);
|
|
17124
17849
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
17125
17850
|
swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
|
|
17126
17851
|
return result;
|
|
@@ -17141,7 +17866,7 @@ const sessionInternal = (clientId, swarmName, { onDispose = () => { } } = {}) =>
|
|
|
17141
17866
|
return await complete(content);
|
|
17142
17867
|
}),
|
|
17143
17868
|
dispose: async () => {
|
|
17144
|
-
await disposeConnection(clientId, swarmName, METHOD_NAME$
|
|
17869
|
+
await disposeConnection(clientId, swarmName, METHOD_NAME$e);
|
|
17145
17870
|
await onDispose();
|
|
17146
17871
|
},
|
|
17147
17872
|
};
|
|
@@ -17241,13 +17966,13 @@ session.scheduled = (clientId, swarmName, { delay = SCHEDULED_DELAY, onDispose }
|
|
|
17241
17966
|
await online();
|
|
17242
17967
|
if (payload) {
|
|
17243
17968
|
return await PayloadContextService.runInContext(async () => {
|
|
17244
|
-
return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$
|
|
17969
|
+
return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$e, clientId, swarmName);
|
|
17245
17970
|
}, {
|
|
17246
17971
|
clientId,
|
|
17247
17972
|
payload,
|
|
17248
17973
|
});
|
|
17249
17974
|
}
|
|
17250
|
-
return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$
|
|
17975
|
+
return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$e, clientId, swarmName);
|
|
17251
17976
|
}),
|
|
17252
17977
|
delay,
|
|
17253
17978
|
});
|
|
@@ -17327,7 +18052,7 @@ session.rate = (clientId, swarmName, { delay = SCHEDULED_DELAY, onDispose } = {}
|
|
|
17327
18052
|
};
|
|
17328
18053
|
|
|
17329
18054
|
/** @private Constant defining the method name for logging purposes */
|
|
17330
|
-
const METHOD_NAME$
|
|
18055
|
+
const METHOD_NAME$d = "function.common.hasSession";
|
|
17331
18056
|
/**
|
|
17332
18057
|
* Checks if a session exists for the given client ID.
|
|
17333
18058
|
*
|
|
@@ -17339,11 +18064,11 @@ const METHOD_NAME$e = "function.common.hasSession";
|
|
|
17339
18064
|
*/
|
|
17340
18065
|
const hasSession = (clientId) => {
|
|
17341
18066
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17342
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
18067
|
+
swarm$1.loggerService.log(METHOD_NAME$d, { clientId });
|
|
17343
18068
|
return swarm$1.sessionValidationService.hasSession(clientId);
|
|
17344
18069
|
};
|
|
17345
18070
|
|
|
17346
|
-
const METHOD_NAME$
|
|
18071
|
+
const METHOD_NAME$c = "function.common.getAgentName";
|
|
17347
18072
|
/**
|
|
17348
18073
|
* Retrieves the name of the active agent for a given client session in a swarm.
|
|
17349
18074
|
*
|
|
@@ -17361,18 +18086,18 @@ const METHOD_NAME$d = "function.common.getAgentName";
|
|
|
17361
18086
|
const getAgentName = beginContext(async (clientId) => {
|
|
17362
18087
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17363
18088
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17364
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
18089
|
+
swarm$1.loggerService.log(METHOD_NAME$c, {
|
|
17365
18090
|
clientId,
|
|
17366
18091
|
});
|
|
17367
18092
|
// Validate the session and swarm to ensure they exist and are accessible
|
|
17368
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
18093
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$c);
|
|
17369
18094
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
17370
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
18095
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$c);
|
|
17371
18096
|
// Retrieve the active agent name via the swarm public service
|
|
17372
|
-
return await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
18097
|
+
return await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$c, clientId, swarmName);
|
|
17373
18098
|
});
|
|
17374
18099
|
|
|
17375
|
-
const METHOD_NAME$
|
|
18100
|
+
const METHOD_NAME$b = "function.common.getAgentHistory";
|
|
17376
18101
|
/**
|
|
17377
18102
|
* Retrieves the history prepared for a specific agent, incorporating rescue algorithm tweaks.
|
|
17378
18103
|
*
|
|
@@ -17391,22 +18116,22 @@ const METHOD_NAME$c = "function.common.getAgentHistory";
|
|
|
17391
18116
|
const getAgentHistory = beginContext(async (clientId, agentName) => {
|
|
17392
18117
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17393
18118
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17394
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
18119
|
+
swarm$1.loggerService.log(METHOD_NAME$b, {
|
|
17395
18120
|
clientId,
|
|
17396
18121
|
agentName,
|
|
17397
18122
|
});
|
|
17398
18123
|
// Validate the session and agent to ensure they exist and are accessible
|
|
17399
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17400
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
18124
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$b);
|
|
18125
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$b);
|
|
17401
18126
|
// Retrieve the agent's prompt configuration from the agent schema service
|
|
17402
18127
|
const { prompt } = swarm$1.agentSchemaService.get(agentName);
|
|
17403
18128
|
// Fetch the agent's history using the prompt and rescue tweaks via the history public service
|
|
17404
|
-
const history = await swarm$1.historyPublicService.toArrayForAgent(prompt, METHOD_NAME$
|
|
18129
|
+
const history = await swarm$1.historyPublicService.toArrayForAgent(prompt, METHOD_NAME$b, clientId, agentName);
|
|
17405
18130
|
// Return a shallow copy of the history array
|
|
17406
18131
|
return [...history];
|
|
17407
18132
|
});
|
|
17408
18133
|
|
|
17409
|
-
const METHOD_NAME$
|
|
18134
|
+
const METHOD_NAME$a = "function.common.getSessionMode";
|
|
17410
18135
|
/**
|
|
17411
18136
|
* Retrieves the session mode for a given client session in a swarm.
|
|
17412
18137
|
*
|
|
@@ -17424,18 +18149,18 @@ const METHOD_NAME$b = "function.common.getSessionMode";
|
|
|
17424
18149
|
const getSessionMode = beginContext(async (clientId) => {
|
|
17425
18150
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17426
18151
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17427
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
18152
|
+
swarm$1.loggerService.log(METHOD_NAME$a, {
|
|
17428
18153
|
clientId,
|
|
17429
18154
|
});
|
|
17430
18155
|
// Validate the session and swarm to ensure they exist and are accessible
|
|
17431
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
18156
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$a);
|
|
17432
18157
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
17433
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
18158
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$a);
|
|
17434
18159
|
// Retrieve the session mode from the session validation service
|
|
17435
18160
|
return swarm$1.sessionValidationService.getSessionMode(clientId);
|
|
17436
18161
|
});
|
|
17437
18162
|
|
|
17438
|
-
const METHOD_NAME$
|
|
18163
|
+
const METHOD_NAME$9 = "function.common.getSessionContext";
|
|
17439
18164
|
/**
|
|
17440
18165
|
* Retrieves the session context for the current execution environment.
|
|
17441
18166
|
*
|
|
@@ -17452,7 +18177,7 @@ const METHOD_NAME$a = "function.common.getSessionContext";
|
|
|
17452
18177
|
const getSessionContext = async () => {
|
|
17453
18178
|
// Log the operation if logging is enabled in GLOBAL_CONFIG
|
|
17454
18179
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17455
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
18180
|
+
swarm$1.loggerService.log(METHOD_NAME$9);
|
|
17456
18181
|
// Determine the method context, if active
|
|
17457
18182
|
const methodContext = MethodContextService.hasContext()
|
|
17458
18183
|
? swarm$1.methodContextService.context
|
|
@@ -17476,7 +18201,7 @@ const getSessionContext = async () => {
|
|
|
17476
18201
|
* @private Constant defining the method name for logging purposes.
|
|
17477
18202
|
* Used as an identifier in log messages to track calls to `getNavigationRoute`.
|
|
17478
18203
|
*/
|
|
17479
|
-
const METHOD_NAME$
|
|
18204
|
+
const METHOD_NAME$8 = "function.common.getNavigationRoute";
|
|
17480
18205
|
/**
|
|
17481
18206
|
* Retrieves the navigation route for a given client and swarm.
|
|
17482
18207
|
* Delegates to `NavigationValidationService.getNavigationRoute` to obtain a `Set` of visited agent names,
|
|
@@ -17487,15 +18212,15 @@ const METHOD_NAME$9 = "function.common.getNavigationRoute";
|
|
|
17487
18212
|
*/
|
|
17488
18213
|
const getNavigationRoute = (clientId, swarmName) => {
|
|
17489
18214
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17490
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
18215
|
+
swarm$1.loggerService.log(METHOD_NAME$8, {
|
|
17491
18216
|
clientId,
|
|
17492
18217
|
swarmName,
|
|
17493
18218
|
});
|
|
17494
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
18219
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$8);
|
|
17495
18220
|
return swarm$1.navigationValidationService.getNavigationRoute(clientId, swarmName);
|
|
17496
18221
|
};
|
|
17497
18222
|
|
|
17498
|
-
const METHOD_NAME$
|
|
18223
|
+
const METHOD_NAME$7 = "function.history.getUserHistory";
|
|
17499
18224
|
/**
|
|
17500
18225
|
* Retrieves the user-specific history entries for a given client session.
|
|
17501
18226
|
*
|
|
@@ -17513,15 +18238,15 @@ const METHOD_NAME$8 = "function.history.getUserHistory";
|
|
|
17513
18238
|
const getUserHistory = beginContext(async (clientId) => {
|
|
17514
18239
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17515
18240
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17516
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
18241
|
+
swarm$1.loggerService.log(METHOD_NAME$7, {
|
|
17517
18242
|
clientId,
|
|
17518
18243
|
});
|
|
17519
18244
|
// Fetch raw history and filter for user role and mode
|
|
17520
|
-
const history = await getRawHistory(clientId, METHOD_NAME$
|
|
18245
|
+
const history = await getRawHistory(clientId, METHOD_NAME$7);
|
|
17521
18246
|
return history.filter(({ role, mode }) => role === "user" && mode === "user");
|
|
17522
18247
|
});
|
|
17523
18248
|
|
|
17524
|
-
const METHOD_NAME$
|
|
18249
|
+
const METHOD_NAME$6 = "function.history.getAssistantHistory";
|
|
17525
18250
|
/**
|
|
17526
18251
|
* Retrieves the assistant's history entries for a given client session.
|
|
17527
18252
|
*
|
|
@@ -17539,15 +18264,15 @@ const METHOD_NAME$7 = "function.history.getAssistantHistory";
|
|
|
17539
18264
|
const getAssistantHistory = beginContext(async (clientId) => {
|
|
17540
18265
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17541
18266
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17542
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
18267
|
+
swarm$1.loggerService.log(METHOD_NAME$6, {
|
|
17543
18268
|
clientId,
|
|
17544
18269
|
});
|
|
17545
18270
|
// Fetch raw history and filter for assistant role
|
|
17546
|
-
const history = await getRawHistory(clientId, METHOD_NAME$
|
|
18271
|
+
const history = await getRawHistory(clientId, METHOD_NAME$6);
|
|
17547
18272
|
return history.filter(({ role }) => role === "assistant");
|
|
17548
18273
|
});
|
|
17549
18274
|
|
|
17550
|
-
const METHOD_NAME$
|
|
18275
|
+
const METHOD_NAME$5 = "function.history.getLastAssistantMessage";
|
|
17551
18276
|
/**
|
|
17552
18277
|
* Retrieves the content of the most recent assistant message from a client's session history.
|
|
17553
18278
|
*
|
|
@@ -17565,16 +18290,16 @@ const METHOD_NAME$6 = "function.history.getLastAssistantMessage";
|
|
|
17565
18290
|
const getLastAssistantMessage = beginContext(async (clientId) => {
|
|
17566
18291
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17567
18292
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17568
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
18293
|
+
swarm$1.loggerService.log(METHOD_NAME$5, {
|
|
17569
18294
|
clientId,
|
|
17570
18295
|
});
|
|
17571
18296
|
// Fetch raw history and find the last assistant message
|
|
17572
|
-
const history = await getRawHistory(clientId, METHOD_NAME$
|
|
18297
|
+
const history = await getRawHistory(clientId, METHOD_NAME$5);
|
|
17573
18298
|
const last = history.findLast(({ role }) => role === "assistant");
|
|
17574
18299
|
return last ? last.content : null;
|
|
17575
18300
|
});
|
|
17576
18301
|
|
|
17577
|
-
const METHOD_NAME$
|
|
18302
|
+
const METHOD_NAME$4 = "function.history.getLastSystemMessage";
|
|
17578
18303
|
/**
|
|
17579
18304
|
* Retrieves the content of the most recent system message from a client's session history.
|
|
17580
18305
|
*
|
|
@@ -17592,16 +18317,16 @@ const METHOD_NAME$5 = "function.history.getLastSystemMessage";
|
|
|
17592
18317
|
const getLastSystemMessage = beginContext(async (clientId) => {
|
|
17593
18318
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17594
18319
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17595
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
18320
|
+
swarm$1.loggerService.log(METHOD_NAME$4, {
|
|
17596
18321
|
clientId,
|
|
17597
18322
|
});
|
|
17598
18323
|
// Fetch raw history and find the last system message
|
|
17599
|
-
const history = await getRawHistory(clientId, METHOD_NAME$
|
|
18324
|
+
const history = await getRawHistory(clientId, METHOD_NAME$4);
|
|
17600
18325
|
const last = history.findLast(({ role }) => role === "system");
|
|
17601
18326
|
return last ? last.content : null;
|
|
17602
18327
|
});
|
|
17603
18328
|
|
|
17604
|
-
const METHOD_NAME$
|
|
18329
|
+
const METHOD_NAME$3 = "function.event.listenEvent";
|
|
17605
18330
|
/**
|
|
17606
18331
|
* Set of reserved event source names that cannot be used for custom events.
|
|
17607
18332
|
* @constant {Set<EventSource>}
|
|
@@ -17637,7 +18362,7 @@ const DISALLOWED_EVENT_SOURCE_LIST$2 = new Set([
|
|
|
17637
18362
|
const event = beginContext((clientId, topicName, payload) => {
|
|
17638
18363
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17639
18364
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17640
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
18365
|
+
swarm$1.loggerService.log(METHOD_NAME$3, {
|
|
17641
18366
|
clientId,
|
|
17642
18367
|
});
|
|
17643
18368
|
// Check if the topic name is reserved
|
|
@@ -17652,7 +18377,7 @@ const event = beginContext((clientId, topicName, payload) => {
|
|
|
17652
18377
|
});
|
|
17653
18378
|
});
|
|
17654
18379
|
|
|
17655
|
-
const METHOD_NAME$
|
|
18380
|
+
const METHOD_NAME$2 = "function.event.listenEvent";
|
|
17656
18381
|
/**
|
|
17657
18382
|
* Set of reserved event source names that cannot be used for custom event topics.
|
|
17658
18383
|
* @constant {Set<EventSource>}
|
|
@@ -17704,7 +18429,7 @@ const validateClientId$g = (clientId) => {
|
|
|
17704
18429
|
const listenEvent = beginContext((clientId, topicName, fn) => {
|
|
17705
18430
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17706
18431
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17707
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
18432
|
+
swarm$1.loggerService.log(METHOD_NAME$2, {
|
|
17708
18433
|
clientId,
|
|
17709
18434
|
});
|
|
17710
18435
|
// Check if the topic name is reserved
|
|
@@ -17717,7 +18442,7 @@ const listenEvent = beginContext((clientId, topicName, fn) => {
|
|
|
17717
18442
|
return swarm$1.busService.subscribe(clientId, topicName, functoolsKit.queued(async ({ payload }) => await fn(payload)));
|
|
17718
18443
|
});
|
|
17719
18444
|
|
|
17720
|
-
const METHOD_NAME$
|
|
18445
|
+
const METHOD_NAME$1 = "function.event.listenEventOnce";
|
|
17721
18446
|
/**
|
|
17722
18447
|
* Set of reserved event source names that cannot be used for custom event topics.
|
|
17723
18448
|
* @constant {Set<EventSource>}
|
|
@@ -17775,7 +18500,7 @@ const validateClientId$f = (clientId) => {
|
|
|
17775
18500
|
const listenEventOnce = beginContext((clientId, topicName, filterFn, fn) => {
|
|
17776
18501
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17777
18502
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17778
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
18503
|
+
swarm$1.loggerService.log(METHOD_NAME$1, {
|
|
17779
18504
|
clientId,
|
|
17780
18505
|
});
|
|
17781
18506
|
// Check if the topic name is reserved
|
|
@@ -17788,112 +18513,6 @@ const listenEventOnce = beginContext((clientId, topicName, filterFn, fn) => {
|
|
|
17788
18513
|
return swarm$1.busService.once(clientId, topicName, ({ payload }) => filterFn(payload), functoolsKit.queued(async ({ payload }) => await fn(payload)));
|
|
17789
18514
|
});
|
|
17790
18515
|
|
|
17791
|
-
const METHOD_NAME$1 = "function.navigate.changeToAgent";
|
|
17792
|
-
/**
|
|
17793
|
-
* Time-to-live for the change agent function in milliseconds.
|
|
17794
|
-
* Defines how long the cached change agent function remains valid before expiring.
|
|
17795
|
-
* @constant {number}
|
|
17796
|
-
*/
|
|
17797
|
-
const CHANGE_AGENT_TTL$1 = 15 * 60 * 1000;
|
|
17798
|
-
/**
|
|
17799
|
-
* Garbage collection interval for the change agent function in milliseconds.
|
|
17800
|
-
* Specifies the frequency at which expired TTL entries are cleaned up.
|
|
17801
|
-
* @constant {number}
|
|
17802
|
-
*/
|
|
17803
|
-
const CHANGE_AGENT_GC$1 = 60 * 1000;
|
|
17804
|
-
/**
|
|
17805
|
-
* Creates a change agent function with time-to-live (TTL) and queuing capabilities.
|
|
17806
|
-
*
|
|
17807
|
-
* This factory function generates a queued, TTL-limited function to handle agent changes for a specific client session,
|
|
17808
|
-
* ensuring operations are executed sequentially and cached results are reused within the TTL period.
|
|
17809
|
-
*
|
|
17810
|
-
* @function
|
|
17811
|
-
* @param {string} clientId - The unique identifier of the client session.
|
|
17812
|
-
* @returns {TChangeToAgentRun} A function that performs the agent change operation with queuing and TTL.
|
|
17813
|
-
*/
|
|
17814
|
-
const createChangeToAgent = functoolsKit.ttl((clientId) => functoolsKit.queued(async (methodName, agentName, swarmName) => {
|
|
17815
|
-
if (!swarm$1.navigationValidationService.shouldNavigate(agentName, clientId, swarmName)) {
|
|
17816
|
-
console.warn(`function "changeToAgent" skipped due to the circular route found clientId=${clientId} swarmName=${swarmName} agentNameTo=${agentName}`);
|
|
17817
|
-
return false;
|
|
17818
|
-
}
|
|
17819
|
-
// Notify all agents in the swarm of the change
|
|
17820
|
-
await Promise.all(swarm$1.swarmValidationService
|
|
17821
|
-
.getAgentList(swarmName)
|
|
17822
|
-
.map(async (agentName) => {
|
|
17823
|
-
await swarm$1.agentPublicService.commitAgentChange(methodName, clientId, agentName);
|
|
17824
|
-
}));
|
|
17825
|
-
{
|
|
17826
|
-
// Dispose of the current agent's resources and set up the new agent
|
|
17827
|
-
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$1, clientId, swarmName);
|
|
17828
|
-
await swarm$1.agentPublicService.dispose(methodName, clientId, agentName);
|
|
17829
|
-
await swarm$1.historyPublicService.dispose(methodName, clientId, agentName);
|
|
17830
|
-
await swarm$1.swarmPublicService.setAgentRef(methodName, clientId, swarmName, agentName, await swarm$1.agentPublicService.createAgentRef(methodName, clientId, agentName));
|
|
17831
|
-
}
|
|
17832
|
-
// Set the new agent as the active agent
|
|
17833
|
-
await swarm$1.swarmPublicService.setAgentName(agentName, methodName, clientId, swarmName);
|
|
17834
|
-
return true;
|
|
17835
|
-
}), {
|
|
17836
|
-
key: ([clientId]) => `${clientId}`,
|
|
17837
|
-
timeout: CHANGE_AGENT_TTL$1,
|
|
17838
|
-
});
|
|
17839
|
-
/**
|
|
17840
|
-
* Creates a garbage collector for the change agent function.
|
|
17841
|
-
*
|
|
17842
|
-
* This function sets up a singleton interval-based garbage collector to periodically clean up expired TTL entries from `createChangeToAgent`.
|
|
17843
|
-
*
|
|
17844
|
-
* @function
|
|
17845
|
-
* @returns {Promise<void>} A promise that resolves when the garbage collector is initialized.
|
|
17846
|
-
*/
|
|
17847
|
-
const createGc$1 = functoolsKit.singleshot(async () => {
|
|
17848
|
-
setInterval(createChangeToAgent.gc, CHANGE_AGENT_GC$1);
|
|
17849
|
-
});
|
|
17850
|
-
/**
|
|
17851
|
-
* Changes the active agent for a given client session in a swarm.
|
|
17852
|
-
*
|
|
17853
|
-
* This function facilitates switching the active agent in a swarm session, validating the session and agent dependencies,
|
|
17854
|
-
* logging the operation if enabled, and executing the change using a TTL-limited, queued runner.
|
|
17855
|
-
* The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts.
|
|
17856
|
-
*
|
|
17857
|
-
* @param {AgentName} agentName - The name of the agent to switch to.
|
|
17858
|
-
* @param {string} clientId - The unique identifier of the client session.
|
|
17859
|
-
* @returns {Promise<boolean>} A promise that resolves when the agent change is complete. If it resolved false, the navigation is canceled due to recursion
|
|
17860
|
-
* @throws {Error} If session or agent validation fails, or if the agent change process encounters an error.
|
|
17861
|
-
* @example
|
|
17862
|
-
* await changeToAgent("AgentX", "client-123");
|
|
17863
|
-
*/
|
|
17864
|
-
const changeToAgent = beginContext(async (agentName, clientId) => {
|
|
17865
|
-
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17866
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17867
|
-
swarm$1.loggerService.log(METHOD_NAME$1, {
|
|
17868
|
-
agentName,
|
|
17869
|
-
clientId,
|
|
17870
|
-
});
|
|
17871
|
-
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
17872
|
-
{
|
|
17873
|
-
// Validate session, agent, and dependencies
|
|
17874
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$1);
|
|
17875
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$1);
|
|
17876
|
-
const activeAgent = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$1, clientId, swarmName);
|
|
17877
|
-
if (!swarm$1.agentValidationService.hasDependency(activeAgent, agentName)) {
|
|
17878
|
-
console.error(`agent-swarm missing dependency detected for activeAgent=${activeAgent} dependencyAgent=${agentName}`);
|
|
17879
|
-
}
|
|
17880
|
-
}
|
|
17881
|
-
if (!swarm$1.swarmValidationService.getAgentSet(swarmName).has(agentName)) {
|
|
17882
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17883
|
-
swarm$1.loggerService.log('function "changeToAgent" skipped due to the agent is not in the swarm', {
|
|
17884
|
-
agentName,
|
|
17885
|
-
clientId,
|
|
17886
|
-
swarmName,
|
|
17887
|
-
});
|
|
17888
|
-
console.warn(`function "changeToAgent" skipped due to the agent is not in the swarm clientId=${clientId} agentName=${agentName} swarmName=${swarmName}`);
|
|
17889
|
-
return false;
|
|
17890
|
-
}
|
|
17891
|
-
// Execute the agent change with TTL and queuing
|
|
17892
|
-
const run = await createChangeToAgent(clientId);
|
|
17893
|
-
createGc$1();
|
|
17894
|
-
return await run(METHOD_NAME$1, agentName, swarmName);
|
|
17895
|
-
});
|
|
17896
|
-
|
|
17897
18516
|
const METHOD_NAME = "function.navigate.changeToPrevAgent";
|
|
17898
18517
|
/**
|
|
17899
18518
|
* Time-to-live for the change agent function in milliseconds.
|
|
@@ -20016,6 +20635,7 @@ exports.Utils = Utils;
|
|
|
20016
20635
|
exports.addAgent = addAgent;
|
|
20017
20636
|
exports.addCompletion = addCompletion;
|
|
20018
20637
|
exports.addEmbedding = addEmbedding;
|
|
20638
|
+
exports.addMCP = addMCP;
|
|
20019
20639
|
exports.addPolicy = addPolicy;
|
|
20020
20640
|
exports.addState = addState;
|
|
20021
20641
|
exports.addStorage = addStorage;
|
|
@@ -20041,6 +20661,7 @@ exports.commitToolOutputForce = commitToolOutputForce;
|
|
|
20041
20661
|
exports.commitUserMessage = commitUserMessage;
|
|
20042
20662
|
exports.commitUserMessageForce = commitUserMessageForce;
|
|
20043
20663
|
exports.complete = complete;
|
|
20664
|
+
exports.createNavigateToAgent = createNavigateToAgent;
|
|
20044
20665
|
exports.createNavigateToTriageAgent = createNavigateToTriageAgent;
|
|
20045
20666
|
exports.disposeConnection = disposeConnection;
|
|
20046
20667
|
exports.dumpAgent = dumpAgent;
|
|
@@ -20094,6 +20715,7 @@ exports.notifyForce = notifyForce;
|
|
|
20094
20715
|
exports.overrideAgent = overrideAgent;
|
|
20095
20716
|
exports.overrideCompletion = overrideCompletion;
|
|
20096
20717
|
exports.overrideEmbeding = overrideEmbeding;
|
|
20718
|
+
exports.overrideMCP = overrideMCP;
|
|
20097
20719
|
exports.overridePolicy = overridePolicy;
|
|
20098
20720
|
exports.overrideState = overrideState;
|
|
20099
20721
|
exports.overrideStorage = overrideStorage;
|