agent-swarm-kit 1.0.84 → 1.0.85
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 +252 -24
- package/build/index.mjs +251 -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,162 @@ 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.map(function (dep) { return _this.makeAgentNode(dep, childSeen); }),
|
|
7288
|
+
});
|
|
7289
|
+
}
|
|
7290
|
+
if (states) {
|
|
7291
|
+
agentTree.push({
|
|
7292
|
+
name: "States (".concat(agentName, ")"),
|
|
7293
|
+
child: states.map(function (name) { return ({ name: name }); }),
|
|
7294
|
+
});
|
|
7295
|
+
}
|
|
7296
|
+
if (storages) {
|
|
7297
|
+
agentTree.push({
|
|
7298
|
+
name: "Storages (".concat(agentName, ")"),
|
|
7299
|
+
child: storages.map(function (name) { return ({ name: name }); }),
|
|
7300
|
+
});
|
|
7301
|
+
}
|
|
7302
|
+
if (tools) {
|
|
7303
|
+
agentTree.push({
|
|
7304
|
+
name: "Tools (".concat(agentName, ")"),
|
|
7305
|
+
child: tools.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
|
+
|
|
7192
7373
|
{
|
|
7193
7374
|
provide(TYPES.busService, function () { return new BusService(); });
|
|
7194
7375
|
provide(TYPES.loggerService, function () { return new LoggerService(); });
|
|
@@ -7222,6 +7403,10 @@ var BusService = /** @class */ (function () {
|
|
|
7222
7403
|
provide(TYPES.storagePublicService, function () { return new StoragePublicService(); });
|
|
7223
7404
|
provide(TYPES.statePublicService, function () { return new StatePublicService(); });
|
|
7224
7405
|
}
|
|
7406
|
+
{
|
|
7407
|
+
provide(TYPES.swarmMetaService, function () { return new SwarmMetaService(); });
|
|
7408
|
+
provide(TYPES.agentMetaService, function () { return new AgentMetaService(); });
|
|
7409
|
+
}
|
|
7225
7410
|
{
|
|
7226
7411
|
provide(TYPES.agentPublicService, function () { return new AgentPublicService(); });
|
|
7227
7412
|
provide(TYPES.historyPublicService, function () { return new HistoryPublicService(); });
|
|
@@ -7271,6 +7456,10 @@ var publicServices = {
|
|
|
7271
7456
|
storagePublicService: inject(TYPES.storagePublicService),
|
|
7272
7457
|
statePublicService: inject(TYPES.statePublicService),
|
|
7273
7458
|
};
|
|
7459
|
+
var metaServices = {
|
|
7460
|
+
agentMetaService: inject(TYPES.agentMetaService),
|
|
7461
|
+
swarmMetaService: inject(TYPES.swarmMetaService),
|
|
7462
|
+
};
|
|
7274
7463
|
var validationServices = {
|
|
7275
7464
|
agentValidationService: inject(TYPES.agentValidationService),
|
|
7276
7465
|
toolValidationService: inject(TYPES.toolValidationService),
|
|
@@ -7280,10 +7469,42 @@ var validationServices = {
|
|
|
7280
7469
|
storageValidationService: inject(TYPES.storageValidationService),
|
|
7281
7470
|
embeddingValidationService: inject(TYPES.embeddingValidationService),
|
|
7282
7471
|
};
|
|
7283
|
-
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);
|
|
7284
7473
|
init();
|
|
7285
7474
|
var swarm$1 = swarm;
|
|
7286
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
|
+
|
|
7287
7508
|
var METHOD_NAME$C = "function.addAgent";
|
|
7288
7509
|
/**
|
|
7289
7510
|
* Adds a new agent to the agent registry. The swarm takes only those agents which was registered
|
|
@@ -7618,26 +7839,22 @@ var CHANGE_AGENT_GC = 60 * 1000;
|
|
|
7618
7839
|
* @returns {TChangeAgentRun} - The change agent function.
|
|
7619
7840
|
*/
|
|
7620
7841
|
var createChangeAgent = functoolsKit.ttl(function (clientId) {
|
|
7621
|
-
return functoolsKit.queued(function (methodName, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7622
|
-
var
|
|
7842
|
+
return functoolsKit.queued(function (methodName, agentName, swarmName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7843
|
+
var _a, _b, _c;
|
|
7623
7844
|
return __generator(this, function (_d) {
|
|
7624
7845
|
switch (_d.label) {
|
|
7625
|
-
case 0:
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
return [2 /*return*/];
|
|
7638
|
-
}
|
|
7639
|
-
});
|
|
7640
|
-
}); }))];
|
|
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
|
+
}); }))];
|
|
7641
7858
|
case 1:
|
|
7642
7859
|
_d.sent();
|
|
7643
7860
|
return [4 /*yield*/, swarm$1.agentPublicService.dispose(methodName, clientId, agentName)];
|
|
@@ -7689,7 +7906,7 @@ var createGc$1 = functoolsKit.singleshot(function () { return __awaiter(void 0,
|
|
|
7689
7906
|
* @returns {Promise<void>} - A promise that resolves when the agent is changed.
|
|
7690
7907
|
*/
|
|
7691
7908
|
var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7692
|
-
var run;
|
|
7909
|
+
var swarmName, activeAgent, run;
|
|
7693
7910
|
return __generator(this, function (_a) {
|
|
7694
7911
|
switch (_a.label) {
|
|
7695
7912
|
case 0:
|
|
@@ -7698,12 +7915,21 @@ var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void
|
|
|
7698
7915
|
agentName: agentName,
|
|
7699
7916
|
clientId: clientId,
|
|
7700
7917
|
});
|
|
7701
|
-
|
|
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)];
|
|
7702
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:
|
|
7703
7929
|
run = _a.sent();
|
|
7704
7930
|
createGc$1();
|
|
7705
|
-
return [4 /*yield*/, run(METHOD_NAME$s, agentName)];
|
|
7706
|
-
case
|
|
7931
|
+
return [4 /*yield*/, run(METHOD_NAME$s, agentName, swarmName)];
|
|
7932
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
7707
7933
|
}
|
|
7708
7934
|
});
|
|
7709
7935
|
}); };
|
|
@@ -9567,6 +9793,8 @@ exports.commitUserMessage = commitUserMessage;
|
|
|
9567
9793
|
exports.commitUserMessageForce = commitUserMessageForce;
|
|
9568
9794
|
exports.complete = complete;
|
|
9569
9795
|
exports.disposeConnection = disposeConnection;
|
|
9796
|
+
exports.dumpAgent = dumpAgent;
|
|
9797
|
+
exports.dumpSwarm = dumpSwarm;
|
|
9570
9798
|
exports.emit = emit;
|
|
9571
9799
|
exports.emitForce = emitForce;
|
|
9572
9800
|
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,162 @@ 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.map(function (dep) { return _this.makeAgentNode(dep, childSeen); }),
|
|
7286
|
+
});
|
|
7287
|
+
}
|
|
7288
|
+
if (states) {
|
|
7289
|
+
agentTree.push({
|
|
7290
|
+
name: "States (".concat(agentName, ")"),
|
|
7291
|
+
child: states.map(function (name) { return ({ name: name }); }),
|
|
7292
|
+
});
|
|
7293
|
+
}
|
|
7294
|
+
if (storages) {
|
|
7295
|
+
agentTree.push({
|
|
7296
|
+
name: "Storages (".concat(agentName, ")"),
|
|
7297
|
+
child: storages.map(function (name) { return ({ name: name }); }),
|
|
7298
|
+
});
|
|
7299
|
+
}
|
|
7300
|
+
if (tools) {
|
|
7301
|
+
agentTree.push({
|
|
7302
|
+
name: "Tools (".concat(agentName, ")"),
|
|
7303
|
+
child: tools.map(function (name) { return ({ name: name }); }),
|
|
7304
|
+
});
|
|
7305
|
+
}
|
|
7306
|
+
return {
|
|
7307
|
+
name: agentName,
|
|
7308
|
+
child: agentTree,
|
|
7309
|
+
};
|
|
7310
|
+
};
|
|
7311
|
+
/**
|
|
7312
|
+
* Converts the meta nodes of the given agent to UML format.
|
|
7313
|
+
* @param {AgentName} agentName - The name of the agent.
|
|
7314
|
+
* @returns {string} The UML representation of the agent's meta nodes.
|
|
7315
|
+
*/
|
|
7316
|
+
this.toUML = function (agentName) {
|
|
7317
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
7318
|
+
_this.loggerService.info("agentMetaService toUML", {
|
|
7319
|
+
agentName: agentName,
|
|
7320
|
+
});
|
|
7321
|
+
var rootNode = _this.makeAgentNode(agentName);
|
|
7322
|
+
return _this.serialize([rootNode]);
|
|
7323
|
+
};
|
|
7324
|
+
}
|
|
7325
|
+
return AgentMetaService;
|
|
7326
|
+
}());
|
|
7327
|
+
|
|
7328
|
+
/**
|
|
7329
|
+
* Service for handling swarm metadata.
|
|
7330
|
+
*/
|
|
7331
|
+
var SwarmMetaService = /** @class */ (function () {
|
|
7332
|
+
function SwarmMetaService() {
|
|
7333
|
+
var _this = this;
|
|
7334
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
7335
|
+
this.swarmSchemaService = inject(TYPES.swarmSchemaService);
|
|
7336
|
+
this.agentMetaService = inject(TYPES.agentMetaService);
|
|
7337
|
+
this.serialize = createSerialize();
|
|
7338
|
+
/**
|
|
7339
|
+
* Creates a swarm node with the given swarm name.
|
|
7340
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
7341
|
+
* @returns {IMetaNode} The metadata node of the swarm.
|
|
7342
|
+
*/
|
|
7343
|
+
this.makeSwarmNode = function (swarmName) {
|
|
7344
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
7345
|
+
_this.loggerService.info("swarmMetaService makeSwarmNode", {
|
|
7346
|
+
swarmName: swarmName,
|
|
7347
|
+
});
|
|
7348
|
+
var agentList = _this.swarmSchemaService.get(swarmName).agentList;
|
|
7349
|
+
return {
|
|
7350
|
+
name: swarmName,
|
|
7351
|
+
child: agentList.map(function (dep) { return _this.agentMetaService.makeAgentNode(dep); }),
|
|
7352
|
+
};
|
|
7353
|
+
};
|
|
7354
|
+
/**
|
|
7355
|
+
* Converts the swarm metadata to UML format.
|
|
7356
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
7357
|
+
* @returns {string} The UML representation of the swarm.
|
|
7358
|
+
*/
|
|
7359
|
+
this.toUML = function (swarmName) {
|
|
7360
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO &&
|
|
7361
|
+
_this.loggerService.info("swarmMetaService toUML", {
|
|
7362
|
+
swarmName: swarmName,
|
|
7363
|
+
});
|
|
7364
|
+
var rootNode = _this.makeSwarmNode(swarmName);
|
|
7365
|
+
return _this.serialize([rootNode]);
|
|
7366
|
+
};
|
|
7367
|
+
}
|
|
7368
|
+
return SwarmMetaService;
|
|
7369
|
+
}());
|
|
7370
|
+
|
|
7190
7371
|
{
|
|
7191
7372
|
provide(TYPES.busService, function () { return new BusService(); });
|
|
7192
7373
|
provide(TYPES.loggerService, function () { return new LoggerService(); });
|
|
@@ -7220,6 +7401,10 @@ var BusService = /** @class */ (function () {
|
|
|
7220
7401
|
provide(TYPES.storagePublicService, function () { return new StoragePublicService(); });
|
|
7221
7402
|
provide(TYPES.statePublicService, function () { return new StatePublicService(); });
|
|
7222
7403
|
}
|
|
7404
|
+
{
|
|
7405
|
+
provide(TYPES.swarmMetaService, function () { return new SwarmMetaService(); });
|
|
7406
|
+
provide(TYPES.agentMetaService, function () { return new AgentMetaService(); });
|
|
7407
|
+
}
|
|
7223
7408
|
{
|
|
7224
7409
|
provide(TYPES.agentPublicService, function () { return new AgentPublicService(); });
|
|
7225
7410
|
provide(TYPES.historyPublicService, function () { return new HistoryPublicService(); });
|
|
@@ -7269,6 +7454,10 @@ var publicServices = {
|
|
|
7269
7454
|
storagePublicService: inject(TYPES.storagePublicService),
|
|
7270
7455
|
statePublicService: inject(TYPES.statePublicService),
|
|
7271
7456
|
};
|
|
7457
|
+
var metaServices = {
|
|
7458
|
+
agentMetaService: inject(TYPES.agentMetaService),
|
|
7459
|
+
swarmMetaService: inject(TYPES.swarmMetaService),
|
|
7460
|
+
};
|
|
7272
7461
|
var validationServices = {
|
|
7273
7462
|
agentValidationService: inject(TYPES.agentValidationService),
|
|
7274
7463
|
toolValidationService: inject(TYPES.toolValidationService),
|
|
@@ -7278,10 +7467,42 @@ var validationServices = {
|
|
|
7278
7467
|
storageValidationService: inject(TYPES.storageValidationService),
|
|
7279
7468
|
embeddingValidationService: inject(TYPES.embeddingValidationService),
|
|
7280
7469
|
};
|
|
7281
|
-
var swarm = __assign(__assign(__assign(__assign(__assign(__assign({}, baseServices), contextServices), connectionServices), schemaServices), publicServices), validationServices);
|
|
7470
|
+
var swarm = __assign(__assign(__assign(__assign(__assign(__assign(__assign({}, baseServices), contextServices), connectionServices), schemaServices), publicServices), metaServices), validationServices);
|
|
7282
7471
|
init();
|
|
7283
7472
|
var swarm$1 = swarm;
|
|
7284
7473
|
|
|
7474
|
+
var METHOD_NAME$E = "function.dumpAgent";
|
|
7475
|
+
/**
|
|
7476
|
+
* Dumps the agent information into PlantUML format.
|
|
7477
|
+
*
|
|
7478
|
+
* @param {SwarmName} swarmName - The name of the swarm to be dumped.
|
|
7479
|
+
* @returns {string} The UML representation of the swarm.
|
|
7480
|
+
*/
|
|
7481
|
+
var dumpAgent = function (agentName) {
|
|
7482
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7483
|
+
swarm$1.loggerService.log(METHOD_NAME$E, {
|
|
7484
|
+
agentName: agentName,
|
|
7485
|
+
});
|
|
7486
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$E);
|
|
7487
|
+
return swarm$1.agentMetaService.toUML(agentName);
|
|
7488
|
+
};
|
|
7489
|
+
|
|
7490
|
+
var METHOD_NAME$D = "function.dumpSwarm";
|
|
7491
|
+
/**
|
|
7492
|
+
* Dumps the swarm information into PlantUML format.
|
|
7493
|
+
*
|
|
7494
|
+
* @param {SwarmName} swarmName - The name of the swarm to be dumped.
|
|
7495
|
+
* @returns {string} The UML representation of the swarm.
|
|
7496
|
+
*/
|
|
7497
|
+
var dumpSwarm = function (swarmName) {
|
|
7498
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
7499
|
+
swarm$1.loggerService.log(METHOD_NAME$D, {
|
|
7500
|
+
swarmName: swarmName,
|
|
7501
|
+
});
|
|
7502
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$D);
|
|
7503
|
+
return swarm$1.swarmMetaService.toUML(swarmName);
|
|
7504
|
+
};
|
|
7505
|
+
|
|
7285
7506
|
var METHOD_NAME$C = "function.addAgent";
|
|
7286
7507
|
/**
|
|
7287
7508
|
* Adds a new agent to the agent registry. The swarm takes only those agents which was registered
|
|
@@ -7616,26 +7837,22 @@ var CHANGE_AGENT_GC = 60 * 1000;
|
|
|
7616
7837
|
* @returns {TChangeAgentRun} - The change agent function.
|
|
7617
7838
|
*/
|
|
7618
7839
|
var createChangeAgent = ttl(function (clientId) {
|
|
7619
|
-
return queued(function (methodName, agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7620
|
-
var
|
|
7840
|
+
return queued(function (methodName, agentName, swarmName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7841
|
+
var _a, _b, _c;
|
|
7621
7842
|
return __generator(this, function (_d) {
|
|
7622
7843
|
switch (_d.label) {
|
|
7623
|
-
case 0:
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
return [2 /*return*/];
|
|
7636
|
-
}
|
|
7637
|
-
});
|
|
7638
|
-
}); }))];
|
|
7844
|
+
case 0: return [4 /*yield*/, Promise.all(swarm$1.swarmValidationService
|
|
7845
|
+
.getAgentList(swarmName)
|
|
7846
|
+
.map(function (agentName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7847
|
+
return __generator(this, function (_a) {
|
|
7848
|
+
switch (_a.label) {
|
|
7849
|
+
case 0: return [4 /*yield*/, swarm$1.agentPublicService.commitAgentChange(methodName, clientId, agentName)];
|
|
7850
|
+
case 1:
|
|
7851
|
+
_a.sent();
|
|
7852
|
+
return [2 /*return*/];
|
|
7853
|
+
}
|
|
7854
|
+
});
|
|
7855
|
+
}); }))];
|
|
7639
7856
|
case 1:
|
|
7640
7857
|
_d.sent();
|
|
7641
7858
|
return [4 /*yield*/, swarm$1.agentPublicService.dispose(methodName, clientId, agentName)];
|
|
@@ -7687,7 +7904,7 @@ var createGc$1 = singleshot(function () { return __awaiter(void 0, void 0, void
|
|
|
7687
7904
|
* @returns {Promise<void>} - A promise that resolves when the agent is changed.
|
|
7688
7905
|
*/
|
|
7689
7906
|
var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
7690
|
-
var run;
|
|
7907
|
+
var swarmName, activeAgent, run;
|
|
7691
7908
|
return __generator(this, function (_a) {
|
|
7692
7909
|
switch (_a.label) {
|
|
7693
7910
|
case 0:
|
|
@@ -7696,12 +7913,21 @@ var changeAgent = function (agentName, clientId) { return __awaiter(void 0, void
|
|
|
7696
7913
|
agentName: agentName,
|
|
7697
7914
|
clientId: clientId,
|
|
7698
7915
|
});
|
|
7699
|
-
|
|
7916
|
+
swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
7917
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$s);
|
|
7918
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$s);
|
|
7919
|
+
return [4 /*yield*/, swarm$1.swarmPublicService.getAgentName(METHOD_NAME$s, clientId, swarmName)];
|
|
7700
7920
|
case 1:
|
|
7921
|
+
activeAgent = _a.sent();
|
|
7922
|
+
if (!swarm$1.agentValidationService.hasDependency(activeAgent, agentName)) {
|
|
7923
|
+
console.error("agent-swarm missing dependency detected for activeAgent=".concat(activeAgent, " dependencyAgent=").concat(agentName));
|
|
7924
|
+
}
|
|
7925
|
+
return [4 /*yield*/, createChangeAgent(clientId)];
|
|
7926
|
+
case 2:
|
|
7701
7927
|
run = _a.sent();
|
|
7702
7928
|
createGc$1();
|
|
7703
|
-
return [4 /*yield*/, run(METHOD_NAME$s, agentName)];
|
|
7704
|
-
case
|
|
7929
|
+
return [4 /*yield*/, run(METHOD_NAME$s, agentName, swarmName)];
|
|
7930
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
7705
7931
|
}
|
|
7706
7932
|
});
|
|
7707
7933
|
}); };
|
|
@@ -9534,4 +9760,4 @@ var SchemaUtils = /** @class */ (function () {
|
|
|
9534
9760
|
*/
|
|
9535
9761
|
var Schema = new SchemaUtils();
|
|
9536
9762
|
|
|
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 };
|
|
9763
|
+
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 };
|