agent-swarm-kit 1.1.5 → 1.1.6
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 +499 -401
- package/build/index.mjs +500 -403
- package/package.json +1 -1
- package/types.d.ts +68 -3
package/build/index.cjs
CHANGED
|
@@ -4840,7 +4840,7 @@ class AgentConnectionService {
|
|
|
4840
4840
|
}
|
|
4841
4841
|
|
|
4842
4842
|
/** @private Constant defining the method name for logging purposes */
|
|
4843
|
-
const METHOD_NAME$
|
|
4843
|
+
const METHOD_NAME$1b = "function.common.getPayload";
|
|
4844
4844
|
/**
|
|
4845
4845
|
* Retrieves the payload from the current PayloadContextService context.
|
|
4846
4846
|
* Returns null if no context is available. Logs the operation if logging is enabled.
|
|
@@ -4851,7 +4851,7 @@ const METHOD_NAME$1a = "function.common.getPayload";
|
|
|
4851
4851
|
* console.log(payload); // { id: number } or null
|
|
4852
4852
|
*/
|
|
4853
4853
|
const getPayload = () => {
|
|
4854
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$
|
|
4854
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$1b);
|
|
4855
4855
|
if (PayloadContextService.hasContext()) {
|
|
4856
4856
|
const { payload } = swarm$1.payloadContextService.context;
|
|
4857
4857
|
return payload;
|
|
@@ -14523,7 +14523,7 @@ const swarm = {
|
|
|
14523
14523
|
init();
|
|
14524
14524
|
var swarm$1 = swarm;
|
|
14525
14525
|
|
|
14526
|
-
const METHOD_NAME$
|
|
14526
|
+
const METHOD_NAME$1a = "cli.dumpDocs";
|
|
14527
14527
|
/**
|
|
14528
14528
|
* Dumps the documentation for the agents and swarms.
|
|
14529
14529
|
*
|
|
@@ -14533,7 +14533,7 @@ const METHOD_NAME$19 = "cli.dumpDocs";
|
|
|
14533
14533
|
*/
|
|
14534
14534
|
const dumpDocs = beginContext((prefix = "swarm", dirName = "./docs/chat", PlantUML) => {
|
|
14535
14535
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14536
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14536
|
+
swarm$1.loggerService.log(METHOD_NAME$1a, {
|
|
14537
14537
|
dirName,
|
|
14538
14538
|
});
|
|
14539
14539
|
if (PlantUML) {
|
|
@@ -14543,10 +14543,10 @@ const dumpDocs = beginContext((prefix = "swarm", dirName = "./docs/chat", PlantU
|
|
|
14543
14543
|
}
|
|
14544
14544
|
swarm$1.agentValidationService
|
|
14545
14545
|
.getAgentList()
|
|
14546
|
-
.forEach((agentName) => swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
14546
|
+
.forEach((agentName) => swarm$1.agentValidationService.validate(agentName, METHOD_NAME$1a));
|
|
14547
14547
|
swarm$1.swarmValidationService
|
|
14548
14548
|
.getSwarmList()
|
|
14549
|
-
.forEach((swarmName) => swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
14549
|
+
.forEach((swarmName) => swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$1a));
|
|
14550
14550
|
swarm$1.agentValidationService.getAgentList().forEach((agentName) => {
|
|
14551
14551
|
const { dependsOn } = swarm$1.agentSchemaService.get(agentName);
|
|
14552
14552
|
if (!dependsOn) {
|
|
@@ -14556,7 +14556,7 @@ const dumpDocs = beginContext((prefix = "swarm", dirName = "./docs/chat", PlantU
|
|
|
14556
14556
|
return swarm$1.docService.dumpDocs(prefix, dirName);
|
|
14557
14557
|
});
|
|
14558
14558
|
|
|
14559
|
-
const METHOD_NAME$
|
|
14559
|
+
const METHOD_NAME$19 = "cli.dumpAgent";
|
|
14560
14560
|
/**
|
|
14561
14561
|
* Dumps the agent information into PlantUML format.
|
|
14562
14562
|
*
|
|
@@ -14565,14 +14565,14 @@ const METHOD_NAME$18 = "cli.dumpAgent";
|
|
|
14565
14565
|
*/
|
|
14566
14566
|
const dumpAgent = beginContext((agentName, { withSubtree = false } = {}) => {
|
|
14567
14567
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14568
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14568
|
+
swarm$1.loggerService.log(METHOD_NAME$19, {
|
|
14569
14569
|
agentName,
|
|
14570
14570
|
});
|
|
14571
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
14571
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$19);
|
|
14572
14572
|
return swarm$1.agentMetaService.toUML(agentName, withSubtree);
|
|
14573
14573
|
});
|
|
14574
14574
|
|
|
14575
|
-
const METHOD_NAME$
|
|
14575
|
+
const METHOD_NAME$18 = "cli.dumpSwarm";
|
|
14576
14576
|
/**
|
|
14577
14577
|
* Dumps the swarm information into PlantUML format.
|
|
14578
14578
|
*
|
|
@@ -14581,14 +14581,14 @@ const METHOD_NAME$17 = "cli.dumpSwarm";
|
|
|
14581
14581
|
*/
|
|
14582
14582
|
const dumpSwarm = beginContext((swarmName) => {
|
|
14583
14583
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14584
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14584
|
+
swarm$1.loggerService.log(METHOD_NAME$18, {
|
|
14585
14585
|
swarmName,
|
|
14586
14586
|
});
|
|
14587
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
14587
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$18);
|
|
14588
14588
|
return swarm$1.swarmMetaService.toUML(swarmName);
|
|
14589
14589
|
});
|
|
14590
14590
|
|
|
14591
|
-
const METHOD_NAME$
|
|
14591
|
+
const METHOD_NAME$17 = "cli.dumpPerfomance";
|
|
14592
14592
|
const METHOD_NAME_INTERNAL$1 = "cli.dumpPerfomance.internal";
|
|
14593
14593
|
const METHOD_NAME_INTERVAL = "cli.dumpPerfomance.interval";
|
|
14594
14594
|
/**
|
|
@@ -14607,7 +14607,7 @@ const dumpPerfomanceInternal = beginContext(async (dirName = "./logs/meta") => {
|
|
|
14607
14607
|
* @returns {Promise<void>} A promise that resolves when the performance data has been dumped.
|
|
14608
14608
|
*/
|
|
14609
14609
|
const dumpPerfomance = async (dirName = "./logs/meta") => {
|
|
14610
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$
|
|
14610
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$17);
|
|
14611
14611
|
await dumpPerfomanceInternal(dirName);
|
|
14612
14612
|
};
|
|
14613
14613
|
/**
|
|
@@ -14665,7 +14665,7 @@ const listenExecutionEvent = beginContext((clientId, fn) => {
|
|
|
14665
14665
|
return swarm$1.busService.subscribe(clientId, "execution-bus", functoolsKit.queued(async (e) => await fn(e)));
|
|
14666
14666
|
});
|
|
14667
14667
|
|
|
14668
|
-
const METHOD_NAME$
|
|
14668
|
+
const METHOD_NAME$16 = "cli.dumpClientPerformance";
|
|
14669
14669
|
const METHOD_NAME_INTERNAL = "cli.dumpClientPerformance.internal";
|
|
14670
14670
|
const METHOD_NAME_EXECUTE = "cli.dumpClientPerformance.execute";
|
|
14671
14671
|
/**
|
|
@@ -14689,7 +14689,7 @@ const dumpClientPerformanceInternal = beginContext(async (clientId, dirName = ".
|
|
|
14689
14689
|
* @returns {Promise<void>} A promise that resolves when the performance data has been dumped.
|
|
14690
14690
|
*/
|
|
14691
14691
|
const dumpClientPerformance = async (clientId, dirName = "./logs/client") => {
|
|
14692
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$
|
|
14692
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$16);
|
|
14693
14693
|
await dumpClientPerformanceInternal(clientId, dirName);
|
|
14694
14694
|
};
|
|
14695
14695
|
/**
|
|
@@ -14710,7 +14710,7 @@ dumpClientPerformance.runAfterExecute = beginContext(async (dirName = "./logs/cl
|
|
|
14710
14710
|
});
|
|
14711
14711
|
|
|
14712
14712
|
/** @private Constant defining the method name for logging and validation context */
|
|
14713
|
-
const METHOD_NAME$
|
|
14713
|
+
const METHOD_NAME$15 = "function.commit.commitFlushForce";
|
|
14714
14714
|
/**
|
|
14715
14715
|
* Forcefully commits a flush of agent history for a specific client in the swarm system, without checking the active agent.
|
|
14716
14716
|
* Validates the session and swarm, then proceeds with flushing the history regardless of the current agent state.
|
|
@@ -14728,20 +14728,20 @@ const METHOD_NAME$14 = "function.commit.commitFlushForce";
|
|
|
14728
14728
|
const commitFlushForce = beginContext(async (clientId) => {
|
|
14729
14729
|
// Log the flush attempt if enabled
|
|
14730
14730
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14731
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14731
|
+
swarm$1.loggerService.log(METHOD_NAME$15, {
|
|
14732
14732
|
clientId,
|
|
14733
|
-
METHOD_NAME: METHOD_NAME$
|
|
14733
|
+
METHOD_NAME: METHOD_NAME$15,
|
|
14734
14734
|
});
|
|
14735
14735
|
// Validate the session exists and retrieve the associated swarm
|
|
14736
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
14736
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$15);
|
|
14737
14737
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14738
14738
|
// Validate the swarm configuration
|
|
14739
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
14739
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$15);
|
|
14740
14740
|
// Commit the flush of agent history via SessionPublicService without agent checks
|
|
14741
|
-
await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$
|
|
14741
|
+
await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$15, clientId, swarmName);
|
|
14742
14742
|
});
|
|
14743
14743
|
|
|
14744
|
-
const METHOD_NAME$
|
|
14744
|
+
const METHOD_NAME$14 = "function.commit.commitToolOutputForce";
|
|
14745
14745
|
/**
|
|
14746
14746
|
* Commits the output of a tool execution to the active agent in a swarm session without checking the active agent.
|
|
14747
14747
|
*
|
|
@@ -14760,24 +14760,24 @@ const METHOD_NAME$13 = "function.commit.commitToolOutputForce";
|
|
|
14760
14760
|
const commitToolOutputForce = beginContext(async (toolId, content, clientId) => {
|
|
14761
14761
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14762
14762
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14763
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14763
|
+
swarm$1.loggerService.log(METHOD_NAME$14, {
|
|
14764
14764
|
toolId,
|
|
14765
14765
|
content,
|
|
14766
14766
|
clientId,
|
|
14767
14767
|
});
|
|
14768
14768
|
// Validate the session and swarm to ensure they exist and are accessible
|
|
14769
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
14769
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$14);
|
|
14770
14770
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14771
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
14771
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$14);
|
|
14772
14772
|
// Commit the tool output to the session via the session public service without checking the active agent
|
|
14773
|
-
await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$
|
|
14773
|
+
await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$14, clientId, swarmName);
|
|
14774
14774
|
});
|
|
14775
14775
|
|
|
14776
14776
|
/**
|
|
14777
14777
|
* @private Constant defining the method name for logging and validation purposes.
|
|
14778
14778
|
* Used as an identifier in log messages and validation checks to track calls to `hasNavigation`.
|
|
14779
14779
|
*/
|
|
14780
|
-
const METHOD_NAME$
|
|
14780
|
+
const METHOD_NAME$13 = "function.common.hasNavigation";
|
|
14781
14781
|
/**
|
|
14782
14782
|
* Checks if a specific agent is part of the navigation route for a given client.
|
|
14783
14783
|
* Validates the agent and client session, retrieves the associated swarm, and queries the navigation route.
|
|
@@ -14788,16 +14788,16 @@ const METHOD_NAME$12 = "function.common.hasNavigation";
|
|
|
14788
14788
|
*/
|
|
14789
14789
|
const hasNavigation = async (clientId, agentName) => {
|
|
14790
14790
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14791
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14792
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
14793
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
14791
|
+
swarm$1.loggerService.log(METHOD_NAME$13, { clientId });
|
|
14792
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$13);
|
|
14793
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$13);
|
|
14794
14794
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14795
14795
|
return swarm$1.navigationValidationService
|
|
14796
14796
|
.getNavigationRoute(clientId, swarmName)
|
|
14797
14797
|
.has(agentName);
|
|
14798
14798
|
};
|
|
14799
14799
|
|
|
14800
|
-
const METHOD_NAME$
|
|
14800
|
+
const METHOD_NAME$12 = "function.history.getRawHistory";
|
|
14801
14801
|
/**
|
|
14802
14802
|
* Retrieves the raw, unmodified history for a given client session.
|
|
14803
14803
|
*
|
|
@@ -14814,10 +14814,10 @@ const METHOD_NAME$11 = "function.history.getRawHistory";
|
|
|
14814
14814
|
* const rawHistory = await getRawHistory("client-123");
|
|
14815
14815
|
* console.log(rawHistory); // Outputs the full raw history array
|
|
14816
14816
|
*/
|
|
14817
|
-
const getRawHistory = beginContext(async (clientId, methodName = METHOD_NAME$
|
|
14817
|
+
const getRawHistory = beginContext(async (clientId, methodName = METHOD_NAME$12) => {
|
|
14818
14818
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14819
14819
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14820
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14820
|
+
swarm$1.loggerService.log(METHOD_NAME$12, {
|
|
14821
14821
|
clientId,
|
|
14822
14822
|
});
|
|
14823
14823
|
// Validate the session and swarm
|
|
@@ -14830,7 +14830,7 @@ const getRawHistory = beginContext(async (clientId, methodName = METHOD_NAME$11)
|
|
|
14830
14830
|
return [...history];
|
|
14831
14831
|
});
|
|
14832
14832
|
|
|
14833
|
-
const METHOD_NAME$
|
|
14833
|
+
const METHOD_NAME$11 = "function.history.getLastUserMessage";
|
|
14834
14834
|
/**
|
|
14835
14835
|
* Retrieves the content of the most recent user message from a client's session history.
|
|
14836
14836
|
*
|
|
@@ -14848,16 +14848,16 @@ const METHOD_NAME$10 = "function.history.getLastUserMessage";
|
|
|
14848
14848
|
const getLastUserMessage = beginContext(async (clientId) => {
|
|
14849
14849
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14850
14850
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14851
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
14851
|
+
swarm$1.loggerService.log(METHOD_NAME$11, {
|
|
14852
14852
|
clientId,
|
|
14853
14853
|
});
|
|
14854
14854
|
// Fetch raw history and find the last user message
|
|
14855
|
-
const history = await getRawHistory(clientId, METHOD_NAME$
|
|
14855
|
+
const history = await getRawHistory(clientId, METHOD_NAME$11);
|
|
14856
14856
|
const last = history.findLast(({ role, mode }) => role === "user" && mode === "user");
|
|
14857
14857
|
return last ? last.content : null;
|
|
14858
14858
|
});
|
|
14859
14859
|
|
|
14860
|
-
const METHOD_NAME
|
|
14860
|
+
const METHOD_NAME$10 = "function.navigate.changeToDefaultAgent";
|
|
14861
14861
|
/**
|
|
14862
14862
|
* Time-to-live for the change agent function in milliseconds.
|
|
14863
14863
|
* Defines how long the cached change agent function remains valid before expiring.
|
|
@@ -14892,7 +14892,7 @@ const createChangeToDefaultAgent = functoolsKit.ttl((clientId) => functoolsKit.q
|
|
|
14892
14892
|
}));
|
|
14893
14893
|
{
|
|
14894
14894
|
// Dispose of the current agent's resources and set up the new default agent
|
|
14895
|
-
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME
|
|
14895
|
+
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$10, clientId, swarmName);
|
|
14896
14896
|
await swarm$1.agentPublicService.dispose(methodName, clientId, agentName);
|
|
14897
14897
|
await swarm$1.historyPublicService.dispose(methodName, clientId, agentName);
|
|
14898
14898
|
await swarm$1.swarmPublicService.setAgentRef(methodName, clientId, swarmName, agentName, await swarm$1.agentPublicService.createAgentRef(methodName, clientId, agentName));
|
|
@@ -14931,23 +14931,23 @@ const createGc$3 = functoolsKit.singleshot(async () => {
|
|
|
14931
14931
|
const changeToDefaultAgent = beginContext(async (clientId) => {
|
|
14932
14932
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14933
14933
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14934
|
-
swarm$1.loggerService.log(METHOD_NAME
|
|
14934
|
+
swarm$1.loggerService.log(METHOD_NAME$10, {
|
|
14935
14935
|
clientId,
|
|
14936
14936
|
});
|
|
14937
14937
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14938
14938
|
const { defaultAgent: agentName } = swarm$1.swarmSchemaService.get(swarmName);
|
|
14939
14939
|
{
|
|
14940
14940
|
// Validate session and default agent
|
|
14941
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME
|
|
14942
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME
|
|
14941
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$10);
|
|
14942
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$10);
|
|
14943
14943
|
}
|
|
14944
14944
|
// Execute the agent change with TTL and queuing
|
|
14945
14945
|
const run = await createChangeToDefaultAgent(clientId);
|
|
14946
14946
|
createGc$3();
|
|
14947
|
-
return await run(METHOD_NAME
|
|
14947
|
+
return await run(METHOD_NAME$10, agentName, swarmName);
|
|
14948
14948
|
});
|
|
14949
14949
|
|
|
14950
|
-
const METHOD_NAME
|
|
14950
|
+
const METHOD_NAME$$ = "function.target.emitForce";
|
|
14951
14951
|
/**
|
|
14952
14952
|
* Emits a string as model output without executing an incoming message or checking the active agent.
|
|
14953
14953
|
*
|
|
@@ -14966,19 +14966,19 @@ const METHOD_NAME$_ = "function.target.emitForce";
|
|
|
14966
14966
|
const emitForce = beginContext(async (content, clientId) => {
|
|
14967
14967
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14968
14968
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14969
|
-
swarm$1.loggerService.log(METHOD_NAME
|
|
14969
|
+
swarm$1.loggerService.log(METHOD_NAME$$, {
|
|
14970
14970
|
content,
|
|
14971
14971
|
clientId,
|
|
14972
14972
|
});
|
|
14973
14973
|
// Validate the session and swarm
|
|
14974
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME
|
|
14974
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$$);
|
|
14975
14975
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14976
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME
|
|
14976
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$$);
|
|
14977
14977
|
// Emit the content directly via the session public service
|
|
14978
|
-
return await swarm$1.sessionPublicService.emit(content, METHOD_NAME
|
|
14978
|
+
return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$$, clientId, swarmName);
|
|
14979
14979
|
});
|
|
14980
14980
|
|
|
14981
|
-
const METHOD_NAME$
|
|
14981
|
+
const METHOD_NAME$_ = "function.target.executeForce";
|
|
14982
14982
|
/**
|
|
14983
14983
|
* Sends a message to the active agent in a swarm session as if it originated from the client side, forcing execution regardless of agent activity.
|
|
14984
14984
|
*
|
|
@@ -14999,22 +14999,22 @@ const executeForce = beginContext(async (content, clientId) => {
|
|
|
14999
14999
|
const executionId = functoolsKit.randomString();
|
|
15000
15000
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15001
15001
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15002
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15002
|
+
swarm$1.loggerService.log(METHOD_NAME$_, {
|
|
15003
15003
|
content,
|
|
15004
15004
|
clientId,
|
|
15005
15005
|
executionId,
|
|
15006
15006
|
});
|
|
15007
15007
|
// Validate the session and swarm
|
|
15008
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
15008
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$_);
|
|
15009
15009
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15010
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15010
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$_);
|
|
15011
15011
|
// Execute the command within an execution context with performance tracking
|
|
15012
15012
|
return ExecutionContextService.runInContext(async () => {
|
|
15013
15013
|
let isFinished = false;
|
|
15014
15014
|
swarm$1.perfService.startExecution(executionId, clientId, content.length);
|
|
15015
15015
|
try {
|
|
15016
15016
|
swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
|
|
15017
|
-
const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$
|
|
15017
|
+
const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$_, clientId, swarmName);
|
|
15018
15018
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
15019
15019
|
swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
|
|
15020
15020
|
return result;
|
|
@@ -15031,7 +15031,7 @@ const executeForce = beginContext(async (content, clientId) => {
|
|
|
15031
15031
|
});
|
|
15032
15032
|
});
|
|
15033
15033
|
|
|
15034
|
-
const METHOD_NAME$
|
|
15034
|
+
const METHOD_NAME$Z = "function.template.navigateToTriageAgent";
|
|
15035
15035
|
const DEFAULT_ACCEPT_FN = (_, defaultAgent) => `Successfully navigated to ${defaultAgent}`;
|
|
15036
15036
|
const DEFAULT_REJECT_FN = (_, defaultAgent) => `Already on ${defaultAgent}`;
|
|
15037
15037
|
/**
|
|
@@ -15080,7 +15080,7 @@ const createNavigateToTriageAgent = async ({ flushMessage, executeMessage, toolO
|
|
|
15080
15080
|
*/
|
|
15081
15081
|
return beginContext(async (toolId, clientId) => {
|
|
15082
15082
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15083
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15083
|
+
swarm$1.loggerService.log(METHOD_NAME$Z, {
|
|
15084
15084
|
clientId,
|
|
15085
15085
|
toolId,
|
|
15086
15086
|
});
|
|
@@ -15110,8 +15110,211 @@ const createNavigateToTriageAgent = async ({ flushMessage, executeMessage, toolO
|
|
|
15110
15110
|
});
|
|
15111
15111
|
};
|
|
15112
15112
|
|
|
15113
|
+
const METHOD_NAME$Y = "function.navigate.changeToAgent";
|
|
15114
|
+
/**
|
|
15115
|
+
* Time-to-live for the change agent function in milliseconds.
|
|
15116
|
+
* Defines how long the cached change agent function remains valid before expiring.
|
|
15117
|
+
* @constant {number}
|
|
15118
|
+
*/
|
|
15119
|
+
const CHANGE_AGENT_TTL$1 = 15 * 60 * 1000;
|
|
15120
|
+
/**
|
|
15121
|
+
* Garbage collection interval for the change agent function in milliseconds.
|
|
15122
|
+
* Specifies the frequency at which expired TTL entries are cleaned up.
|
|
15123
|
+
* @constant {number}
|
|
15124
|
+
*/
|
|
15125
|
+
const CHANGE_AGENT_GC$1 = 60 * 1000;
|
|
15126
|
+
/**
|
|
15127
|
+
* Creates a change agent function with time-to-live (TTL) and queuing capabilities.
|
|
15128
|
+
*
|
|
15129
|
+
* This factory function generates a queued, TTL-limited function to handle agent changes for a specific client session,
|
|
15130
|
+
* ensuring operations are executed sequentially and cached results are reused within the TTL period.
|
|
15131
|
+
*
|
|
15132
|
+
* @function
|
|
15133
|
+
* @param {string} clientId - The unique identifier of the client session.
|
|
15134
|
+
* @returns {TChangeToAgentRun} A function that performs the agent change operation with queuing and TTL.
|
|
15135
|
+
*/
|
|
15136
|
+
const createChangeToAgent = functoolsKit.ttl((clientId) => functoolsKit.queued(async (methodName, agentName, swarmName) => {
|
|
15137
|
+
if (!swarm$1.navigationValidationService.shouldNavigate(agentName, clientId, swarmName)) {
|
|
15138
|
+
console.warn(`function "changeToAgent" skipped due to the circular route found clientId=${clientId} swarmName=${swarmName} agentNameTo=${agentName}`);
|
|
15139
|
+
return false;
|
|
15140
|
+
}
|
|
15141
|
+
// Notify all agents in the swarm of the change
|
|
15142
|
+
await Promise.all(swarm$1.swarmValidationService
|
|
15143
|
+
.getAgentList(swarmName)
|
|
15144
|
+
.map(async (agentName) => {
|
|
15145
|
+
await swarm$1.agentPublicService.commitAgentChange(methodName, clientId, agentName);
|
|
15146
|
+
}));
|
|
15147
|
+
{
|
|
15148
|
+
// Dispose of the current agent's resources and set up the new agent
|
|
15149
|
+
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$Y, clientId, swarmName);
|
|
15150
|
+
await swarm$1.agentPublicService.dispose(methodName, clientId, agentName);
|
|
15151
|
+
await swarm$1.historyPublicService.dispose(methodName, clientId, agentName);
|
|
15152
|
+
await swarm$1.swarmPublicService.setAgentRef(methodName, clientId, swarmName, agentName, await swarm$1.agentPublicService.createAgentRef(methodName, clientId, agentName));
|
|
15153
|
+
}
|
|
15154
|
+
// Set the new agent as the active agent
|
|
15155
|
+
await swarm$1.swarmPublicService.setAgentName(agentName, methodName, clientId, swarmName);
|
|
15156
|
+
return true;
|
|
15157
|
+
}), {
|
|
15158
|
+
key: ([clientId]) => `${clientId}`,
|
|
15159
|
+
timeout: CHANGE_AGENT_TTL$1,
|
|
15160
|
+
});
|
|
15161
|
+
/**
|
|
15162
|
+
* Creates a garbage collector for the change agent function.
|
|
15163
|
+
*
|
|
15164
|
+
* This function sets up a singleton interval-based garbage collector to periodically clean up expired TTL entries from `createChangeToAgent`.
|
|
15165
|
+
*
|
|
15166
|
+
* @function
|
|
15167
|
+
* @returns {Promise<void>} A promise that resolves when the garbage collector is initialized.
|
|
15168
|
+
*/
|
|
15169
|
+
const createGc$2 = functoolsKit.singleshot(async () => {
|
|
15170
|
+
setInterval(createChangeToAgent.gc, CHANGE_AGENT_GC$1);
|
|
15171
|
+
});
|
|
15172
|
+
/**
|
|
15173
|
+
* Changes the active agent for a given client session in a swarm.
|
|
15174
|
+
*
|
|
15175
|
+
* This function facilitates switching the active agent in a swarm session, validating the session and agent dependencies,
|
|
15176
|
+
* logging the operation if enabled, and executing the change using a TTL-limited, queued runner.
|
|
15177
|
+
* The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts.
|
|
15178
|
+
*
|
|
15179
|
+
* @param {AgentName} agentName - The name of the agent to switch to.
|
|
15180
|
+
* @param {string} clientId - The unique identifier of the client session.
|
|
15181
|
+
* @returns {Promise<boolean>} A promise that resolves when the agent change is complete. If it resolved false, the navigation is canceled due to recursion
|
|
15182
|
+
* @throws {Error} If session or agent validation fails, or if the agent change process encounters an error.
|
|
15183
|
+
* @example
|
|
15184
|
+
* await changeToAgent("AgentX", "client-123");
|
|
15185
|
+
*/
|
|
15186
|
+
const changeToAgent = beginContext(async (agentName, clientId) => {
|
|
15187
|
+
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15188
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15189
|
+
swarm$1.loggerService.log(METHOD_NAME$Y, {
|
|
15190
|
+
agentName,
|
|
15191
|
+
clientId,
|
|
15192
|
+
});
|
|
15193
|
+
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15194
|
+
{
|
|
15195
|
+
// Validate session, agent, and dependencies
|
|
15196
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$Y);
|
|
15197
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$Y);
|
|
15198
|
+
const activeAgent = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$Y, clientId, swarmName);
|
|
15199
|
+
if (!swarm$1.agentValidationService.hasDependency(activeAgent, agentName)) {
|
|
15200
|
+
console.error(`agent-swarm missing dependency detected for activeAgent=${activeAgent} dependencyAgent=${agentName}`);
|
|
15201
|
+
}
|
|
15202
|
+
}
|
|
15203
|
+
if (!swarm$1.swarmValidationService.getAgentSet(swarmName).has(agentName)) {
|
|
15204
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15205
|
+
swarm$1.loggerService.log('function "changeToAgent" skipped due to the agent is not in the swarm', {
|
|
15206
|
+
agentName,
|
|
15207
|
+
clientId,
|
|
15208
|
+
swarmName,
|
|
15209
|
+
});
|
|
15210
|
+
console.warn(`function "changeToAgent" skipped due to the agent is not in the swarm clientId=${clientId} agentName=${agentName} swarmName=${swarmName}`);
|
|
15211
|
+
return false;
|
|
15212
|
+
}
|
|
15213
|
+
// Execute the agent change with TTL and queuing
|
|
15214
|
+
const run = await createChangeToAgent(clientId);
|
|
15215
|
+
createGc$2();
|
|
15216
|
+
return await run(METHOD_NAME$Y, agentName, swarmName);
|
|
15217
|
+
});
|
|
15218
|
+
|
|
15219
|
+
const METHOD_NAME$X = "function.template.navigateToAgent";
|
|
15220
|
+
/**
|
|
15221
|
+
* Default tool output message indicating successful navigation to the specified agent.
|
|
15222
|
+
*
|
|
15223
|
+
* @param {SessionId} _ - The client session ID (unused).
|
|
15224
|
+
* @param {AgentName} agentName - The name of the agent navigated to.
|
|
15225
|
+
* @returns {string} A message confirming navigation to the agent.
|
|
15226
|
+
*/
|
|
15227
|
+
const DEFAULT_TOOL_OUTPUT = (_, agentName) => `Successfully navigated to ${agentName}`;
|
|
15228
|
+
/**
|
|
15229
|
+
* Default flush message prompting the user to repeat their input.
|
|
15230
|
+
*
|
|
15231
|
+
* @param {SessionId} _ - The client session ID (unused).
|
|
15232
|
+
* @param {AgentName} _ - The agent name (unused).
|
|
15233
|
+
* @returns {string} A generic retry message.
|
|
15234
|
+
*/
|
|
15235
|
+
const DEFAULT_FLUSH_MESSAGE = ({}, {}) => `Sorry, I missed that. Could you repeat please`;
|
|
15236
|
+
/**
|
|
15237
|
+
* Creates a function to navigate to a specified agent for a given client, handling navigation, message execution, emission, and tool output.
|
|
15238
|
+
* The factory generates a handler that checks navigation state, retrieves the last user message, commits tool outputs, and triggers execution or emission based on provided parameters.
|
|
15239
|
+
* It validates the presence of either `emitMessage` or `executeMessage` to ensure proper navigation behavior.
|
|
15240
|
+
* Logs the navigation operation if logging is enabled in the global configuration.
|
|
15241
|
+
*
|
|
15242
|
+
* @param {IFactoryParams} params - Configuration parameters for the navigation handler.
|
|
15243
|
+
* @param {string | ((clientId: string, defaultAgent: AgentName) => string | Promise<string>)} [params.flushMessage] - Optional message or function to emit after flushing the session, defaults to `DEFAULT_FLUSH_MESSAGE`.
|
|
15244
|
+
* @param {string | ((clientId: string, agentName: AgentName) => string | Promise<string>)} [params.toolOutput] - Optional message or function for tool output when navigation occurs, defaults to `DEFAULT_TOOL_OUTPUT`.
|
|
15245
|
+
* @param {string | ((clientId: string, lastMessage: string, agentName: AgentName) => string | Promise<string>)} [params.emitMessage] - Optional message or function to emit when navigation occurs without execution.
|
|
15246
|
+
* @param {string | ((clientId: string, lastMessage: string, agentName: AgentName) => string | Promise<string>)} [params.executeMessage] - Optional message or function to execute when navigation occurs with execution.
|
|
15247
|
+
* @returns {Promise<(toolId: string, clientId: string, agentName: AgentName) => Promise<void>>} A promise resolving to a function that handles navigation to the specified agent.
|
|
15248
|
+
* @throws {Error} If neither `emitMessage` nor `executeMessage` is provided, or if any internal operation (e.g., navigation, commit, or execution) fails.
|
|
15249
|
+
*
|
|
15250
|
+
* @example
|
|
15251
|
+
* // Create a navigation handler with static messages
|
|
15252
|
+
* const navigate = await createNavigateToAgent({
|
|
15253
|
+
* flushMessage: "Session reset.",
|
|
15254
|
+
* toolOutput: "Navigation completed.",
|
|
15255
|
+
* emitMessage: "Navigation event triggered.",
|
|
15256
|
+
* });
|
|
15257
|
+
* await navigate("tool-123", "client-456", "WeatherAgent");
|
|
15258
|
+
* // Navigates to WeatherAgent, commits tool output, and emits the message.
|
|
15259
|
+
*
|
|
15260
|
+
* @example
|
|
15261
|
+
* // Create a navigation handler with dynamic messages
|
|
15262
|
+
* const navigate = await createNavigateToAgent({
|
|
15263
|
+
* executeMessage: (clientId, lastMessage, agent) => `Processing ${lastMessage} for ${clientId} on ${agent}`,
|
|
15264
|
+
* toolOutput: (clientId, agent) => `Navigated ${clientId} to ${agent}`,
|
|
15265
|
+
* });
|
|
15266
|
+
* await navigate("tool-789", "client-012", "SupportAgent");
|
|
15267
|
+
* // Navigates to SupportAgent, commits dynamic tool output, and executes the message with the last user message.
|
|
15268
|
+
*/
|
|
15269
|
+
const createNavigateToAgent = async ({ executeMessage, emitMessage, flushMessage = DEFAULT_FLUSH_MESSAGE, toolOutput = DEFAULT_TOOL_OUTPUT, }) => {
|
|
15270
|
+
if (!emitMessage && !executeMessage) {
|
|
15271
|
+
throw new Error("agent-swarm createNavigateToAgent emitMessage or executeMessage required");
|
|
15272
|
+
}
|
|
15273
|
+
/**
|
|
15274
|
+
* Navigates to a specified agent for a given client and tool, handling message commits, execution, or emission using the last user message.
|
|
15275
|
+
*
|
|
15276
|
+
* @param {string} toolId - The identifier of the tool triggering the navigation.
|
|
15277
|
+
* @param {string} clientId - The unique identifier of the client session.
|
|
15278
|
+
* @param {AgentName} agentName - The name of the agent to navigate to.
|
|
15279
|
+
* @returns {Promise<void>} A promise that resolves when the navigation and associated actions are complete.
|
|
15280
|
+
* @throws {Error} If navigation, commit, execution, or emission operations fail (e.g., invalid clientId or agentName).
|
|
15281
|
+
*/
|
|
15282
|
+
return beginContext(async (toolId, clientId, agentName) => {
|
|
15283
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15284
|
+
swarm$1.loggerService.log(METHOD_NAME$X, {
|
|
15285
|
+
clientId,
|
|
15286
|
+
toolId,
|
|
15287
|
+
});
|
|
15288
|
+
const lastMessage = await getLastUserMessage(clientId);
|
|
15289
|
+
if (await functoolsKit.and(functoolsKit.not(hasNavigation(clientId, agentName)), Promise.resolve(!!executeMessage))) {
|
|
15290
|
+
await commitToolOutputForce(toolId, typeof toolOutput === "string"
|
|
15291
|
+
? toolOutput
|
|
15292
|
+
: await toolOutput(clientId, agentName), clientId);
|
|
15293
|
+
await changeToAgent(agentName, clientId);
|
|
15294
|
+
await executeForce(typeof executeMessage === "string"
|
|
15295
|
+
? executeMessage
|
|
15296
|
+
: await executeMessage(clientId, lastMessage, agentName), clientId);
|
|
15297
|
+
return;
|
|
15298
|
+
}
|
|
15299
|
+
if (await functoolsKit.and(functoolsKit.not(hasNavigation(clientId, agentName)), Promise.resolve(!!emitMessage))) {
|
|
15300
|
+
await commitToolOutputForce(toolId, typeof toolOutput === "string"
|
|
15301
|
+
? toolOutput
|
|
15302
|
+
: await toolOutput(clientId, agentName), clientId);
|
|
15303
|
+
await changeToAgent(agentName, clientId);
|
|
15304
|
+
await emitForce(typeof emitMessage === "string"
|
|
15305
|
+
? emitMessage
|
|
15306
|
+
: await emitMessage(clientId, lastMessage, agentName), clientId);
|
|
15307
|
+
return;
|
|
15308
|
+
}
|
|
15309
|
+
await commitFlushForce(clientId);
|
|
15310
|
+
await emitForce(typeof flushMessage === "string"
|
|
15311
|
+
? flushMessage
|
|
15312
|
+
: await flushMessage(clientId, agentName), clientId);
|
|
15313
|
+
});
|
|
15314
|
+
};
|
|
15315
|
+
|
|
15113
15316
|
/** @constant {string} METHOD_NAME - The name of the method used for logging */
|
|
15114
|
-
const METHOD_NAME$
|
|
15317
|
+
const METHOD_NAME$W = "function.setup.addWiki";
|
|
15115
15318
|
/**
|
|
15116
15319
|
* Adds a wiki schema to the system
|
|
15117
15320
|
* @function addWiki
|
|
@@ -15120,7 +15323,7 @@ const METHOD_NAME$X = "function.setup.addWiki";
|
|
|
15120
15323
|
*/
|
|
15121
15324
|
const addWiki = beginContext((wikiSchema) => {
|
|
15122
15325
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15123
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15326
|
+
swarm$1.loggerService.log(METHOD_NAME$W, {
|
|
15124
15327
|
wikiSchema,
|
|
15125
15328
|
});
|
|
15126
15329
|
swarm$1.wikiValidationService.addWiki(wikiSchema.wikiName, wikiSchema);
|
|
@@ -15128,7 +15331,7 @@ const addWiki = beginContext((wikiSchema) => {
|
|
|
15128
15331
|
return wikiSchema.wikiName;
|
|
15129
15332
|
});
|
|
15130
15333
|
|
|
15131
|
-
const METHOD_NAME$
|
|
15334
|
+
const METHOD_NAME$V = "function.setup.addAgent";
|
|
15132
15335
|
/**
|
|
15133
15336
|
* Adds a new agent to the agent registry for use within the swarm system.
|
|
15134
15337
|
*
|
|
@@ -15148,7 +15351,7 @@ const METHOD_NAME$W = "function.setup.addAgent";
|
|
|
15148
15351
|
const addAgent = beginContext((agentSchema) => {
|
|
15149
15352
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15150
15353
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15151
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15354
|
+
swarm$1.loggerService.log(METHOD_NAME$V, {
|
|
15152
15355
|
agentSchema,
|
|
15153
15356
|
});
|
|
15154
15357
|
// Register the agent in the validation and schema services
|
|
@@ -15158,7 +15361,7 @@ const addAgent = beginContext((agentSchema) => {
|
|
|
15158
15361
|
return agentSchema.agentName;
|
|
15159
15362
|
});
|
|
15160
15363
|
|
|
15161
|
-
const METHOD_NAME$
|
|
15364
|
+
const METHOD_NAME$U = "function.setup.addCompletion";
|
|
15162
15365
|
/**
|
|
15163
15366
|
* Adds a completion engine to the registry for use by agents in the swarm system.
|
|
15164
15367
|
*
|
|
@@ -15178,7 +15381,7 @@ const METHOD_NAME$V = "function.setup.addCompletion";
|
|
|
15178
15381
|
const addCompletion = beginContext((completionSchema) => {
|
|
15179
15382
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15180
15383
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15181
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15384
|
+
swarm$1.loggerService.log(METHOD_NAME$U, {
|
|
15182
15385
|
completionSchema,
|
|
15183
15386
|
});
|
|
15184
15387
|
// Register the completion in the validation and schema services
|
|
@@ -15188,7 +15391,7 @@ const addCompletion = beginContext((completionSchema) => {
|
|
|
15188
15391
|
return completionSchema.completionName;
|
|
15189
15392
|
});
|
|
15190
15393
|
|
|
15191
|
-
const METHOD_NAME$
|
|
15394
|
+
const METHOD_NAME$T = "function.setup.addSwarm";
|
|
15192
15395
|
/**
|
|
15193
15396
|
* Adds a new swarm to the system for managing client sessions.
|
|
15194
15397
|
*
|
|
@@ -15208,7 +15411,7 @@ const METHOD_NAME$U = "function.setup.addSwarm";
|
|
|
15208
15411
|
const addSwarm = beginContext((swarmSchema) => {
|
|
15209
15412
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15210
15413
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15211
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15414
|
+
swarm$1.loggerService.log(METHOD_NAME$T, {
|
|
15212
15415
|
swarmSchema,
|
|
15213
15416
|
});
|
|
15214
15417
|
// Register the swarm in the validation and schema services
|
|
@@ -15218,7 +15421,7 @@ const addSwarm = beginContext((swarmSchema) => {
|
|
|
15218
15421
|
return swarmSchema.swarmName;
|
|
15219
15422
|
});
|
|
15220
15423
|
|
|
15221
|
-
const METHOD_NAME$
|
|
15424
|
+
const METHOD_NAME$S = "function.setup.addTool";
|
|
15222
15425
|
/**
|
|
15223
15426
|
* Adds a new tool to the tool registry for use by agents in the swarm system.
|
|
15224
15427
|
*
|
|
@@ -15240,7 +15443,7 @@ const METHOD_NAME$T = "function.setup.addTool";
|
|
|
15240
15443
|
const addTool = beginContext((toolSchema) => {
|
|
15241
15444
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15242
15445
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15243
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15446
|
+
swarm$1.loggerService.log(METHOD_NAME$S, {
|
|
15244
15447
|
toolSchema,
|
|
15245
15448
|
});
|
|
15246
15449
|
// Register the tool in the validation and schema services
|
|
@@ -15250,7 +15453,7 @@ const addTool = beginContext((toolSchema) => {
|
|
|
15250
15453
|
return toolSchema.toolName;
|
|
15251
15454
|
});
|
|
15252
15455
|
|
|
15253
|
-
const METHOD_NAME$
|
|
15456
|
+
const METHOD_NAME$R = "function.setup.addState";
|
|
15254
15457
|
/**
|
|
15255
15458
|
* Adds a new state to the state registry for use within the swarm system.
|
|
15256
15459
|
*
|
|
@@ -15272,7 +15475,7 @@ const METHOD_NAME$S = "function.setup.addState";
|
|
|
15272
15475
|
const addState = beginContext((stateSchema) => {
|
|
15273
15476
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15274
15477
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15275
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15478
|
+
swarm$1.loggerService.log(METHOD_NAME$R, {
|
|
15276
15479
|
stateSchema,
|
|
15277
15480
|
});
|
|
15278
15481
|
// Register the state in the schema service
|
|
@@ -15287,7 +15490,7 @@ const addState = beginContext((stateSchema) => {
|
|
|
15287
15490
|
return stateSchema.stateName;
|
|
15288
15491
|
});
|
|
15289
15492
|
|
|
15290
|
-
const METHOD_NAME$
|
|
15493
|
+
const METHOD_NAME$Q = "function.setup.addEmbedding";
|
|
15291
15494
|
/**
|
|
15292
15495
|
* Adds a new embedding engine to the embedding registry for use within the swarm system.
|
|
15293
15496
|
*
|
|
@@ -15307,7 +15510,7 @@ const METHOD_NAME$R = "function.setup.addEmbedding";
|
|
|
15307
15510
|
const addEmbedding = beginContext((embeddingSchema) => {
|
|
15308
15511
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15309
15512
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15310
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15513
|
+
swarm$1.loggerService.log(METHOD_NAME$Q, {
|
|
15311
15514
|
embeddingSchema,
|
|
15312
15515
|
});
|
|
15313
15516
|
// Register the embedding in the validation and schema services
|
|
@@ -15317,7 +15520,7 @@ const addEmbedding = beginContext((embeddingSchema) => {
|
|
|
15317
15520
|
return embeddingSchema.embeddingName;
|
|
15318
15521
|
});
|
|
15319
15522
|
|
|
15320
|
-
const METHOD_NAME$
|
|
15523
|
+
const METHOD_NAME$P = "function.setup.addStorage";
|
|
15321
15524
|
/**
|
|
15322
15525
|
* Adds a new storage engine to the storage registry for use within the swarm system.
|
|
15323
15526
|
*
|
|
@@ -15339,7 +15542,7 @@ const METHOD_NAME$Q = "function.setup.addStorage";
|
|
|
15339
15542
|
const addStorage = beginContext((storageSchema) => {
|
|
15340
15543
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15341
15544
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15342
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15545
|
+
swarm$1.loggerService.log(METHOD_NAME$P, {
|
|
15343
15546
|
storageSchema,
|
|
15344
15547
|
});
|
|
15345
15548
|
// Register the storage in the validation and schema services
|
|
@@ -15356,7 +15559,7 @@ const addStorage = beginContext((storageSchema) => {
|
|
|
15356
15559
|
});
|
|
15357
15560
|
|
|
15358
15561
|
/** @private Constant defining the method name for logging and validation context */
|
|
15359
|
-
const METHOD_NAME$
|
|
15562
|
+
const METHOD_NAME$O = "function.setup.addPolicy";
|
|
15360
15563
|
/**
|
|
15361
15564
|
* Adds a new policy for agents in the swarm system by registering it with validation and schema services.
|
|
15362
15565
|
* Registers the policy with PolicyValidationService for runtime validation and PolicySchemaService for schema management.
|
|
@@ -15372,7 +15575,7 @@ const METHOD_NAME$P = "function.setup.addPolicy";
|
|
|
15372
15575
|
const addPolicy = beginContext((policySchema) => {
|
|
15373
15576
|
// Log the policy addition attempt if enabled
|
|
15374
15577
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15375
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15578
|
+
swarm$1.loggerService.log(METHOD_NAME$O, {
|
|
15376
15579
|
policySchema,
|
|
15377
15580
|
});
|
|
15378
15581
|
// Register the policy with PolicyValidationService for runtime validation
|
|
@@ -15383,7 +15586,7 @@ const addPolicy = beginContext((policySchema) => {
|
|
|
15383
15586
|
return policySchema.policyName;
|
|
15384
15587
|
});
|
|
15385
15588
|
|
|
15386
|
-
const METHOD_NAME$
|
|
15589
|
+
const METHOD_NAME$N = "function.test.overrideAgent";
|
|
15387
15590
|
/**
|
|
15388
15591
|
* Overrides an existing agent schema in the swarm system with a new or partial schema.
|
|
15389
15592
|
* This function updates the configuration of an agent identified by its `agentName`, applying the provided schema properties.
|
|
@@ -15407,13 +15610,13 @@ const METHOD_NAME$O = "function.test.overrideAgent";
|
|
|
15407
15610
|
*/
|
|
15408
15611
|
const overrideAgent = beginContext((agentSchema) => {
|
|
15409
15612
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15410
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15613
|
+
swarm$1.loggerService.log(METHOD_NAME$N, {
|
|
15411
15614
|
agentSchema,
|
|
15412
15615
|
});
|
|
15413
15616
|
return swarm$1.agentSchemaService.override(agentSchema.agentName, agentSchema);
|
|
15414
15617
|
});
|
|
15415
15618
|
|
|
15416
|
-
const METHOD_NAME$
|
|
15619
|
+
const METHOD_NAME$M = "function.test.overrideCompletion";
|
|
15417
15620
|
/**
|
|
15418
15621
|
* Overrides an existing completion schema in the swarm system with a new or partial schema.
|
|
15419
15622
|
* This function updates the configuration of a completion mechanism identified by its `completionName`, applying the provided schema properties.
|
|
@@ -15437,13 +15640,13 @@ const METHOD_NAME$N = "function.test.overrideCompletion";
|
|
|
15437
15640
|
*/
|
|
15438
15641
|
const overrideCompletion = beginContext((completionSchema) => {
|
|
15439
15642
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15440
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15643
|
+
swarm$1.loggerService.log(METHOD_NAME$M, {
|
|
15441
15644
|
completionSchema,
|
|
15442
15645
|
});
|
|
15443
15646
|
return swarm$1.completionSchemaService.override(completionSchema.completionName, completionSchema);
|
|
15444
15647
|
});
|
|
15445
15648
|
|
|
15446
|
-
const METHOD_NAME$
|
|
15649
|
+
const METHOD_NAME$L = "function.test.overrideEmbeding";
|
|
15447
15650
|
/**
|
|
15448
15651
|
* Overrides an existing embedding schema in the swarm system with a new or partial schema.
|
|
15449
15652
|
* This function updates the configuration of an embedding mechanism identified by its `embeddingName`, applying the provided schema properties.
|
|
@@ -15469,13 +15672,13 @@ const METHOD_NAME$M = "function.test.overrideEmbeding";
|
|
|
15469
15672
|
*/
|
|
15470
15673
|
const overrideEmbeding = beginContext((embeddingSchema) => {
|
|
15471
15674
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15472
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15675
|
+
swarm$1.loggerService.log(METHOD_NAME$L, {
|
|
15473
15676
|
embeddingSchema,
|
|
15474
15677
|
});
|
|
15475
15678
|
return swarm$1.embeddingSchemaService.override(embeddingSchema.embeddingName, embeddingSchema);
|
|
15476
15679
|
});
|
|
15477
15680
|
|
|
15478
|
-
const METHOD_NAME$
|
|
15681
|
+
const METHOD_NAME$K = "function.test.overridePolicy";
|
|
15479
15682
|
/**
|
|
15480
15683
|
* Overrides an existing policy schema in the swarm system with a new or partial schema.
|
|
15481
15684
|
* This function updates the configuration of a policy identified by its `policyName`, applying the provided schema properties.
|
|
@@ -15499,13 +15702,13 @@ const METHOD_NAME$L = "function.test.overridePolicy";
|
|
|
15499
15702
|
*/
|
|
15500
15703
|
const overridePolicy = beginContext((policySchema) => {
|
|
15501
15704
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15502
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15705
|
+
swarm$1.loggerService.log(METHOD_NAME$K, {
|
|
15503
15706
|
policySchema,
|
|
15504
15707
|
});
|
|
15505
15708
|
return swarm$1.policySchemaService.override(policySchema.policyName, policySchema);
|
|
15506
15709
|
});
|
|
15507
15710
|
|
|
15508
|
-
const METHOD_NAME$
|
|
15711
|
+
const METHOD_NAME$J = "function.test.overrideState";
|
|
15509
15712
|
/**
|
|
15510
15713
|
* Overrides an existing state schema in the swarm system with a new or partial schema.
|
|
15511
15714
|
* This function updates the configuration of a state identified by its `stateName`, applying the provided schema properties.
|
|
@@ -15530,13 +15733,13 @@ const METHOD_NAME$K = "function.test.overrideState";
|
|
|
15530
15733
|
*/
|
|
15531
15734
|
const overrideState = beginContext((stateSchema) => {
|
|
15532
15735
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15533
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15736
|
+
swarm$1.loggerService.log(METHOD_NAME$J, {
|
|
15534
15737
|
stateSchema,
|
|
15535
15738
|
});
|
|
15536
15739
|
return swarm$1.stateSchemaService.override(stateSchema.stateName, stateSchema);
|
|
15537
15740
|
});
|
|
15538
15741
|
|
|
15539
|
-
const METHOD_NAME$
|
|
15742
|
+
const METHOD_NAME$I = "function.test.overrideStorage";
|
|
15540
15743
|
/**
|
|
15541
15744
|
* Overrides an existing storage schema in the swarm system with a new or partial schema.
|
|
15542
15745
|
* This function updates the configuration of a storage identified by its `storageName`, applying the provided schema properties.
|
|
@@ -15562,13 +15765,13 @@ const METHOD_NAME$J = "function.test.overrideStorage";
|
|
|
15562
15765
|
*/
|
|
15563
15766
|
const overrideStorage = beginContext((storageSchema) => {
|
|
15564
15767
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15565
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15768
|
+
swarm$1.loggerService.log(METHOD_NAME$I, {
|
|
15566
15769
|
storageSchema,
|
|
15567
15770
|
});
|
|
15568
15771
|
return swarm$1.storageSchemaService.override(storageSchema.storageName, storageSchema);
|
|
15569
15772
|
});
|
|
15570
15773
|
|
|
15571
|
-
const METHOD_NAME$
|
|
15774
|
+
const METHOD_NAME$H = "function.test.overrideSwarm";
|
|
15572
15775
|
/**
|
|
15573
15776
|
* Overrides an existing swarm schema in the swarm system with a new or partial schema.
|
|
15574
15777
|
* This function updates the configuration of a swarm identified by its `swarmName`, applying the provided schema properties.
|
|
@@ -15592,13 +15795,13 @@ const METHOD_NAME$I = "function.test.overrideSwarm";
|
|
|
15592
15795
|
*/
|
|
15593
15796
|
const overrideSwarm = beginContext((swarmSchema) => {
|
|
15594
15797
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15595
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15798
|
+
swarm$1.loggerService.log(METHOD_NAME$H, {
|
|
15596
15799
|
swarmSchema,
|
|
15597
15800
|
});
|
|
15598
15801
|
return swarm$1.swarmSchemaService.override(swarmSchema.swarmName, swarmSchema);
|
|
15599
15802
|
});
|
|
15600
15803
|
|
|
15601
|
-
const METHOD_NAME$
|
|
15804
|
+
const METHOD_NAME$G = "function.test.overrideTool";
|
|
15602
15805
|
/**
|
|
15603
15806
|
* Overrides an existing tool schema in the swarm system with a new or partial schema.
|
|
15604
15807
|
* This function updates the configuration of a tool identified by its `toolName`, applying the provided schema properties.
|
|
@@ -15622,13 +15825,13 @@ const METHOD_NAME$H = "function.test.overrideTool";
|
|
|
15622
15825
|
*/
|
|
15623
15826
|
const overrideTool = beginContext((toolSchema) => {
|
|
15624
15827
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15625
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15828
|
+
swarm$1.loggerService.log(METHOD_NAME$G, {
|
|
15626
15829
|
toolSchema,
|
|
15627
15830
|
});
|
|
15628
15831
|
return swarm$1.toolSchemaService.override(toolSchema.toolName, toolSchema);
|
|
15629
15832
|
});
|
|
15630
15833
|
|
|
15631
|
-
const METHOD_NAME$
|
|
15834
|
+
const METHOD_NAME$F = "function.test.overrideWiki";
|
|
15632
15835
|
/**
|
|
15633
15836
|
* Overrides an existing wiki schema in the swarm system with a new or partial schema.
|
|
15634
15837
|
* This function updates the configuration of a wiki identified by its `wikiName`, applying the provided schema properties.
|
|
@@ -15652,13 +15855,13 @@ const METHOD_NAME$G = "function.test.overrideWiki";
|
|
|
15652
15855
|
*/
|
|
15653
15856
|
const overrideWiki = beginContext((wikiSchema) => {
|
|
15654
15857
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15655
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15858
|
+
swarm$1.loggerService.log(METHOD_NAME$F, {
|
|
15656
15859
|
wikiSchema,
|
|
15657
15860
|
});
|
|
15658
15861
|
return swarm$1.wikiSchemaService.override(wikiSchema.wikiName, wikiSchema);
|
|
15659
15862
|
});
|
|
15660
15863
|
|
|
15661
|
-
const METHOD_NAME$
|
|
15864
|
+
const METHOD_NAME$E = "function.other.markOnline";
|
|
15662
15865
|
/**
|
|
15663
15866
|
* Marks a client as online in the specified swarm.
|
|
15664
15867
|
*
|
|
@@ -15670,16 +15873,16 @@ const METHOD_NAME$F = "function.other.markOnline";
|
|
|
15670
15873
|
const markOnline = async (clientId, swarmName) => {
|
|
15671
15874
|
// Log the operation if logging is enabled in the global configuration
|
|
15672
15875
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15673
|
-
swarm.loggerService.log(METHOD_NAME$
|
|
15876
|
+
swarm.loggerService.log(METHOD_NAME$E, {
|
|
15674
15877
|
clientId,
|
|
15675
15878
|
});
|
|
15676
15879
|
// Validate the swarm name
|
|
15677
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15880
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$E);
|
|
15678
15881
|
// Run the operation in the method context
|
|
15679
15882
|
return await MethodContextService.runInContext(async () => {
|
|
15680
|
-
await swarm.aliveService.markOnline(clientId, swarmName, METHOD_NAME$
|
|
15883
|
+
await swarm.aliveService.markOnline(clientId, swarmName, METHOD_NAME$E);
|
|
15681
15884
|
}, {
|
|
15682
|
-
methodName: METHOD_NAME$
|
|
15885
|
+
methodName: METHOD_NAME$E,
|
|
15683
15886
|
agentName: "",
|
|
15684
15887
|
policyName: "",
|
|
15685
15888
|
stateName: "",
|
|
@@ -15689,7 +15892,7 @@ const markOnline = async (clientId, swarmName) => {
|
|
|
15689
15892
|
});
|
|
15690
15893
|
};
|
|
15691
15894
|
|
|
15692
|
-
const METHOD_NAME$
|
|
15895
|
+
const METHOD_NAME$D = "function.other.markOffline";
|
|
15693
15896
|
/**
|
|
15694
15897
|
* Marks a client as offline in the specified swarm.
|
|
15695
15898
|
*
|
|
@@ -15704,14 +15907,14 @@ const METHOD_NAME$E = "function.other.markOffline";
|
|
|
15704
15907
|
*/
|
|
15705
15908
|
const markOffline = async (clientId, swarmName) => {
|
|
15706
15909
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15707
|
-
swarm.loggerService.log(METHOD_NAME$
|
|
15910
|
+
swarm.loggerService.log(METHOD_NAME$D, {
|
|
15708
15911
|
clientId,
|
|
15709
15912
|
});
|
|
15710
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15913
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$D);
|
|
15711
15914
|
return await MethodContextService.runInContext(async () => {
|
|
15712
|
-
await swarm.aliveService.markOffline(clientId, swarmName, METHOD_NAME$
|
|
15915
|
+
await swarm.aliveService.markOffline(clientId, swarmName, METHOD_NAME$D);
|
|
15713
15916
|
}, {
|
|
15714
|
-
methodName: METHOD_NAME$
|
|
15917
|
+
methodName: METHOD_NAME$D,
|
|
15715
15918
|
agentName: "",
|
|
15716
15919
|
policyName: "",
|
|
15717
15920
|
stateName: "",
|
|
@@ -15721,7 +15924,7 @@ const markOffline = async (clientId, swarmName) => {
|
|
|
15721
15924
|
});
|
|
15722
15925
|
};
|
|
15723
15926
|
|
|
15724
|
-
const METHOD_NAME$
|
|
15927
|
+
const METHOD_NAME$C = "function.commit.commitToolOutput";
|
|
15725
15928
|
/**
|
|
15726
15929
|
* Commits the output of a tool execution to the active agent in a swarm session.
|
|
15727
15930
|
*
|
|
@@ -15741,19 +15944,19 @@ const METHOD_NAME$D = "function.commit.commitToolOutput";
|
|
|
15741
15944
|
const commitToolOutput = beginContext(async (toolId, content, clientId, agentName) => {
|
|
15742
15945
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15743
15946
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15744
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15947
|
+
swarm$1.loggerService.log(METHOD_NAME$C, {
|
|
15745
15948
|
toolId,
|
|
15746
15949
|
content,
|
|
15747
15950
|
clientId,
|
|
15748
15951
|
agentName,
|
|
15749
15952
|
});
|
|
15750
15953
|
// Validate the agent, session, and swarm to ensure they exist and are accessible
|
|
15751
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
15752
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
15954
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$C);
|
|
15955
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$C);
|
|
15753
15956
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15754
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15957
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$C);
|
|
15755
15958
|
// Check if the specified agent is still the active agent in the swarm session
|
|
15756
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
15959
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$C, clientId, swarmName);
|
|
15757
15960
|
if (currentAgentName !== agentName) {
|
|
15758
15961
|
// Log a skip message if the agent has changed during the operation
|
|
15759
15962
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
@@ -15766,11 +15969,11 @@ const commitToolOutput = beginContext(async (toolId, content, clientId, agentNam
|
|
|
15766
15969
|
return;
|
|
15767
15970
|
}
|
|
15768
15971
|
// Commit the tool output to the session via the session public service
|
|
15769
|
-
await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$
|
|
15972
|
+
await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$C, clientId, swarmName);
|
|
15770
15973
|
});
|
|
15771
15974
|
|
|
15772
15975
|
/** @private Constant defining the method name for logging and validation context */
|
|
15773
|
-
const METHOD_NAME$
|
|
15976
|
+
const METHOD_NAME$B = "function.commit.commitSystemMessage";
|
|
15774
15977
|
/**
|
|
15775
15978
|
* Commits a system-generated message to the active agent in the swarm system.
|
|
15776
15979
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before committing the message.
|
|
@@ -15789,20 +15992,20 @@ const METHOD_NAME$C = "function.commit.commitSystemMessage";
|
|
|
15789
15992
|
const commitSystemMessage = beginContext(async (content, clientId, agentName) => {
|
|
15790
15993
|
// Log the commit attempt if enabled
|
|
15791
15994
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15792
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15995
|
+
swarm$1.loggerService.log(METHOD_NAME$B, {
|
|
15793
15996
|
content,
|
|
15794
15997
|
clientId,
|
|
15795
15998
|
agentName,
|
|
15796
15999
|
});
|
|
15797
16000
|
// Validate the agent exists
|
|
15798
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16001
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$B);
|
|
15799
16002
|
// Validate the session exists and retrieve the associated swarm
|
|
15800
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16003
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$B);
|
|
15801
16004
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15802
16005
|
// Validate the swarm configuration
|
|
15803
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16006
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$B);
|
|
15804
16007
|
// Check if the current agent matches the provided agent
|
|
15805
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16008
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$B, clientId, swarmName);
|
|
15806
16009
|
if (currentAgentName !== agentName) {
|
|
15807
16010
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15808
16011
|
swarm$1.loggerService.log('function "commitSystemMessage" skipped due to the agent change', {
|
|
@@ -15813,11 +16016,11 @@ const commitSystemMessage = beginContext(async (content, clientId, agentName) =>
|
|
|
15813
16016
|
return;
|
|
15814
16017
|
}
|
|
15815
16018
|
// Commit the system message via SessionPublicService
|
|
15816
|
-
await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$
|
|
16019
|
+
await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$B, clientId, swarmName);
|
|
15817
16020
|
});
|
|
15818
16021
|
|
|
15819
16022
|
/** @private Constant defining the method name for logging and validation context */
|
|
15820
|
-
const METHOD_NAME$
|
|
16023
|
+
const METHOD_NAME$A = "function.commit.commitFlush";
|
|
15821
16024
|
/**
|
|
15822
16025
|
* Commits a flush of agent history for a specific client and agent in the swarm system.
|
|
15823
16026
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before flushing the history.
|
|
@@ -15834,19 +16037,19 @@ const METHOD_NAME$B = "function.commit.commitFlush";
|
|
|
15834
16037
|
const commitFlush = beginContext(async (clientId, agentName) => {
|
|
15835
16038
|
// Log the flush attempt if enabled
|
|
15836
16039
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15837
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16040
|
+
swarm$1.loggerService.log(METHOD_NAME$A, {
|
|
15838
16041
|
clientId,
|
|
15839
16042
|
agentName,
|
|
15840
16043
|
});
|
|
15841
16044
|
// Validate the agent exists
|
|
15842
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16045
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$A);
|
|
15843
16046
|
// Validate the session exists and retrieve the associated swarm
|
|
15844
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16047
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$A);
|
|
15845
16048
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15846
16049
|
// Validate the swarm configuration
|
|
15847
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16050
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$A);
|
|
15848
16051
|
// Check if the current agent matches the provided agent
|
|
15849
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16052
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$A, clientId, swarmName);
|
|
15850
16053
|
if (currentAgentName !== agentName) {
|
|
15851
16054
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15852
16055
|
swarm$1.loggerService.log('function "commitFlush" skipped due to the agent change', {
|
|
@@ -15857,10 +16060,10 @@ const commitFlush = beginContext(async (clientId, agentName) => {
|
|
|
15857
16060
|
return;
|
|
15858
16061
|
}
|
|
15859
16062
|
// Commit the flush of agent history via SessionPublicService
|
|
15860
|
-
await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$
|
|
16063
|
+
await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$A, clientId, swarmName);
|
|
15861
16064
|
});
|
|
15862
16065
|
|
|
15863
|
-
const METHOD_NAME$
|
|
16066
|
+
const METHOD_NAME$z = "function.commit.commitSystemMessage";
|
|
15864
16067
|
/**
|
|
15865
16068
|
* Commits a user message to the active agent's history in a swarm session without triggering a response.
|
|
15866
16069
|
*
|
|
@@ -15879,19 +16082,19 @@ const METHOD_NAME$A = "function.commit.commitSystemMessage";
|
|
|
15879
16082
|
const commitUserMessage = beginContext(async (content, mode, clientId, agentName, payload) => {
|
|
15880
16083
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15881
16084
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15882
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16085
|
+
swarm$1.loggerService.log(METHOD_NAME$z, {
|
|
15883
16086
|
content,
|
|
15884
16087
|
clientId,
|
|
15885
16088
|
agentName,
|
|
15886
16089
|
mode,
|
|
15887
16090
|
});
|
|
15888
16091
|
// Validate the agent, session, and swarm to ensure they exist and are accessible
|
|
15889
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
15890
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16092
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$z);
|
|
16093
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$z);
|
|
15891
16094
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15892
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16095
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$z);
|
|
15893
16096
|
// Check if the specified agent is still the active agent in the swarm session
|
|
15894
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16097
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$z, clientId, swarmName);
|
|
15895
16098
|
if (currentAgentName !== agentName) {
|
|
15896
16099
|
// Log a skip message if the agent has changed during the operation
|
|
15897
16100
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
@@ -15904,18 +16107,18 @@ const commitUserMessage = beginContext(async (content, mode, clientId, agentName
|
|
|
15904
16107
|
}
|
|
15905
16108
|
if (payload) {
|
|
15906
16109
|
return await PayloadContextService.runInContext(async () => {
|
|
15907
|
-
await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$
|
|
16110
|
+
await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$z, clientId, swarmName);
|
|
15908
16111
|
}, {
|
|
15909
16112
|
clientId,
|
|
15910
16113
|
payload,
|
|
15911
16114
|
});
|
|
15912
16115
|
}
|
|
15913
16116
|
// Commit the user message to the agent's history via the session public service
|
|
15914
|
-
return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$
|
|
16117
|
+
return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$z, clientId, swarmName);
|
|
15915
16118
|
});
|
|
15916
16119
|
|
|
15917
16120
|
/** @private Constant defining the method name for logging and validation context */
|
|
15918
|
-
const METHOD_NAME$
|
|
16121
|
+
const METHOD_NAME$y = "function.commit.commitSystemMessageForce";
|
|
15919
16122
|
/**
|
|
15920
16123
|
* Forcefully commits a system-generated message to a session in the swarm system, without checking the active agent.
|
|
15921
16124
|
* Validates the session and swarm, then proceeds with committing the message regardless of the current agent state.
|
|
@@ -15934,20 +16137,20 @@ const METHOD_NAME$z = "function.commit.commitSystemMessageForce";
|
|
|
15934
16137
|
const commitSystemMessageForce = beginContext(async (content, clientId) => {
|
|
15935
16138
|
// Log the commit attempt if enabled
|
|
15936
16139
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15937
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16140
|
+
swarm$1.loggerService.log(METHOD_NAME$y, {
|
|
15938
16141
|
content,
|
|
15939
16142
|
clientId,
|
|
15940
16143
|
});
|
|
15941
16144
|
// Validate the session exists and retrieve the associated swarm
|
|
15942
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16145
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$y);
|
|
15943
16146
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15944
16147
|
// Validate the swarm configuration
|
|
15945
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16148
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$y);
|
|
15946
16149
|
// Commit the system message via SessionPublicService without agent checks
|
|
15947
|
-
await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$
|
|
16150
|
+
await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$y, clientId, swarmName);
|
|
15948
16151
|
});
|
|
15949
16152
|
|
|
15950
|
-
const METHOD_NAME$
|
|
16153
|
+
const METHOD_NAME$x = "function.commit.commitSystemMessage";
|
|
15951
16154
|
/**
|
|
15952
16155
|
* Commits a user message to the active agent's history in a swarm session without triggering a response and without checking the active agent.
|
|
15953
16156
|
*
|
|
@@ -15965,29 +16168,29 @@ const METHOD_NAME$y = "function.commit.commitSystemMessage";
|
|
|
15965
16168
|
const commitUserMessageForce = beginContext(async (content, mode, clientId, payload) => {
|
|
15966
16169
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15967
16170
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15968
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16171
|
+
swarm$1.loggerService.log(METHOD_NAME$x, {
|
|
15969
16172
|
content,
|
|
15970
16173
|
clientId,
|
|
15971
16174
|
mode,
|
|
15972
16175
|
});
|
|
15973
16176
|
// Validate the session and swarm to ensure they exist and are accessible
|
|
15974
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16177
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$x);
|
|
15975
16178
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15976
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16179
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$x);
|
|
15977
16180
|
if (payload) {
|
|
15978
16181
|
return await PayloadContextService.runInContext(async () => {
|
|
15979
|
-
await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$
|
|
16182
|
+
await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$x, clientId, swarmName);
|
|
15980
16183
|
}, {
|
|
15981
16184
|
clientId,
|
|
15982
16185
|
payload,
|
|
15983
16186
|
});
|
|
15984
16187
|
}
|
|
15985
16188
|
// Commit the user message to the agent's history via the session public service without checking the active agent
|
|
15986
|
-
return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$
|
|
16189
|
+
return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$x, clientId, swarmName);
|
|
15987
16190
|
});
|
|
15988
16191
|
|
|
15989
16192
|
/** @private Constant defining the method name for logging and validation context */
|
|
15990
|
-
const METHOD_NAME$
|
|
16193
|
+
const METHOD_NAME$w = "function.commit.commitAssistantMessage";
|
|
15991
16194
|
/**
|
|
15992
16195
|
* Commits an assistant-generated message to the active agent in the swarm system.
|
|
15993
16196
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before committing the message.
|
|
@@ -16005,20 +16208,20 @@ const METHOD_NAME$x = "function.commit.commitAssistantMessage";
|
|
|
16005
16208
|
const commitAssistantMessage = beginContext(async (content, clientId, agentName) => {
|
|
16006
16209
|
// Log the commit attempt if enabled
|
|
16007
16210
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16008
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16211
|
+
swarm$1.loggerService.log(METHOD_NAME$w, {
|
|
16009
16212
|
content,
|
|
16010
16213
|
clientId,
|
|
16011
16214
|
agentName,
|
|
16012
16215
|
});
|
|
16013
16216
|
// Validate the agent exists
|
|
16014
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16217
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$w);
|
|
16015
16218
|
// Validate the session exists and retrieve the associated swarm
|
|
16016
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16219
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$w);
|
|
16017
16220
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16018
16221
|
// Validate the swarm configuration
|
|
16019
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16222
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$w);
|
|
16020
16223
|
// Check if the current agent matches the provided agent
|
|
16021
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16224
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$w, clientId, swarmName);
|
|
16022
16225
|
if (currentAgentName !== agentName) {
|
|
16023
16226
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16024
16227
|
swarm$1.loggerService.log('function "commitAssistantMessage" skipped due to the agent change', {
|
|
@@ -16029,11 +16232,11 @@ const commitAssistantMessage = beginContext(async (content, clientId, agentName)
|
|
|
16029
16232
|
return;
|
|
16030
16233
|
}
|
|
16031
16234
|
// Commit the assistant message via SessionPublicService
|
|
16032
|
-
await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$
|
|
16235
|
+
await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$w, clientId, swarmName);
|
|
16033
16236
|
});
|
|
16034
16237
|
|
|
16035
16238
|
/** @private Constant defining the method name for logging and validation context */
|
|
16036
|
-
const METHOD_NAME$
|
|
16239
|
+
const METHOD_NAME$v = "function.commit.commitAssistantMessageForce";
|
|
16037
16240
|
/**
|
|
16038
16241
|
* Forcefully commits an assistant-generated message to a session in the swarm system, without checking the active agent.
|
|
16039
16242
|
* Validates the session and swarm, then proceeds with committing the message regardless of the current agent state.
|
|
@@ -16052,21 +16255,21 @@ const METHOD_NAME$w = "function.commit.commitAssistantMessageForce";
|
|
|
16052
16255
|
const commitAssistantMessageForce = beginContext(async (content, clientId) => {
|
|
16053
16256
|
// Log the commit attempt if enabled
|
|
16054
16257
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16055
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16258
|
+
swarm$1.loggerService.log(METHOD_NAME$v, {
|
|
16056
16259
|
content,
|
|
16057
16260
|
clientId,
|
|
16058
16261
|
});
|
|
16059
16262
|
// Validate the session exists and retrieve the associated swarm
|
|
16060
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16263
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$v);
|
|
16061
16264
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16062
16265
|
// Validate the swarm configuration
|
|
16063
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16266
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$v);
|
|
16064
16267
|
// Commit the assistant message via SessionPublicService without agent checks
|
|
16065
|
-
await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$
|
|
16268
|
+
await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$v, clientId, swarmName);
|
|
16066
16269
|
});
|
|
16067
16270
|
|
|
16068
16271
|
/** @private Constant defining the method name for logging and validation context */
|
|
16069
|
-
const METHOD_NAME$
|
|
16272
|
+
const METHOD_NAME$u = "function.commit.cancelOutput";
|
|
16070
16273
|
/**
|
|
16071
16274
|
* Cancels the awaited output for a specific client and agent by emitting an empty string.
|
|
16072
16275
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before cancellation.
|
|
@@ -16082,19 +16285,19 @@ const METHOD_NAME$v = "function.commit.cancelOutput";
|
|
|
16082
16285
|
const cancelOutput = beginContext(async (clientId, agentName) => {
|
|
16083
16286
|
// Log the cancellation attempt if enabled
|
|
16084
16287
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16085
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16288
|
+
swarm$1.loggerService.log(METHOD_NAME$u, {
|
|
16086
16289
|
clientId,
|
|
16087
16290
|
agentName,
|
|
16088
16291
|
});
|
|
16089
16292
|
// Validate the agent exists
|
|
16090
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16293
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$u);
|
|
16091
16294
|
// Validate the session exists and retrieve the associated swarm
|
|
16092
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16295
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$u);
|
|
16093
16296
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16094
16297
|
// Validate the swarm configuration
|
|
16095
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16298
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$u);
|
|
16096
16299
|
// Check if the current agent matches the provided agent
|
|
16097
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16300
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$u, clientId, swarmName);
|
|
16098
16301
|
if (currentAgentName !== agentName) {
|
|
16099
16302
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16100
16303
|
swarm$1.loggerService.log('function "cancelOutput" skipped due to the agent change', {
|
|
@@ -16105,11 +16308,11 @@ const cancelOutput = beginContext(async (clientId, agentName) => {
|
|
|
16105
16308
|
return;
|
|
16106
16309
|
}
|
|
16107
16310
|
// Perform the output cancellation via SwarmPublicService
|
|
16108
|
-
await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$
|
|
16311
|
+
await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$u, clientId, swarmName);
|
|
16109
16312
|
});
|
|
16110
16313
|
|
|
16111
16314
|
/** @private Constant defining the method name for logging and validation context */
|
|
16112
|
-
const METHOD_NAME$
|
|
16315
|
+
const METHOD_NAME$t = "function.commit.cancelOutputForce";
|
|
16113
16316
|
/**
|
|
16114
16317
|
* Forcefully cancels the awaited output for a specific client by emitting an empty string, without checking the active agent.
|
|
16115
16318
|
* Validates the session and swarm, then proceeds with cancellation regardless of the current agent state.
|
|
@@ -16126,20 +16329,20 @@ const METHOD_NAME$u = "function.commit.cancelOutputForce";
|
|
|
16126
16329
|
const cancelOutputForce = beginContext(async (clientId) => {
|
|
16127
16330
|
// Log the cancellation attempt if enabled
|
|
16128
16331
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16129
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16332
|
+
swarm$1.loggerService.log(METHOD_NAME$t, {
|
|
16130
16333
|
clientId,
|
|
16131
16334
|
});
|
|
16132
16335
|
// Validate the session exists and retrieve the associated swarm
|
|
16133
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16336
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$t);
|
|
16134
16337
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16135
16338
|
// Validate the swarm configuration
|
|
16136
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16339
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$t);
|
|
16137
16340
|
// Perform the output cancellation via SwarmPublicService without agent checks
|
|
16138
|
-
await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$
|
|
16341
|
+
await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$t, clientId, swarmName);
|
|
16139
16342
|
});
|
|
16140
16343
|
|
|
16141
16344
|
/** @private Constant defining the method name for logging and validation context */
|
|
16142
|
-
const METHOD_NAME$
|
|
16345
|
+
const METHOD_NAME$s = "function.commit.commitStopTools";
|
|
16143
16346
|
/**
|
|
16144
16347
|
* Prevents the next tool from being executed for a specific client and agent in the swarm system.
|
|
16145
16348
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before stopping tool execution.
|
|
@@ -16156,19 +16359,19 @@ const METHOD_NAME$t = "function.commit.commitStopTools";
|
|
|
16156
16359
|
const commitStopTools = beginContext(async (clientId, agentName) => {
|
|
16157
16360
|
// Log the stop tools attempt if enabled
|
|
16158
16361
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16159
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16362
|
+
swarm$1.loggerService.log(METHOD_NAME$s, {
|
|
16160
16363
|
clientId,
|
|
16161
16364
|
agentName,
|
|
16162
16365
|
});
|
|
16163
16366
|
// Validate the agent exists
|
|
16164
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16367
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$s);
|
|
16165
16368
|
// Validate the session exists and retrieve the associated swarm
|
|
16166
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16369
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$s);
|
|
16167
16370
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16168
16371
|
// Validate the swarm configuration
|
|
16169
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16372
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$s);
|
|
16170
16373
|
// Check if the current agent matches the provided agent
|
|
16171
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16374
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$s, clientId, swarmName);
|
|
16172
16375
|
if (currentAgentName !== agentName) {
|
|
16173
16376
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16174
16377
|
swarm$1.loggerService.log('function "commitStopTools" skipped due to the agent change', {
|
|
@@ -16179,11 +16382,11 @@ const commitStopTools = beginContext(async (clientId, agentName) => {
|
|
|
16179
16382
|
return;
|
|
16180
16383
|
}
|
|
16181
16384
|
// Commit the stop of the next tool execution via SessionPublicService
|
|
16182
|
-
await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$
|
|
16385
|
+
await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$s, clientId, swarmName);
|
|
16183
16386
|
});
|
|
16184
16387
|
|
|
16185
16388
|
/** @private Constant defining the method name for logging and validation context */
|
|
16186
|
-
const METHOD_NAME$
|
|
16389
|
+
const METHOD_NAME$r = "function.commit.commitStopToolsForce";
|
|
16187
16390
|
/**
|
|
16188
16391
|
* Forcefully prevents the next tool from being executed for a specific client in the swarm system, without checking the active agent.
|
|
16189
16392
|
* Validates the session and swarm, then proceeds with stopping tool execution regardless of the current agent state.
|
|
@@ -16201,21 +16404,21 @@ const METHOD_NAME$s = "function.commit.commitStopToolsForce";
|
|
|
16201
16404
|
const commitStopToolsForce = beginContext(async (clientId) => {
|
|
16202
16405
|
// Log the stop tools attempt if enabled
|
|
16203
16406
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16204
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16407
|
+
swarm$1.loggerService.log(METHOD_NAME$r, {
|
|
16205
16408
|
clientId,
|
|
16206
|
-
METHOD_NAME: METHOD_NAME$
|
|
16409
|
+
METHOD_NAME: METHOD_NAME$r,
|
|
16207
16410
|
});
|
|
16208
16411
|
// Validate the session exists and retrieve the associated swarm
|
|
16209
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16412
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$r);
|
|
16210
16413
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16211
16414
|
// Validate the swarm configuration
|
|
16212
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16415
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$r);
|
|
16213
16416
|
// Commit the stop of the next tool execution via SessionPublicService without agent checks
|
|
16214
|
-
await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$
|
|
16417
|
+
await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$r, clientId, swarmName);
|
|
16215
16418
|
});
|
|
16216
16419
|
|
|
16217
16420
|
/** @constant {string} METHOD_NAME - The name of the method used for logging and validation */
|
|
16218
|
-
const METHOD_NAME$
|
|
16421
|
+
const METHOD_NAME$q = "function.target.question";
|
|
16219
16422
|
/**
|
|
16220
16423
|
* Initiates a question process within a chat context
|
|
16221
16424
|
* @function question
|
|
@@ -16227,21 +16430,21 @@ const METHOD_NAME$r = "function.target.question";
|
|
|
16227
16430
|
*/
|
|
16228
16431
|
const question = beginContext(async (message, clientId, agentName, wikiName) => {
|
|
16229
16432
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16230
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16433
|
+
swarm$1.loggerService.log(METHOD_NAME$q, {
|
|
16231
16434
|
message,
|
|
16232
16435
|
clientId,
|
|
16233
16436
|
agentName,
|
|
16234
16437
|
wikiName,
|
|
16235
16438
|
});
|
|
16236
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16237
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16439
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$q);
|
|
16440
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$q);
|
|
16238
16441
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16239
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16240
|
-
swarm$1.wikiValidationService.validate(wikiName, METHOD_NAME$
|
|
16442
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$q);
|
|
16443
|
+
swarm$1.wikiValidationService.validate(wikiName, METHOD_NAME$q);
|
|
16241
16444
|
if (!swarm$1.agentValidationService.hasWiki(agentName, wikiName)) {
|
|
16242
|
-
throw new Error(`agent-swarm ${METHOD_NAME$
|
|
16445
|
+
throw new Error(`agent-swarm ${METHOD_NAME$q} ${wikiName} not registered in ${agentName}`);
|
|
16243
16446
|
}
|
|
16244
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16447
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$q, clientId, swarmName);
|
|
16245
16448
|
if (currentAgentName !== agentName) {
|
|
16246
16449
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16247
16450
|
swarm$1.loggerService.log('function "question" skipped due to the agent change', {
|
|
@@ -16264,7 +16467,7 @@ const question = beginContext(async (message, clientId, agentName, wikiName) =>
|
|
|
16264
16467
|
});
|
|
16265
16468
|
|
|
16266
16469
|
/** @constant {string} METHOD_NAME - The name of the method used for logging and validation */
|
|
16267
|
-
const METHOD_NAME$
|
|
16470
|
+
const METHOD_NAME$p = "function.target.questionForce";
|
|
16268
16471
|
/**
|
|
16269
16472
|
* Initiates a forced question process within a chat context
|
|
16270
16473
|
* @function questionForce
|
|
@@ -16275,17 +16478,17 @@ const METHOD_NAME$q = "function.target.questionForce";
|
|
|
16275
16478
|
*/
|
|
16276
16479
|
const questionForce = beginContext(async (message, clientId, wikiName) => {
|
|
16277
16480
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16278
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16481
|
+
swarm$1.loggerService.log(METHOD_NAME$p, {
|
|
16279
16482
|
message,
|
|
16280
16483
|
clientId,
|
|
16281
16484
|
wikiName,
|
|
16282
16485
|
});
|
|
16283
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16486
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$p);
|
|
16284
16487
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16285
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16286
|
-
swarm$1.wikiValidationService.validate(wikiName, METHOD_NAME$
|
|
16488
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$p);
|
|
16489
|
+
swarm$1.wikiValidationService.validate(wikiName, METHOD_NAME$p);
|
|
16287
16490
|
const { getChat, callbacks } = swarm$1.wikiSchemaService.get(wikiName);
|
|
16288
|
-
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16491
|
+
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$p, clientId, swarmName);
|
|
16289
16492
|
const args = {
|
|
16290
16493
|
clientId,
|
|
16291
16494
|
message,
|
|
@@ -16297,7 +16500,7 @@ const questionForce = beginContext(async (message, clientId, wikiName) => {
|
|
|
16297
16500
|
return await getChat(args);
|
|
16298
16501
|
});
|
|
16299
16502
|
|
|
16300
|
-
const METHOD_NAME$
|
|
16503
|
+
const METHOD_NAME$o = "function.target.disposeConnection";
|
|
16301
16504
|
/**
|
|
16302
16505
|
* Disposes of a client session and all related resources within a swarm.
|
|
16303
16506
|
*
|
|
@@ -16314,10 +16517,10 @@ const METHOD_NAME$p = "function.target.disposeConnection";
|
|
|
16314
16517
|
* @example
|
|
16315
16518
|
* await disposeConnection("client-123", "TaskSwarm");
|
|
16316
16519
|
*/
|
|
16317
|
-
const disposeConnection = beginContext(async (clientId, swarmName, methodName = METHOD_NAME$
|
|
16520
|
+
const disposeConnection = beginContext(async (clientId, swarmName, methodName = METHOD_NAME$o) => {
|
|
16318
16521
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16319
16522
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16320
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16523
|
+
swarm$1.loggerService.log(METHOD_NAME$o, {
|
|
16321
16524
|
clientId,
|
|
16322
16525
|
swarmName,
|
|
16323
16526
|
});
|
|
@@ -16389,7 +16592,7 @@ const disposeConnection = beginContext(async (clientId, swarmName, methodName =
|
|
|
16389
16592
|
PersistMemoryAdapter.dispose(clientId);
|
|
16390
16593
|
});
|
|
16391
16594
|
|
|
16392
|
-
const METHOD_NAME$
|
|
16595
|
+
const METHOD_NAME$n = "function.target.makeAutoDispose";
|
|
16393
16596
|
/**
|
|
16394
16597
|
* Default timeout in seconds before auto-dispose is triggered.
|
|
16395
16598
|
* @constant {number}
|
|
@@ -16420,7 +16623,7 @@ const DEFAULT_TIMEOUT = 15 * 60;
|
|
|
16420
16623
|
const makeAutoDispose = beginContext((clientId, swarmName, { timeoutSeconds = DEFAULT_TIMEOUT, onDestroy, } = {}) => {
|
|
16421
16624
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16422
16625
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16423
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16626
|
+
swarm$1.loggerService.log(METHOD_NAME$n, {
|
|
16424
16627
|
clientId,
|
|
16425
16628
|
swarmName,
|
|
16426
16629
|
});
|
|
@@ -16453,7 +16656,7 @@ const makeAutoDispose = beginContext((clientId, swarmName, { timeoutSeconds = DE
|
|
|
16453
16656
|
};
|
|
16454
16657
|
});
|
|
16455
16658
|
|
|
16456
|
-
const METHOD_NAME$
|
|
16659
|
+
const METHOD_NAME$m = "function.target.execute";
|
|
16457
16660
|
/**
|
|
16458
16661
|
* Sends a message to the active agent in a swarm session as if it originated from the client side.
|
|
16459
16662
|
*
|
|
@@ -16475,19 +16678,19 @@ const execute = beginContext(async (content, clientId, agentName) => {
|
|
|
16475
16678
|
const executionId = functoolsKit.randomString();
|
|
16476
16679
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16477
16680
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16478
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16681
|
+
swarm$1.loggerService.log(METHOD_NAME$m, {
|
|
16479
16682
|
content,
|
|
16480
16683
|
clientId,
|
|
16481
16684
|
agentName,
|
|
16482
16685
|
executionId,
|
|
16483
16686
|
});
|
|
16484
16687
|
// Validate the agent, session, and swarm
|
|
16485
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16486
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16688
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$m);
|
|
16689
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$m);
|
|
16487
16690
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16488
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16691
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$m);
|
|
16489
16692
|
// Check if the specified agent is still the active agent
|
|
16490
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16693
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$m, clientId, swarmName);
|
|
16491
16694
|
if (currentAgentName !== agentName) {
|
|
16492
16695
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16493
16696
|
swarm$1.loggerService.log('function "execute" skipped due to the agent change', {
|
|
@@ -16506,7 +16709,7 @@ const execute = beginContext(async (content, clientId, agentName) => {
|
|
|
16506
16709
|
agentName,
|
|
16507
16710
|
swarmName,
|
|
16508
16711
|
});
|
|
16509
|
-
const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$
|
|
16712
|
+
const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$m, clientId, swarmName);
|
|
16510
16713
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
16511
16714
|
swarm$1.busService.commitExecutionEnd(clientId, {
|
|
16512
16715
|
agentName,
|
|
@@ -16526,7 +16729,7 @@ const execute = beginContext(async (content, clientId, agentName) => {
|
|
|
16526
16729
|
});
|
|
16527
16730
|
});
|
|
16528
16731
|
|
|
16529
|
-
const METHOD_NAME$
|
|
16732
|
+
const METHOD_NAME$l = "function.target.emit";
|
|
16530
16733
|
/**
|
|
16531
16734
|
* Emits a string as model output without executing an incoming message, with agent activity validation.
|
|
16532
16735
|
*
|
|
@@ -16546,18 +16749,18 @@ const METHOD_NAME$m = "function.target.emit";
|
|
|
16546
16749
|
const emit = beginContext(async (content, clientId, agentName) => {
|
|
16547
16750
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16548
16751
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16549
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16752
|
+
swarm$1.loggerService.log(METHOD_NAME$l, {
|
|
16550
16753
|
content,
|
|
16551
16754
|
clientId,
|
|
16552
16755
|
agentName,
|
|
16553
16756
|
});
|
|
16554
16757
|
// Validate the agent, session, and swarm
|
|
16555
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16556
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16758
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$l);
|
|
16759
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$l);
|
|
16557
16760
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16558
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16761
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$l);
|
|
16559
16762
|
// Check if the specified agent is still the active agent
|
|
16560
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16763
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$l, clientId, swarmName);
|
|
16561
16764
|
if (currentAgentName !== agentName) {
|
|
16562
16765
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16563
16766
|
swarm$1.loggerService.log('function "emit" skipped due to the agent change', {
|
|
@@ -16568,10 +16771,10 @@ const emit = beginContext(async (content, clientId, agentName) => {
|
|
|
16568
16771
|
return;
|
|
16569
16772
|
}
|
|
16570
16773
|
// Emit the content directly via the session public service
|
|
16571
|
-
return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$
|
|
16774
|
+
return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$l, clientId, swarmName);
|
|
16572
16775
|
});
|
|
16573
16776
|
|
|
16574
|
-
const METHOD_NAME$
|
|
16777
|
+
const METHOD_NAME$k = "function.target.notify";
|
|
16575
16778
|
/**
|
|
16576
16779
|
* Sends a notification message as output from the swarm session without executing an incoming message.
|
|
16577
16780
|
*
|
|
@@ -16591,23 +16794,23 @@ const METHOD_NAME$l = "function.target.notify";
|
|
|
16591
16794
|
const notify = beginContext(async (content, clientId, agentName) => {
|
|
16592
16795
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16593
16796
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16594
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16797
|
+
swarm$1.loggerService.log(METHOD_NAME$k, {
|
|
16595
16798
|
content,
|
|
16596
16799
|
clientId,
|
|
16597
16800
|
agentName,
|
|
16598
16801
|
});
|
|
16599
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16802
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$k);
|
|
16600
16803
|
// Check if the session mode is "makeConnection"
|
|
16601
16804
|
if (swarm$1.sessionValidationService.getSessionMode(clientId) !==
|
|
16602
16805
|
"makeConnection") {
|
|
16603
16806
|
throw new Error(`agent-swarm-kit notify session is not makeConnection clientId=${clientId}`);
|
|
16604
16807
|
}
|
|
16605
16808
|
// Validate the agent, session, and swarm
|
|
16606
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16809
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$k);
|
|
16607
16810
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16608
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16811
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$k);
|
|
16609
16812
|
// Check if the specified agent is still the active agent
|
|
16610
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16813
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$k, clientId, swarmName);
|
|
16611
16814
|
if (currentAgentName !== agentName) {
|
|
16612
16815
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16613
16816
|
swarm$1.loggerService.log('function "notify" skipped due to the agent change', {
|
|
@@ -16618,10 +16821,10 @@ const notify = beginContext(async (content, clientId, agentName) => {
|
|
|
16618
16821
|
return;
|
|
16619
16822
|
}
|
|
16620
16823
|
// Notify the content directly via the session public service
|
|
16621
|
-
return await swarm$1.sessionPublicService.notify(content, METHOD_NAME$
|
|
16824
|
+
return await swarm$1.sessionPublicService.notify(content, METHOD_NAME$k, clientId, swarmName);
|
|
16622
16825
|
});
|
|
16623
16826
|
|
|
16624
|
-
const METHOD_NAME$
|
|
16827
|
+
const METHOD_NAME$j = "function.target.notifyForce";
|
|
16625
16828
|
/**
|
|
16626
16829
|
* Sends a notification message as output from the swarm session without executing an incoming message.
|
|
16627
16830
|
*
|
|
@@ -16640,11 +16843,11 @@ const METHOD_NAME$k = "function.target.notifyForce";
|
|
|
16640
16843
|
const notifyForce = beginContext(async (content, clientId) => {
|
|
16641
16844
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16642
16845
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16643
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16846
|
+
swarm$1.loggerService.log(METHOD_NAME$j, {
|
|
16644
16847
|
content,
|
|
16645
16848
|
clientId,
|
|
16646
16849
|
});
|
|
16647
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16850
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$j);
|
|
16648
16851
|
// Check if the session mode is "makeConnection"
|
|
16649
16852
|
if (swarm$1.sessionValidationService.getSessionMode(clientId) !==
|
|
16650
16853
|
"makeConnection") {
|
|
@@ -16652,12 +16855,12 @@ const notifyForce = beginContext(async (content, clientId) => {
|
|
|
16652
16855
|
}
|
|
16653
16856
|
// Validate the agent, session, and swarm
|
|
16654
16857
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16655
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16858
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$j);
|
|
16656
16859
|
// Notify the content directly via the session public service
|
|
16657
|
-
return await swarm$1.sessionPublicService.notify(content, METHOD_NAME$
|
|
16860
|
+
return await swarm$1.sessionPublicService.notify(content, METHOD_NAME$j, clientId, swarmName);
|
|
16658
16861
|
});
|
|
16659
16862
|
|
|
16660
|
-
const METHOD_NAME$
|
|
16863
|
+
const METHOD_NAME$i = "function.target.runStateless";
|
|
16661
16864
|
/**
|
|
16662
16865
|
* Executes a message statelessly with an agent in a swarm session, bypassing chat history.
|
|
16663
16866
|
*
|
|
@@ -16680,19 +16883,19 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
|
|
|
16680
16883
|
const executionId = functoolsKit.randomString();
|
|
16681
16884
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16682
16885
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16683
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16886
|
+
swarm$1.loggerService.log(METHOD_NAME$i, {
|
|
16684
16887
|
content,
|
|
16685
16888
|
clientId,
|
|
16686
16889
|
agentName,
|
|
16687
16890
|
executionId,
|
|
16688
16891
|
});
|
|
16689
16892
|
// Validate the agent, session, and swarm
|
|
16690
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16691
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16893
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$i);
|
|
16894
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$i);
|
|
16692
16895
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16693
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16896
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$i);
|
|
16694
16897
|
// Check if the specified agent is still the active agent
|
|
16695
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16898
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$i, clientId, swarmName);
|
|
16696
16899
|
if (currentAgentName !== agentName) {
|
|
16697
16900
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16698
16901
|
swarm$1.loggerService.log('function "runStateless" skipped due to the agent change', {
|
|
@@ -16711,7 +16914,7 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
|
|
|
16711
16914
|
agentName,
|
|
16712
16915
|
swarmName,
|
|
16713
16916
|
});
|
|
16714
|
-
const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$
|
|
16917
|
+
const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$i, clientId, swarmName);
|
|
16715
16918
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
16716
16919
|
swarm$1.busService.commitExecutionEnd(clientId, {
|
|
16717
16920
|
agentName,
|
|
@@ -16731,7 +16934,7 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
|
|
|
16731
16934
|
});
|
|
16732
16935
|
});
|
|
16733
16936
|
|
|
16734
|
-
const METHOD_NAME$
|
|
16937
|
+
const METHOD_NAME$h = "function.target.runStatelessForce";
|
|
16735
16938
|
/**
|
|
16736
16939
|
* Executes a message statelessly with the active agent in a swarm session, bypassing chat history and forcing execution regardless of agent activity.
|
|
16737
16940
|
*
|
|
@@ -16752,22 +16955,22 @@ const runStatelessForce = beginContext(async (content, clientId) => {
|
|
|
16752
16955
|
const executionId = functoolsKit.randomString();
|
|
16753
16956
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16754
16957
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16755
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16958
|
+
swarm$1.loggerService.log(METHOD_NAME$h, {
|
|
16756
16959
|
content,
|
|
16757
16960
|
clientId,
|
|
16758
16961
|
executionId,
|
|
16759
16962
|
});
|
|
16760
16963
|
// Validate the session and swarm
|
|
16761
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16964
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$h);
|
|
16762
16965
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16763
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16966
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$h);
|
|
16764
16967
|
// Execute the command statelessly within an execution context with performance tracking
|
|
16765
16968
|
return ExecutionContextService.runInContext(async () => {
|
|
16766
16969
|
let isFinished = false;
|
|
16767
16970
|
swarm$1.perfService.startExecution(executionId, clientId, content.length);
|
|
16768
16971
|
try {
|
|
16769
16972
|
swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
|
|
16770
|
-
const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$
|
|
16973
|
+
const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$h, clientId, swarmName);
|
|
16771
16974
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
16772
16975
|
swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
|
|
16773
16976
|
return result;
|
|
@@ -16794,7 +16997,7 @@ const SCHEDULED_DELAY$1 = 1000;
|
|
|
16794
16997
|
* @constant {number}
|
|
16795
16998
|
*/
|
|
16796
16999
|
const RATE_DELAY = 10000;
|
|
16797
|
-
const METHOD_NAME$
|
|
17000
|
+
const METHOD_NAME$g = "function.target.makeConnection";
|
|
16798
17001
|
/**
|
|
16799
17002
|
* Internal implementation of the connection factory for a client to a swarm.
|
|
16800
17003
|
*
|
|
@@ -16809,21 +17012,21 @@ const METHOD_NAME$h = "function.target.makeConnection";
|
|
|
16809
17012
|
const makeConnectionInternal = (connector, clientId, swarmName) => {
|
|
16810
17013
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16811
17014
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16812
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17015
|
+
swarm$1.loggerService.log(METHOD_NAME$g, {
|
|
16813
17016
|
clientId,
|
|
16814
17017
|
swarmName,
|
|
16815
17018
|
});
|
|
16816
17019
|
// Validate the swarm and initialize the session
|
|
16817
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
17020
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$g);
|
|
16818
17021
|
swarm$1.sessionValidationService.addSession(clientId, swarmName, "makeConnection");
|
|
16819
17022
|
// Create a queued send function using the session public service
|
|
16820
|
-
const send = functoolsKit.queued(swarm$1.sessionPublicService.connect(connector, METHOD_NAME$
|
|
17023
|
+
const send = functoolsKit.queued(swarm$1.sessionPublicService.connect(connector, METHOD_NAME$g, clientId, swarmName));
|
|
16821
17024
|
// Return a wrapped send function with validation and agent context
|
|
16822
17025
|
return (async (outgoing) => {
|
|
16823
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17026
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$g);
|
|
16824
17027
|
return await send({
|
|
16825
17028
|
data: outgoing,
|
|
16826
|
-
agentName: await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
17029
|
+
agentName: await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$g, clientId, swarmName),
|
|
16827
17030
|
clientId,
|
|
16828
17031
|
});
|
|
16829
17032
|
});
|
|
@@ -16906,13 +17109,13 @@ makeConnection.scheduled = (connector, clientId, swarmName, { delay = SCHEDULED_
|
|
|
16906
17109
|
await online();
|
|
16907
17110
|
if (payload) {
|
|
16908
17111
|
return await PayloadContextService.runInContext(async () => {
|
|
16909
|
-
await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$
|
|
17112
|
+
await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$g, clientId, swarmName);
|
|
16910
17113
|
}, {
|
|
16911
17114
|
clientId,
|
|
16912
17115
|
payload,
|
|
16913
17116
|
});
|
|
16914
17117
|
}
|
|
16915
|
-
await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$
|
|
17118
|
+
await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$g, clientId, swarmName);
|
|
16916
17119
|
}),
|
|
16917
17120
|
delay,
|
|
16918
17121
|
});
|
|
@@ -16975,7 +17178,7 @@ makeConnection.rate = (connector, clientId, swarmName, { delay = RATE_DELAY } =
|
|
|
16975
17178
|
};
|
|
16976
17179
|
};
|
|
16977
17180
|
|
|
16978
|
-
const METHOD_NAME$
|
|
17181
|
+
const METHOD_NAME$f = "function.target.complete";
|
|
16979
17182
|
/**
|
|
16980
17183
|
* Time-to-live for the complete function in milliseconds.
|
|
16981
17184
|
* Defines how long the cached complete function remains valid before expiring.
|
|
@@ -17017,7 +17220,7 @@ const createComplete = functoolsKit.ttl((clientId, swarmName) => functoolsKit.qu
|
|
|
17017
17220
|
*
|
|
17018
17221
|
* @returns {Promise<void>} A promise that resolves when the garbage collector is initialized.
|
|
17019
17222
|
*/
|
|
17020
|
-
const createGc$
|
|
17223
|
+
const createGc$1 = functoolsKit.singleshot(async () => {
|
|
17021
17224
|
setInterval(createComplete.gc, COMPLETE_GC);
|
|
17022
17225
|
});
|
|
17023
17226
|
/**
|
|
@@ -17041,7 +17244,7 @@ const complete = beginContext(async (content, clientId, swarmName, payload = nul
|
|
|
17041
17244
|
const executionId = functoolsKit.randomString();
|
|
17042
17245
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17043
17246
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17044
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17247
|
+
swarm$1.loggerService.log(METHOD_NAME$f, {
|
|
17045
17248
|
content,
|
|
17046
17249
|
clientId,
|
|
17047
17250
|
executionId,
|
|
@@ -17050,7 +17253,7 @@ const complete = beginContext(async (content, clientId, swarmName, payload = nul
|
|
|
17050
17253
|
await markOnline(clientId, swarmName);
|
|
17051
17254
|
// Set up the TTL-limited, queued execution function and garbage collector
|
|
17052
17255
|
const run = await createComplete(clientId, swarmName);
|
|
17053
|
-
createGc$
|
|
17256
|
+
createGc$1();
|
|
17054
17257
|
// Execute the command within an execution context with performance tracking
|
|
17055
17258
|
const handleRun = async () => {
|
|
17056
17259
|
return await ExecutionContextService.runInContext(async () => {
|
|
@@ -17059,7 +17262,7 @@ const complete = beginContext(async (content, clientId, swarmName, payload = nul
|
|
|
17059
17262
|
swarm$1.navigationValidationService.beginMonit(clientId, swarmName);
|
|
17060
17263
|
try {
|
|
17061
17264
|
swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
|
|
17062
|
-
const result = await run(METHOD_NAME$
|
|
17265
|
+
const result = await run(METHOD_NAME$f, content);
|
|
17063
17266
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
17064
17267
|
swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
|
|
17065
17268
|
return result;
|
|
@@ -17089,7 +17292,7 @@ const complete = beginContext(async (content, clientId, swarmName, payload = nul
|
|
|
17089
17292
|
* @constant {number}
|
|
17090
17293
|
*/
|
|
17091
17294
|
const SCHEDULED_DELAY = 1000;
|
|
17092
|
-
const METHOD_NAME$
|
|
17295
|
+
const METHOD_NAME$e = "function.target.session";
|
|
17093
17296
|
/**
|
|
17094
17297
|
* Internal implementation of the session factory for a client and swarm.
|
|
17095
17298
|
*
|
|
@@ -17104,23 +17307,23 @@ const sessionInternal = (clientId, swarmName, { onDispose = () => { } } = {}) =>
|
|
|
17104
17307
|
const executionId = functoolsKit.randomString();
|
|
17105
17308
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17106
17309
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17107
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17310
|
+
swarm$1.loggerService.log(METHOD_NAME$e, {
|
|
17108
17311
|
clientId,
|
|
17109
17312
|
swarmName,
|
|
17110
17313
|
executionId,
|
|
17111
17314
|
});
|
|
17112
17315
|
// Validate the swarm and initialize the session
|
|
17113
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
17316
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$e);
|
|
17114
17317
|
swarm$1.sessionValidationService.addSession(clientId, swarmName, "session");
|
|
17115
17318
|
const complete = functoolsKit.queued(async (content) => {
|
|
17116
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17319
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$e);
|
|
17117
17320
|
return ExecutionContextService.runInContext(async () => {
|
|
17118
17321
|
let isFinished = false;
|
|
17119
17322
|
swarm$1.perfService.startExecution(executionId, clientId, content.length);
|
|
17120
17323
|
swarm$1.navigationValidationService.beginMonit(clientId, swarmName);
|
|
17121
17324
|
try {
|
|
17122
17325
|
swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
|
|
17123
|
-
const result = await swarm$1.sessionPublicService.execute(content, "user", METHOD_NAME$
|
|
17326
|
+
const result = await swarm$1.sessionPublicService.execute(content, "user", METHOD_NAME$e, clientId, swarmName);
|
|
17124
17327
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
17125
17328
|
swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
|
|
17126
17329
|
return result;
|
|
@@ -17141,7 +17344,7 @@ const sessionInternal = (clientId, swarmName, { onDispose = () => { } } = {}) =>
|
|
|
17141
17344
|
return await complete(content);
|
|
17142
17345
|
}),
|
|
17143
17346
|
dispose: async () => {
|
|
17144
|
-
await disposeConnection(clientId, swarmName, METHOD_NAME$
|
|
17347
|
+
await disposeConnection(clientId, swarmName, METHOD_NAME$e);
|
|
17145
17348
|
await onDispose();
|
|
17146
17349
|
},
|
|
17147
17350
|
};
|
|
@@ -17241,13 +17444,13 @@ session.scheduled = (clientId, swarmName, { delay = SCHEDULED_DELAY, onDispose }
|
|
|
17241
17444
|
await online();
|
|
17242
17445
|
if (payload) {
|
|
17243
17446
|
return await PayloadContextService.runInContext(async () => {
|
|
17244
|
-
return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$
|
|
17447
|
+
return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$e, clientId, swarmName);
|
|
17245
17448
|
}, {
|
|
17246
17449
|
clientId,
|
|
17247
17450
|
payload,
|
|
17248
17451
|
});
|
|
17249
17452
|
}
|
|
17250
|
-
return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$
|
|
17453
|
+
return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$e, clientId, swarmName);
|
|
17251
17454
|
}),
|
|
17252
17455
|
delay,
|
|
17253
17456
|
});
|
|
@@ -17327,7 +17530,7 @@ session.rate = (clientId, swarmName, { delay = SCHEDULED_DELAY, onDispose } = {}
|
|
|
17327
17530
|
};
|
|
17328
17531
|
|
|
17329
17532
|
/** @private Constant defining the method name for logging purposes */
|
|
17330
|
-
const METHOD_NAME$
|
|
17533
|
+
const METHOD_NAME$d = "function.common.hasSession";
|
|
17331
17534
|
/**
|
|
17332
17535
|
* Checks if a session exists for the given client ID.
|
|
17333
17536
|
*
|
|
@@ -17339,11 +17542,11 @@ const METHOD_NAME$e = "function.common.hasSession";
|
|
|
17339
17542
|
*/
|
|
17340
17543
|
const hasSession = (clientId) => {
|
|
17341
17544
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17342
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17545
|
+
swarm$1.loggerService.log(METHOD_NAME$d, { clientId });
|
|
17343
17546
|
return swarm$1.sessionValidationService.hasSession(clientId);
|
|
17344
17547
|
};
|
|
17345
17548
|
|
|
17346
|
-
const METHOD_NAME$
|
|
17549
|
+
const METHOD_NAME$c = "function.common.getAgentName";
|
|
17347
17550
|
/**
|
|
17348
17551
|
* Retrieves the name of the active agent for a given client session in a swarm.
|
|
17349
17552
|
*
|
|
@@ -17361,18 +17564,18 @@ const METHOD_NAME$d = "function.common.getAgentName";
|
|
|
17361
17564
|
const getAgentName = beginContext(async (clientId) => {
|
|
17362
17565
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17363
17566
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17364
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17567
|
+
swarm$1.loggerService.log(METHOD_NAME$c, {
|
|
17365
17568
|
clientId,
|
|
17366
17569
|
});
|
|
17367
17570
|
// Validate the session and swarm to ensure they exist and are accessible
|
|
17368
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17571
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$c);
|
|
17369
17572
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
17370
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
17573
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$c);
|
|
17371
17574
|
// Retrieve the active agent name via the swarm public service
|
|
17372
|
-
return await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
17575
|
+
return await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$c, clientId, swarmName);
|
|
17373
17576
|
});
|
|
17374
17577
|
|
|
17375
|
-
const METHOD_NAME$
|
|
17578
|
+
const METHOD_NAME$b = "function.common.getAgentHistory";
|
|
17376
17579
|
/**
|
|
17377
17580
|
* Retrieves the history prepared for a specific agent, incorporating rescue algorithm tweaks.
|
|
17378
17581
|
*
|
|
@@ -17391,22 +17594,22 @@ const METHOD_NAME$c = "function.common.getAgentHistory";
|
|
|
17391
17594
|
const getAgentHistory = beginContext(async (clientId, agentName) => {
|
|
17392
17595
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17393
17596
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17394
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17597
|
+
swarm$1.loggerService.log(METHOD_NAME$b, {
|
|
17395
17598
|
clientId,
|
|
17396
17599
|
agentName,
|
|
17397
17600
|
});
|
|
17398
17601
|
// Validate the session and agent to ensure they exist and are accessible
|
|
17399
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17400
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
17602
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$b);
|
|
17603
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$b);
|
|
17401
17604
|
// Retrieve the agent's prompt configuration from the agent schema service
|
|
17402
17605
|
const { prompt } = swarm$1.agentSchemaService.get(agentName);
|
|
17403
17606
|
// Fetch the agent's history using the prompt and rescue tweaks via the history public service
|
|
17404
|
-
const history = await swarm$1.historyPublicService.toArrayForAgent(prompt, METHOD_NAME$
|
|
17607
|
+
const history = await swarm$1.historyPublicService.toArrayForAgent(prompt, METHOD_NAME$b, clientId, agentName);
|
|
17405
17608
|
// Return a shallow copy of the history array
|
|
17406
17609
|
return [...history];
|
|
17407
17610
|
});
|
|
17408
17611
|
|
|
17409
|
-
const METHOD_NAME$
|
|
17612
|
+
const METHOD_NAME$a = "function.common.getSessionMode";
|
|
17410
17613
|
/**
|
|
17411
17614
|
* Retrieves the session mode for a given client session in a swarm.
|
|
17412
17615
|
*
|
|
@@ -17424,18 +17627,18 @@ const METHOD_NAME$b = "function.common.getSessionMode";
|
|
|
17424
17627
|
const getSessionMode = beginContext(async (clientId) => {
|
|
17425
17628
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17426
17629
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17427
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17630
|
+
swarm$1.loggerService.log(METHOD_NAME$a, {
|
|
17428
17631
|
clientId,
|
|
17429
17632
|
});
|
|
17430
17633
|
// Validate the session and swarm to ensure they exist and are accessible
|
|
17431
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17634
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$a);
|
|
17432
17635
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
17433
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
17636
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$a);
|
|
17434
17637
|
// Retrieve the session mode from the session validation service
|
|
17435
17638
|
return swarm$1.sessionValidationService.getSessionMode(clientId);
|
|
17436
17639
|
});
|
|
17437
17640
|
|
|
17438
|
-
const METHOD_NAME$
|
|
17641
|
+
const METHOD_NAME$9 = "function.common.getSessionContext";
|
|
17439
17642
|
/**
|
|
17440
17643
|
* Retrieves the session context for the current execution environment.
|
|
17441
17644
|
*
|
|
@@ -17452,7 +17655,7 @@ const METHOD_NAME$a = "function.common.getSessionContext";
|
|
|
17452
17655
|
const getSessionContext = async () => {
|
|
17453
17656
|
// Log the operation if logging is enabled in GLOBAL_CONFIG
|
|
17454
17657
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17455
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17658
|
+
swarm$1.loggerService.log(METHOD_NAME$9);
|
|
17456
17659
|
// Determine the method context, if active
|
|
17457
17660
|
const methodContext = MethodContextService.hasContext()
|
|
17458
17661
|
? swarm$1.methodContextService.context
|
|
@@ -17476,7 +17679,7 @@ const getSessionContext = async () => {
|
|
|
17476
17679
|
* @private Constant defining the method name for logging purposes.
|
|
17477
17680
|
* Used as an identifier in log messages to track calls to `getNavigationRoute`.
|
|
17478
17681
|
*/
|
|
17479
|
-
const METHOD_NAME$
|
|
17682
|
+
const METHOD_NAME$8 = "function.common.getNavigationRoute";
|
|
17480
17683
|
/**
|
|
17481
17684
|
* Retrieves the navigation route for a given client and swarm.
|
|
17482
17685
|
* Delegates to `NavigationValidationService.getNavigationRoute` to obtain a `Set` of visited agent names,
|
|
@@ -17487,15 +17690,15 @@ const METHOD_NAME$9 = "function.common.getNavigationRoute";
|
|
|
17487
17690
|
*/
|
|
17488
17691
|
const getNavigationRoute = (clientId, swarmName) => {
|
|
17489
17692
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17490
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17693
|
+
swarm$1.loggerService.log(METHOD_NAME$8, {
|
|
17491
17694
|
clientId,
|
|
17492
17695
|
swarmName,
|
|
17493
17696
|
});
|
|
17494
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17697
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$8);
|
|
17495
17698
|
return swarm$1.navigationValidationService.getNavigationRoute(clientId, swarmName);
|
|
17496
17699
|
};
|
|
17497
17700
|
|
|
17498
|
-
const METHOD_NAME$
|
|
17701
|
+
const METHOD_NAME$7 = "function.history.getUserHistory";
|
|
17499
17702
|
/**
|
|
17500
17703
|
* Retrieves the user-specific history entries for a given client session.
|
|
17501
17704
|
*
|
|
@@ -17513,15 +17716,15 @@ const METHOD_NAME$8 = "function.history.getUserHistory";
|
|
|
17513
17716
|
const getUserHistory = beginContext(async (clientId) => {
|
|
17514
17717
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17515
17718
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17516
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17719
|
+
swarm$1.loggerService.log(METHOD_NAME$7, {
|
|
17517
17720
|
clientId,
|
|
17518
17721
|
});
|
|
17519
17722
|
// Fetch raw history and filter for user role and mode
|
|
17520
|
-
const history = await getRawHistory(clientId, METHOD_NAME$
|
|
17723
|
+
const history = await getRawHistory(clientId, METHOD_NAME$7);
|
|
17521
17724
|
return history.filter(({ role, mode }) => role === "user" && mode === "user");
|
|
17522
17725
|
});
|
|
17523
17726
|
|
|
17524
|
-
const METHOD_NAME$
|
|
17727
|
+
const METHOD_NAME$6 = "function.history.getAssistantHistory";
|
|
17525
17728
|
/**
|
|
17526
17729
|
* Retrieves the assistant's history entries for a given client session.
|
|
17527
17730
|
*
|
|
@@ -17539,15 +17742,15 @@ const METHOD_NAME$7 = "function.history.getAssistantHistory";
|
|
|
17539
17742
|
const getAssistantHistory = beginContext(async (clientId) => {
|
|
17540
17743
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17541
17744
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17542
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17745
|
+
swarm$1.loggerService.log(METHOD_NAME$6, {
|
|
17543
17746
|
clientId,
|
|
17544
17747
|
});
|
|
17545
17748
|
// Fetch raw history and filter for assistant role
|
|
17546
|
-
const history = await getRawHistory(clientId, METHOD_NAME$
|
|
17749
|
+
const history = await getRawHistory(clientId, METHOD_NAME$6);
|
|
17547
17750
|
return history.filter(({ role }) => role === "assistant");
|
|
17548
17751
|
});
|
|
17549
17752
|
|
|
17550
|
-
const METHOD_NAME$
|
|
17753
|
+
const METHOD_NAME$5 = "function.history.getLastAssistantMessage";
|
|
17551
17754
|
/**
|
|
17552
17755
|
* Retrieves the content of the most recent assistant message from a client's session history.
|
|
17553
17756
|
*
|
|
@@ -17565,16 +17768,16 @@ const METHOD_NAME$6 = "function.history.getLastAssistantMessage";
|
|
|
17565
17768
|
const getLastAssistantMessage = beginContext(async (clientId) => {
|
|
17566
17769
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17567
17770
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17568
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17771
|
+
swarm$1.loggerService.log(METHOD_NAME$5, {
|
|
17569
17772
|
clientId,
|
|
17570
17773
|
});
|
|
17571
17774
|
// Fetch raw history and find the last assistant message
|
|
17572
|
-
const history = await getRawHistory(clientId, METHOD_NAME$
|
|
17775
|
+
const history = await getRawHistory(clientId, METHOD_NAME$5);
|
|
17573
17776
|
const last = history.findLast(({ role }) => role === "assistant");
|
|
17574
17777
|
return last ? last.content : null;
|
|
17575
17778
|
});
|
|
17576
17779
|
|
|
17577
|
-
const METHOD_NAME$
|
|
17780
|
+
const METHOD_NAME$4 = "function.history.getLastSystemMessage";
|
|
17578
17781
|
/**
|
|
17579
17782
|
* Retrieves the content of the most recent system message from a client's session history.
|
|
17580
17783
|
*
|
|
@@ -17592,16 +17795,16 @@ const METHOD_NAME$5 = "function.history.getLastSystemMessage";
|
|
|
17592
17795
|
const getLastSystemMessage = beginContext(async (clientId) => {
|
|
17593
17796
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17594
17797
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17595
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17798
|
+
swarm$1.loggerService.log(METHOD_NAME$4, {
|
|
17596
17799
|
clientId,
|
|
17597
17800
|
});
|
|
17598
17801
|
// Fetch raw history and find the last system message
|
|
17599
|
-
const history = await getRawHistory(clientId, METHOD_NAME$
|
|
17802
|
+
const history = await getRawHistory(clientId, METHOD_NAME$4);
|
|
17600
17803
|
const last = history.findLast(({ role }) => role === "system");
|
|
17601
17804
|
return last ? last.content : null;
|
|
17602
17805
|
});
|
|
17603
17806
|
|
|
17604
|
-
const METHOD_NAME$
|
|
17807
|
+
const METHOD_NAME$3 = "function.event.listenEvent";
|
|
17605
17808
|
/**
|
|
17606
17809
|
* Set of reserved event source names that cannot be used for custom events.
|
|
17607
17810
|
* @constant {Set<EventSource>}
|
|
@@ -17637,7 +17840,7 @@ const DISALLOWED_EVENT_SOURCE_LIST$2 = new Set([
|
|
|
17637
17840
|
const event = beginContext((clientId, topicName, payload) => {
|
|
17638
17841
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17639
17842
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17640
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17843
|
+
swarm$1.loggerService.log(METHOD_NAME$3, {
|
|
17641
17844
|
clientId,
|
|
17642
17845
|
});
|
|
17643
17846
|
// Check if the topic name is reserved
|
|
@@ -17652,7 +17855,7 @@ const event = beginContext((clientId, topicName, payload) => {
|
|
|
17652
17855
|
});
|
|
17653
17856
|
});
|
|
17654
17857
|
|
|
17655
|
-
const METHOD_NAME$
|
|
17858
|
+
const METHOD_NAME$2 = "function.event.listenEvent";
|
|
17656
17859
|
/**
|
|
17657
17860
|
* Set of reserved event source names that cannot be used for custom event topics.
|
|
17658
17861
|
* @constant {Set<EventSource>}
|
|
@@ -17704,7 +17907,7 @@ const validateClientId$g = (clientId) => {
|
|
|
17704
17907
|
const listenEvent = beginContext((clientId, topicName, fn) => {
|
|
17705
17908
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17706
17909
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17707
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17910
|
+
swarm$1.loggerService.log(METHOD_NAME$2, {
|
|
17708
17911
|
clientId,
|
|
17709
17912
|
});
|
|
17710
17913
|
// Check if the topic name is reserved
|
|
@@ -17717,7 +17920,7 @@ const listenEvent = beginContext((clientId, topicName, fn) => {
|
|
|
17717
17920
|
return swarm$1.busService.subscribe(clientId, topicName, functoolsKit.queued(async ({ payload }) => await fn(payload)));
|
|
17718
17921
|
});
|
|
17719
17922
|
|
|
17720
|
-
const METHOD_NAME$
|
|
17923
|
+
const METHOD_NAME$1 = "function.event.listenEventOnce";
|
|
17721
17924
|
/**
|
|
17722
17925
|
* Set of reserved event source names that cannot be used for custom event topics.
|
|
17723
17926
|
* @constant {Set<EventSource>}
|
|
@@ -17775,7 +17978,7 @@ const validateClientId$f = (clientId) => {
|
|
|
17775
17978
|
const listenEventOnce = beginContext((clientId, topicName, filterFn, fn) => {
|
|
17776
17979
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17777
17980
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17778
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17981
|
+
swarm$1.loggerService.log(METHOD_NAME$1, {
|
|
17779
17982
|
clientId,
|
|
17780
17983
|
});
|
|
17781
17984
|
// Check if the topic name is reserved
|
|
@@ -17788,112 +17991,6 @@ const listenEventOnce = beginContext((clientId, topicName, filterFn, fn) => {
|
|
|
17788
17991
|
return swarm$1.busService.once(clientId, topicName, ({ payload }) => filterFn(payload), functoolsKit.queued(async ({ payload }) => await fn(payload)));
|
|
17789
17992
|
});
|
|
17790
17993
|
|
|
17791
|
-
const METHOD_NAME$1 = "function.navigate.changeToAgent";
|
|
17792
|
-
/**
|
|
17793
|
-
* Time-to-live for the change agent function in milliseconds.
|
|
17794
|
-
* Defines how long the cached change agent function remains valid before expiring.
|
|
17795
|
-
* @constant {number}
|
|
17796
|
-
*/
|
|
17797
|
-
const CHANGE_AGENT_TTL$1 = 15 * 60 * 1000;
|
|
17798
|
-
/**
|
|
17799
|
-
* Garbage collection interval for the change agent function in milliseconds.
|
|
17800
|
-
* Specifies the frequency at which expired TTL entries are cleaned up.
|
|
17801
|
-
* @constant {number}
|
|
17802
|
-
*/
|
|
17803
|
-
const CHANGE_AGENT_GC$1 = 60 * 1000;
|
|
17804
|
-
/**
|
|
17805
|
-
* Creates a change agent function with time-to-live (TTL) and queuing capabilities.
|
|
17806
|
-
*
|
|
17807
|
-
* This factory function generates a queued, TTL-limited function to handle agent changes for a specific client session,
|
|
17808
|
-
* ensuring operations are executed sequentially and cached results are reused within the TTL period.
|
|
17809
|
-
*
|
|
17810
|
-
* @function
|
|
17811
|
-
* @param {string} clientId - The unique identifier of the client session.
|
|
17812
|
-
* @returns {TChangeToAgentRun} A function that performs the agent change operation with queuing and TTL.
|
|
17813
|
-
*/
|
|
17814
|
-
const createChangeToAgent = functoolsKit.ttl((clientId) => functoolsKit.queued(async (methodName, agentName, swarmName) => {
|
|
17815
|
-
if (!swarm$1.navigationValidationService.shouldNavigate(agentName, clientId, swarmName)) {
|
|
17816
|
-
console.warn(`function "changeToAgent" skipped due to the circular route found clientId=${clientId} swarmName=${swarmName} agentNameTo=${agentName}`);
|
|
17817
|
-
return false;
|
|
17818
|
-
}
|
|
17819
|
-
// Notify all agents in the swarm of the change
|
|
17820
|
-
await Promise.all(swarm$1.swarmValidationService
|
|
17821
|
-
.getAgentList(swarmName)
|
|
17822
|
-
.map(async (agentName) => {
|
|
17823
|
-
await swarm$1.agentPublicService.commitAgentChange(methodName, clientId, agentName);
|
|
17824
|
-
}));
|
|
17825
|
-
{
|
|
17826
|
-
// Dispose of the current agent's resources and set up the new agent
|
|
17827
|
-
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$1, clientId, swarmName);
|
|
17828
|
-
await swarm$1.agentPublicService.dispose(methodName, clientId, agentName);
|
|
17829
|
-
await swarm$1.historyPublicService.dispose(methodName, clientId, agentName);
|
|
17830
|
-
await swarm$1.swarmPublicService.setAgentRef(methodName, clientId, swarmName, agentName, await swarm$1.agentPublicService.createAgentRef(methodName, clientId, agentName));
|
|
17831
|
-
}
|
|
17832
|
-
// Set the new agent as the active agent
|
|
17833
|
-
await swarm$1.swarmPublicService.setAgentName(agentName, methodName, clientId, swarmName);
|
|
17834
|
-
return true;
|
|
17835
|
-
}), {
|
|
17836
|
-
key: ([clientId]) => `${clientId}`,
|
|
17837
|
-
timeout: CHANGE_AGENT_TTL$1,
|
|
17838
|
-
});
|
|
17839
|
-
/**
|
|
17840
|
-
* Creates a garbage collector for the change agent function.
|
|
17841
|
-
*
|
|
17842
|
-
* This function sets up a singleton interval-based garbage collector to periodically clean up expired TTL entries from `createChangeToAgent`.
|
|
17843
|
-
*
|
|
17844
|
-
* @function
|
|
17845
|
-
* @returns {Promise<void>} A promise that resolves when the garbage collector is initialized.
|
|
17846
|
-
*/
|
|
17847
|
-
const createGc$1 = functoolsKit.singleshot(async () => {
|
|
17848
|
-
setInterval(createChangeToAgent.gc, CHANGE_AGENT_GC$1);
|
|
17849
|
-
});
|
|
17850
|
-
/**
|
|
17851
|
-
* Changes the active agent for a given client session in a swarm.
|
|
17852
|
-
*
|
|
17853
|
-
* This function facilitates switching the active agent in a swarm session, validating the session and agent dependencies,
|
|
17854
|
-
* logging the operation if enabled, and executing the change using a TTL-limited, queued runner.
|
|
17855
|
-
* The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts.
|
|
17856
|
-
*
|
|
17857
|
-
* @param {AgentName} agentName - The name of the agent to switch to.
|
|
17858
|
-
* @param {string} clientId - The unique identifier of the client session.
|
|
17859
|
-
* @returns {Promise<boolean>} A promise that resolves when the agent change is complete. If it resolved false, the navigation is canceled due to recursion
|
|
17860
|
-
* @throws {Error} If session or agent validation fails, or if the agent change process encounters an error.
|
|
17861
|
-
* @example
|
|
17862
|
-
* await changeToAgent("AgentX", "client-123");
|
|
17863
|
-
*/
|
|
17864
|
-
const changeToAgent = beginContext(async (agentName, clientId) => {
|
|
17865
|
-
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17866
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17867
|
-
swarm$1.loggerService.log(METHOD_NAME$1, {
|
|
17868
|
-
agentName,
|
|
17869
|
-
clientId,
|
|
17870
|
-
});
|
|
17871
|
-
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
17872
|
-
{
|
|
17873
|
-
// Validate session, agent, and dependencies
|
|
17874
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$1);
|
|
17875
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$1);
|
|
17876
|
-
const activeAgent = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$1, clientId, swarmName);
|
|
17877
|
-
if (!swarm$1.agentValidationService.hasDependency(activeAgent, agentName)) {
|
|
17878
|
-
console.error(`agent-swarm missing dependency detected for activeAgent=${activeAgent} dependencyAgent=${agentName}`);
|
|
17879
|
-
}
|
|
17880
|
-
}
|
|
17881
|
-
if (!swarm$1.swarmValidationService.getAgentSet(swarmName).has(agentName)) {
|
|
17882
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17883
|
-
swarm$1.loggerService.log('function "changeToAgent" skipped due to the agent is not in the swarm', {
|
|
17884
|
-
agentName,
|
|
17885
|
-
clientId,
|
|
17886
|
-
swarmName,
|
|
17887
|
-
});
|
|
17888
|
-
console.warn(`function "changeToAgent" skipped due to the agent is not in the swarm clientId=${clientId} agentName=${agentName} swarmName=${swarmName}`);
|
|
17889
|
-
return false;
|
|
17890
|
-
}
|
|
17891
|
-
// Execute the agent change with TTL and queuing
|
|
17892
|
-
const run = await createChangeToAgent(clientId);
|
|
17893
|
-
createGc$1();
|
|
17894
|
-
return await run(METHOD_NAME$1, agentName, swarmName);
|
|
17895
|
-
});
|
|
17896
|
-
|
|
17897
17994
|
const METHOD_NAME = "function.navigate.changeToPrevAgent";
|
|
17898
17995
|
/**
|
|
17899
17996
|
* Time-to-live for the change agent function in milliseconds.
|
|
@@ -20041,6 +20138,7 @@ exports.commitToolOutputForce = commitToolOutputForce;
|
|
|
20041
20138
|
exports.commitUserMessage = commitUserMessage;
|
|
20042
20139
|
exports.commitUserMessageForce = commitUserMessageForce;
|
|
20043
20140
|
exports.complete = complete;
|
|
20141
|
+
exports.createNavigateToAgent = createNavigateToAgent;
|
|
20044
20142
|
exports.createNavigateToTriageAgent = createNavigateToTriageAgent;
|
|
20045
20143
|
exports.disposeConnection = disposeConnection;
|
|
20046
20144
|
exports.dumpAgent = dumpAgent;
|