agent-swarm-kit 1.0.204 → 1.0.206
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 +359 -329
- package/build/index.mjs +359 -330
- package/package.json +1 -1
- package/types.d.ts +131 -33
package/build/index.cjs
CHANGED
|
@@ -4228,7 +4228,7 @@ class AgentConnectionService {
|
|
|
4228
4228
|
}
|
|
4229
4229
|
|
|
4230
4230
|
/** @private Constant defining the method name for logging purposes */
|
|
4231
|
-
const METHOD_NAME$
|
|
4231
|
+
const METHOD_NAME$V = "function.common.getPayload";
|
|
4232
4232
|
/**
|
|
4233
4233
|
* Retrieves the payload from the current PayloadContextService context.
|
|
4234
4234
|
* Returns null if no context is available. Logs the operation if logging is enabled.
|
|
@@ -4239,7 +4239,7 @@ const METHOD_NAME$U = "function.common.getPayload";
|
|
|
4239
4239
|
* console.log(payload); // { id: number } or null
|
|
4240
4240
|
*/
|
|
4241
4241
|
const getPayload = () => {
|
|
4242
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$
|
|
4242
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$V);
|
|
4243
4243
|
if (PayloadContextService.hasContext()) {
|
|
4244
4244
|
const { payload } = swarm$1.payloadContextService.context;
|
|
4245
4245
|
return payload;
|
|
@@ -13155,7 +13155,7 @@ const swarm = {
|
|
|
13155
13155
|
init();
|
|
13156
13156
|
var swarm$1 = swarm;
|
|
13157
13157
|
|
|
13158
|
-
const METHOD_NAME$
|
|
13158
|
+
const METHOD_NAME$U = "cli.dumpDocs";
|
|
13159
13159
|
/**
|
|
13160
13160
|
* Dumps the documentation for the agents and swarms.
|
|
13161
13161
|
*
|
|
@@ -13165,7 +13165,7 @@ const METHOD_NAME$T = "cli.dumpDocs";
|
|
|
13165
13165
|
*/
|
|
13166
13166
|
const dumpDocs = beginContext((dirName = "./docs/chat", PlantUML) => {
|
|
13167
13167
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13168
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13168
|
+
swarm$1.loggerService.log(METHOD_NAME$U, {
|
|
13169
13169
|
dirName,
|
|
13170
13170
|
});
|
|
13171
13171
|
if (PlantUML) {
|
|
@@ -13175,10 +13175,10 @@ const dumpDocs = beginContext((dirName = "./docs/chat", PlantUML) => {
|
|
|
13175
13175
|
}
|
|
13176
13176
|
swarm$1.agentValidationService
|
|
13177
13177
|
.getAgentList()
|
|
13178
|
-
.forEach((agentName) => swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
13178
|
+
.forEach((agentName) => swarm$1.agentValidationService.validate(agentName, METHOD_NAME$U));
|
|
13179
13179
|
swarm$1.swarmValidationService
|
|
13180
13180
|
.getSwarmList()
|
|
13181
|
-
.forEach((swarmName) => swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
13181
|
+
.forEach((swarmName) => swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$U));
|
|
13182
13182
|
swarm$1.agentValidationService.getAgentList().forEach((agentName) => {
|
|
13183
13183
|
const { dependsOn } = swarm$1.agentSchemaService.get(agentName);
|
|
13184
13184
|
if (!dependsOn) {
|
|
@@ -13188,7 +13188,7 @@ const dumpDocs = beginContext((dirName = "./docs/chat", PlantUML) => {
|
|
|
13188
13188
|
return swarm$1.docService.dumpDocs(dirName);
|
|
13189
13189
|
});
|
|
13190
13190
|
|
|
13191
|
-
const METHOD_NAME$
|
|
13191
|
+
const METHOD_NAME$T = "cli.dumpAgent";
|
|
13192
13192
|
/**
|
|
13193
13193
|
* Dumps the agent information into PlantUML format.
|
|
13194
13194
|
*
|
|
@@ -13197,14 +13197,14 @@ const METHOD_NAME$S = "cli.dumpAgent";
|
|
|
13197
13197
|
*/
|
|
13198
13198
|
const dumpAgent = beginContext((agentName, { withSubtree = false } = {}) => {
|
|
13199
13199
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13200
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13200
|
+
swarm$1.loggerService.log(METHOD_NAME$T, {
|
|
13201
13201
|
agentName,
|
|
13202
13202
|
});
|
|
13203
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
13203
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$T);
|
|
13204
13204
|
return swarm$1.agentMetaService.toUML(agentName, withSubtree);
|
|
13205
13205
|
});
|
|
13206
13206
|
|
|
13207
|
-
const METHOD_NAME$
|
|
13207
|
+
const METHOD_NAME$S = "cli.dumpSwarm";
|
|
13208
13208
|
/**
|
|
13209
13209
|
* Dumps the swarm information into PlantUML format.
|
|
13210
13210
|
*
|
|
@@ -13213,14 +13213,14 @@ const METHOD_NAME$R = "cli.dumpSwarm";
|
|
|
13213
13213
|
*/
|
|
13214
13214
|
const dumpSwarm = beginContext((swarmName) => {
|
|
13215
13215
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13216
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13216
|
+
swarm$1.loggerService.log(METHOD_NAME$S, {
|
|
13217
13217
|
swarmName,
|
|
13218
13218
|
});
|
|
13219
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
13219
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$S);
|
|
13220
13220
|
return swarm$1.swarmMetaService.toUML(swarmName);
|
|
13221
13221
|
});
|
|
13222
13222
|
|
|
13223
|
-
const METHOD_NAME$
|
|
13223
|
+
const METHOD_NAME$R = "cli.dumpPerfomance";
|
|
13224
13224
|
const METHOD_NAME_INTERNAL$1 = "cli.dumpPerfomance.internal";
|
|
13225
13225
|
const METHOD_NAME_INTERVAL = "cli.dumpPerfomance.interval";
|
|
13226
13226
|
/**
|
|
@@ -13239,7 +13239,7 @@ const dumpPerfomanceInternal = beginContext(async (dirName = "./logs/meta") => {
|
|
|
13239
13239
|
* @returns {Promise<void>} A promise that resolves when the performance data has been dumped.
|
|
13240
13240
|
*/
|
|
13241
13241
|
const dumpPerfomance = async (dirName = "./logs/meta") => {
|
|
13242
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$
|
|
13242
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$R);
|
|
13243
13243
|
await dumpPerfomanceInternal(dirName);
|
|
13244
13244
|
};
|
|
13245
13245
|
/**
|
|
@@ -13297,7 +13297,7 @@ const listenExecutionEvent = beginContext((clientId, fn) => {
|
|
|
13297
13297
|
return swarm$1.busService.subscribe(clientId, "execution-bus", functoolsKit.queued(async (e) => await fn(e)));
|
|
13298
13298
|
});
|
|
13299
13299
|
|
|
13300
|
-
const METHOD_NAME$
|
|
13300
|
+
const METHOD_NAME$Q = "cli.dumpClientPerformance";
|
|
13301
13301
|
const METHOD_NAME_INTERNAL = "cli.dumpClientPerformance.internal";
|
|
13302
13302
|
const METHOD_NAME_EXECUTE = "cli.dumpClientPerformance.execute";
|
|
13303
13303
|
/**
|
|
@@ -13321,7 +13321,7 @@ const dumpClientPerformanceInternal = beginContext(async (clientId, dirName = ".
|
|
|
13321
13321
|
* @returns {Promise<void>} A promise that resolves when the performance data has been dumped.
|
|
13322
13322
|
*/
|
|
13323
13323
|
const dumpClientPerformance = async (clientId, dirName = "./logs/client") => {
|
|
13324
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$
|
|
13324
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$Q);
|
|
13325
13325
|
await dumpClientPerformanceInternal(clientId, dirName);
|
|
13326
13326
|
};
|
|
13327
13327
|
/**
|
|
@@ -13341,7 +13341,7 @@ dumpClientPerformance.runAfterExecute = beginContext(async (dirName = "./logs/cl
|
|
|
13341
13341
|
});
|
|
13342
13342
|
});
|
|
13343
13343
|
|
|
13344
|
-
const METHOD_NAME$
|
|
13344
|
+
const METHOD_NAME$P = "function.setup.addAgent";
|
|
13345
13345
|
/**
|
|
13346
13346
|
* Adds a new agent to the agent registry for use within the swarm system.
|
|
13347
13347
|
*
|
|
@@ -13361,7 +13361,7 @@ const METHOD_NAME$O = "function.setup.addAgent";
|
|
|
13361
13361
|
const addAgent = beginContext((agentSchema) => {
|
|
13362
13362
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
13363
13363
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13364
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13364
|
+
swarm$1.loggerService.log(METHOD_NAME$P, {
|
|
13365
13365
|
agentSchema,
|
|
13366
13366
|
});
|
|
13367
13367
|
// Register the agent in the validation and schema services
|
|
@@ -13371,7 +13371,7 @@ const addAgent = beginContext((agentSchema) => {
|
|
|
13371
13371
|
return agentSchema.agentName;
|
|
13372
13372
|
});
|
|
13373
13373
|
|
|
13374
|
-
const METHOD_NAME$
|
|
13374
|
+
const METHOD_NAME$O = "function.setup.addCompletion";
|
|
13375
13375
|
/**
|
|
13376
13376
|
* Adds a completion engine to the registry for use by agents in the swarm system.
|
|
13377
13377
|
*
|
|
@@ -13391,7 +13391,7 @@ const METHOD_NAME$N = "function.setup.addCompletion";
|
|
|
13391
13391
|
const addCompletion = beginContext((completionSchema) => {
|
|
13392
13392
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
13393
13393
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13394
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13394
|
+
swarm$1.loggerService.log(METHOD_NAME$O, {
|
|
13395
13395
|
completionSchema,
|
|
13396
13396
|
});
|
|
13397
13397
|
// Register the completion in the validation and schema services
|
|
@@ -13401,7 +13401,7 @@ const addCompletion = beginContext((completionSchema) => {
|
|
|
13401
13401
|
return completionSchema.completionName;
|
|
13402
13402
|
});
|
|
13403
13403
|
|
|
13404
|
-
const METHOD_NAME$
|
|
13404
|
+
const METHOD_NAME$N = "function.setup.addSwarm";
|
|
13405
13405
|
/**
|
|
13406
13406
|
* Adds a new swarm to the system for managing client sessions.
|
|
13407
13407
|
*
|
|
@@ -13421,7 +13421,7 @@ const METHOD_NAME$M = "function.setup.addSwarm";
|
|
|
13421
13421
|
const addSwarm = beginContext((swarmSchema) => {
|
|
13422
13422
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
13423
13423
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13424
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13424
|
+
swarm$1.loggerService.log(METHOD_NAME$N, {
|
|
13425
13425
|
swarmSchema,
|
|
13426
13426
|
});
|
|
13427
13427
|
// Register the swarm in the validation and schema services
|
|
@@ -13431,7 +13431,7 @@ const addSwarm = beginContext((swarmSchema) => {
|
|
|
13431
13431
|
return swarmSchema.swarmName;
|
|
13432
13432
|
});
|
|
13433
13433
|
|
|
13434
|
-
const METHOD_NAME$
|
|
13434
|
+
const METHOD_NAME$M = "function.setup.addTool";
|
|
13435
13435
|
/**
|
|
13436
13436
|
* Adds a new tool to the tool registry for use by agents in the swarm system.
|
|
13437
13437
|
*
|
|
@@ -13453,7 +13453,7 @@ const METHOD_NAME$L = "function.setup.addTool";
|
|
|
13453
13453
|
const addTool = beginContext((toolSchema) => {
|
|
13454
13454
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
13455
13455
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13456
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13456
|
+
swarm$1.loggerService.log(METHOD_NAME$M, {
|
|
13457
13457
|
toolSchema,
|
|
13458
13458
|
});
|
|
13459
13459
|
// Register the tool in the validation and schema services
|
|
@@ -13463,7 +13463,7 @@ const addTool = beginContext((toolSchema) => {
|
|
|
13463
13463
|
return toolSchema.toolName;
|
|
13464
13464
|
});
|
|
13465
13465
|
|
|
13466
|
-
const METHOD_NAME$
|
|
13466
|
+
const METHOD_NAME$L = "function.setup.addState";
|
|
13467
13467
|
/**
|
|
13468
13468
|
* Adds a new state to the state registry for use within the swarm system.
|
|
13469
13469
|
*
|
|
@@ -13485,7 +13485,7 @@ const METHOD_NAME$K = "function.setup.addState";
|
|
|
13485
13485
|
const addState = beginContext((stateSchema) => {
|
|
13486
13486
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
13487
13487
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13488
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13488
|
+
swarm$1.loggerService.log(METHOD_NAME$L, {
|
|
13489
13489
|
stateSchema,
|
|
13490
13490
|
});
|
|
13491
13491
|
// Register the state in the schema service
|
|
@@ -13500,7 +13500,7 @@ const addState = beginContext((stateSchema) => {
|
|
|
13500
13500
|
return stateSchema.stateName;
|
|
13501
13501
|
});
|
|
13502
13502
|
|
|
13503
|
-
const METHOD_NAME$
|
|
13503
|
+
const METHOD_NAME$K = "function.setup.addEmbedding";
|
|
13504
13504
|
/**
|
|
13505
13505
|
* Adds a new embedding engine to the embedding registry for use within the swarm system.
|
|
13506
13506
|
*
|
|
@@ -13520,7 +13520,7 @@ const METHOD_NAME$J = "function.setup.addEmbedding";
|
|
|
13520
13520
|
const addEmbedding = beginContext((embeddingSchema) => {
|
|
13521
13521
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
13522
13522
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13523
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13523
|
+
swarm$1.loggerService.log(METHOD_NAME$K, {
|
|
13524
13524
|
embeddingSchema,
|
|
13525
13525
|
});
|
|
13526
13526
|
// Register the embedding in the validation and schema services
|
|
@@ -13530,7 +13530,7 @@ const addEmbedding = beginContext((embeddingSchema) => {
|
|
|
13530
13530
|
return embeddingSchema.embeddingName;
|
|
13531
13531
|
});
|
|
13532
13532
|
|
|
13533
|
-
const METHOD_NAME$
|
|
13533
|
+
const METHOD_NAME$J = "function.setup.addStorage";
|
|
13534
13534
|
/**
|
|
13535
13535
|
* Adds a new storage engine to the storage registry for use within the swarm system.
|
|
13536
13536
|
*
|
|
@@ -13552,7 +13552,7 @@ const METHOD_NAME$I = "function.setup.addStorage";
|
|
|
13552
13552
|
const addStorage = beginContext((storageSchema) => {
|
|
13553
13553
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
13554
13554
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13555
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13555
|
+
swarm$1.loggerService.log(METHOD_NAME$J, {
|
|
13556
13556
|
storageSchema,
|
|
13557
13557
|
});
|
|
13558
13558
|
// Register the storage in the validation and schema services
|
|
@@ -13569,7 +13569,7 @@ const addStorage = beginContext((storageSchema) => {
|
|
|
13569
13569
|
});
|
|
13570
13570
|
|
|
13571
13571
|
/** @private Constant defining the method name for logging and validation context */
|
|
13572
|
-
const METHOD_NAME$
|
|
13572
|
+
const METHOD_NAME$I = "function.setup.addPolicy";
|
|
13573
13573
|
/**
|
|
13574
13574
|
* Adds a new policy for agents in the swarm system by registering it with validation and schema services.
|
|
13575
13575
|
* Registers the policy with PolicyValidationService for runtime validation and PolicySchemaService for schema management.
|
|
@@ -13585,7 +13585,7 @@ const METHOD_NAME$H = "function.setup.addPolicy";
|
|
|
13585
13585
|
const addPolicy = beginContext((policySchema) => {
|
|
13586
13586
|
// Log the policy addition attempt if enabled
|
|
13587
13587
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13588
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13588
|
+
swarm$1.loggerService.log(METHOD_NAME$I, {
|
|
13589
13589
|
policySchema,
|
|
13590
13590
|
});
|
|
13591
13591
|
// Register the policy with PolicyValidationService for runtime validation
|
|
@@ -13596,17 +13596,17 @@ const addPolicy = beginContext((policySchema) => {
|
|
|
13596
13596
|
return policySchema.policyName;
|
|
13597
13597
|
});
|
|
13598
13598
|
|
|
13599
|
-
const METHOD_NAME$
|
|
13599
|
+
const METHOD_NAME$H = "function.other.markOnline";
|
|
13600
13600
|
const markOnline = async (clientId, swarmName) => {
|
|
13601
13601
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13602
|
-
swarm.loggerService.log(METHOD_NAME$
|
|
13602
|
+
swarm.loggerService.log(METHOD_NAME$H, {
|
|
13603
13603
|
clientId,
|
|
13604
13604
|
});
|
|
13605
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
13605
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$H);
|
|
13606
13606
|
return await MethodContextService.runInContext(async () => {
|
|
13607
|
-
await swarm.aliveService.markOnline(clientId, swarmName, METHOD_NAME$
|
|
13607
|
+
await swarm.aliveService.markOnline(clientId, swarmName, METHOD_NAME$H);
|
|
13608
13608
|
}, {
|
|
13609
|
-
methodName: METHOD_NAME$
|
|
13609
|
+
methodName: METHOD_NAME$H,
|
|
13610
13610
|
agentName: "",
|
|
13611
13611
|
policyName: "",
|
|
13612
13612
|
stateName: "",
|
|
@@ -13616,17 +13616,17 @@ const markOnline = async (clientId, swarmName) => {
|
|
|
13616
13616
|
});
|
|
13617
13617
|
};
|
|
13618
13618
|
|
|
13619
|
-
const METHOD_NAME$
|
|
13619
|
+
const METHOD_NAME$G = "function.other.markOffline";
|
|
13620
13620
|
const markOffline = async (clientId, swarmName) => {
|
|
13621
13621
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13622
|
-
swarm.loggerService.log(METHOD_NAME$
|
|
13622
|
+
swarm.loggerService.log(METHOD_NAME$G, {
|
|
13623
13623
|
clientId,
|
|
13624
13624
|
});
|
|
13625
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
13625
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$G);
|
|
13626
13626
|
return await MethodContextService.runInContext(async () => {
|
|
13627
|
-
await swarm.aliveService.markOffline(clientId, swarmName, METHOD_NAME$
|
|
13627
|
+
await swarm.aliveService.markOffline(clientId, swarmName, METHOD_NAME$G);
|
|
13628
13628
|
}, {
|
|
13629
|
-
methodName: METHOD_NAME$
|
|
13629
|
+
methodName: METHOD_NAME$G,
|
|
13630
13630
|
agentName: "",
|
|
13631
13631
|
policyName: "",
|
|
13632
13632
|
stateName: "",
|
|
@@ -13636,7 +13636,7 @@ const markOffline = async (clientId, swarmName) => {
|
|
|
13636
13636
|
});
|
|
13637
13637
|
};
|
|
13638
13638
|
|
|
13639
|
-
const METHOD_NAME$
|
|
13639
|
+
const METHOD_NAME$F = "function.commit.commitToolOutput";
|
|
13640
13640
|
/**
|
|
13641
13641
|
* Commits the output of a tool execution to the active agent in a swarm session.
|
|
13642
13642
|
*
|
|
@@ -13656,19 +13656,19 @@ const METHOD_NAME$E = "function.commit.commitToolOutput";
|
|
|
13656
13656
|
const commitToolOutput = beginContext(async (toolId, content, clientId, agentName) => {
|
|
13657
13657
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
13658
13658
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13659
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13659
|
+
swarm$1.loggerService.log(METHOD_NAME$F, {
|
|
13660
13660
|
toolId,
|
|
13661
13661
|
content,
|
|
13662
13662
|
clientId,
|
|
13663
13663
|
agentName,
|
|
13664
13664
|
});
|
|
13665
13665
|
// Validate the agent, session, and swarm to ensure they exist and are accessible
|
|
13666
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
13667
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
13666
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$F);
|
|
13667
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$F);
|
|
13668
13668
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
13669
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
13669
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$F);
|
|
13670
13670
|
// Check if the specified agent is still the active agent in the swarm session
|
|
13671
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
13671
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$F, clientId, swarmName);
|
|
13672
13672
|
if (currentAgentName !== agentName) {
|
|
13673
13673
|
// Log a skip message if the agent has changed during the operation
|
|
13674
13674
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
@@ -13681,11 +13681,11 @@ const commitToolOutput = beginContext(async (toolId, content, clientId, agentNam
|
|
|
13681
13681
|
return;
|
|
13682
13682
|
}
|
|
13683
13683
|
// Commit the tool output to the session via the session public service
|
|
13684
|
-
await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$
|
|
13684
|
+
await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$F, clientId, swarmName);
|
|
13685
13685
|
});
|
|
13686
13686
|
|
|
13687
13687
|
/** @private Constant defining the method name for logging and validation context */
|
|
13688
|
-
const METHOD_NAME$
|
|
13688
|
+
const METHOD_NAME$E = "function.commit.commitSystemMessage";
|
|
13689
13689
|
/**
|
|
13690
13690
|
* Commits a system-generated message to the active agent in the swarm system.
|
|
13691
13691
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before committing the message.
|
|
@@ -13704,20 +13704,20 @@ const METHOD_NAME$D = "function.commit.commitSystemMessage";
|
|
|
13704
13704
|
const commitSystemMessage = beginContext(async (content, clientId, agentName) => {
|
|
13705
13705
|
// Log the commit attempt if enabled
|
|
13706
13706
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13707
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13707
|
+
swarm$1.loggerService.log(METHOD_NAME$E, {
|
|
13708
13708
|
content,
|
|
13709
13709
|
clientId,
|
|
13710
13710
|
agentName,
|
|
13711
13711
|
});
|
|
13712
13712
|
// Validate the agent exists
|
|
13713
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
13713
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$E);
|
|
13714
13714
|
// Validate the session exists and retrieve the associated swarm
|
|
13715
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
13715
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$E);
|
|
13716
13716
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
13717
13717
|
// Validate the swarm configuration
|
|
13718
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
13718
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$E);
|
|
13719
13719
|
// Check if the current agent matches the provided agent
|
|
13720
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
13720
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$E, clientId, swarmName);
|
|
13721
13721
|
if (currentAgentName !== agentName) {
|
|
13722
13722
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13723
13723
|
swarm$1.loggerService.log('function "commitSystemMessage" skipped due to the agent change', {
|
|
@@ -13728,11 +13728,11 @@ const commitSystemMessage = beginContext(async (content, clientId, agentName) =>
|
|
|
13728
13728
|
return;
|
|
13729
13729
|
}
|
|
13730
13730
|
// Commit the system message via SessionPublicService
|
|
13731
|
-
await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$
|
|
13731
|
+
await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$E, clientId, swarmName);
|
|
13732
13732
|
});
|
|
13733
13733
|
|
|
13734
13734
|
/** @private Constant defining the method name for logging and validation context */
|
|
13735
|
-
const METHOD_NAME$
|
|
13735
|
+
const METHOD_NAME$D = "function.commit.commitFlush";
|
|
13736
13736
|
/**
|
|
13737
13737
|
* Commits a flush of agent history for a specific client and agent in the swarm system.
|
|
13738
13738
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before flushing the history.
|
|
@@ -13749,19 +13749,19 @@ const METHOD_NAME$C = "function.commit.commitFlush";
|
|
|
13749
13749
|
const commitFlush = beginContext(async (clientId, agentName) => {
|
|
13750
13750
|
// Log the flush attempt if enabled
|
|
13751
13751
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13752
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13752
|
+
swarm$1.loggerService.log(METHOD_NAME$D, {
|
|
13753
13753
|
clientId,
|
|
13754
13754
|
agentName,
|
|
13755
13755
|
});
|
|
13756
13756
|
// Validate the agent exists
|
|
13757
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
13757
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$D);
|
|
13758
13758
|
// Validate the session exists and retrieve the associated swarm
|
|
13759
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
13759
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$D);
|
|
13760
13760
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
13761
13761
|
// Validate the swarm configuration
|
|
13762
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
13762
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$D);
|
|
13763
13763
|
// Check if the current agent matches the provided agent
|
|
13764
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
13764
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$D, clientId, swarmName);
|
|
13765
13765
|
if (currentAgentName !== agentName) {
|
|
13766
13766
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13767
13767
|
swarm$1.loggerService.log('function "commitFlush" skipped due to the agent change', {
|
|
@@ -13772,10 +13772,10 @@ const commitFlush = beginContext(async (clientId, agentName) => {
|
|
|
13772
13772
|
return;
|
|
13773
13773
|
}
|
|
13774
13774
|
// Commit the flush of agent history via SessionPublicService
|
|
13775
|
-
await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$
|
|
13775
|
+
await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$D, clientId, swarmName);
|
|
13776
13776
|
});
|
|
13777
13777
|
|
|
13778
|
-
const METHOD_NAME$
|
|
13778
|
+
const METHOD_NAME$C = "function.commit.commitSystemMessage";
|
|
13779
13779
|
/**
|
|
13780
13780
|
* Commits a user message to the active agent's history in a swarm session without triggering a response.
|
|
13781
13781
|
*
|
|
@@ -13794,19 +13794,19 @@ const METHOD_NAME$B = "function.commit.commitSystemMessage";
|
|
|
13794
13794
|
const commitUserMessage = beginContext(async (content, mode, clientId, agentName, payload) => {
|
|
13795
13795
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
13796
13796
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13797
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13797
|
+
swarm$1.loggerService.log(METHOD_NAME$C, {
|
|
13798
13798
|
content,
|
|
13799
13799
|
clientId,
|
|
13800
13800
|
agentName,
|
|
13801
13801
|
mode,
|
|
13802
13802
|
});
|
|
13803
13803
|
// Validate the agent, session, and swarm to ensure they exist and are accessible
|
|
13804
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
13805
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
13804
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$C);
|
|
13805
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$C);
|
|
13806
13806
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
13807
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
13807
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$C);
|
|
13808
13808
|
// Check if the specified agent is still the active agent in the swarm session
|
|
13809
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
13809
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$C, clientId, swarmName);
|
|
13810
13810
|
if (currentAgentName !== agentName) {
|
|
13811
13811
|
// Log a skip message if the agent has changed during the operation
|
|
13812
13812
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
@@ -13819,17 +13819,17 @@ const commitUserMessage = beginContext(async (content, mode, clientId, agentName
|
|
|
13819
13819
|
}
|
|
13820
13820
|
if (payload) {
|
|
13821
13821
|
return await PayloadContextService.runInContext(async () => {
|
|
13822
|
-
await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$
|
|
13822
|
+
await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$C, clientId, swarmName);
|
|
13823
13823
|
}, {
|
|
13824
13824
|
clientId,
|
|
13825
13825
|
payload,
|
|
13826
13826
|
});
|
|
13827
13827
|
}
|
|
13828
13828
|
// Commit the user message to the agent's history via the session public service
|
|
13829
|
-
return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$
|
|
13829
|
+
return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$C, clientId, swarmName);
|
|
13830
13830
|
});
|
|
13831
13831
|
|
|
13832
|
-
const METHOD_NAME$
|
|
13832
|
+
const METHOD_NAME$B = "function.commit.commitToolOutputForce";
|
|
13833
13833
|
/**
|
|
13834
13834
|
* Commits the output of a tool execution to the active agent in a swarm session without checking the active agent.
|
|
13835
13835
|
*
|
|
@@ -13848,21 +13848,21 @@ const METHOD_NAME$A = "function.commit.commitToolOutputForce";
|
|
|
13848
13848
|
const commitToolOutputForce = beginContext(async (toolId, content, clientId) => {
|
|
13849
13849
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
13850
13850
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13851
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13851
|
+
swarm$1.loggerService.log(METHOD_NAME$B, {
|
|
13852
13852
|
toolId,
|
|
13853
13853
|
content,
|
|
13854
13854
|
clientId,
|
|
13855
13855
|
});
|
|
13856
13856
|
// Validate the session and swarm to ensure they exist and are accessible
|
|
13857
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
13857
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$B);
|
|
13858
13858
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
13859
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
13859
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$B);
|
|
13860
13860
|
// Commit the tool output to the session via the session public service without checking the active agent
|
|
13861
|
-
await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$
|
|
13861
|
+
await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$B, clientId, swarmName);
|
|
13862
13862
|
});
|
|
13863
13863
|
|
|
13864
13864
|
/** @private Constant defining the method name for logging and validation context */
|
|
13865
|
-
const METHOD_NAME$
|
|
13865
|
+
const METHOD_NAME$A = "function.commit.commitSystemMessageForce";
|
|
13866
13866
|
/**
|
|
13867
13867
|
* Forcefully commits a system-generated message to a session in the swarm system, without checking the active agent.
|
|
13868
13868
|
* Validates the session and swarm, then proceeds with committing the message regardless of the current agent state.
|
|
@@ -13881,21 +13881,21 @@ const METHOD_NAME$z = "function.commit.commitSystemMessageForce";
|
|
|
13881
13881
|
const commitSystemMessageForce = beginContext(async (content, clientId) => {
|
|
13882
13882
|
// Log the commit attempt if enabled
|
|
13883
13883
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13884
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13884
|
+
swarm$1.loggerService.log(METHOD_NAME$A, {
|
|
13885
13885
|
content,
|
|
13886
13886
|
clientId,
|
|
13887
13887
|
});
|
|
13888
13888
|
// Validate the session exists and retrieve the associated swarm
|
|
13889
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
13889
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$A);
|
|
13890
13890
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
13891
13891
|
// Validate the swarm configuration
|
|
13892
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
13892
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$A);
|
|
13893
13893
|
// Commit the system message via SessionPublicService without agent checks
|
|
13894
|
-
await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$
|
|
13894
|
+
await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$A, clientId, swarmName);
|
|
13895
13895
|
});
|
|
13896
13896
|
|
|
13897
13897
|
/** @private Constant defining the method name for logging and validation context */
|
|
13898
|
-
const METHOD_NAME$
|
|
13898
|
+
const METHOD_NAME$z = "function.commit.commitFlushForce";
|
|
13899
13899
|
/**
|
|
13900
13900
|
* Forcefully commits a flush of agent history for a specific client in the swarm system, without checking the active agent.
|
|
13901
13901
|
* Validates the session and swarm, then proceeds with flushing the history regardless of the current agent state.
|
|
@@ -13913,20 +13913,20 @@ const METHOD_NAME$y = "function.commit.commitFlushForce";
|
|
|
13913
13913
|
const commitFlushForce = beginContext(async (clientId) => {
|
|
13914
13914
|
// Log the flush attempt if enabled
|
|
13915
13915
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13916
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13916
|
+
swarm$1.loggerService.log(METHOD_NAME$z, {
|
|
13917
13917
|
clientId,
|
|
13918
|
-
METHOD_NAME: METHOD_NAME$
|
|
13918
|
+
METHOD_NAME: METHOD_NAME$z,
|
|
13919
13919
|
});
|
|
13920
13920
|
// Validate the session exists and retrieve the associated swarm
|
|
13921
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
13921
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$z);
|
|
13922
13922
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
13923
13923
|
// Validate the swarm configuration
|
|
13924
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
13924
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$z);
|
|
13925
13925
|
// Commit the flush of agent history via SessionPublicService without agent checks
|
|
13926
|
-
await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$
|
|
13926
|
+
await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$z, clientId, swarmName);
|
|
13927
13927
|
});
|
|
13928
13928
|
|
|
13929
|
-
const METHOD_NAME$
|
|
13929
|
+
const METHOD_NAME$y = "function.commit.commitSystemMessage";
|
|
13930
13930
|
/**
|
|
13931
13931
|
* Commits a user message to the active agent's history in a swarm session without triggering a response and without checking the active agent.
|
|
13932
13932
|
*
|
|
@@ -13944,29 +13944,29 @@ const METHOD_NAME$x = "function.commit.commitSystemMessage";
|
|
|
13944
13944
|
const commitUserMessageForce = beginContext(async (content, mode, clientId, payload) => {
|
|
13945
13945
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
13946
13946
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13947
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13947
|
+
swarm$1.loggerService.log(METHOD_NAME$y, {
|
|
13948
13948
|
content,
|
|
13949
13949
|
clientId,
|
|
13950
13950
|
mode,
|
|
13951
13951
|
});
|
|
13952
13952
|
// Validate the session and swarm to ensure they exist and are accessible
|
|
13953
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
13953
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$y);
|
|
13954
13954
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
13955
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
13955
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$y);
|
|
13956
13956
|
if (payload) {
|
|
13957
13957
|
return await PayloadContextService.runInContext(async () => {
|
|
13958
|
-
await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$
|
|
13958
|
+
await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$y, clientId, swarmName);
|
|
13959
13959
|
}, {
|
|
13960
13960
|
clientId,
|
|
13961
13961
|
payload,
|
|
13962
13962
|
});
|
|
13963
13963
|
}
|
|
13964
13964
|
// Commit the user message to the agent's history via the session public service without checking the active agent
|
|
13965
|
-
return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$
|
|
13965
|
+
return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$y, clientId, swarmName);
|
|
13966
13966
|
});
|
|
13967
13967
|
|
|
13968
13968
|
/** @private Constant defining the method name for logging and validation context */
|
|
13969
|
-
const METHOD_NAME$
|
|
13969
|
+
const METHOD_NAME$x = "function.commit.commitAssistantMessage";
|
|
13970
13970
|
/**
|
|
13971
13971
|
* Commits an assistant-generated message to the active agent in the swarm system.
|
|
13972
13972
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before committing the message.
|
|
@@ -13984,20 +13984,20 @@ const METHOD_NAME$w = "function.commit.commitAssistantMessage";
|
|
|
13984
13984
|
const commitAssistantMessage = beginContext(async (content, clientId, agentName) => {
|
|
13985
13985
|
// Log the commit attempt if enabled
|
|
13986
13986
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
13987
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
13987
|
+
swarm$1.loggerService.log(METHOD_NAME$x, {
|
|
13988
13988
|
content,
|
|
13989
13989
|
clientId,
|
|
13990
13990
|
agentName,
|
|
13991
13991
|
});
|
|
13992
13992
|
// Validate the agent exists
|
|
13993
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
13993
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$x);
|
|
13994
13994
|
// Validate the session exists and retrieve the associated swarm
|
|
13995
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
13995
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$x);
|
|
13996
13996
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
13997
13997
|
// Validate the swarm configuration
|
|
13998
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
13998
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$x);
|
|
13999
13999
|
// Check if the current agent matches the provided agent
|
|
14000
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
14000
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$x, clientId, swarmName);
|
|
14001
14001
|
if (currentAgentName !== agentName) {
|
|
14002
14002
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14003
14003
|
swarm$1.loggerService.log('function "commitAssistantMessage" skipped due to the agent change', {
|
|
@@ -14008,11 +14008,11 @@ const commitAssistantMessage = beginContext(async (content, clientId, agentName)
|
|
|
14008
14008
|
return;
|
|
14009
14009
|
}
|
|
14010
14010
|
// Commit the assistant message via SessionPublicService
|
|
14011
|
-
await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$
|
|
14011
|
+
await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$x, clientId, swarmName);
|
|
14012
14012
|
});
|
|
14013
14013
|
|
|
14014
14014
|
/** @private Constant defining the method name for logging and validation context */
|
|
14015
|
-
const METHOD_NAME$
|
|
14015
|
+
const METHOD_NAME$w = "function.commit.commitAssistantMessageForce";
|
|
14016
14016
|
/**
|
|
14017
14017
|
* Forcefully commits an assistant-generated message to a session in the swarm system, without checking the active agent.
|
|
14018
14018
|
* Validates the session and swarm, then proceeds with committing the message regardless of the current agent state.
|
|
@@ -14031,21 +14031,21 @@ const METHOD_NAME$v = "function.commit.commitAssistantMessageForce";
|
|
|
14031
14031
|
const commitAssistantMessageForce = beginContext(async (content, clientId) => {
|
|
14032
14032
|
// Log the commit attempt if enabled
|
|
14033
14033
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14034
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14034
|
+
swarm$1.loggerService.log(METHOD_NAME$w, {
|
|
14035
14035
|
content,
|
|
14036
14036
|
clientId,
|
|
14037
14037
|
});
|
|
14038
14038
|
// Validate the session exists and retrieve the associated swarm
|
|
14039
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
14039
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$w);
|
|
14040
14040
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14041
14041
|
// Validate the swarm configuration
|
|
14042
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
14042
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$w);
|
|
14043
14043
|
// Commit the assistant message via SessionPublicService without agent checks
|
|
14044
|
-
await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$
|
|
14044
|
+
await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$w, clientId, swarmName);
|
|
14045
14045
|
});
|
|
14046
14046
|
|
|
14047
14047
|
/** @private Constant defining the method name for logging and validation context */
|
|
14048
|
-
const METHOD_NAME$
|
|
14048
|
+
const METHOD_NAME$v = "function.commit.cancelOutput";
|
|
14049
14049
|
/**
|
|
14050
14050
|
* Cancels the awaited output for a specific client and agent by emitting an empty string.
|
|
14051
14051
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before cancellation.
|
|
@@ -14061,19 +14061,19 @@ const METHOD_NAME$u = "function.commit.cancelOutput";
|
|
|
14061
14061
|
const cancelOutput = beginContext(async (clientId, agentName) => {
|
|
14062
14062
|
// Log the cancellation attempt if enabled
|
|
14063
14063
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14064
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14064
|
+
swarm$1.loggerService.log(METHOD_NAME$v, {
|
|
14065
14065
|
clientId,
|
|
14066
14066
|
agentName,
|
|
14067
14067
|
});
|
|
14068
14068
|
// Validate the agent exists
|
|
14069
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
14069
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$v);
|
|
14070
14070
|
// Validate the session exists and retrieve the associated swarm
|
|
14071
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
14071
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$v);
|
|
14072
14072
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14073
14073
|
// Validate the swarm configuration
|
|
14074
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
14074
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$v);
|
|
14075
14075
|
// Check if the current agent matches the provided agent
|
|
14076
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
14076
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$v, clientId, swarmName);
|
|
14077
14077
|
if (currentAgentName !== agentName) {
|
|
14078
14078
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14079
14079
|
swarm$1.loggerService.log('function "cancelOutput" skipped due to the agent change', {
|
|
@@ -14084,11 +14084,11 @@ const cancelOutput = beginContext(async (clientId, agentName) => {
|
|
|
14084
14084
|
return;
|
|
14085
14085
|
}
|
|
14086
14086
|
// Perform the output cancellation via SwarmPublicService
|
|
14087
|
-
await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$
|
|
14087
|
+
await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$v, clientId, swarmName);
|
|
14088
14088
|
});
|
|
14089
14089
|
|
|
14090
14090
|
/** @private Constant defining the method name for logging and validation context */
|
|
14091
|
-
const METHOD_NAME$
|
|
14091
|
+
const METHOD_NAME$u = "function.commit.cancelOutputForce";
|
|
14092
14092
|
/**
|
|
14093
14093
|
* Forcefully cancels the awaited output for a specific client by emitting an empty string, without checking the active agent.
|
|
14094
14094
|
* Validates the session and swarm, then proceeds with cancellation regardless of the current agent state.
|
|
@@ -14105,20 +14105,20 @@ const METHOD_NAME$t = "function.commit.cancelOutputForce";
|
|
|
14105
14105
|
const cancelOutputForce = beginContext(async (clientId) => {
|
|
14106
14106
|
// Log the cancellation attempt if enabled
|
|
14107
14107
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14108
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14108
|
+
swarm$1.loggerService.log(METHOD_NAME$u, {
|
|
14109
14109
|
clientId,
|
|
14110
14110
|
});
|
|
14111
14111
|
// Validate the session exists and retrieve the associated swarm
|
|
14112
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
14112
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$u);
|
|
14113
14113
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14114
14114
|
// Validate the swarm configuration
|
|
14115
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
14115
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$u);
|
|
14116
14116
|
// Perform the output cancellation via SwarmPublicService without agent checks
|
|
14117
|
-
await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$
|
|
14117
|
+
await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$u, clientId, swarmName);
|
|
14118
14118
|
});
|
|
14119
14119
|
|
|
14120
14120
|
/** @private Constant defining the method name for logging and validation context */
|
|
14121
|
-
const METHOD_NAME$
|
|
14121
|
+
const METHOD_NAME$t = "function.commit.commitStopTools";
|
|
14122
14122
|
/**
|
|
14123
14123
|
* Prevents the next tool from being executed for a specific client and agent in the swarm system.
|
|
14124
14124
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before stopping tool execution.
|
|
@@ -14135,19 +14135,19 @@ const METHOD_NAME$s = "function.commit.commitStopTools";
|
|
|
14135
14135
|
const commitStopTools = beginContext(async (clientId, agentName) => {
|
|
14136
14136
|
// Log the stop tools attempt if enabled
|
|
14137
14137
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14138
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14138
|
+
swarm$1.loggerService.log(METHOD_NAME$t, {
|
|
14139
14139
|
clientId,
|
|
14140
14140
|
agentName,
|
|
14141
14141
|
});
|
|
14142
14142
|
// Validate the agent exists
|
|
14143
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
14143
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$t);
|
|
14144
14144
|
// Validate the session exists and retrieve the associated swarm
|
|
14145
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
14145
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$t);
|
|
14146
14146
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14147
14147
|
// Validate the swarm configuration
|
|
14148
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
14148
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$t);
|
|
14149
14149
|
// Check if the current agent matches the provided agent
|
|
14150
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
14150
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$t, clientId, swarmName);
|
|
14151
14151
|
if (currentAgentName !== agentName) {
|
|
14152
14152
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14153
14153
|
swarm$1.loggerService.log('function "commitStopTools" skipped due to the agent change', {
|
|
@@ -14158,11 +14158,11 @@ const commitStopTools = beginContext(async (clientId, agentName) => {
|
|
|
14158
14158
|
return;
|
|
14159
14159
|
}
|
|
14160
14160
|
// Commit the stop of the next tool execution via SessionPublicService
|
|
14161
|
-
await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$
|
|
14161
|
+
await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$t, clientId, swarmName);
|
|
14162
14162
|
});
|
|
14163
14163
|
|
|
14164
14164
|
/** @private Constant defining the method name for logging and validation context */
|
|
14165
|
-
const METHOD_NAME$
|
|
14165
|
+
const METHOD_NAME$s = "function.commit.commitStopToolsForce";
|
|
14166
14166
|
/**
|
|
14167
14167
|
* Forcefully prevents the next tool from being executed for a specific client in the swarm system, without checking the active agent.
|
|
14168
14168
|
* Validates the session and swarm, then proceeds with stopping tool execution regardless of the current agent state.
|
|
@@ -14180,20 +14180,20 @@ const METHOD_NAME$r = "function.commit.commitStopToolsForce";
|
|
|
14180
14180
|
const commitStopToolsForce = beginContext(async (clientId) => {
|
|
14181
14181
|
// Log the stop tools attempt if enabled
|
|
14182
14182
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14183
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14183
|
+
swarm$1.loggerService.log(METHOD_NAME$s, {
|
|
14184
14184
|
clientId,
|
|
14185
|
-
METHOD_NAME: METHOD_NAME$
|
|
14185
|
+
METHOD_NAME: METHOD_NAME$s,
|
|
14186
14186
|
});
|
|
14187
14187
|
// Validate the session exists and retrieve the associated swarm
|
|
14188
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
14188
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$s);
|
|
14189
14189
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14190
14190
|
// Validate the swarm configuration
|
|
14191
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
14191
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$s);
|
|
14192
14192
|
// Commit the stop of the next tool execution via SessionPublicService without agent checks
|
|
14193
|
-
await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$
|
|
14193
|
+
await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$s, clientId, swarmName);
|
|
14194
14194
|
});
|
|
14195
14195
|
|
|
14196
|
-
const METHOD_NAME$
|
|
14196
|
+
const METHOD_NAME$r = "function.target.emitForce";
|
|
14197
14197
|
/**
|
|
14198
14198
|
* Emits a string as model output without executing an incoming message or checking the active agent.
|
|
14199
14199
|
*
|
|
@@ -14212,19 +14212,19 @@ const METHOD_NAME$q = "function.target.emitForce";
|
|
|
14212
14212
|
const emitForce = beginContext(async (content, clientId) => {
|
|
14213
14213
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14214
14214
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14215
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14215
|
+
swarm$1.loggerService.log(METHOD_NAME$r, {
|
|
14216
14216
|
content,
|
|
14217
14217
|
clientId,
|
|
14218
14218
|
});
|
|
14219
14219
|
// Validate the session and swarm
|
|
14220
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
14220
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$r);
|
|
14221
14221
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14222
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
14222
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$r);
|
|
14223
14223
|
// Emit the content directly via the session public service
|
|
14224
|
-
return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$
|
|
14224
|
+
return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$r, clientId, swarmName);
|
|
14225
14225
|
});
|
|
14226
14226
|
|
|
14227
|
-
const METHOD_NAME$
|
|
14227
|
+
const METHOD_NAME$q = "function.target.executeForce";
|
|
14228
14228
|
/**
|
|
14229
14229
|
* Sends a message to the active agent in a swarm session as if it originated from the client side, forcing execution regardless of agent activity.
|
|
14230
14230
|
*
|
|
@@ -14245,22 +14245,22 @@ const executeForce = beginContext(async (content, clientId) => {
|
|
|
14245
14245
|
const executionId = functoolsKit.randomString();
|
|
14246
14246
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14247
14247
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14248
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14248
|
+
swarm$1.loggerService.log(METHOD_NAME$q, {
|
|
14249
14249
|
content,
|
|
14250
14250
|
clientId,
|
|
14251
14251
|
executionId,
|
|
14252
14252
|
});
|
|
14253
14253
|
// Validate the session and swarm
|
|
14254
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
14254
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$q);
|
|
14255
14255
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14256
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
14256
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$q);
|
|
14257
14257
|
// Execute the command within an execution context with performance tracking
|
|
14258
14258
|
return ExecutionContextService.runInContext(async () => {
|
|
14259
14259
|
let isFinished = false;
|
|
14260
14260
|
swarm$1.perfService.startExecution(executionId, clientId, content.length);
|
|
14261
14261
|
try {
|
|
14262
14262
|
swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
|
|
14263
|
-
const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$
|
|
14263
|
+
const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$q, clientId, swarmName);
|
|
14264
14264
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
14265
14265
|
swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
|
|
14266
14266
|
return result;
|
|
@@ -14277,7 +14277,7 @@ const executeForce = beginContext(async (content, clientId) => {
|
|
|
14277
14277
|
});
|
|
14278
14278
|
});
|
|
14279
14279
|
|
|
14280
|
-
const METHOD_NAME$
|
|
14280
|
+
const METHOD_NAME$p = "function.target.disposeConnection";
|
|
14281
14281
|
/**
|
|
14282
14282
|
* Disposes of a client session and all related resources within a swarm.
|
|
14283
14283
|
*
|
|
@@ -14294,10 +14294,10 @@ const METHOD_NAME$o = "function.target.disposeConnection";
|
|
|
14294
14294
|
* @example
|
|
14295
14295
|
* await disposeConnection("client-123", "TaskSwarm");
|
|
14296
14296
|
*/
|
|
14297
|
-
const disposeConnection = beginContext(async (clientId, swarmName, methodName = METHOD_NAME$
|
|
14297
|
+
const disposeConnection = beginContext(async (clientId, swarmName, methodName = METHOD_NAME$p) => {
|
|
14298
14298
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14299
14299
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14300
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14300
|
+
swarm$1.loggerService.log(METHOD_NAME$p, {
|
|
14301
14301
|
clientId,
|
|
14302
14302
|
swarmName,
|
|
14303
14303
|
});
|
|
@@ -14366,7 +14366,7 @@ const disposeConnection = beginContext(async (clientId, swarmName, methodName =
|
|
|
14366
14366
|
PersistMemoryAdapter.dispose(clientId);
|
|
14367
14367
|
});
|
|
14368
14368
|
|
|
14369
|
-
const METHOD_NAME$
|
|
14369
|
+
const METHOD_NAME$o = "function.target.makeAutoDispose";
|
|
14370
14370
|
/**
|
|
14371
14371
|
* Default timeout in seconds before auto-dispose is triggered.
|
|
14372
14372
|
* @constant {number}
|
|
@@ -14397,7 +14397,7 @@ const DEFAULT_TIMEOUT = 15 * 60;
|
|
|
14397
14397
|
const makeAutoDispose = beginContext((clientId, swarmName, { timeoutSeconds = DEFAULT_TIMEOUT, onDestroy, } = {}) => {
|
|
14398
14398
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14399
14399
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14400
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14400
|
+
swarm$1.loggerService.log(METHOD_NAME$o, {
|
|
14401
14401
|
clientId,
|
|
14402
14402
|
swarmName,
|
|
14403
14403
|
});
|
|
@@ -14430,7 +14430,7 @@ const makeAutoDispose = beginContext((clientId, swarmName, { timeoutSeconds = DE
|
|
|
14430
14430
|
};
|
|
14431
14431
|
});
|
|
14432
14432
|
|
|
14433
|
-
const METHOD_NAME$
|
|
14433
|
+
const METHOD_NAME$n = "function.target.execute";
|
|
14434
14434
|
/**
|
|
14435
14435
|
* Sends a message to the active agent in a swarm session as if it originated from the client side.
|
|
14436
14436
|
*
|
|
@@ -14452,19 +14452,19 @@ const execute = beginContext(async (content, clientId, agentName) => {
|
|
|
14452
14452
|
const executionId = functoolsKit.randomString();
|
|
14453
14453
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14454
14454
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14455
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14455
|
+
swarm$1.loggerService.log(METHOD_NAME$n, {
|
|
14456
14456
|
content,
|
|
14457
14457
|
clientId,
|
|
14458
14458
|
agentName,
|
|
14459
14459
|
executionId,
|
|
14460
14460
|
});
|
|
14461
14461
|
// Validate the agent, session, and swarm
|
|
14462
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
14463
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
14462
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$n);
|
|
14463
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$n);
|
|
14464
14464
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14465
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
14465
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$n);
|
|
14466
14466
|
// Check if the specified agent is still the active agent
|
|
14467
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
14467
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$n, clientId, swarmName);
|
|
14468
14468
|
if (currentAgentName !== agentName) {
|
|
14469
14469
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14470
14470
|
swarm$1.loggerService.log('function "execute" skipped due to the agent change', {
|
|
@@ -14483,7 +14483,7 @@ const execute = beginContext(async (content, clientId, agentName) => {
|
|
|
14483
14483
|
agentName,
|
|
14484
14484
|
swarmName,
|
|
14485
14485
|
});
|
|
14486
|
-
const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$
|
|
14486
|
+
const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$n, clientId, swarmName);
|
|
14487
14487
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
14488
14488
|
swarm$1.busService.commitExecutionEnd(clientId, {
|
|
14489
14489
|
agentName,
|
|
@@ -14503,7 +14503,7 @@ const execute = beginContext(async (content, clientId, agentName) => {
|
|
|
14503
14503
|
});
|
|
14504
14504
|
});
|
|
14505
14505
|
|
|
14506
|
-
const METHOD_NAME$
|
|
14506
|
+
const METHOD_NAME$m = "function.target.emit";
|
|
14507
14507
|
/**
|
|
14508
14508
|
* Emits a string as model output without executing an incoming message, with agent activity validation.
|
|
14509
14509
|
*
|
|
@@ -14523,18 +14523,18 @@ const METHOD_NAME$l = "function.target.emit";
|
|
|
14523
14523
|
const emit = beginContext(async (content, clientId, agentName) => {
|
|
14524
14524
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14525
14525
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14526
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14526
|
+
swarm$1.loggerService.log(METHOD_NAME$m, {
|
|
14527
14527
|
content,
|
|
14528
14528
|
clientId,
|
|
14529
14529
|
agentName,
|
|
14530
14530
|
});
|
|
14531
14531
|
// Validate the agent, session, and swarm
|
|
14532
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
14533
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
14532
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$m);
|
|
14533
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$m);
|
|
14534
14534
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14535
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
14535
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$m);
|
|
14536
14536
|
// Check if the specified agent is still the active agent
|
|
14537
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
14537
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$m, clientId, swarmName);
|
|
14538
14538
|
if (currentAgentName !== agentName) {
|
|
14539
14539
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14540
14540
|
swarm$1.loggerService.log('function "emit" skipped due to the agent change', {
|
|
@@ -14545,10 +14545,10 @@ const emit = beginContext(async (content, clientId, agentName) => {
|
|
|
14545
14545
|
return;
|
|
14546
14546
|
}
|
|
14547
14547
|
// Emit the content directly via the session public service
|
|
14548
|
-
return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$
|
|
14548
|
+
return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$m, clientId, swarmName);
|
|
14549
14549
|
});
|
|
14550
14550
|
|
|
14551
|
-
const METHOD_NAME$
|
|
14551
|
+
const METHOD_NAME$l = "function.target.runStateless";
|
|
14552
14552
|
/**
|
|
14553
14553
|
* Executes a message statelessly with an agent in a swarm session, bypassing chat history.
|
|
14554
14554
|
*
|
|
@@ -14571,19 +14571,19 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
|
|
|
14571
14571
|
const executionId = functoolsKit.randomString();
|
|
14572
14572
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14573
14573
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14574
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14574
|
+
swarm$1.loggerService.log(METHOD_NAME$l, {
|
|
14575
14575
|
content,
|
|
14576
14576
|
clientId,
|
|
14577
14577
|
agentName,
|
|
14578
14578
|
executionId,
|
|
14579
14579
|
});
|
|
14580
14580
|
// Validate the agent, session, and swarm
|
|
14581
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
14582
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
14581
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$l);
|
|
14582
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$l);
|
|
14583
14583
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14584
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
14584
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$l);
|
|
14585
14585
|
// Check if the specified agent is still the active agent
|
|
14586
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
14586
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$l, clientId, swarmName);
|
|
14587
14587
|
if (currentAgentName !== agentName) {
|
|
14588
14588
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14589
14589
|
swarm$1.loggerService.log('function "runStateless" skipped due to the agent change', {
|
|
@@ -14602,7 +14602,7 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
|
|
|
14602
14602
|
agentName,
|
|
14603
14603
|
swarmName,
|
|
14604
14604
|
});
|
|
14605
|
-
const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$
|
|
14605
|
+
const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$l, clientId, swarmName);
|
|
14606
14606
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
14607
14607
|
swarm$1.busService.commitExecutionEnd(clientId, {
|
|
14608
14608
|
agentName,
|
|
@@ -14622,7 +14622,7 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
|
|
|
14622
14622
|
});
|
|
14623
14623
|
});
|
|
14624
14624
|
|
|
14625
|
-
const METHOD_NAME$
|
|
14625
|
+
const METHOD_NAME$k = "function.target.runStatelessForce";
|
|
14626
14626
|
/**
|
|
14627
14627
|
* Executes a message statelessly with the active agent in a swarm session, bypassing chat history and forcing execution regardless of agent activity.
|
|
14628
14628
|
*
|
|
@@ -14643,22 +14643,22 @@ const runStatelessForce = beginContext(async (content, clientId) => {
|
|
|
14643
14643
|
const executionId = functoolsKit.randomString();
|
|
14644
14644
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14645
14645
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14646
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14646
|
+
swarm$1.loggerService.log(METHOD_NAME$k, {
|
|
14647
14647
|
content,
|
|
14648
14648
|
clientId,
|
|
14649
14649
|
executionId,
|
|
14650
14650
|
});
|
|
14651
14651
|
// Validate the session and swarm
|
|
14652
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
14652
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$k);
|
|
14653
14653
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14654
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
14654
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$k);
|
|
14655
14655
|
// Execute the command statelessly within an execution context with performance tracking
|
|
14656
14656
|
return ExecutionContextService.runInContext(async () => {
|
|
14657
14657
|
let isFinished = false;
|
|
14658
14658
|
swarm$1.perfService.startExecution(executionId, clientId, content.length);
|
|
14659
14659
|
try {
|
|
14660
14660
|
swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
|
|
14661
|
-
const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$
|
|
14661
|
+
const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$k, clientId, swarmName);
|
|
14662
14662
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
14663
14663
|
swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
|
|
14664
14664
|
return result;
|
|
@@ -14685,7 +14685,7 @@ const SCHEDULED_DELAY$1 = 1000;
|
|
|
14685
14685
|
* @constant {number}
|
|
14686
14686
|
*/
|
|
14687
14687
|
const RATE_DELAY = 10000;
|
|
14688
|
-
const METHOD_NAME$
|
|
14688
|
+
const METHOD_NAME$j = "function.target.makeConnection";
|
|
14689
14689
|
/**
|
|
14690
14690
|
* Internal implementation of the connection factory for a client to a swarm.
|
|
14691
14691
|
*
|
|
@@ -14700,21 +14700,21 @@ const METHOD_NAME$i = "function.target.makeConnection";
|
|
|
14700
14700
|
const makeConnectionInternal = (connector, clientId, swarmName) => {
|
|
14701
14701
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14702
14702
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14703
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14703
|
+
swarm$1.loggerService.log(METHOD_NAME$j, {
|
|
14704
14704
|
clientId,
|
|
14705
14705
|
swarmName,
|
|
14706
14706
|
});
|
|
14707
14707
|
// Validate the swarm and initialize the session
|
|
14708
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
14708
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$j);
|
|
14709
14709
|
swarm$1.sessionValidationService.addSession(clientId, swarmName, "makeConnection");
|
|
14710
14710
|
// Create a queued send function using the session public service
|
|
14711
|
-
const send = functoolsKit.queued(swarm$1.sessionPublicService.connect(connector, METHOD_NAME$
|
|
14711
|
+
const send = functoolsKit.queued(swarm$1.sessionPublicService.connect(connector, METHOD_NAME$j, clientId, swarmName));
|
|
14712
14712
|
// Return a wrapped send function with validation and agent context
|
|
14713
14713
|
return (async (outgoing) => {
|
|
14714
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
14714
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$j);
|
|
14715
14715
|
return await send({
|
|
14716
14716
|
data: outgoing,
|
|
14717
|
-
agentName: await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
14717
|
+
agentName: await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$j, clientId, swarmName),
|
|
14718
14718
|
clientId,
|
|
14719
14719
|
});
|
|
14720
14720
|
});
|
|
@@ -14797,13 +14797,13 @@ makeConnection.scheduled = (connector, clientId, swarmName, { delay = SCHEDULED_
|
|
|
14797
14797
|
await online();
|
|
14798
14798
|
if (payload) {
|
|
14799
14799
|
return await PayloadContextService.runInContext(async () => {
|
|
14800
|
-
await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$
|
|
14800
|
+
await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$j, clientId, swarmName);
|
|
14801
14801
|
}, {
|
|
14802
14802
|
clientId,
|
|
14803
14803
|
payload,
|
|
14804
14804
|
});
|
|
14805
14805
|
}
|
|
14806
|
-
await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$
|
|
14806
|
+
await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$j, clientId, swarmName);
|
|
14807
14807
|
}),
|
|
14808
14808
|
delay,
|
|
14809
14809
|
});
|
|
@@ -14866,7 +14866,7 @@ makeConnection.rate = (connector, clientId, swarmName, { delay = RATE_DELAY } =
|
|
|
14866
14866
|
};
|
|
14867
14867
|
};
|
|
14868
14868
|
|
|
14869
|
-
const METHOD_NAME$
|
|
14869
|
+
const METHOD_NAME$i = "function.target.complete";
|
|
14870
14870
|
/**
|
|
14871
14871
|
* Time-to-live for the complete function in milliseconds.
|
|
14872
14872
|
* Defines how long the cached complete function remains valid before expiring.
|
|
@@ -14932,7 +14932,7 @@ const complete = beginContext(async (content, clientId, swarmName, payload = nul
|
|
|
14932
14932
|
const executionId = functoolsKit.randomString();
|
|
14933
14933
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14934
14934
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14935
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14935
|
+
swarm$1.loggerService.log(METHOD_NAME$i, {
|
|
14936
14936
|
content,
|
|
14937
14937
|
clientId,
|
|
14938
14938
|
executionId,
|
|
@@ -14949,7 +14949,7 @@ const complete = beginContext(async (content, clientId, swarmName, payload = nul
|
|
|
14949
14949
|
swarm$1.perfService.startExecution(executionId, clientId, content.length);
|
|
14950
14950
|
try {
|
|
14951
14951
|
swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
|
|
14952
|
-
const result = await run(METHOD_NAME$
|
|
14952
|
+
const result = await run(METHOD_NAME$i, content);
|
|
14953
14953
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
14954
14954
|
swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
|
|
14955
14955
|
return result;
|
|
@@ -14979,7 +14979,7 @@ const complete = beginContext(async (content, clientId, swarmName, payload = nul
|
|
|
14979
14979
|
* @constant {number}
|
|
14980
14980
|
*/
|
|
14981
14981
|
const SCHEDULED_DELAY = 1000;
|
|
14982
|
-
const METHOD_NAME$
|
|
14982
|
+
const METHOD_NAME$h = "function.target.session";
|
|
14983
14983
|
/**
|
|
14984
14984
|
* Internal implementation of the session factory for a client and swarm.
|
|
14985
14985
|
*
|
|
@@ -14994,22 +14994,22 @@ const sessionInternal = (clientId, swarmName, { onDispose = () => { } } = {}) =>
|
|
|
14994
14994
|
const executionId = functoolsKit.randomString();
|
|
14995
14995
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14996
14996
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14997
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14997
|
+
swarm$1.loggerService.log(METHOD_NAME$h, {
|
|
14998
14998
|
clientId,
|
|
14999
14999
|
swarmName,
|
|
15000
15000
|
executionId,
|
|
15001
15001
|
});
|
|
15002
15002
|
// Validate the swarm and initialize the session
|
|
15003
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15003
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$h);
|
|
15004
15004
|
swarm$1.sessionValidationService.addSession(clientId, swarmName, "session");
|
|
15005
15005
|
const complete = functoolsKit.queued(async (content) => {
|
|
15006
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
15006
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$h);
|
|
15007
15007
|
return ExecutionContextService.runInContext(async () => {
|
|
15008
15008
|
let isFinished = false;
|
|
15009
15009
|
swarm$1.perfService.startExecution(executionId, clientId, content.length);
|
|
15010
15010
|
try {
|
|
15011
15011
|
swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
|
|
15012
|
-
const result = await swarm$1.sessionPublicService.execute(content, "user", METHOD_NAME$
|
|
15012
|
+
const result = await swarm$1.sessionPublicService.execute(content, "user", METHOD_NAME$h, clientId, swarmName);
|
|
15013
15013
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
15014
15014
|
swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
|
|
15015
15015
|
return result;
|
|
@@ -15030,7 +15030,7 @@ const sessionInternal = (clientId, swarmName, { onDispose = () => { } } = {}) =>
|
|
|
15030
15030
|
return await complete(content);
|
|
15031
15031
|
}),
|
|
15032
15032
|
dispose: async () => {
|
|
15033
|
-
await disposeConnection(clientId, swarmName, METHOD_NAME$
|
|
15033
|
+
await disposeConnection(clientId, swarmName, METHOD_NAME$h);
|
|
15034
15034
|
await onDispose();
|
|
15035
15035
|
},
|
|
15036
15036
|
};
|
|
@@ -15130,13 +15130,13 @@ session.scheduled = (clientId, swarmName, { delay = SCHEDULED_DELAY, onDispose }
|
|
|
15130
15130
|
await online();
|
|
15131
15131
|
if (payload) {
|
|
15132
15132
|
return await PayloadContextService.runInContext(async () => {
|
|
15133
|
-
return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$
|
|
15133
|
+
return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$h, clientId, swarmName);
|
|
15134
15134
|
}, {
|
|
15135
15135
|
clientId,
|
|
15136
15136
|
payload,
|
|
15137
15137
|
});
|
|
15138
15138
|
}
|
|
15139
|
-
return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$
|
|
15139
|
+
return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$h, clientId, swarmName);
|
|
15140
15140
|
}),
|
|
15141
15141
|
delay,
|
|
15142
15142
|
});
|
|
@@ -15215,6 +15215,22 @@ session.rate = (clientId, swarmName, { delay = SCHEDULED_DELAY, onDispose } = {}
|
|
|
15215
15215
|
};
|
|
15216
15216
|
};
|
|
15217
15217
|
|
|
15218
|
+
/** @private Constant defining the method name for logging purposes */
|
|
15219
|
+
const METHOD_NAME$g = "function.common.hasSession";
|
|
15220
|
+
/**
|
|
15221
|
+
* Checks if a session exists for the given client ID.
|
|
15222
|
+
*
|
|
15223
|
+
* This function logs the method name if logging is enabled in the global configuration.
|
|
15224
|
+
* It then delegates the session validation to the `swarm.sessionValidationService`.
|
|
15225
|
+
*
|
|
15226
|
+
* @param {string} clientId - The unique identifier of the client whose session is being validated.
|
|
15227
|
+
* @returns {boolean} `true` if the session exists, otherwise `false`.
|
|
15228
|
+
*/
|
|
15229
|
+
const hasSession = (clientId) => {
|
|
15230
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$g);
|
|
15231
|
+
return swarm$1.sessionValidationService.hasSession(clientId);
|
|
15232
|
+
};
|
|
15233
|
+
|
|
15218
15234
|
const METHOD_NAME$f = "function.common.getAgentName";
|
|
15219
15235
|
/**
|
|
15220
15236
|
* Retrieves the name of the active agent for a given client session in a swarm.
|
|
@@ -16862,140 +16878,137 @@ class SharedStateUtils {
|
|
|
16862
16878
|
*/
|
|
16863
16879
|
const SharedState = new SharedStateUtils();
|
|
16864
16880
|
|
|
16865
|
-
/** @constant {
|
|
16866
|
-
const CHAT_UTILS_METHOD_NAME_BEGIN_CHAT = "ChatUtils.beginChat";
|
|
16867
|
-
/** @constant {string} Method name for sending a message in ChatUtils */
|
|
16868
|
-
const CHAT_UTILS_METHOD_NAME_SEND_MESSAGE = "ChatUtils.sendMessage";
|
|
16869
|
-
/** @constant {string} Method name for listening to dispose events in ChatUtils */
|
|
16870
|
-
const CHAT_UTILS_METHOD_NAME_LISTEN_DISPOSE = "ChatUtils.listenDispose";
|
|
16871
|
-
/** @constant {string} Method name for disposing a chat in ChatUtils */
|
|
16872
|
-
const CHAT_UTILS_METHOD_NAME_DISPOSE = "ChatUtils.dispose";
|
|
16873
|
-
/** @constant {string} Method name for beginning a chat in ChatInstance */
|
|
16874
|
-
const CHAT_INSTANCE_METHOD_NAME_BEGIN_CHAT = "ChatInstance.beginChat";
|
|
16875
|
-
/** @constant {string} Method name for sending a message in ChatInstance */
|
|
16876
|
-
const CHAT_INSTANCE_METHOD_NAME_SEND_MESSAGE = "ChatInstance.sendMessage";
|
|
16877
|
-
/** @constant {string} Method name for disposing a chat in ChatInstance */
|
|
16878
|
-
const CHAT_INSTANCE_METHOD_NAME_DISPOSE = "ChatInstance.dispose";
|
|
16879
|
-
/** @constant {string} Method name for listening to dispose events in ChatInstance */
|
|
16880
|
-
const CHAT_INSTANCE_METHOD_NAME_LISTEN_DISPOSE = "ChatInstance.listenDispose";
|
|
16881
|
-
/** @constant {number} Time interval in milliseconds for inactivity checks (1 minute) */
|
|
16881
|
+
/** @constant {number} INACTIVITY_CHECK - Interval for checking inactivity in milliseconds (1 minute) */
|
|
16882
16882
|
const INACTIVITY_CHECK = 60 * 1000;
|
|
16883
|
-
/** @constant {number}
|
|
16883
|
+
/** @constant {number} INACTIVITY_TIMEOUT - Timeout duration for inactivity in milliseconds (15 minutes) */
|
|
16884
16884
|
const INACTIVITY_TIMEOUT = 15 * 60 * 1000;
|
|
16885
16885
|
/**
|
|
16886
|
-
*
|
|
16887
|
-
* @
|
|
16886
|
+
* @class ChatInstance
|
|
16887
|
+
* @implements {IChatInstance}
|
|
16888
|
+
* @description Implementation of a single chat instance
|
|
16888
16889
|
*/
|
|
16889
16890
|
class ChatInstance {
|
|
16890
16891
|
/**
|
|
16891
|
-
* Gets the timestamp of the last activity
|
|
16892
|
-
* @public
|
|
16893
|
-
* @returns {number} Last activity timestamp in milliseconds
|
|
16894
|
-
*/
|
|
16895
|
-
get lastActivity() {
|
|
16896
|
-
return this._lastActivity;
|
|
16897
|
-
}
|
|
16898
|
-
/**
|
|
16899
|
-
* Creates a new ChatInstance
|
|
16900
16892
|
* @constructor
|
|
16901
|
-
* @param {SessionId} clientId - Unique identifier
|
|
16902
|
-
* @param {SwarmName} swarmName - Name of the swarm
|
|
16903
|
-
* @param {
|
|
16893
|
+
* @param {SessionId} clientId - Unique client identifier
|
|
16894
|
+
* @param {SwarmName} swarmName - Name of the swarm
|
|
16895
|
+
* @param {Partial<IChatInstanceCallbacks>} callbacks - Event callbacks
|
|
16896
|
+
* @param {DisposeFn} onDispose - Dispose callback function
|
|
16904
16897
|
*/
|
|
16905
|
-
constructor(clientId, swarmName, onDispose) {
|
|
16898
|
+
constructor(clientId, swarmName, onDispose, callbacks) {
|
|
16906
16899
|
this.clientId = clientId;
|
|
16907
16900
|
this.swarmName = swarmName;
|
|
16908
16901
|
this.onDispose = onDispose;
|
|
16909
|
-
|
|
16910
|
-
|
|
16911
|
-
|
|
16902
|
+
this.callbacks = callbacks;
|
|
16903
|
+
/** @private */
|
|
16904
|
+
this._disposeSubject = new functoolsKit.Subject();
|
|
16905
|
+
/** @private */
|
|
16912
16906
|
this._lastActivity = Date.now();
|
|
16913
|
-
|
|
16914
|
-
|
|
16915
|
-
|
|
16916
|
-
|
|
16917
|
-
|
|
16918
|
-
|
|
16919
|
-
this.beginChat = () => {
|
|
16920
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
16921
|
-
swarm$1.loggerService.debug(CHAT_INSTANCE_METHOD_NAME_BEGIN_CHAT, {
|
|
16922
|
-
clientId: this.clientId,
|
|
16923
|
-
swarmName: this.swarmName,
|
|
16924
|
-
timestamp: new Date().toISOString(),
|
|
16925
|
-
});
|
|
16926
|
-
return Promise.resolve();
|
|
16927
|
-
};
|
|
16928
|
-
/**
|
|
16929
|
-
* Sends a message through the chat session
|
|
16930
|
-
* @public
|
|
16931
|
-
* @async
|
|
16932
|
-
* @param {string} content - The message content to send
|
|
16933
|
-
* @returns {Promise<any>} Result of the message completion
|
|
16934
|
-
*/
|
|
16935
|
-
this.sendMessage = async (content) => {
|
|
16936
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
16937
|
-
swarm$1.loggerService.debug(CHAT_INSTANCE_METHOD_NAME_SEND_MESSAGE, {
|
|
16938
|
-
content,
|
|
16939
|
-
clientId: this.clientId,
|
|
16940
|
-
swarmName: this.swarmName,
|
|
16941
|
-
timestamp: new Date().toISOString(),
|
|
16942
|
-
});
|
|
16943
|
-
this._lastActivity = Date.now();
|
|
16944
|
-
return await this.chatSession.complete(content);
|
|
16945
|
-
};
|
|
16946
|
-
/**
|
|
16947
|
-
* Disposes of the chat instance and cleans up resources
|
|
16948
|
-
* @public
|
|
16949
|
-
* @async
|
|
16950
|
-
* @returns {Promise<void>} Promise that resolves when disposal is complete
|
|
16951
|
-
*/
|
|
16952
|
-
this.dispose = async () => {
|
|
16953
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
16954
|
-
swarm$1.loggerService.debug(CHAT_INSTANCE_METHOD_NAME_DISPOSE, {
|
|
16955
|
-
clientId: this.clientId,
|
|
16956
|
-
swarmName: this.swarmName,
|
|
16957
|
-
timestamp: new Date().toISOString(),
|
|
16958
|
-
});
|
|
16959
|
-
await this.disposeSubject.next(this.clientId);
|
|
16960
|
-
await this.chatSession.dispose();
|
|
16961
|
-
};
|
|
16962
|
-
/**
|
|
16963
|
-
* Subscribes to disposal events for this chat instance
|
|
16964
|
-
* @public
|
|
16965
|
-
* @param {(clientId: SessionId) => void} fn - Callback function to execute on disposal
|
|
16966
|
-
* @returns {any} Subscription object for managing the subscription
|
|
16967
|
-
*/
|
|
16968
|
-
this.listenDispose = (fn) => {
|
|
16969
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
16970
|
-
swarm$1.loggerService.debug(CHAT_INSTANCE_METHOD_NAME_LISTEN_DISPOSE, {
|
|
16971
|
-
clientId: this.clientId,
|
|
16972
|
-
swarmName: this.swarmName,
|
|
16973
|
-
});
|
|
16974
|
-
return this.disposeSubject.once(fn);
|
|
16975
|
-
};
|
|
16976
|
-
this.chatSession = session(this.clientId, this.swarmName, {
|
|
16907
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
16908
|
+
swarm$1.loggerService.debug("ChatInstance CTOR", {
|
|
16909
|
+
clientId: this.clientId,
|
|
16910
|
+
swarmName: this.swarmName,
|
|
16911
|
+
});
|
|
16912
|
+
this._chatSession = session(this.clientId, this.swarmName, {
|
|
16977
16913
|
onDispose: this.onDispose,
|
|
16978
16914
|
});
|
|
16915
|
+
this.callbacks.onInit &&
|
|
16916
|
+
this.callbacks.onInit(this.clientId, this.swarmName, this);
|
|
16917
|
+
}
|
|
16918
|
+
/**
|
|
16919
|
+
* Checks if the chat has been active within the timeout period
|
|
16920
|
+
* @param {number} now - Current timestamp
|
|
16921
|
+
* @returns {boolean} Whether the chat is still active
|
|
16922
|
+
*/
|
|
16923
|
+
async checkLastActivity(now) {
|
|
16924
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
16925
|
+
swarm$1.loggerService.debug("ChatInstance.checkLastActivity", {
|
|
16926
|
+
clientId: this.clientId,
|
|
16927
|
+
swarmName: this.swarmName,
|
|
16928
|
+
});
|
|
16929
|
+
const isActive = now - this._lastActivity <= INACTIVITY_TIMEOUT;
|
|
16930
|
+
this.callbacks.onCheckActivity &&
|
|
16931
|
+
this.callbacks.onCheckActivity(this.clientId, this.swarmName, isActive, this._lastActivity);
|
|
16932
|
+
return isActive;
|
|
16933
|
+
}
|
|
16934
|
+
/**
|
|
16935
|
+
* Begins a chat session
|
|
16936
|
+
* @returns {Promise<void>}
|
|
16937
|
+
*/
|
|
16938
|
+
beginChat() {
|
|
16939
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
16940
|
+
swarm$1.loggerService.debug("ChatInstance.beginChat", {
|
|
16941
|
+
clientId: this.clientId,
|
|
16942
|
+
swarmName: this.swarmName,
|
|
16943
|
+
});
|
|
16944
|
+
this.callbacks.onBeginChat &&
|
|
16945
|
+
this.callbacks.onBeginChat(this.clientId, this.swarmName);
|
|
16946
|
+
return Promise.resolve();
|
|
16947
|
+
}
|
|
16948
|
+
/**
|
|
16949
|
+
* Sends a message in the chat
|
|
16950
|
+
* @param {string} content - Message content to send
|
|
16951
|
+
* @returns {Promise<string>} Response from the chat session
|
|
16952
|
+
*/
|
|
16953
|
+
async sendMessage(content) {
|
|
16954
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
16955
|
+
swarm$1.loggerService.debug("ChatInstance.sendMessage", {
|
|
16956
|
+
content,
|
|
16957
|
+
clientId: this.clientId,
|
|
16958
|
+
swarmName: this.swarmName,
|
|
16959
|
+
});
|
|
16960
|
+
this._lastActivity = Date.now();
|
|
16961
|
+
this.callbacks.onSendMessage &&
|
|
16962
|
+
this.callbacks.onSendMessage(this.clientId, this.swarmName, content);
|
|
16963
|
+
return await this._chatSession.complete(content);
|
|
16964
|
+
}
|
|
16965
|
+
/**
|
|
16966
|
+
* Disposes of the chat instance
|
|
16967
|
+
* @returns {Promise<void>}
|
|
16968
|
+
*/
|
|
16969
|
+
async dispose() {
|
|
16970
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
16971
|
+
swarm$1.loggerService.debug("ChatInstance.dispose", {
|
|
16972
|
+
clientId: this.clientId,
|
|
16973
|
+
swarmName: this.swarmName,
|
|
16974
|
+
});
|
|
16975
|
+
await this._disposeSubject.next(this.clientId);
|
|
16976
|
+
await this._chatSession.dispose();
|
|
16977
|
+
this.callbacks.onDispose &&
|
|
16978
|
+
this.callbacks.onDispose(this.clientId, this.swarmName, this);
|
|
16979
|
+
}
|
|
16980
|
+
/**
|
|
16981
|
+
* Adds a listener for dispose events
|
|
16982
|
+
* @param {(clientId: SessionId) => void} fn - Callback function to execute on dispose
|
|
16983
|
+
*/
|
|
16984
|
+
listenDispose(fn) {
|
|
16985
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_DEBUG &&
|
|
16986
|
+
swarm$1.loggerService.debug("ChatInstance.listenDispose", {
|
|
16987
|
+
clientId: this.clientId,
|
|
16988
|
+
swarmName: this.swarmName,
|
|
16989
|
+
});
|
|
16990
|
+
return this._disposeSubject.once(fn);
|
|
16979
16991
|
}
|
|
16980
16992
|
}
|
|
16981
16993
|
/**
|
|
16982
|
-
*
|
|
16983
|
-
* @
|
|
16994
|
+
* @class ChatUtils
|
|
16995
|
+
* @implements {IChatControl}
|
|
16996
|
+
* @description Utility class for managing multiple chat instances
|
|
16984
16997
|
*/
|
|
16985
16998
|
class ChatUtils {
|
|
16986
16999
|
constructor() {
|
|
16987
|
-
/** @private
|
|
17000
|
+
/** @private */
|
|
17001
|
+
this.ChatInstanceFactory = ChatInstance;
|
|
17002
|
+
/** @private */
|
|
17003
|
+
this.ChatInstanceCallbacks = {};
|
|
17004
|
+
/** @private */
|
|
16988
17005
|
this._chats = new Map();
|
|
16989
|
-
/**
|
|
16990
|
-
* Initializes cleanup interval for inactive chats
|
|
16991
|
-
* @private
|
|
16992
|
-
* @returns {void}
|
|
16993
|
-
*/
|
|
17006
|
+
/** @private */
|
|
16994
17007
|
this.initializeCleanup = functoolsKit.singleshot(() => {
|
|
16995
17008
|
const handleCleanup = async () => {
|
|
16996
17009
|
const now = Date.now();
|
|
16997
17010
|
for (const chat of this._chats.values()) {
|
|
16998
|
-
if (
|
|
17011
|
+
if (!chat.checkLastActivity(now)) {
|
|
16999
17012
|
await chat.dispose();
|
|
17000
17013
|
}
|
|
17001
17014
|
}
|
|
@@ -17005,30 +17018,31 @@ class ChatUtils {
|
|
|
17005
17018
|
/**
|
|
17006
17019
|
* Gets or creates a chat instance for a client
|
|
17007
17020
|
* @private
|
|
17008
|
-
* @param {SessionId} clientId - Unique identifier
|
|
17021
|
+
* @param {SessionId} clientId - Unique client identifier
|
|
17009
17022
|
* @param {SwarmName} swarmName - Name of the swarm
|
|
17010
|
-
* @returns {
|
|
17023
|
+
* @returns {IChatInstance} The chat instance for the given client
|
|
17011
17024
|
*/
|
|
17012
17025
|
this.getChatInstance = (clientId, swarmName) => {
|
|
17013
17026
|
return this._chats.has(clientId)
|
|
17014
17027
|
? this._chats.get(clientId)
|
|
17015
17028
|
: this._chats
|
|
17016
|
-
.set(clientId,
|
|
17017
|
-
|
|
17018
|
-
|
|
17029
|
+
.set(clientId, Reflect.construct(this.ChatInstanceFactory, [
|
|
17030
|
+
clientId,
|
|
17031
|
+
swarmName,
|
|
17032
|
+
() => this._chats.delete(clientId),
|
|
17033
|
+
this.ChatInstanceCallbacks,
|
|
17034
|
+
]))
|
|
17019
17035
|
.get(clientId);
|
|
17020
17036
|
};
|
|
17021
17037
|
/**
|
|
17022
17038
|
* Begins a chat session for a client
|
|
17023
|
-
* @
|
|
17024
|
-
* @async
|
|
17025
|
-
* @param {SessionId} clientId - Unique identifier for the client
|
|
17039
|
+
* @param {SessionId} clientId - Unique client identifier
|
|
17026
17040
|
* @param {SwarmName} swarmName - Name of the swarm
|
|
17027
|
-
* @returns {Promise<void>}
|
|
17041
|
+
* @returns {Promise<void>}
|
|
17028
17042
|
*/
|
|
17029
17043
|
this.beginChat = async (clientId, swarmName) => {
|
|
17030
17044
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17031
|
-
swarm$1.loggerService.log(
|
|
17045
|
+
swarm$1.loggerService.log("ChatUtils.beginChat", {
|
|
17032
17046
|
clientId,
|
|
17033
17047
|
swarmName,
|
|
17034
17048
|
});
|
|
@@ -17036,17 +17050,15 @@ class ChatUtils {
|
|
|
17036
17050
|
return await this.getChatInstance(clientId, swarmName).beginChat();
|
|
17037
17051
|
};
|
|
17038
17052
|
/**
|
|
17039
|
-
* Sends a message for a
|
|
17040
|
-
* @
|
|
17041
|
-
* @
|
|
17042
|
-
* @param {SessionId} clientId - Unique identifier for the client
|
|
17043
|
-
* @param {string} message - Message content to send
|
|
17053
|
+
* Sends a message for a client
|
|
17054
|
+
* @param {SessionId} clientId - Unique client identifier
|
|
17055
|
+
* @param {string} message - Message content
|
|
17044
17056
|
* @param {SwarmName} swarmName - Name of the swarm
|
|
17045
|
-
* @returns {Promise<
|
|
17057
|
+
* @returns {Promise<string>}
|
|
17046
17058
|
*/
|
|
17047
17059
|
this.sendMessage = async (clientId, message, swarmName) => {
|
|
17048
17060
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17049
|
-
swarm$1.loggerService.log(
|
|
17061
|
+
swarm$1.loggerService.log("ChatUtils.sendMessage", {
|
|
17050
17062
|
clientId,
|
|
17051
17063
|
message,
|
|
17052
17064
|
swarmName,
|
|
@@ -17055,32 +17067,28 @@ class ChatUtils {
|
|
|
17055
17067
|
return await this.getChatInstance(clientId, swarmName).sendMessage(message);
|
|
17056
17068
|
};
|
|
17057
17069
|
/**
|
|
17058
|
-
*
|
|
17059
|
-
* @
|
|
17060
|
-
* @param {SessionId} clientId - Unique identifier for the client
|
|
17070
|
+
* Listens for dispose events for a client
|
|
17071
|
+
* @param {SessionId} clientId - Unique client identifier
|
|
17061
17072
|
* @param {SwarmName} swarmName - Name of the swarm
|
|
17062
|
-
* @param {(clientId: SessionId) => void} fn -
|
|
17063
|
-
* @returns {any} Subscription object for managing the subscription
|
|
17073
|
+
* @param {(clientId: SessionId) => void} fn - Dispose callback
|
|
17064
17074
|
*/
|
|
17065
17075
|
this.listenDispose = (clientId, swarmName, fn) => {
|
|
17066
17076
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17067
|
-
swarm$1.loggerService.log(
|
|
17077
|
+
swarm$1.loggerService.log("ChatUtils.listenDispose", {
|
|
17068
17078
|
clientId,
|
|
17069
17079
|
swarmName,
|
|
17070
17080
|
});
|
|
17071
17081
|
return this.getChatInstance(clientId, swarmName).listenDispose(fn);
|
|
17072
17082
|
};
|
|
17073
17083
|
/**
|
|
17074
|
-
* Disposes of a
|
|
17075
|
-
* @
|
|
17076
|
-
* @async
|
|
17077
|
-
* @param {SessionId} clientId - Unique identifier for the client
|
|
17084
|
+
* Disposes of a chat instance
|
|
17085
|
+
* @param {SessionId} clientId - Unique client identifier
|
|
17078
17086
|
* @param {SwarmName} swarmName - Name of the swarm
|
|
17079
|
-
* @returns {Promise<void>}
|
|
17087
|
+
* @returns {Promise<void>}
|
|
17080
17088
|
*/
|
|
17081
17089
|
this.dispose = async (clientId, swarmName) => {
|
|
17082
17090
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17083
|
-
swarm$1.loggerService.log(
|
|
17091
|
+
swarm$1.loggerService.log("ChatUtils.dispose", {
|
|
17084
17092
|
clientId,
|
|
17085
17093
|
swarmName,
|
|
17086
17094
|
});
|
|
@@ -17090,8 +17098,29 @@ class ChatUtils {
|
|
|
17090
17098
|
return await this.getChatInstance(clientId, swarmName).dispose();
|
|
17091
17099
|
};
|
|
17092
17100
|
}
|
|
17101
|
+
/**
|
|
17102
|
+
* Sets the chat instance constructor
|
|
17103
|
+
* @param {TChatInstanceCtor} Ctor - Chat instance constructor
|
|
17104
|
+
*/
|
|
17105
|
+
useChatAdapter(Ctor) {
|
|
17106
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17107
|
+
swarm$1.loggerService.log("ChatUtils.useChatAdapter");
|
|
17108
|
+
this.ChatInstanceFactory = Ctor;
|
|
17109
|
+
}
|
|
17110
|
+
/**
|
|
17111
|
+
* Sets chat instance callbacks
|
|
17112
|
+
* @param {Partial<IChatInstanceCallbacks>} Callbacks - Callback implementations
|
|
17113
|
+
*/
|
|
17114
|
+
useChatCallbacks(Callbacks) {
|
|
17115
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17116
|
+
swarm$1.loggerService.log("ChatUtils.useChatCallbacks");
|
|
17117
|
+
Object.assign(this.ChatInstanceCallbacks, Callbacks);
|
|
17118
|
+
}
|
|
17093
17119
|
}
|
|
17094
|
-
/**
|
|
17120
|
+
/**
|
|
17121
|
+
* @constant {ChatUtils} Chat
|
|
17122
|
+
* @description Singleton instance of ChatUtils
|
|
17123
|
+
*/
|
|
17095
17124
|
const Chat = new ChatUtils();
|
|
17096
17125
|
|
|
17097
17126
|
/** @private Constant for logging the take method in StorageUtils */
|
|
@@ -17953,6 +17982,7 @@ exports.getRawHistory = getRawHistory;
|
|
|
17953
17982
|
exports.getSessionContext = getSessionContext;
|
|
17954
17983
|
exports.getSessionMode = getSessionMode;
|
|
17955
17984
|
exports.getUserHistory = getUserHistory;
|
|
17985
|
+
exports.hasSession = hasSession;
|
|
17956
17986
|
exports.listenAgentEvent = listenAgentEvent;
|
|
17957
17987
|
exports.listenAgentEventOnce = listenAgentEventOnce;
|
|
17958
17988
|
exports.listenEvent = listenEvent;
|