agent-swarm-kit 1.0.240 → 1.0.242
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 +38 -5
- package/build/index.mjs +38 -5
- package/package.json +1 -1
- package/types.d.ts +8 -0
package/build/index.cjs
CHANGED
|
@@ -3572,7 +3572,7 @@ const RUN_FN = async (incoming, self) => {
|
|
|
3572
3572
|
self.params.logger.debug(`ClientAgent agentName=${self.params.agentName} clientId=${self.params.clientId} run begin`, { incoming });
|
|
3573
3573
|
self.params.onRun &&
|
|
3574
3574
|
self.params.onRun(self.params.clientId, self.params.agentName, incoming);
|
|
3575
|
-
const messages = await self.params.history.toArrayForAgent(self.params.prompt, await self._resolveSystemPrompt());
|
|
3575
|
+
const messages = await self.params.history.toArrayForAgent(self.params.prompt ?? "", await self._resolveSystemPrompt());
|
|
3576
3576
|
messages.push({
|
|
3577
3577
|
agentName: self.params.agentName,
|
|
3578
3578
|
content: incoming,
|
|
@@ -4049,7 +4049,7 @@ class ClientAgent {
|
|
|
4049
4049
|
async getCompletion(mode) {
|
|
4050
4050
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4051
4051
|
this.params.logger.debug(`ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} getCompletion`);
|
|
4052
|
-
const messages = await this.params.history.toArrayForAgent(this.params.prompt, await this._resolveSystemPrompt());
|
|
4052
|
+
const messages = await this.params.history.toArrayForAgent(this.params.prompt ?? "", await this._resolveSystemPrompt());
|
|
4053
4053
|
const args = {
|
|
4054
4054
|
clientId: this.params.clientId,
|
|
4055
4055
|
agentName: this.params.agentName,
|
|
@@ -4093,7 +4093,7 @@ class ClientAgent {
|
|
|
4093
4093
|
agentName: this.params.agentName,
|
|
4094
4094
|
content: GLOBAL_CONFIG.CC_TOOL_CALL_EXCEPTION_RECOMPLETE_PROMPT,
|
|
4095
4095
|
});
|
|
4096
|
-
const messages = await this.params.history.toArrayForAgent(this.params.prompt, await this._resolveSystemPrompt());
|
|
4096
|
+
const messages = await this.params.history.toArrayForAgent(this.params.prompt ?? "", await this._resolveSystemPrompt());
|
|
4097
4097
|
const args = {
|
|
4098
4098
|
clientId: this.params.clientId,
|
|
4099
4099
|
agentName: this.params.agentName,
|
|
@@ -4990,7 +4990,7 @@ class ClientHistory {
|
|
|
4990
4990
|
});
|
|
4991
4991
|
const promptMessages = [];
|
|
4992
4992
|
{
|
|
4993
|
-
promptMessages.push({
|
|
4993
|
+
prompt && promptMessages.push({
|
|
4994
4994
|
agentName: this.params.agentName,
|
|
4995
4995
|
mode: "tool",
|
|
4996
4996
|
content: prompt,
|
|
@@ -5467,6 +5467,9 @@ class ClientSwarm {
|
|
|
5467
5467
|
this.params.logger.debug(`ClientSwarm swarmName=${this.params.swarmName} clientId=${this.params.clientId} getAgent`);
|
|
5468
5468
|
const agentName = await this.getAgentName();
|
|
5469
5469
|
const result = this.params.agentMap[agentName];
|
|
5470
|
+
if (!result) {
|
|
5471
|
+
throw new Error(`agent-swarm ClientSwarm getAgent current agent is not in the swarm agentName=${agentName} clientId=${this.params.clientId} swarmName=${this.params.swarmName}`);
|
|
5472
|
+
}
|
|
5470
5473
|
await this.params.bus.emit(this.params.clientId, {
|
|
5471
5474
|
type: "get-agent",
|
|
5472
5475
|
source: "swarm-bus",
|
|
@@ -8919,6 +8922,24 @@ class SwarmValidationService {
|
|
|
8919
8922
|
}
|
|
8920
8923
|
return swarm.agentList;
|
|
8921
8924
|
};
|
|
8925
|
+
/**
|
|
8926
|
+
* Retrieves the set of agent names associated with a given swarm.
|
|
8927
|
+
* Logs the operation and validates swarm existence, supporting ClientSwarm’s agent management.
|
|
8928
|
+
* @param {SwarmName} swarmName - The name of the swarm to query, sourced from Swarm.interface.
|
|
8929
|
+
* @returns {string[]} An array of agent names from the swarm’s schema.
|
|
8930
|
+
* @throws {Error} If the swarm is not found in _swarmMap.
|
|
8931
|
+
*/
|
|
8932
|
+
this.getAgentSet = functoolsKit.memoize(([swarmName]) => `${swarmName}`, (swarmName) => {
|
|
8933
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
8934
|
+
this.loggerService.info("swarmValidationService getAgentSet", {
|
|
8935
|
+
swarmName,
|
|
8936
|
+
});
|
|
8937
|
+
const swarm = this._swarmMap.get(swarmName);
|
|
8938
|
+
if (!swarm) {
|
|
8939
|
+
throw new Error(`agent-swarm swarm ${swarmName} not found`);
|
|
8940
|
+
}
|
|
8941
|
+
return new Set(swarm.agentList);
|
|
8942
|
+
});
|
|
8922
8943
|
/**
|
|
8923
8944
|
* Retrieves the list of policy names associated with a given swarm.
|
|
8924
8945
|
* Logs the operation and validates swarm existence, supporting ClientSwarm’s policy enforcement.
|
|
@@ -11500,10 +11521,14 @@ class DocService {
|
|
|
11500
11521
|
}
|
|
11501
11522
|
result.push("");
|
|
11502
11523
|
}
|
|
11503
|
-
{
|
|
11524
|
+
if (agentSchema.completion) {
|
|
11504
11525
|
result.push(`**Completion:** \`${agentSchema.completion}\``);
|
|
11505
11526
|
result.push("");
|
|
11506
11527
|
}
|
|
11528
|
+
{
|
|
11529
|
+
result.push(`*Operator:* [${agentSchema.operator ? "x" : " "}]`);
|
|
11530
|
+
result.push("");
|
|
11531
|
+
}
|
|
11507
11532
|
{
|
|
11508
11533
|
const umlSchema = this.agentMetaService.toUML(agentSchema.agentName, true);
|
|
11509
11534
|
const umlName = `agent_schema_${agentSchema.agentName}.svg`;
|
|
@@ -17112,6 +17137,14 @@ const changeToAgent = beginContext(async (agentName, clientId) => {
|
|
|
17112
17137
|
console.error(`agent-swarm missing dependency detected for activeAgent=${activeAgent} dependencyAgent=${agentName}`);
|
|
17113
17138
|
}
|
|
17114
17139
|
}
|
|
17140
|
+
if (!swarm$1.swarmValidationService.getAgentSet(swarmName).has(agentName)) {
|
|
17141
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17142
|
+
swarm$1.loggerService.log('function "changeToAgent" skipped due to the agent is not in the swarm', {
|
|
17143
|
+
agentName,
|
|
17144
|
+
clientId,
|
|
17145
|
+
});
|
|
17146
|
+
return false;
|
|
17147
|
+
}
|
|
17115
17148
|
// Execute the agent change with TTL and queuing
|
|
17116
17149
|
const run = await createChangeToAgent(clientId);
|
|
17117
17150
|
createGc$2();
|
package/build/index.mjs
CHANGED
|
@@ -3570,7 +3570,7 @@ const RUN_FN = async (incoming, self) => {
|
|
|
3570
3570
|
self.params.logger.debug(`ClientAgent agentName=${self.params.agentName} clientId=${self.params.clientId} run begin`, { incoming });
|
|
3571
3571
|
self.params.onRun &&
|
|
3572
3572
|
self.params.onRun(self.params.clientId, self.params.agentName, incoming);
|
|
3573
|
-
const messages = await self.params.history.toArrayForAgent(self.params.prompt, await self._resolveSystemPrompt());
|
|
3573
|
+
const messages = await self.params.history.toArrayForAgent(self.params.prompt ?? "", await self._resolveSystemPrompt());
|
|
3574
3574
|
messages.push({
|
|
3575
3575
|
agentName: self.params.agentName,
|
|
3576
3576
|
content: incoming,
|
|
@@ -4047,7 +4047,7 @@ class ClientAgent {
|
|
|
4047
4047
|
async getCompletion(mode) {
|
|
4048
4048
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
4049
4049
|
this.params.logger.debug(`ClientAgent agentName=${this.params.agentName} clientId=${this.params.clientId} getCompletion`);
|
|
4050
|
-
const messages = await this.params.history.toArrayForAgent(this.params.prompt, await this._resolveSystemPrompt());
|
|
4050
|
+
const messages = await this.params.history.toArrayForAgent(this.params.prompt ?? "", await this._resolveSystemPrompt());
|
|
4051
4051
|
const args = {
|
|
4052
4052
|
clientId: this.params.clientId,
|
|
4053
4053
|
agentName: this.params.agentName,
|
|
@@ -4091,7 +4091,7 @@ class ClientAgent {
|
|
|
4091
4091
|
agentName: this.params.agentName,
|
|
4092
4092
|
content: GLOBAL_CONFIG.CC_TOOL_CALL_EXCEPTION_RECOMPLETE_PROMPT,
|
|
4093
4093
|
});
|
|
4094
|
-
const messages = await this.params.history.toArrayForAgent(this.params.prompt, await this._resolveSystemPrompt());
|
|
4094
|
+
const messages = await this.params.history.toArrayForAgent(this.params.prompt ?? "", await this._resolveSystemPrompt());
|
|
4095
4095
|
const args = {
|
|
4096
4096
|
clientId: this.params.clientId,
|
|
4097
4097
|
agentName: this.params.agentName,
|
|
@@ -4988,7 +4988,7 @@ class ClientHistory {
|
|
|
4988
4988
|
});
|
|
4989
4989
|
const promptMessages = [];
|
|
4990
4990
|
{
|
|
4991
|
-
promptMessages.push({
|
|
4991
|
+
prompt && promptMessages.push({
|
|
4992
4992
|
agentName: this.params.agentName,
|
|
4993
4993
|
mode: "tool",
|
|
4994
4994
|
content: prompt,
|
|
@@ -5465,6 +5465,9 @@ class ClientSwarm {
|
|
|
5465
5465
|
this.params.logger.debug(`ClientSwarm swarmName=${this.params.swarmName} clientId=${this.params.clientId} getAgent`);
|
|
5466
5466
|
const agentName = await this.getAgentName();
|
|
5467
5467
|
const result = this.params.agentMap[agentName];
|
|
5468
|
+
if (!result) {
|
|
5469
|
+
throw new Error(`agent-swarm ClientSwarm getAgent current agent is not in the swarm agentName=${agentName} clientId=${this.params.clientId} swarmName=${this.params.swarmName}`);
|
|
5470
|
+
}
|
|
5468
5471
|
await this.params.bus.emit(this.params.clientId, {
|
|
5469
5472
|
type: "get-agent",
|
|
5470
5473
|
source: "swarm-bus",
|
|
@@ -8917,6 +8920,24 @@ class SwarmValidationService {
|
|
|
8917
8920
|
}
|
|
8918
8921
|
return swarm.agentList;
|
|
8919
8922
|
};
|
|
8923
|
+
/**
|
|
8924
|
+
* Retrieves the set of agent names associated with a given swarm.
|
|
8925
|
+
* Logs the operation and validates swarm existence, supporting ClientSwarm’s agent management.
|
|
8926
|
+
* @param {SwarmName} swarmName - The name of the swarm to query, sourced from Swarm.interface.
|
|
8927
|
+
* @returns {string[]} An array of agent names from the swarm’s schema.
|
|
8928
|
+
* @throws {Error} If the swarm is not found in _swarmMap.
|
|
8929
|
+
*/
|
|
8930
|
+
this.getAgentSet = memoize(([swarmName]) => `${swarmName}`, (swarmName) => {
|
|
8931
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
8932
|
+
this.loggerService.info("swarmValidationService getAgentSet", {
|
|
8933
|
+
swarmName,
|
|
8934
|
+
});
|
|
8935
|
+
const swarm = this._swarmMap.get(swarmName);
|
|
8936
|
+
if (!swarm) {
|
|
8937
|
+
throw new Error(`agent-swarm swarm ${swarmName} not found`);
|
|
8938
|
+
}
|
|
8939
|
+
return new Set(swarm.agentList);
|
|
8940
|
+
});
|
|
8920
8941
|
/**
|
|
8921
8942
|
* Retrieves the list of policy names associated with a given swarm.
|
|
8922
8943
|
* Logs the operation and validates swarm existence, supporting ClientSwarm’s policy enforcement.
|
|
@@ -11498,10 +11519,14 @@ class DocService {
|
|
|
11498
11519
|
}
|
|
11499
11520
|
result.push("");
|
|
11500
11521
|
}
|
|
11501
|
-
{
|
|
11522
|
+
if (agentSchema.completion) {
|
|
11502
11523
|
result.push(`**Completion:** \`${agentSchema.completion}\``);
|
|
11503
11524
|
result.push("");
|
|
11504
11525
|
}
|
|
11526
|
+
{
|
|
11527
|
+
result.push(`*Operator:* [${agentSchema.operator ? "x" : " "}]`);
|
|
11528
|
+
result.push("");
|
|
11529
|
+
}
|
|
11505
11530
|
{
|
|
11506
11531
|
const umlSchema = this.agentMetaService.toUML(agentSchema.agentName, true);
|
|
11507
11532
|
const umlName = `agent_schema_${agentSchema.agentName}.svg`;
|
|
@@ -17110,6 +17135,14 @@ const changeToAgent = beginContext(async (agentName, clientId) => {
|
|
|
17110
17135
|
console.error(`agent-swarm missing dependency detected for activeAgent=${activeAgent} dependencyAgent=${agentName}`);
|
|
17111
17136
|
}
|
|
17112
17137
|
}
|
|
17138
|
+
if (!swarm$1.swarmValidationService.getAgentSet(swarmName).has(agentName)) {
|
|
17139
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17140
|
+
swarm$1.loggerService.log('function "changeToAgent" skipped due to the agent is not in the swarm', {
|
|
17141
|
+
agentName,
|
|
17142
|
+
clientId,
|
|
17143
|
+
});
|
|
17144
|
+
return false;
|
|
17145
|
+
}
|
|
17113
17146
|
// Execute the agent change with TTL and queuing
|
|
17114
17147
|
const run = await createChangeToAgent(clientId);
|
|
17115
17148
|
createGc$2();
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -5887,6 +5887,14 @@ declare class SwarmValidationService {
|
|
|
5887
5887
|
* @throws {Error} If the swarm is not found in _swarmMap.
|
|
5888
5888
|
*/
|
|
5889
5889
|
getAgentList: (swarmName: SwarmName) => string[];
|
|
5890
|
+
/**
|
|
5891
|
+
* Retrieves the set of agent names associated with a given swarm.
|
|
5892
|
+
* Logs the operation and validates swarm existence, supporting ClientSwarm’s agent management.
|
|
5893
|
+
* @param {SwarmName} swarmName - The name of the swarm to query, sourced from Swarm.interface.
|
|
5894
|
+
* @returns {string[]} An array of agent names from the swarm’s schema.
|
|
5895
|
+
* @throws {Error} If the swarm is not found in _swarmMap.
|
|
5896
|
+
*/
|
|
5897
|
+
getAgentSet: ((swarmName: SwarmName) => Set<string>) & functools_kit.IClearableMemoize<string> & functools_kit.IControlMemoize<string, Set<string>>;
|
|
5890
5898
|
/**
|
|
5891
5899
|
* Retrieves the list of policy names associated with a given swarm.
|
|
5892
5900
|
* Logs the operation and validates swarm existence, supporting ClientSwarm’s policy enforcement.
|