agent-swarm-kit 1.0.84 → 1.0.86
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 +254 -24
- package/build/index.mjs +253 -25
- package/package.json +1 -1
- package/types.d.ts +77 -1
package/build/index.cjs
CHANGED
|
@@ -195,6 +195,10 @@ var schemaServices$1 = {
|
|
|
195
195
|
storageSchemaService: Symbol('storageSchemaService'),
|
|
196
196
|
stateSchemaService: Symbol('stateSchemaService'),
|
|
197
197
|
};
|
|
198
|
+
var metaServices$1 = {
|
|
199
|
+
agentMetaService: Symbol('agentMetaService'),
|
|
200
|
+
swarmMetaService: Symbol('swarmMetaService'),
|
|
201
|
+
};
|
|
198
202
|
var publicServices$1 = {
|
|
199
203
|
agentPublicService: Symbol('agentPublicService'),
|
|
200
204
|
historyPublicService: Symbol('historyPublicService'),
|
|
@@ -212,7 +216,7 @@ var validationServices$1 = {
|
|
|
212
216
|
embeddingValidationService: Symbol('embeddingValidationService'),
|
|
213
217
|
storageValidationService: Symbol('storageValidationService'),
|
|
214
218
|
};
|
|
215
|
-
var TYPES = __assign(__assign(__assign(__assign(__assign(__assign({}, baseServices$1), contextServices$1), schemaServices$1), connectionServices$1), publicServices$1), validationServices$1);
|
|
219
|
+
var TYPES = __assign(__assign(__assign(__assign(__assign(__assign(__assign({}, baseServices$1), contextServices$1), schemaServices$1), connectionServices$1), publicServices$1), validationServices$1), metaServices$1);
|
|
216
220
|
|
|
217
221
|
/**
|
|
218
222
|
* Service providing execution context information.
|
|
@@ -4933,6 +4937,7 @@ var AgentValidationService = /** @class */ (function () {
|
|
|
4933
4937
|
this.completionValidationService = inject(TYPES.completionValidationService);
|
|
4934
4938
|
this.storageValidationService = inject(TYPES.storageValidationService);
|
|
4935
4939
|
this._agentMap = new Map();
|
|
4940
|
+
this._agentDepsMap = new Map();
|
|
4936
4941
|
/**
|
|
4937
4942
|
* Retrieves the storages used by the agent
|
|
4938
4943
|
* @param {agentName} agentName - The name of the swarm.
|
|
@@ -4973,6 +4978,9 @@ var AgentValidationService = /** @class */ (function () {
|
|
|
4973
4978
|
throw new Error("agent-swarm agent ".concat(agentName, " already exist"));
|
|
4974
4979
|
}
|
|
4975
4980
|
_this._agentMap.set(agentName, agentSchema);
|
|
4981
|
+
if (agentSchema.dependsOn) {
|
|
4982
|
+
_this._agentDepsMap.set(agentName, agentSchema.dependsOn);
|
|
4983
|
+
}
|
|
4976
4984
|
};
|
|
4977
4985
|
/**
|
|
4978
4986
|
* Check if agent got registered storage
|
|
@@ -4992,6 +5000,23 @@ var AgentValidationService = /** @class */ (function () {
|
|
|
4992
5000
|
var _a = _this._agentMap.get(agentName).storages, storages = _a === void 0 ? [] : _a;
|
|
4993
5001
|
return storages.includes(storageName);
|
|
4994
5002
|
});
|
|
5003
|
+
/**
|
|
5004
|
+
* Check if agent got registered dependency
|
|
5005
|
+
*/
|
|
5006
|
+
this.hasDependency = functoolsKit.memoize(function (_a) {
|
|
5007
|
+
var _b = __read(_a, 2), targetAgentName = _b[0], depAgentName = _b[1];
|
|
5008
|
+
return "".concat(targetAgentName, "-").concat(depAgentName);
|
|
5009
|
+
}, function (targetAgentName, depAgentName) {
|
|
5010
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5011
|
+
_this.loggerService.info("agentValidationService hasDependency", {
|
|
5012
|
+
targetAgentName: targetAgentName,
|
|
5013
|
+
depAgentName: depAgentName,
|
|
5014
|
+
});
|
|
5015
|
+
if (_this._agentDepsMap.has(targetAgentName)) {
|
|
5016
|
+
return _this._agentDepsMap.get(targetAgentName).includes(depAgentName);
|
|
5017
|
+
}
|
|
5018
|
+
return true;
|
|
5019
|
+
});
|
|
4995
5020
|
/**
|
|
4996
5021
|
* Check if agent got registered state
|
|
4997
5022
|
*/
|
|
@@ -7189,6 +7214,164 @@ var BusService = /** @class */ (function () {
|
|
|
7189
7214
|
return BusService;
|
|
7190
7215
|
}());
|
|
7191
7216
|
|
|
7217
|
+
var MAX_NESTING = 10;
|
|
7218
|
+
var UML_STEP = "\t";
|
|
7219
|
+
var UML_BULLET = "•";
|
|
7220
|
+
/**
|
|
7221
|
+
* Creates a function to serialize meta nodes to UML format.
|
|
7222
|
+
* @returns {Function} A function that takes an array of IMetaNode and returns a string in UML format.
|
|
7223
|
+
*/
|
|
7224
|
+
var createSerialize = function () { return function (nodes) {
|
|
7225
|
+
var lines = [];
|
|
7226
|
+
var process = function (nodes, level, seen) {
|
|
7227
|
+
var e_1, _a;
|
|
7228
|
+
var _b;
|
|
7229
|
+
if (level === void 0) { level = 0; }
|
|
7230
|
+
if (seen === void 0) { seen = new Set(); }
|
|
7231
|
+
try {
|
|
7232
|
+
for (var nodes_1 = __values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) {
|
|
7233
|
+
var node = nodes_1_1.value;
|
|
7234
|
+
var space = __spreadArray([], __read(new Array(level)), false).fill(UML_STEP).join("");
|
|
7235
|
+
if (seen.has(node.name)) {
|
|
7236
|
+
lines.push("".concat(space).concat(String(node.name), ": \"\""));
|
|
7237
|
+
}
|
|
7238
|
+
else if (((_b = node.child) === null || _b === void 0 ? void 0 : _b.length) && level < MAX_NESTING) {
|
|
7239
|
+
lines.push("".concat(space).concat(String(node.name), ":"));
|
|
7240
|
+
lines.push("".concat(space).concat(UML_STEP).concat(UML_BULLET, " ").concat(String(node.name), ": \"\""));
|
|
7241
|
+
process(node.child, level + 1, seen.add(node.name));
|
|
7242
|
+
}
|
|
7243
|
+
else {
|
|
7244
|
+
lines.push("".concat(space).concat(String(node.name), ": \"\""));
|
|
7245
|
+
}
|
|
7246
|
+
}
|
|
7247
|
+
}
|
|
7248
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
7249
|
+
finally {
|
|
7250
|
+
try {
|
|
7251
|
+
if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) _a.call(nodes_1);
|
|
7252
|
+
}
|
|
7253
|
+
finally { if (e_1) throw e_1.error; }
|
|
7254
|
+
}
|
|
7255
|
+
};
|
|
7256
|
+
process(nodes);
|
|
7257
|
+
var result = __spreadArray(__spreadArray(["@startyaml"], __read(lines), false), ["@endyaml"], false).join("\n");
|
|
7258
|
+
return result;
|
|
7259
|
+
}; };
|
|
7260
|
+
/**
|
|
7261
|
+
* Service class for managing agent meta nodes and converting them to UML format.
|
|
7262
|
+
*/
|
|
7263
|
+
var AgentMetaService = /** @class */ (function () {
|
|
7264
|
+
function AgentMetaService() {
|
|
7265
|
+
var _this = this;
|
|
7266
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
7267
|
+
this.agentSchemaService = inject(TYPES.agentSchemaService);
|
|
7268
|
+
this.serialize = createSerialize();
|
|
7269
|
+
/**
|
|
7270
|
+
* Creates a meta node for the given agent.
|
|
7271
|
+
* @param {AgentName} agentName - The name of the agent.
|
|
7272
|
+
* @param {Set<AgentName>} seen - A set of seen agent names to avoid circular dependencies.
|
|
7273
|
+
* @returns {IMetaNode} The created meta node.
|
|
7274
|
+
*/
|
|
7275
|
+
this.makeAgentNode = function (agentName, seen) {
|
|
7276
|
+
if (seen === void 0) { seen = new Set(); }
|
|
7277
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
7278
|
+
_this.loggerService.info("agentMetaService makeAgentNode", {
|
|
7279
|
+
agentName: agentName,
|
|
7280
|
+
});
|
|
7281
|
+
var _a = _this.agentSchemaService.get(agentName), dependsOn = _a.dependsOn, states = _a.states, storages = _a.storages, tools = _a.tools;
|
|
7282
|
+
var childSeen = seen.add(agentName);
|
|
7283
|
+
var agentTree = [];
|
|
7284
|
+
if (dependsOn && !seen.has(agentName)) {
|
|
7285
|
+
agentTree.push({
|
|
7286
|
+
name: "Agents (".concat(agentName, ")"),
|
|
7287
|
+
child: dependsOn
|
|
7288
|
+
.filter(function (name) { return !!name; })
|
|
7289
|
+
.map(function (dep) { return _this.makeAgentNode(dep, childSeen); }),
|
|
7290
|
+
});
|
|
7291
|
+
}
|
|
7292
|
+
if (states) {
|
|
7293
|
+
agentTree.push({
|
|
7294
|
+
name: "States (".concat(agentName, ")"),
|
|
7295
|
+
child: states.filter(function (name) { return !!name; }).map(function (name) { return ({ name: name }); }),
|
|
7296
|
+
});
|
|
7297
|
+
}
|
|
7298
|
+
if (storages) {
|
|
7299
|
+
agentTree.push({
|
|
7300
|
+
name: "Storages (".concat(agentName, ")"),
|
|
7301
|
+
child: storages.filter(function (name) { return !!name; }).map(function (name) { return ({ name: name }); }),
|
|
7302
|
+
});
|
|
7303
|
+
}
|
|
7304
|
+
if (tools) {
|
|
7305
|
+
agentTree.push({
|
|
7306
|
+
name: "Tools (".concat(agentName, ")"),
|
|
7307
|
+
child: tools.filter(function (name) { return !!name; }).map(function (name) { return ({ name: name }); }),
|
|
7308
|
+
});
|
|
7309
|
+
}
|
|
7310
|
+
return {
|
|
7311
|
+
name: agentName,
|
|
7312
|
+
child: agentTree,
|
|
7313
|
+
};
|
|
7314
|
+
};
|
|
7315
|
+
/**
|
|
7316
|
+
* Converts the meta nodes of the given agent to UML format.
|
|
7317
|
+
* @param {AgentName} agentName - The name of the agent.
|
|
7318
|
+
* @returns {string} The UML representation of the agent's meta nodes.
|
|
7319
|
+
*/
|
|
7320
|
+
this.toUML = function (agentName) {
|
|
7321
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
7322
|
+
_this.loggerService.info("agentMetaService toUML", {
|
|
7323
|
+
agentName: agentName,
|
|
7324
|
+
});
|
|
7325
|
+
var rootNode = _this.makeAgentNode(agentName);
|
|
7326
|
+
return _this.serialize([rootNode]);
|
|
7327
|
+
};
|
|
7328
|
+
}
|
|
7329
|
+
return AgentMetaService;
|
|
7330
|
+
}());
|
|
7331
|
+
|
|
7332
|
+
/**
|
|
7333
|
+
* Service for handling swarm metadata.
|
|
7334
|
+
*/
|
|
7335
|
+
var SwarmMetaService = /** @class */ (function () {
|
|
7336
|
+
function SwarmMetaService() {
|
|
7337
|
+
var _this = this;
|
|
7338
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
7339
|
+
this.swarmSchemaService = inject(TYPES.swarmSchemaService);
|
|
7340
|
+
this.agentMetaService = inject(TYPES.agentMetaService);
|
|
7341
|
+
this.serialize = createSerialize();
|
|
7342
|
+
/**
|
|
7343
|
+
* Creates a swarm node with the given swarm name.
|
|
7344
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
7345
|
+
* @returns {IMetaNode} The metadata node of the swarm.
|
|
7346
|
+
*/
|
|
7347
|
+
this.makeSwarmNode = function (swarmName) {
|
|
7348
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
7349
|
+
_this.loggerService.info("swarmMetaService makeSwarmNode", {
|
|
7350
|
+
swarmName: swarmName,
|
|
7351
|
+
});
|
|
7352
|
+
var agentList = _this.swarmSchemaService.get(swarmName).agentList;
|
|
7353
|
+
return {
|
|
7354
|
+
name: swarmName,
|
|
7355
|
+
child: agentList.map(function (dep) { return _this.agentMetaService.makeAgentNode(dep); }),
|
|
7356
|
+
};
|
|
7357
|
+
};
|
|
7358
|
+
/**
|
|
7359
|
+
* Converts the swarm metadata to UML format.
|
|
7360
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
7361
|
+
* @returns {string} The UML representation of the swarm.
|
|
7362
|
+
*/
|
|
7363
|
+
this.toUML = function (swarmName) {
|
|
7364
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
7365
|
+
_this.loggerService.info("swarmMetaService toUML", {
|
|
7366
|
+
swarmName: swarmName,
|
|
7367
|
+
});
|
|
7368
|
+
var rootNode = _this.makeSwarmNode(swarmName);
|
|
7369
|
+
return _this.serialize([rootNode]);
|
|
7370
|
+
};
|
|
7371
|
+
}
|
|
7372
|
+
return SwarmMetaService;
|
|
7373
|
+
}());
|
|
7374
|
+
|
|
7192
7375
|
{
|
|
7193
7376
|
provide(TYPES.busService, function () { return new BusService(); });
|
|
7194
7377
|
provide(TYPES.loggerService, function () { return new LoggerService(); });
|
|
@@ -7222,6 +7405,10 @@ var BusService = /** @class */ (function () {
|
|
|
7222
7405
|
provide(TYPES.storagePublicService, function () { return new StoragePublicService(); });
|
|
7223
7406
|
provide(TYPES.statePublicService, function () { return new StatePublicService(); });
|
|
7224
7407
|
}
|
|
7408
|
+
{
|
|
7409
|
+
provide(TYPES.swarmMetaService, function () { return new SwarmMetaService(); });
|
|
7410
|
+
provide(TYPES.agentMetaService, function () { return new AgentMetaService(); });
|
|
7411
|
+
}
|
|
7225
7412
|
{
|
|
7226
7413
|
provide(TYPES.agentPublicService, function () { return new AgentPublicService(); });
|
|
7227
7414
|
provide(TYPES.historyPublicService, function () { return new HistoryPublicService(); });
|
|
@@ -7271,6 +7458,10 @@ var publicServices = {
|
|
|
7271
7458
|
storagePublicService: inject(TYPES.storagePublicService),
|
|
7272
7459
|
statePublicService: inject(TYPES.statePublicService),
|
|
7273
7460
|
};
|
|
7461
|
+
var metaServices = {
|
|
7462
|
+
agentMetaService: inject(TYPES.agentMetaService),
|
|
7463
|
+
swarmMetaService: inject(TYPES.swarmMetaService),
|
|
7464
|
+
};
|
|
7274
7465
|
var validationServices = {
|
|
7275
7466
|
agentValidationService: inject(TYPES.agentValidationService),
|
|
7276
7467
|
toolValidationService: inject(TYPES.toolValidationService),
|
|
@@ -7280,10 +7471,42 @@ var validationServices = {
|
|
|
7280
7471
|
storageValidationService: inject(TYPES.storageValidationService),
|
|
7281
7472
|
embeddingValidationService: inject(TYPES.embeddingValidationService),
|
|
7282
7473
|
};
|
|
7283
|
-
var swarm = __assign(__assign(__assign(__assign(__assign(__assign({}, baseServices), contextServices), connectionServices), schemaServices), publicServices), validationServices);
|
|
7474
|
+
var swarm = __assign(__assign(__assign(__assign(__assign(__assign(__assign({}, baseServices), contextServices), connectionServices), schemaServices), publicServices), metaServices), validationServices);
|
|
7284
7475
|
init();
|
|
7285
7476
|
var swarm$1 = swarm;
|
|
7286
7477
|
|
|
7478
|
+
var METHOD_NAME$E = "function.dumpAgent";
|
|
7479
|
+
/**
|
|
7480
|
+
* Dumps the agent information into PlantUML format.
|
|
7481
|
+
*
|
|
7482
|
+
* @param {SwarmName} swarmName - The name of the swarm to be dumped.
|
|
7483
|
+
* @returns {string} The UML representation of the swarm.
|
|
7484
|
+
*/
|
|
7485
|
+
var dumpAgent = function (agentName) {
|
|
7486
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7487
|
+
swarm$1.loggerService.log(METHOD_NAME$E, {
|
|
7488
|
+
agentName: agentName,
|
|
7489
|
+
});
|
|
7490
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$E);
|
|
7491
|
+
return swarm$1.agentMetaService.toUML(agentName);
|
|
7492
|
+
};
|
|
7493
|
+
|
|
7494
|
+
var METHOD_NAME$D = "function.dumpSwarm";
|
|
7495
|
+
/**
|
|
7496
|
+
* Dumps the swarm information into PlantUML format.
|
|
7497
|
+
*
|
|
7498
|
+
* @param {SwarmName} swarmName - The name of the swarm to be dumped.
|
|
7499
|
+
* @returns {string} The UML representation of the swarm.
|
|
7500
|
+
*/
|
|
7501
|
+
var dumpSwarm = function (swarmName) {
|
|
7502
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7503
|
+
swarm$1.loggerService.log(METHOD_NAME$D, {
|
|
7504
|
+
swarmName: swarmName,
|
|
7505
|
+
});
|
|
7506
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$D);
|
|
7507
|
+
return swarm$1.swarmMetaService.toUML(swarmName);
|
|
7508
|
+
};
|
|
7509
|
+
|
|
7287
7510
|
var METHOD_NAME$C = "function.addAgent";
|
|
7288
7511
|
/**
|
|
7289
7512
|
* Adds a new agent to the agent registry. The swarm takes only those agents which was registered
|
|
@@ -7618,26 +7841,22 @@ var CHANGE_AGENT_GC = 60 * 1000;
|
|
|
7618
7841
|
* @returns {TChangeAgentRun} - The change agent function.
|
|
7619
7842
|
*/
|
|
7620
7843
|
var createChangeAgent = functoolsKit.ttl(function (clientId) {
|
|
7621
|
-
return functoolsKit.queued(function (methodName, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7622
|
-
var
|
|
7844
|
+
return functoolsKit.queued(function (methodName, agentName, swarmName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7845
|
+
var _a, _b, _c;
|
|
7623
7846
|
return __generator(this, function (_d) {
|
|
7624
7847
|
switch (_d.label) {
|
|
7625
|
-
case 0:
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
return [2 /*return*/];
|
|
7638
|
-
}
|
|
7639
|
-
});
|
|
7640
|
-
}); }))];
|
|
7848
|
+
case 0: return [4 /*yield*/, Promise.all(swarm$1.swarmValidationService
|
|
7849
|
+
.getAgentList(swarmName)
|
|
7850
|
+
.map(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7851
|
+
return __generator(this, function (_a) {
|
|
7852
|
+
switch (_a.label) {
|
|
7853
|
+
case 0: return [4 /*yield*/, swarm$1.agentPublicService.commitAgentChange(methodName, clientId, agentName)];
|
|
7854
|
+
case 1:
|
|
7855
|
+
_a.sent();
|
|
7856
|
+
return [2 /*return*/];
|
|
7857
|
+
}
|
|
7858
|
+
});
|
|
7859
|
+
}); }))];
|
|
7641
7860
|
case 1:
|
|
7642
7861
|
_d.sent();
|
|
7643
7862
|
return [4 /*yield*/, swarm$1.agentPublicService.dispose(methodName, clientId, agentName)];
|
|
@@ -7689,7 +7908,7 @@ var createGc$1 = functoolsKit.singleshot(function () { return __awaiter(void 0,
|
|
|
7689
7908
|
* @returns {Promise<void>} - A promise that resolves when the agent is changed.
|
|
7690
7909
|
*/
|
|
7691
7910
|
var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7692
|
-
var run;
|
|
7911
|
+
var swarmName, activeAgent, run;
|
|
7693
7912
|
return __generator(this, function (_a) {
|
|
7694
7913
|
switch (_a.label) {
|
|
7695
7914
|
case 0:
|
|
@@ -7698,12 +7917,21 @@ var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void
|
|
|
7698
7917
|
agentName: agentName,
|
|
7699
7918
|
clientId: clientId,
|
|
7700
7919
|
});
|
|
7701
|
-
|
|
7920
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
7921
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$s);
|
|
7922
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$s);
|
|
7923
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$s, clientId, swarmName)];
|
|
7702
7924
|
case 1:
|
|
7925
|
+
activeAgent = _a.sent();
|
|
7926
|
+
if (!swarm$1.agentValidationService.hasDependency(activeAgent, agentName)) {
|
|
7927
|
+
console.error("agent-swarm missing dependency detected for activeAgent=".concat(activeAgent, " dependencyAgent=").concat(agentName));
|
|
7928
|
+
}
|
|
7929
|
+
return [4 /*yield*/, createChangeAgent(clientId)];
|
|
7930
|
+
case 2:
|
|
7703
7931
|
run = _a.sent();
|
|
7704
7932
|
createGc$1();
|
|
7705
|
-
return [4 /*yield*/, run(METHOD_NAME$s, agentName)];
|
|
7706
|
-
case
|
|
7933
|
+
return [4 /*yield*/, run(METHOD_NAME$s, agentName, swarmName)];
|
|
7934
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
7707
7935
|
}
|
|
7708
7936
|
});
|
|
7709
7937
|
}); };
|
|
@@ -9567,6 +9795,8 @@ exports.commitUserMessage = commitUserMessage;
|
|
|
9567
9795
|
exports.commitUserMessageForce = commitUserMessageForce;
|
|
9568
9796
|
exports.complete = complete;
|
|
9569
9797
|
exports.disposeConnection = disposeConnection;
|
|
9798
|
+
exports.dumpAgent = dumpAgent;
|
|
9799
|
+
exports.dumpSwarm = dumpSwarm;
|
|
9570
9800
|
exports.emit = emit;
|
|
9571
9801
|
exports.emitForce = emitForce;
|
|
9572
9802
|
exports.event = event;
|
package/build/index.mjs
CHANGED
|
@@ -193,6 +193,10 @@ var schemaServices$1 = {
|
|
|
193
193
|
storageSchemaService: Symbol('storageSchemaService'),
|
|
194
194
|
stateSchemaService: Symbol('stateSchemaService'),
|
|
195
195
|
};
|
|
196
|
+
var metaServices$1 = {
|
|
197
|
+
agentMetaService: Symbol('agentMetaService'),
|
|
198
|
+
swarmMetaService: Symbol('swarmMetaService'),
|
|
199
|
+
};
|
|
196
200
|
var publicServices$1 = {
|
|
197
201
|
agentPublicService: Symbol('agentPublicService'),
|
|
198
202
|
historyPublicService: Symbol('historyPublicService'),
|
|
@@ -210,7 +214,7 @@ var validationServices$1 = {
|
|
|
210
214
|
embeddingValidationService: Symbol('embeddingValidationService'),
|
|
211
215
|
storageValidationService: Symbol('storageValidationService'),
|
|
212
216
|
};
|
|
213
|
-
var TYPES = __assign(__assign(__assign(__assign(__assign(__assign({}, baseServices$1), contextServices$1), schemaServices$1), connectionServices$1), publicServices$1), validationServices$1);
|
|
217
|
+
var TYPES = __assign(__assign(__assign(__assign(__assign(__assign(__assign({}, baseServices$1), contextServices$1), schemaServices$1), connectionServices$1), publicServices$1), validationServices$1), metaServices$1);
|
|
214
218
|
|
|
215
219
|
/**
|
|
216
220
|
* Service providing execution context information.
|
|
@@ -4931,6 +4935,7 @@ var AgentValidationService = /** @class */ (function () {
|
|
|
4931
4935
|
this.completionValidationService = inject(TYPES.completionValidationService);
|
|
4932
4936
|
this.storageValidationService = inject(TYPES.storageValidationService);
|
|
4933
4937
|
this._agentMap = new Map();
|
|
4938
|
+
this._agentDepsMap = new Map();
|
|
4934
4939
|
/**
|
|
4935
4940
|
* Retrieves the storages used by the agent
|
|
4936
4941
|
* @param {agentName} agentName - The name of the swarm.
|
|
@@ -4971,6 +4976,9 @@ var AgentValidationService = /** @class */ (function () {
|
|
|
4971
4976
|
throw new Error("agent-swarm agent ".concat(agentName, " already exist"));
|
|
4972
4977
|
}
|
|
4973
4978
|
_this._agentMap.set(agentName, agentSchema);
|
|
4979
|
+
if (agentSchema.dependsOn) {
|
|
4980
|
+
_this._agentDepsMap.set(agentName, agentSchema.dependsOn);
|
|
4981
|
+
}
|
|
4974
4982
|
};
|
|
4975
4983
|
/**
|
|
4976
4984
|
* Check if agent got registered storage
|
|
@@ -4990,6 +4998,23 @@ var AgentValidationService = /** @class */ (function () {
|
|
|
4990
4998
|
var _a = _this._agentMap.get(agentName).storages, storages = _a === void 0 ? [] : _a;
|
|
4991
4999
|
return storages.includes(storageName);
|
|
4992
5000
|
});
|
|
5001
|
+
/**
|
|
5002
|
+
* Check if agent got registered dependency
|
|
5003
|
+
*/
|
|
5004
|
+
this.hasDependency = memoize(function (_a) {
|
|
5005
|
+
var _b = __read(_a, 2), targetAgentName = _b[0], depAgentName = _b[1];
|
|
5006
|
+
return "".concat(targetAgentName, "-").concat(depAgentName);
|
|
5007
|
+
}, function (targetAgentName, depAgentName) {
|
|
5008
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
5009
|
+
_this.loggerService.info("agentValidationService hasDependency", {
|
|
5010
|
+
targetAgentName: targetAgentName,
|
|
5011
|
+
depAgentName: depAgentName,
|
|
5012
|
+
});
|
|
5013
|
+
if (_this._agentDepsMap.has(targetAgentName)) {
|
|
5014
|
+
return _this._agentDepsMap.get(targetAgentName).includes(depAgentName);
|
|
5015
|
+
}
|
|
5016
|
+
return true;
|
|
5017
|
+
});
|
|
4993
5018
|
/**
|
|
4994
5019
|
* Check if agent got registered state
|
|
4995
5020
|
*/
|
|
@@ -7187,6 +7212,164 @@ var BusService = /** @class */ (function () {
|
|
|
7187
7212
|
return BusService;
|
|
7188
7213
|
}());
|
|
7189
7214
|
|
|
7215
|
+
var MAX_NESTING = 10;
|
|
7216
|
+
var UML_STEP = "\t";
|
|
7217
|
+
var UML_BULLET = "•";
|
|
7218
|
+
/**
|
|
7219
|
+
* Creates a function to serialize meta nodes to UML format.
|
|
7220
|
+
* @returns {Function} A function that takes an array of IMetaNode and returns a string in UML format.
|
|
7221
|
+
*/
|
|
7222
|
+
var createSerialize = function () { return function (nodes) {
|
|
7223
|
+
var lines = [];
|
|
7224
|
+
var process = function (nodes, level, seen) {
|
|
7225
|
+
var e_1, _a;
|
|
7226
|
+
var _b;
|
|
7227
|
+
if (level === void 0) { level = 0; }
|
|
7228
|
+
if (seen === void 0) { seen = new Set(); }
|
|
7229
|
+
try {
|
|
7230
|
+
for (var nodes_1 = __values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) {
|
|
7231
|
+
var node = nodes_1_1.value;
|
|
7232
|
+
var space = __spreadArray([], __read(new Array(level)), false).fill(UML_STEP).join("");
|
|
7233
|
+
if (seen.has(node.name)) {
|
|
7234
|
+
lines.push("".concat(space).concat(String(node.name), ": \"\""));
|
|
7235
|
+
}
|
|
7236
|
+
else if (((_b = node.child) === null || _b === void 0 ? void 0 : _b.length) && level < MAX_NESTING) {
|
|
7237
|
+
lines.push("".concat(space).concat(String(node.name), ":"));
|
|
7238
|
+
lines.push("".concat(space).concat(UML_STEP).concat(UML_BULLET, " ").concat(String(node.name), ": \"\""));
|
|
7239
|
+
process(node.child, level + 1, seen.add(node.name));
|
|
7240
|
+
}
|
|
7241
|
+
else {
|
|
7242
|
+
lines.push("".concat(space).concat(String(node.name), ": \"\""));
|
|
7243
|
+
}
|
|
7244
|
+
}
|
|
7245
|
+
}
|
|
7246
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
7247
|
+
finally {
|
|
7248
|
+
try {
|
|
7249
|
+
if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) _a.call(nodes_1);
|
|
7250
|
+
}
|
|
7251
|
+
finally { if (e_1) throw e_1.error; }
|
|
7252
|
+
}
|
|
7253
|
+
};
|
|
7254
|
+
process(nodes);
|
|
7255
|
+
var result = __spreadArray(__spreadArray(["@startyaml"], __read(lines), false), ["@endyaml"], false).join("\n");
|
|
7256
|
+
return result;
|
|
7257
|
+
}; };
|
|
7258
|
+
/**
|
|
7259
|
+
* Service class for managing agent meta nodes and converting them to UML format.
|
|
7260
|
+
*/
|
|
7261
|
+
var AgentMetaService = /** @class */ (function () {
|
|
7262
|
+
function AgentMetaService() {
|
|
7263
|
+
var _this = this;
|
|
7264
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
7265
|
+
this.agentSchemaService = inject(TYPES.agentSchemaService);
|
|
7266
|
+
this.serialize = createSerialize();
|
|
7267
|
+
/**
|
|
7268
|
+
* Creates a meta node for the given agent.
|
|
7269
|
+
* @param {AgentName} agentName - The name of the agent.
|
|
7270
|
+
* @param {Set<AgentName>} seen - A set of seen agent names to avoid circular dependencies.
|
|
7271
|
+
* @returns {IMetaNode} The created meta node.
|
|
7272
|
+
*/
|
|
7273
|
+
this.makeAgentNode = function (agentName, seen) {
|
|
7274
|
+
if (seen === void 0) { seen = new Set(); }
|
|
7275
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
7276
|
+
_this.loggerService.info("agentMetaService makeAgentNode", {
|
|
7277
|
+
agentName: agentName,
|
|
7278
|
+
});
|
|
7279
|
+
var _a = _this.agentSchemaService.get(agentName), dependsOn = _a.dependsOn, states = _a.states, storages = _a.storages, tools = _a.tools;
|
|
7280
|
+
var childSeen = seen.add(agentName);
|
|
7281
|
+
var agentTree = [];
|
|
7282
|
+
if (dependsOn && !seen.has(agentName)) {
|
|
7283
|
+
agentTree.push({
|
|
7284
|
+
name: "Agents (".concat(agentName, ")"),
|
|
7285
|
+
child: dependsOn
|
|
7286
|
+
.filter(function (name) { return !!name; })
|
|
7287
|
+
.map(function (dep) { return _this.makeAgentNode(dep, childSeen); }),
|
|
7288
|
+
});
|
|
7289
|
+
}
|
|
7290
|
+
if (states) {
|
|
7291
|
+
agentTree.push({
|
|
7292
|
+
name: "States (".concat(agentName, ")"),
|
|
7293
|
+
child: states.filter(function (name) { return !!name; }).map(function (name) { return ({ name: name }); }),
|
|
7294
|
+
});
|
|
7295
|
+
}
|
|
7296
|
+
if (storages) {
|
|
7297
|
+
agentTree.push({
|
|
7298
|
+
name: "Storages (".concat(agentName, ")"),
|
|
7299
|
+
child: storages.filter(function (name) { return !!name; }).map(function (name) { return ({ name: name }); }),
|
|
7300
|
+
});
|
|
7301
|
+
}
|
|
7302
|
+
if (tools) {
|
|
7303
|
+
agentTree.push({
|
|
7304
|
+
name: "Tools (".concat(agentName, ")"),
|
|
7305
|
+
child: tools.filter(function (name) { return !!name; }).map(function (name) { return ({ name: name }); }),
|
|
7306
|
+
});
|
|
7307
|
+
}
|
|
7308
|
+
return {
|
|
7309
|
+
name: agentName,
|
|
7310
|
+
child: agentTree,
|
|
7311
|
+
};
|
|
7312
|
+
};
|
|
7313
|
+
/**
|
|
7314
|
+
* Converts the meta nodes of the given agent to UML format.
|
|
7315
|
+
* @param {AgentName} agentName - The name of the agent.
|
|
7316
|
+
* @returns {string} The UML representation of the agent's meta nodes.
|
|
7317
|
+
*/
|
|
7318
|
+
this.toUML = function (agentName) {
|
|
7319
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
7320
|
+
_this.loggerService.info("agentMetaService toUML", {
|
|
7321
|
+
agentName: agentName,
|
|
7322
|
+
});
|
|
7323
|
+
var rootNode = _this.makeAgentNode(agentName);
|
|
7324
|
+
return _this.serialize([rootNode]);
|
|
7325
|
+
};
|
|
7326
|
+
}
|
|
7327
|
+
return AgentMetaService;
|
|
7328
|
+
}());
|
|
7329
|
+
|
|
7330
|
+
/**
|
|
7331
|
+
* Service for handling swarm metadata.
|
|
7332
|
+
*/
|
|
7333
|
+
var SwarmMetaService = /** @class */ (function () {
|
|
7334
|
+
function SwarmMetaService() {
|
|
7335
|
+
var _this = this;
|
|
7336
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
7337
|
+
this.swarmSchemaService = inject(TYPES.swarmSchemaService);
|
|
7338
|
+
this.agentMetaService = inject(TYPES.agentMetaService);
|
|
7339
|
+
this.serialize = createSerialize();
|
|
7340
|
+
/**
|
|
7341
|
+
* Creates a swarm node with the given swarm name.
|
|
7342
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
7343
|
+
* @returns {IMetaNode} The metadata node of the swarm.
|
|
7344
|
+
*/
|
|
7345
|
+
this.makeSwarmNode = function (swarmName) {
|
|
7346
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
7347
|
+
_this.loggerService.info("swarmMetaService makeSwarmNode", {
|
|
7348
|
+
swarmName: swarmName,
|
|
7349
|
+
});
|
|
7350
|
+
var agentList = _this.swarmSchemaService.get(swarmName).agentList;
|
|
7351
|
+
return {
|
|
7352
|
+
name: swarmName,
|
|
7353
|
+
child: agentList.map(function (dep) { return _this.agentMetaService.makeAgentNode(dep); }),
|
|
7354
|
+
};
|
|
7355
|
+
};
|
|
7356
|
+
/**
|
|
7357
|
+
* Converts the swarm metadata to UML format.
|
|
7358
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
7359
|
+
* @returns {string} The UML representation of the swarm.
|
|
7360
|
+
*/
|
|
7361
|
+
this.toUML = function (swarmName) {
|
|
7362
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
7363
|
+
_this.loggerService.info("swarmMetaService toUML", {
|
|
7364
|
+
swarmName: swarmName,
|
|
7365
|
+
});
|
|
7366
|
+
var rootNode = _this.makeSwarmNode(swarmName);
|
|
7367
|
+
return _this.serialize([rootNode]);
|
|
7368
|
+
};
|
|
7369
|
+
}
|
|
7370
|
+
return SwarmMetaService;
|
|
7371
|
+
}());
|
|
7372
|
+
|
|
7190
7373
|
{
|
|
7191
7374
|
provide(TYPES.busService, function () { return new BusService(); });
|
|
7192
7375
|
provide(TYPES.loggerService, function () { return new LoggerService(); });
|
|
@@ -7220,6 +7403,10 @@ var BusService = /** @class */ (function () {
|
|
|
7220
7403
|
provide(TYPES.storagePublicService, function () { return new StoragePublicService(); });
|
|
7221
7404
|
provide(TYPES.statePublicService, function () { return new StatePublicService(); });
|
|
7222
7405
|
}
|
|
7406
|
+
{
|
|
7407
|
+
provide(TYPES.swarmMetaService, function () { return new SwarmMetaService(); });
|
|
7408
|
+
provide(TYPES.agentMetaService, function () { return new AgentMetaService(); });
|
|
7409
|
+
}
|
|
7223
7410
|
{
|
|
7224
7411
|
provide(TYPES.agentPublicService, function () { return new AgentPublicService(); });
|
|
7225
7412
|
provide(TYPES.historyPublicService, function () { return new HistoryPublicService(); });
|
|
@@ -7269,6 +7456,10 @@ var publicServices = {
|
|
|
7269
7456
|
storagePublicService: inject(TYPES.storagePublicService),
|
|
7270
7457
|
statePublicService: inject(TYPES.statePublicService),
|
|
7271
7458
|
};
|
|
7459
|
+
var metaServices = {
|
|
7460
|
+
agentMetaService: inject(TYPES.agentMetaService),
|
|
7461
|
+
swarmMetaService: inject(TYPES.swarmMetaService),
|
|
7462
|
+
};
|
|
7272
7463
|
var validationServices = {
|
|
7273
7464
|
agentValidationService: inject(TYPES.agentValidationService),
|
|
7274
7465
|
toolValidationService: inject(TYPES.toolValidationService),
|
|
@@ -7278,10 +7469,42 @@ var validationServices = {
|
|
|
7278
7469
|
storageValidationService: inject(TYPES.storageValidationService),
|
|
7279
7470
|
embeddingValidationService: inject(TYPES.embeddingValidationService),
|
|
7280
7471
|
};
|
|
7281
|
-
var swarm = __assign(__assign(__assign(__assign(__assign(__assign({}, baseServices), contextServices), connectionServices), schemaServices), publicServices), validationServices);
|
|
7472
|
+
var swarm = __assign(__assign(__assign(__assign(__assign(__assign(__assign({}, baseServices), contextServices), connectionServices), schemaServices), publicServices), metaServices), validationServices);
|
|
7282
7473
|
init();
|
|
7283
7474
|
var swarm$1 = swarm;
|
|
7284
7475
|
|
|
7476
|
+
var METHOD_NAME$E = "function.dumpAgent";
|
|
7477
|
+
/**
|
|
7478
|
+
* Dumps the agent information into PlantUML format.
|
|
7479
|
+
*
|
|
7480
|
+
* @param {SwarmName} swarmName - The name of the swarm to be dumped.
|
|
7481
|
+
* @returns {string} The UML representation of the swarm.
|
|
7482
|
+
*/
|
|
7483
|
+
var dumpAgent = function (agentName) {
|
|
7484
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7485
|
+
swarm$1.loggerService.log(METHOD_NAME$E, {
|
|
7486
|
+
agentName: agentName,
|
|
7487
|
+
});
|
|
7488
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$E);
|
|
7489
|
+
return swarm$1.agentMetaService.toUML(agentName);
|
|
7490
|
+
};
|
|
7491
|
+
|
|
7492
|
+
var METHOD_NAME$D = "function.dumpSwarm";
|
|
7493
|
+
/**
|
|
7494
|
+
* Dumps the swarm information into PlantUML format.
|
|
7495
|
+
*
|
|
7496
|
+
* @param {SwarmName} swarmName - The name of the swarm to be dumped.
|
|
7497
|
+
* @returns {string} The UML representation of the swarm.
|
|
7498
|
+
*/
|
|
7499
|
+
var dumpSwarm = function (swarmName) {
|
|
7500
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7501
|
+
swarm$1.loggerService.log(METHOD_NAME$D, {
|
|
7502
|
+
swarmName: swarmName,
|
|
7503
|
+
});
|
|
7504
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$D);
|
|
7505
|
+
return swarm$1.swarmMetaService.toUML(swarmName);
|
|
7506
|
+
};
|
|
7507
|
+
|
|
7285
7508
|
var METHOD_NAME$C = "function.addAgent";
|
|
7286
7509
|
/**
|
|
7287
7510
|
* Adds a new agent to the agent registry. The swarm takes only those agents which was registered
|
|
@@ -7616,26 +7839,22 @@ var CHANGE_AGENT_GC = 60 * 1000;
|
|
|
7616
7839
|
* @returns {TChangeAgentRun} - The change agent function.
|
|
7617
7840
|
*/
|
|
7618
7841
|
var createChangeAgent = ttl(function (clientId) {
|
|
7619
|
-
return queued(function (methodName, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7620
|
-
var
|
|
7842
|
+
return queued(function (methodName, agentName, swarmName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7843
|
+
var _a, _b, _c;
|
|
7621
7844
|
return __generator(this, function (_d) {
|
|
7622
7845
|
switch (_d.label) {
|
|
7623
|
-
case 0:
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
return [2 /*return*/];
|
|
7636
|
-
}
|
|
7637
|
-
});
|
|
7638
|
-
}); }))];
|
|
7846
|
+
case 0: return [4 /*yield*/, Promise.all(swarm$1.swarmValidationService
|
|
7847
|
+
.getAgentList(swarmName)
|
|
7848
|
+
.map(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7849
|
+
return __generator(this, function (_a) {
|
|
7850
|
+
switch (_a.label) {
|
|
7851
|
+
case 0: return [4 /*yield*/, swarm$1.agentPublicService.commitAgentChange(methodName, clientId, agentName)];
|
|
7852
|
+
case 1:
|
|
7853
|
+
_a.sent();
|
|
7854
|
+
return [2 /*return*/];
|
|
7855
|
+
}
|
|
7856
|
+
});
|
|
7857
|
+
}); }))];
|
|
7639
7858
|
case 1:
|
|
7640
7859
|
_d.sent();
|
|
7641
7860
|
return [4 /*yield*/, swarm$1.agentPublicService.dispose(methodName, clientId, agentName)];
|
|
@@ -7687,7 +7906,7 @@ var createGc$1 = singleshot(function () { return __awaiter(void 0, void 0, void
|
|
|
7687
7906
|
* @returns {Promise<void>} - A promise that resolves when the agent is changed.
|
|
7688
7907
|
*/
|
|
7689
7908
|
var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7690
|
-
var run;
|
|
7909
|
+
var swarmName, activeAgent, run;
|
|
7691
7910
|
return __generator(this, function (_a) {
|
|
7692
7911
|
switch (_a.label) {
|
|
7693
7912
|
case 0:
|
|
@@ -7696,12 +7915,21 @@ var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void
|
|
|
7696
7915
|
agentName: agentName,
|
|
7697
7916
|
clientId: clientId,
|
|
7698
7917
|
});
|
|
7699
|
-
|
|
7918
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
7919
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$s);
|
|
7920
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$s);
|
|
7921
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$s, clientId, swarmName)];
|
|
7700
7922
|
case 1:
|
|
7923
|
+
activeAgent = _a.sent();
|
|
7924
|
+
if (!swarm$1.agentValidationService.hasDependency(activeAgent, agentName)) {
|
|
7925
|
+
console.error("agent-swarm missing dependency detected for activeAgent=".concat(activeAgent, " dependencyAgent=").concat(agentName));
|
|
7926
|
+
}
|
|
7927
|
+
return [4 /*yield*/, createChangeAgent(clientId)];
|
|
7928
|
+
case 2:
|
|
7701
7929
|
run = _a.sent();
|
|
7702
7930
|
createGc$1();
|
|
7703
|
-
return [4 /*yield*/, run(METHOD_NAME$s, agentName)];
|
|
7704
|
-
case
|
|
7931
|
+
return [4 /*yield*/, run(METHOD_NAME$s, agentName, swarmName)];
|
|
7932
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
7705
7933
|
}
|
|
7706
7934
|
});
|
|
7707
7935
|
}); };
|
|
@@ -9534,4 +9762,4 @@ var SchemaUtils = /** @class */ (function () {
|
|
|
9534
9762
|
*/
|
|
9535
9763
|
var Schema = new SchemaUtils();
|
|
9536
9764
|
|
|
9537
|
-
export { ExecutionContextService, History, HistoryAdapter, HistoryInstance, Logger, LoggerAdapter, LoggerInstance, MethodContextService, Schema, State, Storage, addAgent, addCompletion, addEmbedding, addState, addStorage, addSwarm, addTool, cancelOutput, cancelOutputForce, changeAgent, commitFlush, commitFlushForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitUserMessage, commitUserMessageForce, complete, disposeConnection, emit, emitForce, event, execute, executeForce, getAgentHistory, getAgentName, getAssistantHistory, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getRawHistory, getSessionMode, getUserHistory, listenAgentEvent, listenAgentEventOnce, listenEvent, listenEventOnce, listenHistoryEvent, listenHistoryEventOnce, listenSessionEvent, listenSessionEventOnce, listenStateEvent, listenStateEventOnce, listenStorageEvent, listenStorageEventOnce, listenSwarmEvent, listenSwarmEventOnce, makeAutoDispose, makeConnection, session, setConfig, swarm };
|
|
9765
|
+
export { ExecutionContextService, History, HistoryAdapter, HistoryInstance, Logger, LoggerAdapter, LoggerInstance, MethodContextService, Schema, State, Storage, addAgent, addCompletion, addEmbedding, addState, addStorage, addSwarm, addTool, cancelOutput, cancelOutputForce, changeAgent, commitFlush, commitFlushForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitUserMessage, commitUserMessageForce, complete, disposeConnection, dumpAgent, dumpSwarm, emit, emitForce, event, execute, executeForce, getAgentHistory, getAgentName, getAssistantHistory, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getRawHistory, getSessionMode, getUserHistory, listenAgentEvent, listenAgentEventOnce, listenEvent, listenEventOnce, listenHistoryEvent, listenHistoryEventOnce, listenSessionEvent, listenSessionEventOnce, listenStateEvent, listenStateEventOnce, listenStorageEvent, listenStorageEventOnce, listenSwarmEvent, listenSwarmEventOnce, makeAutoDispose, makeConnection, session, setConfig, swarm };
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1394,6 +1394,8 @@ interface IAgentSchema {
|
|
|
1394
1394
|
storages?: StorageName[];
|
|
1395
1395
|
/** The names of the states used by the agent. */
|
|
1396
1396
|
states?: StateName[];
|
|
1397
|
+
/** The list of dependencies for changeAgent */
|
|
1398
|
+
dependsOn?: AgentName[];
|
|
1397
1399
|
/**
|
|
1398
1400
|
* Validates the output.
|
|
1399
1401
|
* @param output - The output to validate.
|
|
@@ -2343,6 +2345,7 @@ declare class AgentValidationService {
|
|
|
2343
2345
|
private readonly completionValidationService;
|
|
2344
2346
|
private readonly storageValidationService;
|
|
2345
2347
|
private _agentMap;
|
|
2348
|
+
private _agentDepsMap;
|
|
2346
2349
|
/**
|
|
2347
2350
|
* Retrieves the storages used by the agent
|
|
2348
2351
|
* @param {agentName} agentName - The name of the swarm.
|
|
@@ -2368,6 +2371,10 @@ declare class AgentValidationService {
|
|
|
2368
2371
|
* Check if agent got registered storage
|
|
2369
2372
|
*/
|
|
2370
2373
|
hasStorage: ((agentName: AgentName, storageName: StorageName) => boolean) & functools_kit.IClearableMemoize<string> & functools_kit.IControlMemoize<string, boolean>;
|
|
2374
|
+
/**
|
|
2375
|
+
* Check if agent got registered dependency
|
|
2376
|
+
*/
|
|
2377
|
+
hasDependency: ((targetAgentName: AgentName, depAgentName: StorageName) => boolean) & functools_kit.IClearableMemoize<string> & functools_kit.IControlMemoize<string, boolean>;
|
|
2371
2378
|
/**
|
|
2372
2379
|
* Check if agent got registered state
|
|
2373
2380
|
*/
|
|
@@ -3028,6 +3035,57 @@ declare class BusService implements IBus {
|
|
|
3028
3035
|
dispose: (clientId: string) => void;
|
|
3029
3036
|
}
|
|
3030
3037
|
|
|
3038
|
+
/**
|
|
3039
|
+
* Interface representing a meta node.
|
|
3040
|
+
*/
|
|
3041
|
+
interface IMetaNode {
|
|
3042
|
+
name: string;
|
|
3043
|
+
child?: IMetaNode[];
|
|
3044
|
+
}
|
|
3045
|
+
/**
|
|
3046
|
+
* Service class for managing agent meta nodes and converting them to UML format.
|
|
3047
|
+
*/
|
|
3048
|
+
declare class AgentMetaService {
|
|
3049
|
+
private readonly loggerService;
|
|
3050
|
+
private readonly agentSchemaService;
|
|
3051
|
+
private serialize;
|
|
3052
|
+
/**
|
|
3053
|
+
* Creates a meta node for the given agent.
|
|
3054
|
+
* @param {AgentName} agentName - The name of the agent.
|
|
3055
|
+
* @param {Set<AgentName>} seen - A set of seen agent names to avoid circular dependencies.
|
|
3056
|
+
* @returns {IMetaNode} The created meta node.
|
|
3057
|
+
*/
|
|
3058
|
+
makeAgentNode: (agentName: AgentName, seen?: Set<string>) => IMetaNode;
|
|
3059
|
+
/**
|
|
3060
|
+
* Converts the meta nodes of the given agent to UML format.
|
|
3061
|
+
* @param {AgentName} agentName - The name of the agent.
|
|
3062
|
+
* @returns {string} The UML representation of the agent's meta nodes.
|
|
3063
|
+
*/
|
|
3064
|
+
toUML: (agentName: AgentName) => string;
|
|
3065
|
+
}
|
|
3066
|
+
|
|
3067
|
+
/**
|
|
3068
|
+
* Service for handling swarm metadata.
|
|
3069
|
+
*/
|
|
3070
|
+
declare class SwarmMetaService {
|
|
3071
|
+
private readonly loggerService;
|
|
3072
|
+
private readonly swarmSchemaService;
|
|
3073
|
+
private readonly agentMetaService;
|
|
3074
|
+
private serialize;
|
|
3075
|
+
/**
|
|
3076
|
+
* Creates a swarm node with the given swarm name.
|
|
3077
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
3078
|
+
* @returns {IMetaNode} The metadata node of the swarm.
|
|
3079
|
+
*/
|
|
3080
|
+
makeSwarmNode: (swarmName: SwarmName) => IMetaNode;
|
|
3081
|
+
/**
|
|
3082
|
+
* Converts the swarm metadata to UML format.
|
|
3083
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
3084
|
+
* @returns {string} The UML representation of the swarm.
|
|
3085
|
+
*/
|
|
3086
|
+
toUML: (swarmName: SwarmName) => string;
|
|
3087
|
+
}
|
|
3088
|
+
|
|
3031
3089
|
declare const swarm: {
|
|
3032
3090
|
agentValidationService: AgentValidationService;
|
|
3033
3091
|
toolValidationService: ToolValidationService;
|
|
@@ -3036,6 +3094,8 @@ declare const swarm: {
|
|
|
3036
3094
|
completionValidationService: CompletionValidationService;
|
|
3037
3095
|
storageValidationService: StorageValidationService;
|
|
3038
3096
|
embeddingValidationService: EmbeddingValidationService;
|
|
3097
|
+
agentMetaService: AgentMetaService;
|
|
3098
|
+
swarmMetaService: SwarmMetaService;
|
|
3039
3099
|
agentPublicService: AgentPublicService;
|
|
3040
3100
|
historyPublicService: HistoryPublicService;
|
|
3041
3101
|
sessionPublicService: SessionPublicService;
|
|
@@ -3065,6 +3125,22 @@ declare const swarm: {
|
|
|
3065
3125
|
loggerService: LoggerService;
|
|
3066
3126
|
};
|
|
3067
3127
|
|
|
3128
|
+
/**
|
|
3129
|
+
* Dumps the agent information into PlantUML format.
|
|
3130
|
+
*
|
|
3131
|
+
* @param {SwarmName} swarmName - The name of the swarm to be dumped.
|
|
3132
|
+
* @returns {string} The UML representation of the swarm.
|
|
3133
|
+
*/
|
|
3134
|
+
declare const dumpAgent: (agentName: AgentName) => string;
|
|
3135
|
+
|
|
3136
|
+
/**
|
|
3137
|
+
* Dumps the swarm information into PlantUML format.
|
|
3138
|
+
*
|
|
3139
|
+
* @param {SwarmName} swarmName - The name of the swarm to be dumped.
|
|
3140
|
+
* @returns {string} The UML representation of the swarm.
|
|
3141
|
+
*/
|
|
3142
|
+
declare const dumpSwarm: (swarmName: SwarmName) => string;
|
|
3143
|
+
|
|
3068
3144
|
/**
|
|
3069
3145
|
* Adds a new agent to the agent registry. The swarm takes only those agents which was registered
|
|
3070
3146
|
*
|
|
@@ -3988,4 +4064,4 @@ declare class SchemaUtils {
|
|
|
3988
4064
|
*/
|
|
3989
4065
|
declare const Schema: SchemaUtils;
|
|
3990
4066
|
|
|
3991
|
-
export { type EventSource, ExecutionContextService, History, HistoryAdapter, HistoryInstance, type IAgentSchema, type IAgentTool, type IBaseEvent, type IBusEvent, type IBusEventContext, type ICompletionArgs, type ICompletionSchema, type ICustomEvent, type IEmbeddingSchema, type IHistoryAdapter, type IHistoryInstance, type IHistoryInstanceCallbacks, type IIncomingMessage, type ILoggerAdapter, type ILoggerInstance, type ILoggerInstanceCallbacks, type IMakeConnectionConfig, type IMakeDisposeParams, type IModelMessage, type IOutgoingMessage, type ISessionConfig, type IStateSchema, type IStorageSchema, type ISwarmSchema, type ITool, type IToolCall, Logger, LoggerAdapter, LoggerInstance, MethodContextService, type ReceiveMessageFn, Schema, type SendMessageFn$1 as SendMessageFn, State, Storage, addAgent, addCompletion, addEmbedding, addState, addStorage, addSwarm, addTool, cancelOutput, cancelOutputForce, changeAgent, commitFlush, commitFlushForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitUserMessage, commitUserMessageForce, complete, disposeConnection, emit, emitForce, event, execute, executeForce, getAgentHistory, getAgentName, getAssistantHistory, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getRawHistory, getSessionMode, getUserHistory, listenAgentEvent, listenAgentEventOnce, listenEvent, listenEventOnce, listenHistoryEvent, listenHistoryEventOnce, listenSessionEvent, listenSessionEventOnce, listenStateEvent, listenStateEventOnce, listenStorageEvent, listenStorageEventOnce, listenSwarmEvent, listenSwarmEventOnce, makeAutoDispose, makeConnection, session, setConfig, swarm };
|
|
4067
|
+
export { type EventSource, ExecutionContextService, History, HistoryAdapter, HistoryInstance, type IAgentSchema, type IAgentTool, type IBaseEvent, type IBusEvent, type IBusEventContext, type ICompletionArgs, type ICompletionSchema, type ICustomEvent, type IEmbeddingSchema, type IHistoryAdapter, type IHistoryInstance, type IHistoryInstanceCallbacks, type IIncomingMessage, type ILoggerAdapter, type ILoggerInstance, type ILoggerInstanceCallbacks, type IMakeConnectionConfig, type IMakeDisposeParams, type IModelMessage, type IOutgoingMessage, type ISessionConfig, type IStateSchema, type IStorageSchema, type ISwarmSchema, type ITool, type IToolCall, Logger, LoggerAdapter, LoggerInstance, MethodContextService, type ReceiveMessageFn, Schema, type SendMessageFn$1 as SendMessageFn, State, Storage, addAgent, addCompletion, addEmbedding, addState, addStorage, addSwarm, addTool, cancelOutput, cancelOutputForce, changeAgent, commitFlush, commitFlushForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitUserMessage, commitUserMessageForce, complete, disposeConnection, dumpAgent, dumpSwarm, emit, emitForce, event, execute, executeForce, getAgentHistory, getAgentName, getAssistantHistory, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getRawHistory, getSessionMode, getUserHistory, listenAgentEvent, listenAgentEventOnce, listenEvent, listenEventOnce, listenHistoryEvent, listenHistoryEventOnce, listenSessionEvent, listenSessionEventOnce, listenStateEvent, listenStateEventOnce, listenStorageEvent, listenStorageEventOnce, listenSwarmEvent, listenSwarmEventOnce, makeAutoDispose, makeConnection, session, setConfig, swarm };
|