agent-swarm-kit 1.1.4 → 1.1.5
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 +681 -601
- package/build/index.mjs +682 -603
- package/package.json +1 -1
- package/types.d.ts +65 -1
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$1a = "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$19 = "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$1a);
|
|
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$19 = "cli.dumpDocs";
|
|
14527
14527
|
/**
|
|
14528
14528
|
* Dumps the documentation for the agents and swarms.
|
|
14529
14529
|
*
|
|
@@ -14533,7 +14533,7 @@ const METHOD_NAME$18 = "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$19, {
|
|
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$19));
|
|
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$19));
|
|
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$18 = "cli.dumpAgent";
|
|
14560
14560
|
/**
|
|
14561
14561
|
* Dumps the agent information into PlantUML format.
|
|
14562
14562
|
*
|
|
@@ -14565,14 +14565,14 @@ const METHOD_NAME$17 = "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$18, {
|
|
14569
14569
|
agentName,
|
|
14570
14570
|
});
|
|
14571
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
14571
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$18);
|
|
14572
14572
|
return swarm$1.agentMetaService.toUML(agentName, withSubtree);
|
|
14573
14573
|
});
|
|
14574
14574
|
|
|
14575
|
-
const METHOD_NAME$
|
|
14575
|
+
const METHOD_NAME$17 = "cli.dumpSwarm";
|
|
14576
14576
|
/**
|
|
14577
14577
|
* Dumps the swarm information into PlantUML format.
|
|
14578
14578
|
*
|
|
@@ -14581,14 +14581,14 @@ const METHOD_NAME$16 = "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$17, {
|
|
14585
14585
|
swarmName,
|
|
14586
14586
|
});
|
|
14587
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
14587
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$17);
|
|
14588
14588
|
return swarm$1.swarmMetaService.toUML(swarmName);
|
|
14589
14589
|
});
|
|
14590
14590
|
|
|
14591
|
-
const METHOD_NAME$
|
|
14591
|
+
const METHOD_NAME$16 = "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$16);
|
|
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$15 = "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$15);
|
|
14693
14693
|
await dumpClientPerformanceInternal(clientId, dirName);
|
|
14694
14694
|
};
|
|
14695
14695
|
/**
|
|
@@ -14709,8 +14709,409 @@ dumpClientPerformance.runAfterExecute = beginContext(async (dirName = "./logs/cl
|
|
|
14709
14709
|
});
|
|
14710
14710
|
});
|
|
14711
14711
|
|
|
14712
|
+
/** @private Constant defining the method name for logging and validation context */
|
|
14713
|
+
const METHOD_NAME$14 = "function.commit.commitFlushForce";
|
|
14714
|
+
/**
|
|
14715
|
+
* Forcefully commits a flush of agent history for a specific client in the swarm system, without checking the active agent.
|
|
14716
|
+
* Validates the session and swarm, then proceeds with flushing the history regardless of the current agent state.
|
|
14717
|
+
* Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
|
|
14718
|
+
* Integrates with SessionValidationService (session and swarm retrieval), SwarmValidationService (swarm validation),
|
|
14719
|
+
* SessionPublicService (history flush), and LoggerService (logging).
|
|
14720
|
+
* Unlike commitFlush, this function skips agent validation and active agent checks, providing a more aggressive flush mechanism,
|
|
14721
|
+
* analogous to commitAssistantMessageForce vs. commitAssistantMessage.
|
|
14722
|
+
*
|
|
14723
|
+
* @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
|
|
14724
|
+
* @param {string} agentName - The name of the agent (unused in this implementation, included for interface consistency with commitFlush).
|
|
14725
|
+
* @returns {Promise<void>} A promise that resolves when the history flush is committed.
|
|
14726
|
+
* @throws {Error} If session or swarm validation fails, propagated from respective validation services.
|
|
14727
|
+
*/
|
|
14728
|
+
const commitFlushForce = beginContext(async (clientId) => {
|
|
14729
|
+
// Log the flush attempt if enabled
|
|
14730
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14731
|
+
swarm$1.loggerService.log(METHOD_NAME$14, {
|
|
14732
|
+
clientId,
|
|
14733
|
+
METHOD_NAME: METHOD_NAME$14,
|
|
14734
|
+
});
|
|
14735
|
+
// Validate the session exists and retrieve the associated swarm
|
|
14736
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$14);
|
|
14737
|
+
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14738
|
+
// Validate the swarm configuration
|
|
14739
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$14);
|
|
14740
|
+
// Commit the flush of agent history via SessionPublicService without agent checks
|
|
14741
|
+
await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$14, clientId, swarmName);
|
|
14742
|
+
});
|
|
14743
|
+
|
|
14744
|
+
const METHOD_NAME$13 = "function.commit.commitToolOutputForce";
|
|
14745
|
+
/**
|
|
14746
|
+
* Commits the output of a tool execution to the active agent in a swarm session without checking the active agent.
|
|
14747
|
+
*
|
|
14748
|
+
* This function forcefully commits the tool output to the session, bypassing the check for whether the agent is still active in the swarm session.
|
|
14749
|
+
* It performs validation on the session and swarm, logs the operation if enabled, and delegates the commit operation to the session public service.
|
|
14750
|
+
* The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
|
|
14751
|
+
*
|
|
14752
|
+
* @param {string} toolId - The unique identifier of the tool whose output is being committed.
|
|
14753
|
+
* @param {string} content - The content or result of the tool execution to be committed.
|
|
14754
|
+
* @param {string} clientId - The unique identifier of the client session associated with the operation.
|
|
14755
|
+
* @returns {Promise<void>} A promise that resolves when the tool output is successfully committed.
|
|
14756
|
+
* @throws {Error} If validation fails (e.g., invalid session or swarm) or if the session public service encounters an error during the commit operation.
|
|
14757
|
+
* @example
|
|
14758
|
+
* await commitToolOutputForce("tool-123", "Tool execution result", "client-456");
|
|
14759
|
+
*/
|
|
14760
|
+
const commitToolOutputForce = beginContext(async (toolId, content, clientId) => {
|
|
14761
|
+
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14762
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14763
|
+
swarm$1.loggerService.log(METHOD_NAME$13, {
|
|
14764
|
+
toolId,
|
|
14765
|
+
content,
|
|
14766
|
+
clientId,
|
|
14767
|
+
});
|
|
14768
|
+
// Validate the session and swarm to ensure they exist and are accessible
|
|
14769
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$13);
|
|
14770
|
+
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14771
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$13);
|
|
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$13, clientId, swarmName);
|
|
14774
|
+
});
|
|
14775
|
+
|
|
14776
|
+
/**
|
|
14777
|
+
* @private Constant defining the method name for logging and validation purposes.
|
|
14778
|
+
* Used as an identifier in log messages and validation checks to track calls to `hasNavigation`.
|
|
14779
|
+
*/
|
|
14780
|
+
const METHOD_NAME$12 = "function.common.hasNavigation";
|
|
14781
|
+
/**
|
|
14782
|
+
* Checks if a specific agent is part of the navigation route for a given client.
|
|
14783
|
+
* Validates the agent and client session, retrieves the associated swarm, and queries the navigation route.
|
|
14784
|
+
* Logs the operation if enabled by global configuration.
|
|
14785
|
+
* @param {string} clientId - The unique identifier of the client whose navigation route is being checked.
|
|
14786
|
+
* @param {AgentName} agentName - The name of the agent to check within the navigation route.
|
|
14787
|
+
* @returns {Promise<boolean>} A promise resolving to true if the agent is in the navigation route, false otherwise.
|
|
14788
|
+
*/
|
|
14789
|
+
const hasNavigation = async (clientId, agentName) => {
|
|
14790
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14791
|
+
swarm$1.loggerService.log(METHOD_NAME$12, { clientId });
|
|
14792
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$12);
|
|
14793
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$12);
|
|
14794
|
+
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14795
|
+
return swarm$1.navigationValidationService
|
|
14796
|
+
.getNavigationRoute(clientId, swarmName)
|
|
14797
|
+
.has(agentName);
|
|
14798
|
+
};
|
|
14799
|
+
|
|
14800
|
+
const METHOD_NAME$11 = "function.history.getRawHistory";
|
|
14801
|
+
/**
|
|
14802
|
+
* Retrieves the raw, unmodified history for a given client session.
|
|
14803
|
+
*
|
|
14804
|
+
* This function fetches the complete history associated with a client’s active agent in a swarm session, without any filtering or modifications.
|
|
14805
|
+
* It is wrapped in `beginContext` for a clean execution environment and logs the operation if enabled via `GLOBAL_CONFIG`. The function validates
|
|
14806
|
+
* the session and swarm, retrieves the current agent, and uses `historyPublicService.toArrayForRaw` to obtain the raw history as an array.
|
|
14807
|
+
* The result is a fresh copy of the history array.
|
|
14808
|
+
*
|
|
14809
|
+
* @param {string} clientId - The unique identifier of the client session whose raw history is to be retrieved.
|
|
14810
|
+
* @param {string} [methodName="function.history.getRawHistory"] - The name of the calling method, used for validation and logging (defaults to `METHOD_NAME`).
|
|
14811
|
+
* @returns {Promise<object[]>} A promise that resolves to an array containing the raw history entries.
|
|
14812
|
+
* @throws {Error} If session or swarm validation fails, or if history retrieval encounters an issue.
|
|
14813
|
+
* @example
|
|
14814
|
+
* const rawHistory = await getRawHistory("client-123");
|
|
14815
|
+
* console.log(rawHistory); // Outputs the full raw history array
|
|
14816
|
+
*/
|
|
14817
|
+
const getRawHistory = beginContext(async (clientId, methodName = METHOD_NAME$11) => {
|
|
14818
|
+
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14819
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14820
|
+
swarm$1.loggerService.log(METHOD_NAME$11, {
|
|
14821
|
+
clientId,
|
|
14822
|
+
});
|
|
14823
|
+
// Validate the session and swarm
|
|
14824
|
+
swarm$1.sessionValidationService.validate(clientId, methodName);
|
|
14825
|
+
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14826
|
+
swarm$1.swarmValidationService.validate(swarmName, methodName);
|
|
14827
|
+
// Get the current agent and fetch raw history
|
|
14828
|
+
const agentName = await swarm$1.swarmPublicService.getAgentName(methodName, clientId, swarmName);
|
|
14829
|
+
const history = await swarm$1.historyPublicService.toArrayForRaw(methodName, clientId, agentName);
|
|
14830
|
+
return [...history];
|
|
14831
|
+
});
|
|
14832
|
+
|
|
14833
|
+
const METHOD_NAME$10 = "function.history.getLastUserMessage";
|
|
14834
|
+
/**
|
|
14835
|
+
* Retrieves the content of the most recent user message from a client's session history.
|
|
14836
|
+
*
|
|
14837
|
+
* This function fetches the raw history for a specified client using `getRawHistory` and finds the last entry where the role is "user" and the mode
|
|
14838
|
+
* is "user". It is wrapped in `beginContext` for a clean execution environment and logs the operation if enabled via `GLOBAL_CONFIG`. The result is
|
|
14839
|
+
* the content of the last user message as a string, or `null` if no matching user message exists in the history.
|
|
14840
|
+
*
|
|
14841
|
+
* @param {string} clientId - The unique identifier of the client session whose last user message is to be retrieved.
|
|
14842
|
+
* @returns {Promise<string | null>} A promise that resolves to the content of the last user message, or `null` if none is found.
|
|
14843
|
+
* @throws {Error} If `getRawHistory` fails due to session validation or history retrieval issues.
|
|
14844
|
+
* @example
|
|
14845
|
+
* const lastMessage = await getLastUserMessage("client-123");
|
|
14846
|
+
* console.log(lastMessage); // Outputs the last user message or null
|
|
14847
|
+
*/
|
|
14848
|
+
const getLastUserMessage = beginContext(async (clientId) => {
|
|
14849
|
+
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14850
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14851
|
+
swarm$1.loggerService.log(METHOD_NAME$10, {
|
|
14852
|
+
clientId,
|
|
14853
|
+
});
|
|
14854
|
+
// Fetch raw history and find the last user message
|
|
14855
|
+
const history = await getRawHistory(clientId, METHOD_NAME$10);
|
|
14856
|
+
const last = history.findLast(({ role, mode }) => role === "user" && mode === "user");
|
|
14857
|
+
return last ? last.content : null;
|
|
14858
|
+
});
|
|
14859
|
+
|
|
14860
|
+
const METHOD_NAME$$ = "function.navigate.changeToDefaultAgent";
|
|
14861
|
+
/**
|
|
14862
|
+
* Time-to-live for the change agent function in milliseconds.
|
|
14863
|
+
* Defines how long the cached change agent function remains valid before expiring.
|
|
14864
|
+
* @constant {number}
|
|
14865
|
+
*/
|
|
14866
|
+
const CHANGE_AGENT_TTL$2 = 15 * 60 * 1000;
|
|
14867
|
+
/**
|
|
14868
|
+
* Garbage collection interval for the change agent function in milliseconds.
|
|
14869
|
+
* Specifies the frequency at which expired TTL entries are cleaned up.
|
|
14870
|
+
* @constant {number}
|
|
14871
|
+
*/
|
|
14872
|
+
const CHANGE_AGENT_GC$2 = 60 * 1000;
|
|
14873
|
+
/**
|
|
14874
|
+
* Creates a change agent function with time-to-live (TTL) and queuing capabilities for switching to the default agent.
|
|
14875
|
+
*
|
|
14876
|
+
* This factory function generates a queued, TTL-limited function to handle agent changes to the default agent for a specific client session,
|
|
14877
|
+
* ensuring operations are executed sequentially and cached results are reused within the TTL period.
|
|
14878
|
+
*
|
|
14879
|
+
* @function
|
|
14880
|
+
* @param {string} clientId - The unique identifier of the client session.
|
|
14881
|
+
* @returns {TChangeToDefaultAgentRun} A function that performs the default agent change operation with queuing and TTL.
|
|
14882
|
+
*/
|
|
14883
|
+
const createChangeToDefaultAgent = functoolsKit.ttl((clientId) => functoolsKit.queued(async (methodName, agentName, swarmName) => {
|
|
14884
|
+
if (!swarm$1.navigationValidationService.shouldNavigate(agentName, clientId, swarmName)) {
|
|
14885
|
+
return false;
|
|
14886
|
+
}
|
|
14887
|
+
// Notify all agents in the swarm of the change
|
|
14888
|
+
await Promise.all(swarm$1.swarmValidationService
|
|
14889
|
+
.getAgentList(swarmName)
|
|
14890
|
+
.map(async (agentName) => {
|
|
14891
|
+
await swarm$1.agentPublicService.commitAgentChange(methodName, clientId, agentName);
|
|
14892
|
+
}));
|
|
14893
|
+
{
|
|
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$$, clientId, swarmName);
|
|
14896
|
+
await swarm$1.agentPublicService.dispose(methodName, clientId, agentName);
|
|
14897
|
+
await swarm$1.historyPublicService.dispose(methodName, clientId, agentName);
|
|
14898
|
+
await swarm$1.swarmPublicService.setAgentRef(methodName, clientId, swarmName, agentName, await swarm$1.agentPublicService.createAgentRef(methodName, clientId, agentName));
|
|
14899
|
+
}
|
|
14900
|
+
// Set the default agent as the active agent
|
|
14901
|
+
await swarm$1.swarmPublicService.setAgentName(agentName, methodName, clientId, swarmName);
|
|
14902
|
+
return true;
|
|
14903
|
+
}), {
|
|
14904
|
+
key: ([clientId]) => `${clientId}`,
|
|
14905
|
+
timeout: CHANGE_AGENT_TTL$2,
|
|
14906
|
+
});
|
|
14907
|
+
/**
|
|
14908
|
+
* Creates a garbage collector for the change agent function.
|
|
14909
|
+
*
|
|
14910
|
+
* This function sets up a singleton interval-based garbage collector to periodically clean up expired TTL entries from `createChangeToDefaultAgent`.
|
|
14911
|
+
*
|
|
14912
|
+
* @function
|
|
14913
|
+
* @returns {Promise<void>} A promise that resolves when the garbage collector is initialized.
|
|
14914
|
+
*/
|
|
14915
|
+
const createGc$3 = functoolsKit.singleshot(async () => {
|
|
14916
|
+
setInterval(createChangeToDefaultAgent.gc, CHANGE_AGENT_GC$2);
|
|
14917
|
+
});
|
|
14918
|
+
/**
|
|
14919
|
+
* Navigates back to the default agent for a given client session in a swarm.
|
|
14920
|
+
*
|
|
14921
|
+
* This function switches the active agent to the default agent defined in the swarm schema for the specified client session.
|
|
14922
|
+
* It validates the session and default agent, logs the operation if enabled, and executes the change using a TTL-limited, queued runner.
|
|
14923
|
+
* The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts.
|
|
14924
|
+
*
|
|
14925
|
+
* @param {string} clientId - The unique identifier of the client session.
|
|
14926
|
+
* @returns {Promise<boolean>} A promise that resolves when the default agent change is complete. If navigation stack contains recursion being canceled
|
|
14927
|
+
* @throws {Error} If session or agent validation fails, or if the agent change process encounters an error.
|
|
14928
|
+
* @example
|
|
14929
|
+
* await changeToDefaultAgent("client-123");
|
|
14930
|
+
*/
|
|
14931
|
+
const changeToDefaultAgent = beginContext(async (clientId) => {
|
|
14932
|
+
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14933
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14934
|
+
swarm$1.loggerService.log(METHOD_NAME$$, {
|
|
14935
|
+
clientId,
|
|
14936
|
+
});
|
|
14937
|
+
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14938
|
+
const { defaultAgent: agentName } = swarm$1.swarmSchemaService.get(swarmName);
|
|
14939
|
+
{
|
|
14940
|
+
// Validate session and default agent
|
|
14941
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$$);
|
|
14942
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$$);
|
|
14943
|
+
}
|
|
14944
|
+
// Execute the agent change with TTL and queuing
|
|
14945
|
+
const run = await createChangeToDefaultAgent(clientId);
|
|
14946
|
+
createGc$3();
|
|
14947
|
+
return await run(METHOD_NAME$$, agentName, swarmName);
|
|
14948
|
+
});
|
|
14949
|
+
|
|
14950
|
+
const METHOD_NAME$_ = "function.target.emitForce";
|
|
14951
|
+
/**
|
|
14952
|
+
* Emits a string as model output without executing an incoming message or checking the active agent.
|
|
14953
|
+
*
|
|
14954
|
+
* This function directly emits a provided string as output from the swarm session, bypassing message execution and agent activity checks.
|
|
14955
|
+
* It is designed exclusively for sessions established via `makeConnection`, ensuring compatibility with its connection model.
|
|
14956
|
+
* The execution is wrapped in `beginContext` for a clean environment, validates the session and swarm, and throws an error if the session mode
|
|
14957
|
+
* is not "makeConnection". The operation is logged if enabled, and resolves when the content is successfully emitted.
|
|
14958
|
+
*
|
|
14959
|
+
* @param {string} content - The content to be emitted as the model output.
|
|
14960
|
+
* @param {string} clientId - The unique identifier of the client session emitting the content.
|
|
14961
|
+
* @returns {Promise<void>} A promise that resolves when the content is emitted.
|
|
14962
|
+
* @throws {Error} If the session mode is not "makeConnection", or if session or swarm validation fails.
|
|
14963
|
+
* @example
|
|
14964
|
+
* await emitForce("Direct output", "client-123"); // Emits "Direct output" in a makeConnection session
|
|
14965
|
+
*/
|
|
14966
|
+
const emitForce = beginContext(async (content, clientId) => {
|
|
14967
|
+
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14968
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14969
|
+
swarm$1.loggerService.log(METHOD_NAME$_, {
|
|
14970
|
+
content,
|
|
14971
|
+
clientId,
|
|
14972
|
+
});
|
|
14973
|
+
// Validate the session and swarm
|
|
14974
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$_);
|
|
14975
|
+
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
14976
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$_);
|
|
14977
|
+
// Emit the content directly via the session public service
|
|
14978
|
+
return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$_, clientId, swarmName);
|
|
14979
|
+
});
|
|
14980
|
+
|
|
14981
|
+
const METHOD_NAME$Z = "function.target.executeForce";
|
|
14982
|
+
/**
|
|
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
|
+
*
|
|
14985
|
+
* This function executes a command or message on behalf of the active agent within a swarm session, designed for scenarios like reviewing tool output
|
|
14986
|
+
* or initiating a model-to-client conversation. Unlike `execute`, it does not check if the agent is currently active, ensuring execution even if the
|
|
14987
|
+
* agent has changed or is inactive. It validates the session and swarm, executes the content with performance tracking and event bus notifications,
|
|
14988
|
+
* and is wrapped in `beginContext` for a clean environment and `ExecutionContextService` for metadata tracking.
|
|
14989
|
+
*
|
|
14990
|
+
* @param {string} content - The content or command to be executed by the active agent.
|
|
14991
|
+
* @param {string} clientId - The unique identifier of the client session requesting the execution.
|
|
14992
|
+
* @returns {Promise<string>} A promise that resolves to the result of the execution.
|
|
14993
|
+
* @throws {Error} If session or swarm validation fails, or if the execution process encounters an error.
|
|
14994
|
+
* @example
|
|
14995
|
+
* const result = await executeForce("Force this execution", "client-123");
|
|
14996
|
+
* console.log(result); // Outputs the agent's response regardless of its active state
|
|
14997
|
+
*/
|
|
14998
|
+
const executeForce = beginContext(async (content, clientId) => {
|
|
14999
|
+
const executionId = functoolsKit.randomString();
|
|
15000
|
+
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15001
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15002
|
+
swarm$1.loggerService.log(METHOD_NAME$Z, {
|
|
15003
|
+
content,
|
|
15004
|
+
clientId,
|
|
15005
|
+
executionId,
|
|
15006
|
+
});
|
|
15007
|
+
// Validate the session and swarm
|
|
15008
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$Z);
|
|
15009
|
+
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15010
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$Z);
|
|
15011
|
+
// Execute the command within an execution context with performance tracking
|
|
15012
|
+
return ExecutionContextService.runInContext(async () => {
|
|
15013
|
+
let isFinished = false;
|
|
15014
|
+
swarm$1.perfService.startExecution(executionId, clientId, content.length);
|
|
15015
|
+
try {
|
|
15016
|
+
swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
|
|
15017
|
+
const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$Z, clientId, swarmName);
|
|
15018
|
+
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
15019
|
+
swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
|
|
15020
|
+
return result;
|
|
15021
|
+
}
|
|
15022
|
+
finally {
|
|
15023
|
+
if (!isFinished) {
|
|
15024
|
+
swarm$1.perfService.endExecution(executionId, clientId, 0);
|
|
15025
|
+
}
|
|
15026
|
+
}
|
|
15027
|
+
}, {
|
|
15028
|
+
clientId,
|
|
15029
|
+
executionId,
|
|
15030
|
+
processId: GLOBAL_CONFIG.CC_PROCESS_UUID,
|
|
15031
|
+
});
|
|
15032
|
+
});
|
|
15033
|
+
|
|
15034
|
+
const METHOD_NAME$Y = "function.template.navigateToTriageAgent";
|
|
15035
|
+
const DEFAULT_ACCEPT_FN = (_, defaultAgent) => `Successfully navigated to ${defaultAgent}`;
|
|
15036
|
+
const DEFAULT_REJECT_FN = (_, defaultAgent) => `Already on ${defaultAgent}`;
|
|
15037
|
+
/**
|
|
15038
|
+
* Creates a function to navigate to a triage agent for a specific client, handling navigation, message execution, and tool output.
|
|
15039
|
+
* The factory generates a handler that checks navigation state, commits tool outputs with accept/reject messages, and triggers execution or emission based on provided parameters.
|
|
15040
|
+
* It operates outside any existing method or execution contexts to ensure isolation, leveraging `beginContext` for a clean execution scope.
|
|
15041
|
+
* Logs the navigation operation if logging is enabled in the global configuration.
|
|
15042
|
+
*
|
|
15043
|
+
* @param {IFactoryParams} params - Configuration parameters for the navigation handler.
|
|
15044
|
+
* @param {string | ((clientId: string, defaultAgent: AgentName) => string | Promise<string>)} [params.flushMessage] - Optional message or function to emit after flushing the session.
|
|
15045
|
+
* @param {string | ((clientId: string, defaultAgent: AgentName) => string | Promise<string>)} [params.executeMessage] - Optional message or function to execute if no navigation is needed.
|
|
15046
|
+
* @param {string | ((clientId: string, defaultAgent: AgentName) => string | Promise<string>)} [params.toolOutputAccept] - Optional message or function for tool output when navigation occurs, defaults to `DEFAULT_ACCEPT_FN`.
|
|
15047
|
+
* @param {string | ((clientId: string, defaultAgent: AgentName) => string | Promise<string>)} [params.toolOutputReject] - Optional message or function for tool output when already on the default agent, defaults to `DEFAULT_REJECT_FN`.
|
|
15048
|
+
* @returns {Promise<(toolId: string, clientId: string) => Promise<void>>} A promise resolving to a function that handles navigation to the triage agent.
|
|
15049
|
+
* @throws {Error} If neither `flushMessage` nor `executeMessage` is provided, or if any internal operation (e.g., navigation, commit, or execution) fails.
|
|
15050
|
+
*
|
|
15051
|
+
* @example
|
|
15052
|
+
* // Create a navigation handler with a static flush message
|
|
15053
|
+
* const navigate = await createNavigateToTriageAgent({
|
|
15054
|
+
* flushMessage: "Session reset for triage.",
|
|
15055
|
+
* toolOutputAccept: "Navigation completed.",
|
|
15056
|
+
* });
|
|
15057
|
+
* await navigate("tool-123", "client-456");
|
|
15058
|
+
* // Navigates to default agent, commits custom tool output, and emits the flush message if applicable.
|
|
15059
|
+
*
|
|
15060
|
+
* @example
|
|
15061
|
+
* // Create a navigation handler with dynamic messages
|
|
15062
|
+
* const navigate = await createNavigateToTriageAgent({
|
|
15063
|
+
* executeMessage: (clientId, agent) => `Processing ${clientId} on ${agent}`,
|
|
15064
|
+
* toolOutputReject: (clientId, agent) => `No navigation needed for ${clientId}`,
|
|
15065
|
+
* });
|
|
15066
|
+
* await navigate("tool-789", "client-012");
|
|
15067
|
+
* // Commits dynamic reject message and executes the message if already on the default agent.
|
|
15068
|
+
*/
|
|
15069
|
+
const createNavigateToTriageAgent = async ({ flushMessage, executeMessage, toolOutputAccept = DEFAULT_ACCEPT_FN, toolOutputReject = DEFAULT_REJECT_FN, }) => {
|
|
15070
|
+
if (!flushMessage && !executeMessage) {
|
|
15071
|
+
throw new Error("agent-swarm createNavigateToTriageAgent flushMessage or executeMessage required");
|
|
15072
|
+
}
|
|
15073
|
+
/**
|
|
15074
|
+
* Navigates to the default triage agent for a given client and tool, handling message commits and execution.
|
|
15075
|
+
*
|
|
15076
|
+
* @param {string} toolId - The identifier of the tool triggering the navigation.
|
|
15077
|
+
* @param {string} clientId - The unique identifier of the client session.
|
|
15078
|
+
* @returns {Promise<void>} A promise that resolves when the navigation and associated actions are complete.
|
|
15079
|
+
* @throws {Error} If navigation, commit, or execution operations fail (e.g., invalid clientId or swarm configuration).
|
|
15080
|
+
*/
|
|
15081
|
+
return beginContext(async (toolId, clientId) => {
|
|
15082
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15083
|
+
swarm$1.loggerService.log(METHOD_NAME$Y, {
|
|
15084
|
+
clientId,
|
|
15085
|
+
toolId,
|
|
15086
|
+
});
|
|
15087
|
+
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15088
|
+
const { defaultAgent } = swarm$1.swarmSchemaService.get(swarmName);
|
|
15089
|
+
if (await functoolsKit.not(hasNavigation(clientId, defaultAgent))) {
|
|
15090
|
+
const lastMessage = await getLastUserMessage(clientId);
|
|
15091
|
+
await changeToDefaultAgent(clientId);
|
|
15092
|
+
await commitToolOutputForce(toolId, typeof toolOutputAccept === "string"
|
|
15093
|
+
? toolOutputAccept
|
|
15094
|
+
: await toolOutputAccept(clientId, defaultAgent), clientId);
|
|
15095
|
+
await executeForce(lastMessage, clientId);
|
|
15096
|
+
}
|
|
15097
|
+
if (flushMessage) {
|
|
15098
|
+
await commitFlushForce(clientId);
|
|
15099
|
+
await emitForce(typeof flushMessage === "string"
|
|
15100
|
+
? flushMessage
|
|
15101
|
+
: await flushMessage(clientId, defaultAgent), clientId);
|
|
15102
|
+
return;
|
|
15103
|
+
}
|
|
15104
|
+
await commitToolOutputForce(toolId, typeof toolOutputReject === "string"
|
|
15105
|
+
? toolOutputReject
|
|
15106
|
+
: await toolOutputReject(clientId, defaultAgent), clientId);
|
|
15107
|
+
await executeForce(typeof executeMessage === "string"
|
|
15108
|
+
? executeMessage
|
|
15109
|
+
: await executeMessage(clientId, defaultAgent), clientId);
|
|
15110
|
+
});
|
|
15111
|
+
};
|
|
15112
|
+
|
|
14712
15113
|
/** @constant {string} METHOD_NAME - The name of the method used for logging */
|
|
14713
|
-
const METHOD_NAME$
|
|
15114
|
+
const METHOD_NAME$X = "function.setup.addWiki";
|
|
14714
15115
|
/**
|
|
14715
15116
|
* Adds a wiki schema to the system
|
|
14716
15117
|
* @function addWiki
|
|
@@ -14719,7 +15120,7 @@ const METHOD_NAME$13 = "function.setup.addWiki";
|
|
|
14719
15120
|
*/
|
|
14720
15121
|
const addWiki = beginContext((wikiSchema) => {
|
|
14721
15122
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14722
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15123
|
+
swarm$1.loggerService.log(METHOD_NAME$X, {
|
|
14723
15124
|
wikiSchema,
|
|
14724
15125
|
});
|
|
14725
15126
|
swarm$1.wikiValidationService.addWiki(wikiSchema.wikiName, wikiSchema);
|
|
@@ -14727,7 +15128,7 @@ const addWiki = beginContext((wikiSchema) => {
|
|
|
14727
15128
|
return wikiSchema.wikiName;
|
|
14728
15129
|
});
|
|
14729
15130
|
|
|
14730
|
-
const METHOD_NAME$
|
|
15131
|
+
const METHOD_NAME$W = "function.setup.addAgent";
|
|
14731
15132
|
/**
|
|
14732
15133
|
* Adds a new agent to the agent registry for use within the swarm system.
|
|
14733
15134
|
*
|
|
@@ -14747,7 +15148,7 @@ const METHOD_NAME$12 = "function.setup.addAgent";
|
|
|
14747
15148
|
const addAgent = beginContext((agentSchema) => {
|
|
14748
15149
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14749
15150
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14750
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15151
|
+
swarm$1.loggerService.log(METHOD_NAME$W, {
|
|
14751
15152
|
agentSchema,
|
|
14752
15153
|
});
|
|
14753
15154
|
// Register the agent in the validation and schema services
|
|
@@ -14757,7 +15158,7 @@ const addAgent = beginContext((agentSchema) => {
|
|
|
14757
15158
|
return agentSchema.agentName;
|
|
14758
15159
|
});
|
|
14759
15160
|
|
|
14760
|
-
const METHOD_NAME$
|
|
15161
|
+
const METHOD_NAME$V = "function.setup.addCompletion";
|
|
14761
15162
|
/**
|
|
14762
15163
|
* Adds a completion engine to the registry for use by agents in the swarm system.
|
|
14763
15164
|
*
|
|
@@ -14777,7 +15178,7 @@ const METHOD_NAME$11 = "function.setup.addCompletion";
|
|
|
14777
15178
|
const addCompletion = beginContext((completionSchema) => {
|
|
14778
15179
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14779
15180
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14780
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15181
|
+
swarm$1.loggerService.log(METHOD_NAME$V, {
|
|
14781
15182
|
completionSchema,
|
|
14782
15183
|
});
|
|
14783
15184
|
// Register the completion in the validation and schema services
|
|
@@ -14787,7 +15188,7 @@ const addCompletion = beginContext((completionSchema) => {
|
|
|
14787
15188
|
return completionSchema.completionName;
|
|
14788
15189
|
});
|
|
14789
15190
|
|
|
14790
|
-
const METHOD_NAME$
|
|
15191
|
+
const METHOD_NAME$U = "function.setup.addSwarm";
|
|
14791
15192
|
/**
|
|
14792
15193
|
* Adds a new swarm to the system for managing client sessions.
|
|
14793
15194
|
*
|
|
@@ -14807,7 +15208,7 @@ const METHOD_NAME$10 = "function.setup.addSwarm";
|
|
|
14807
15208
|
const addSwarm = beginContext((swarmSchema) => {
|
|
14808
15209
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14809
15210
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14810
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15211
|
+
swarm$1.loggerService.log(METHOD_NAME$U, {
|
|
14811
15212
|
swarmSchema,
|
|
14812
15213
|
});
|
|
14813
15214
|
// Register the swarm in the validation and schema services
|
|
@@ -14817,7 +15218,7 @@ const addSwarm = beginContext((swarmSchema) => {
|
|
|
14817
15218
|
return swarmSchema.swarmName;
|
|
14818
15219
|
});
|
|
14819
15220
|
|
|
14820
|
-
const METHOD_NAME
|
|
15221
|
+
const METHOD_NAME$T = "function.setup.addTool";
|
|
14821
15222
|
/**
|
|
14822
15223
|
* Adds a new tool to the tool registry for use by agents in the swarm system.
|
|
14823
15224
|
*
|
|
@@ -14839,7 +15240,7 @@ const METHOD_NAME$$ = "function.setup.addTool";
|
|
|
14839
15240
|
const addTool = beginContext((toolSchema) => {
|
|
14840
15241
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14841
15242
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14842
|
-
swarm$1.loggerService.log(METHOD_NAME
|
|
15243
|
+
swarm$1.loggerService.log(METHOD_NAME$T, {
|
|
14843
15244
|
toolSchema,
|
|
14844
15245
|
});
|
|
14845
15246
|
// Register the tool in the validation and schema services
|
|
@@ -14849,7 +15250,7 @@ const addTool = beginContext((toolSchema) => {
|
|
|
14849
15250
|
return toolSchema.toolName;
|
|
14850
15251
|
});
|
|
14851
15252
|
|
|
14852
|
-
const METHOD_NAME$
|
|
15253
|
+
const METHOD_NAME$S = "function.setup.addState";
|
|
14853
15254
|
/**
|
|
14854
15255
|
* Adds a new state to the state registry for use within the swarm system.
|
|
14855
15256
|
*
|
|
@@ -14871,7 +15272,7 @@ const METHOD_NAME$_ = "function.setup.addState";
|
|
|
14871
15272
|
const addState = beginContext((stateSchema) => {
|
|
14872
15273
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14873
15274
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14874
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15275
|
+
swarm$1.loggerService.log(METHOD_NAME$S, {
|
|
14875
15276
|
stateSchema,
|
|
14876
15277
|
});
|
|
14877
15278
|
// Register the state in the schema service
|
|
@@ -14886,7 +15287,7 @@ const addState = beginContext((stateSchema) => {
|
|
|
14886
15287
|
return stateSchema.stateName;
|
|
14887
15288
|
});
|
|
14888
15289
|
|
|
14889
|
-
const METHOD_NAME$
|
|
15290
|
+
const METHOD_NAME$R = "function.setup.addEmbedding";
|
|
14890
15291
|
/**
|
|
14891
15292
|
* Adds a new embedding engine to the embedding registry for use within the swarm system.
|
|
14892
15293
|
*
|
|
@@ -14906,7 +15307,7 @@ const METHOD_NAME$Z = "function.setup.addEmbedding";
|
|
|
14906
15307
|
const addEmbedding = beginContext((embeddingSchema) => {
|
|
14907
15308
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14908
15309
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14909
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15310
|
+
swarm$1.loggerService.log(METHOD_NAME$R, {
|
|
14910
15311
|
embeddingSchema,
|
|
14911
15312
|
});
|
|
14912
15313
|
// Register the embedding in the validation and schema services
|
|
@@ -14916,7 +15317,7 @@ const addEmbedding = beginContext((embeddingSchema) => {
|
|
|
14916
15317
|
return embeddingSchema.embeddingName;
|
|
14917
15318
|
});
|
|
14918
15319
|
|
|
14919
|
-
const METHOD_NAME$
|
|
15320
|
+
const METHOD_NAME$Q = "function.setup.addStorage";
|
|
14920
15321
|
/**
|
|
14921
15322
|
* Adds a new storage engine to the storage registry for use within the swarm system.
|
|
14922
15323
|
*
|
|
@@ -14938,7 +15339,7 @@ const METHOD_NAME$Y = "function.setup.addStorage";
|
|
|
14938
15339
|
const addStorage = beginContext((storageSchema) => {
|
|
14939
15340
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
14940
15341
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14941
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15342
|
+
swarm$1.loggerService.log(METHOD_NAME$Q, {
|
|
14942
15343
|
storageSchema,
|
|
14943
15344
|
});
|
|
14944
15345
|
// Register the storage in the validation and schema services
|
|
@@ -14955,7 +15356,7 @@ const addStorage = beginContext((storageSchema) => {
|
|
|
14955
15356
|
});
|
|
14956
15357
|
|
|
14957
15358
|
/** @private Constant defining the method name for logging and validation context */
|
|
14958
|
-
const METHOD_NAME$
|
|
15359
|
+
const METHOD_NAME$P = "function.setup.addPolicy";
|
|
14959
15360
|
/**
|
|
14960
15361
|
* Adds a new policy for agents in the swarm system by registering it with validation and schema services.
|
|
14961
15362
|
* Registers the policy with PolicyValidationService for runtime validation and PolicySchemaService for schema management.
|
|
@@ -14971,7 +15372,7 @@ const METHOD_NAME$X = "function.setup.addPolicy";
|
|
|
14971
15372
|
const addPolicy = beginContext((policySchema) => {
|
|
14972
15373
|
// Log the policy addition attempt if enabled
|
|
14973
15374
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
14974
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15375
|
+
swarm$1.loggerService.log(METHOD_NAME$P, {
|
|
14975
15376
|
policySchema,
|
|
14976
15377
|
});
|
|
14977
15378
|
// Register the policy with PolicyValidationService for runtime validation
|
|
@@ -14982,7 +15383,7 @@ const addPolicy = beginContext((policySchema) => {
|
|
|
14982
15383
|
return policySchema.policyName;
|
|
14983
15384
|
});
|
|
14984
15385
|
|
|
14985
|
-
const METHOD_NAME$
|
|
15386
|
+
const METHOD_NAME$O = "function.test.overrideAgent";
|
|
14986
15387
|
/**
|
|
14987
15388
|
* Overrides an existing agent schema in the swarm system with a new or partial schema.
|
|
14988
15389
|
* This function updates the configuration of an agent identified by its `agentName`, applying the provided schema properties.
|
|
@@ -15006,13 +15407,13 @@ const METHOD_NAME$W = "function.test.overrideAgent";
|
|
|
15006
15407
|
*/
|
|
15007
15408
|
const overrideAgent = beginContext((agentSchema) => {
|
|
15008
15409
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15009
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15410
|
+
swarm$1.loggerService.log(METHOD_NAME$O, {
|
|
15010
15411
|
agentSchema,
|
|
15011
15412
|
});
|
|
15012
15413
|
return swarm$1.agentSchemaService.override(agentSchema.agentName, agentSchema);
|
|
15013
15414
|
});
|
|
15014
15415
|
|
|
15015
|
-
const METHOD_NAME$
|
|
15416
|
+
const METHOD_NAME$N = "function.test.overrideCompletion";
|
|
15016
15417
|
/**
|
|
15017
15418
|
* Overrides an existing completion schema in the swarm system with a new or partial schema.
|
|
15018
15419
|
* This function updates the configuration of a completion mechanism identified by its `completionName`, applying the provided schema properties.
|
|
@@ -15036,13 +15437,13 @@ const METHOD_NAME$V = "function.test.overrideCompletion";
|
|
|
15036
15437
|
*/
|
|
15037
15438
|
const overrideCompletion = beginContext((completionSchema) => {
|
|
15038
15439
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15039
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15440
|
+
swarm$1.loggerService.log(METHOD_NAME$N, {
|
|
15040
15441
|
completionSchema,
|
|
15041
15442
|
});
|
|
15042
15443
|
return swarm$1.completionSchemaService.override(completionSchema.completionName, completionSchema);
|
|
15043
15444
|
});
|
|
15044
15445
|
|
|
15045
|
-
const METHOD_NAME$
|
|
15446
|
+
const METHOD_NAME$M = "function.test.overrideEmbeding";
|
|
15046
15447
|
/**
|
|
15047
15448
|
* Overrides an existing embedding schema in the swarm system with a new or partial schema.
|
|
15048
15449
|
* This function updates the configuration of an embedding mechanism identified by its `embeddingName`, applying the provided schema properties.
|
|
@@ -15068,13 +15469,13 @@ const METHOD_NAME$U = "function.test.overrideEmbeding";
|
|
|
15068
15469
|
*/
|
|
15069
15470
|
const overrideEmbeding = beginContext((embeddingSchema) => {
|
|
15070
15471
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15071
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15472
|
+
swarm$1.loggerService.log(METHOD_NAME$M, {
|
|
15072
15473
|
embeddingSchema,
|
|
15073
15474
|
});
|
|
15074
15475
|
return swarm$1.embeddingSchemaService.override(embeddingSchema.embeddingName, embeddingSchema);
|
|
15075
15476
|
});
|
|
15076
15477
|
|
|
15077
|
-
const METHOD_NAME$
|
|
15478
|
+
const METHOD_NAME$L = "function.test.overridePolicy";
|
|
15078
15479
|
/**
|
|
15079
15480
|
* Overrides an existing policy schema in the swarm system with a new or partial schema.
|
|
15080
15481
|
* This function updates the configuration of a policy identified by its `policyName`, applying the provided schema properties.
|
|
@@ -15098,13 +15499,13 @@ const METHOD_NAME$T = "function.test.overridePolicy";
|
|
|
15098
15499
|
*/
|
|
15099
15500
|
const overridePolicy = beginContext((policySchema) => {
|
|
15100
15501
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15101
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15502
|
+
swarm$1.loggerService.log(METHOD_NAME$L, {
|
|
15102
15503
|
policySchema,
|
|
15103
15504
|
});
|
|
15104
15505
|
return swarm$1.policySchemaService.override(policySchema.policyName, policySchema);
|
|
15105
15506
|
});
|
|
15106
15507
|
|
|
15107
|
-
const METHOD_NAME$
|
|
15508
|
+
const METHOD_NAME$K = "function.test.overrideState";
|
|
15108
15509
|
/**
|
|
15109
15510
|
* Overrides an existing state schema in the swarm system with a new or partial schema.
|
|
15110
15511
|
* This function updates the configuration of a state identified by its `stateName`, applying the provided schema properties.
|
|
@@ -15129,13 +15530,13 @@ const METHOD_NAME$S = "function.test.overrideState";
|
|
|
15129
15530
|
*/
|
|
15130
15531
|
const overrideState = beginContext((stateSchema) => {
|
|
15131
15532
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15132
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15533
|
+
swarm$1.loggerService.log(METHOD_NAME$K, {
|
|
15133
15534
|
stateSchema,
|
|
15134
15535
|
});
|
|
15135
15536
|
return swarm$1.stateSchemaService.override(stateSchema.stateName, stateSchema);
|
|
15136
15537
|
});
|
|
15137
15538
|
|
|
15138
|
-
const METHOD_NAME$
|
|
15539
|
+
const METHOD_NAME$J = "function.test.overrideStorage";
|
|
15139
15540
|
/**
|
|
15140
15541
|
* Overrides an existing storage schema in the swarm system with a new or partial schema.
|
|
15141
15542
|
* This function updates the configuration of a storage identified by its `storageName`, applying the provided schema properties.
|
|
@@ -15161,13 +15562,13 @@ const METHOD_NAME$R = "function.test.overrideStorage";
|
|
|
15161
15562
|
*/
|
|
15162
15563
|
const overrideStorage = beginContext((storageSchema) => {
|
|
15163
15564
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15164
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15565
|
+
swarm$1.loggerService.log(METHOD_NAME$J, {
|
|
15165
15566
|
storageSchema,
|
|
15166
15567
|
});
|
|
15167
15568
|
return swarm$1.storageSchemaService.override(storageSchema.storageName, storageSchema);
|
|
15168
15569
|
});
|
|
15169
15570
|
|
|
15170
|
-
const METHOD_NAME$
|
|
15571
|
+
const METHOD_NAME$I = "function.test.overrideSwarm";
|
|
15171
15572
|
/**
|
|
15172
15573
|
* Overrides an existing swarm schema in the swarm system with a new or partial schema.
|
|
15173
15574
|
* This function updates the configuration of a swarm identified by its `swarmName`, applying the provided schema properties.
|
|
@@ -15191,13 +15592,13 @@ const METHOD_NAME$Q = "function.test.overrideSwarm";
|
|
|
15191
15592
|
*/
|
|
15192
15593
|
const overrideSwarm = beginContext((swarmSchema) => {
|
|
15193
15594
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15194
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15595
|
+
swarm$1.loggerService.log(METHOD_NAME$I, {
|
|
15195
15596
|
swarmSchema,
|
|
15196
15597
|
});
|
|
15197
15598
|
return swarm$1.swarmSchemaService.override(swarmSchema.swarmName, swarmSchema);
|
|
15198
15599
|
});
|
|
15199
15600
|
|
|
15200
|
-
const METHOD_NAME$
|
|
15601
|
+
const METHOD_NAME$H = "function.test.overrideTool";
|
|
15201
15602
|
/**
|
|
15202
15603
|
* Overrides an existing tool schema in the swarm system with a new or partial schema.
|
|
15203
15604
|
* This function updates the configuration of a tool identified by its `toolName`, applying the provided schema properties.
|
|
@@ -15221,13 +15622,13 @@ const METHOD_NAME$P = "function.test.overrideTool";
|
|
|
15221
15622
|
*/
|
|
15222
15623
|
const overrideTool = beginContext((toolSchema) => {
|
|
15223
15624
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15224
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15625
|
+
swarm$1.loggerService.log(METHOD_NAME$H, {
|
|
15225
15626
|
toolSchema,
|
|
15226
15627
|
});
|
|
15227
15628
|
return swarm$1.toolSchemaService.override(toolSchema.toolName, toolSchema);
|
|
15228
15629
|
});
|
|
15229
15630
|
|
|
15230
|
-
const METHOD_NAME$
|
|
15631
|
+
const METHOD_NAME$G = "function.test.overrideWiki";
|
|
15231
15632
|
/**
|
|
15232
15633
|
* Overrides an existing wiki schema in the swarm system with a new or partial schema.
|
|
15233
15634
|
* This function updates the configuration of a wiki identified by its `wikiName`, applying the provided schema properties.
|
|
@@ -15251,13 +15652,13 @@ const METHOD_NAME$O = "function.test.overrideWiki";
|
|
|
15251
15652
|
*/
|
|
15252
15653
|
const overrideWiki = beginContext((wikiSchema) => {
|
|
15253
15654
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15254
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15655
|
+
swarm$1.loggerService.log(METHOD_NAME$G, {
|
|
15255
15656
|
wikiSchema,
|
|
15256
15657
|
});
|
|
15257
15658
|
return swarm$1.wikiSchemaService.override(wikiSchema.wikiName, wikiSchema);
|
|
15258
15659
|
});
|
|
15259
15660
|
|
|
15260
|
-
const METHOD_NAME$
|
|
15661
|
+
const METHOD_NAME$F = "function.other.markOnline";
|
|
15261
15662
|
/**
|
|
15262
15663
|
* Marks a client as online in the specified swarm.
|
|
15263
15664
|
*
|
|
@@ -15269,16 +15670,16 @@ const METHOD_NAME$N = "function.other.markOnline";
|
|
|
15269
15670
|
const markOnline = async (clientId, swarmName) => {
|
|
15270
15671
|
// Log the operation if logging is enabled in the global configuration
|
|
15271
15672
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15272
|
-
swarm.loggerService.log(METHOD_NAME$
|
|
15673
|
+
swarm.loggerService.log(METHOD_NAME$F, {
|
|
15273
15674
|
clientId,
|
|
15274
15675
|
});
|
|
15275
15676
|
// Validate the swarm name
|
|
15276
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15677
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$F);
|
|
15277
15678
|
// Run the operation in the method context
|
|
15278
15679
|
return await MethodContextService.runInContext(async () => {
|
|
15279
|
-
await swarm.aliveService.markOnline(clientId, swarmName, METHOD_NAME$
|
|
15680
|
+
await swarm.aliveService.markOnline(clientId, swarmName, METHOD_NAME$F);
|
|
15280
15681
|
}, {
|
|
15281
|
-
methodName: METHOD_NAME$
|
|
15682
|
+
methodName: METHOD_NAME$F,
|
|
15282
15683
|
agentName: "",
|
|
15283
15684
|
policyName: "",
|
|
15284
15685
|
stateName: "",
|
|
@@ -15288,7 +15689,7 @@ const markOnline = async (clientId, swarmName) => {
|
|
|
15288
15689
|
});
|
|
15289
15690
|
};
|
|
15290
15691
|
|
|
15291
|
-
const METHOD_NAME$
|
|
15692
|
+
const METHOD_NAME$E = "function.other.markOffline";
|
|
15292
15693
|
/**
|
|
15293
15694
|
* Marks a client as offline in the specified swarm.
|
|
15294
15695
|
*
|
|
@@ -15303,14 +15704,14 @@ const METHOD_NAME$M = "function.other.markOffline";
|
|
|
15303
15704
|
*/
|
|
15304
15705
|
const markOffline = async (clientId, swarmName) => {
|
|
15305
15706
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15306
|
-
swarm.loggerService.log(METHOD_NAME$
|
|
15707
|
+
swarm.loggerService.log(METHOD_NAME$E, {
|
|
15307
15708
|
clientId,
|
|
15308
15709
|
});
|
|
15309
|
-
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15710
|
+
swarm.swarmValidationService.validate(swarmName, METHOD_NAME$E);
|
|
15310
15711
|
return await MethodContextService.runInContext(async () => {
|
|
15311
|
-
await swarm.aliveService.markOffline(clientId, swarmName, METHOD_NAME$
|
|
15712
|
+
await swarm.aliveService.markOffline(clientId, swarmName, METHOD_NAME$E);
|
|
15312
15713
|
}, {
|
|
15313
|
-
methodName: METHOD_NAME$
|
|
15714
|
+
methodName: METHOD_NAME$E,
|
|
15314
15715
|
agentName: "",
|
|
15315
15716
|
policyName: "",
|
|
15316
15717
|
stateName: "",
|
|
@@ -15320,7 +15721,7 @@ const markOffline = async (clientId, swarmName) => {
|
|
|
15320
15721
|
});
|
|
15321
15722
|
};
|
|
15322
15723
|
|
|
15323
|
-
const METHOD_NAME$
|
|
15724
|
+
const METHOD_NAME$D = "function.commit.commitToolOutput";
|
|
15324
15725
|
/**
|
|
15325
15726
|
* Commits the output of a tool execution to the active agent in a swarm session.
|
|
15326
15727
|
*
|
|
@@ -15340,19 +15741,19 @@ const METHOD_NAME$L = "function.commit.commitToolOutput";
|
|
|
15340
15741
|
const commitToolOutput = beginContext(async (toolId, content, clientId, agentName) => {
|
|
15341
15742
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15342
15743
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15343
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15744
|
+
swarm$1.loggerService.log(METHOD_NAME$D, {
|
|
15344
15745
|
toolId,
|
|
15345
15746
|
content,
|
|
15346
15747
|
clientId,
|
|
15347
15748
|
agentName,
|
|
15348
15749
|
});
|
|
15349
15750
|
// Validate the agent, session, and swarm to ensure they exist and are accessible
|
|
15350
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
15351
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
15751
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$D);
|
|
15752
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$D);
|
|
15352
15753
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15353
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15754
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$D);
|
|
15354
15755
|
// Check if the specified agent is still the active agent in the swarm session
|
|
15355
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
15756
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$D, clientId, swarmName);
|
|
15356
15757
|
if (currentAgentName !== agentName) {
|
|
15357
15758
|
// Log a skip message if the agent has changed during the operation
|
|
15358
15759
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
@@ -15365,11 +15766,11 @@ const commitToolOutput = beginContext(async (toolId, content, clientId, agentNam
|
|
|
15365
15766
|
return;
|
|
15366
15767
|
}
|
|
15367
15768
|
// Commit the tool output to the session via the session public service
|
|
15368
|
-
await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$
|
|
15769
|
+
await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$D, clientId, swarmName);
|
|
15369
15770
|
});
|
|
15370
15771
|
|
|
15371
15772
|
/** @private Constant defining the method name for logging and validation context */
|
|
15372
|
-
const METHOD_NAME$
|
|
15773
|
+
const METHOD_NAME$C = "function.commit.commitSystemMessage";
|
|
15373
15774
|
/**
|
|
15374
15775
|
* Commits a system-generated message to the active agent in the swarm system.
|
|
15375
15776
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before committing the message.
|
|
@@ -15388,20 +15789,20 @@ const METHOD_NAME$K = "function.commit.commitSystemMessage";
|
|
|
15388
15789
|
const commitSystemMessage = beginContext(async (content, clientId, agentName) => {
|
|
15389
15790
|
// Log the commit attempt if enabled
|
|
15390
15791
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15391
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15792
|
+
swarm$1.loggerService.log(METHOD_NAME$C, {
|
|
15392
15793
|
content,
|
|
15393
15794
|
clientId,
|
|
15394
15795
|
agentName,
|
|
15395
15796
|
});
|
|
15396
15797
|
// Validate the agent exists
|
|
15397
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
15798
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$C);
|
|
15398
15799
|
// Validate the session exists and retrieve the associated swarm
|
|
15399
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
15800
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$C);
|
|
15400
15801
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15401
15802
|
// Validate the swarm configuration
|
|
15402
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15803
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$C);
|
|
15403
15804
|
// Check if the current agent matches the provided agent
|
|
15404
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
15805
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$C, clientId, swarmName);
|
|
15405
15806
|
if (currentAgentName !== agentName) {
|
|
15406
15807
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15407
15808
|
swarm$1.loggerService.log('function "commitSystemMessage" skipped due to the agent change', {
|
|
@@ -15412,11 +15813,11 @@ const commitSystemMessage = beginContext(async (content, clientId, agentName) =>
|
|
|
15412
15813
|
return;
|
|
15413
15814
|
}
|
|
15414
15815
|
// Commit the system message via SessionPublicService
|
|
15415
|
-
await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$
|
|
15816
|
+
await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$C, clientId, swarmName);
|
|
15416
15817
|
});
|
|
15417
15818
|
|
|
15418
15819
|
/** @private Constant defining the method name for logging and validation context */
|
|
15419
|
-
const METHOD_NAME$
|
|
15820
|
+
const METHOD_NAME$B = "function.commit.commitFlush";
|
|
15420
15821
|
/**
|
|
15421
15822
|
* Commits a flush of agent history for a specific client and agent in the swarm system.
|
|
15422
15823
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before flushing the history.
|
|
@@ -15433,19 +15834,19 @@ const METHOD_NAME$J = "function.commit.commitFlush";
|
|
|
15433
15834
|
const commitFlush = beginContext(async (clientId, agentName) => {
|
|
15434
15835
|
// Log the flush attempt if enabled
|
|
15435
15836
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15436
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15837
|
+
swarm$1.loggerService.log(METHOD_NAME$B, {
|
|
15437
15838
|
clientId,
|
|
15438
15839
|
agentName,
|
|
15439
15840
|
});
|
|
15440
15841
|
// Validate the agent exists
|
|
15441
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
15842
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$B);
|
|
15442
15843
|
// Validate the session exists and retrieve the associated swarm
|
|
15443
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
15844
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$B);
|
|
15444
15845
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15445
15846
|
// Validate the swarm configuration
|
|
15446
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15847
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$B);
|
|
15447
15848
|
// Check if the current agent matches the provided agent
|
|
15448
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
15849
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$B, clientId, swarmName);
|
|
15449
15850
|
if (currentAgentName !== agentName) {
|
|
15450
15851
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15451
15852
|
swarm$1.loggerService.log('function "commitFlush" skipped due to the agent change', {
|
|
@@ -15456,10 +15857,10 @@ const commitFlush = beginContext(async (clientId, agentName) => {
|
|
|
15456
15857
|
return;
|
|
15457
15858
|
}
|
|
15458
15859
|
// Commit the flush of agent history via SessionPublicService
|
|
15459
|
-
await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$
|
|
15860
|
+
await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$B, clientId, swarmName);
|
|
15460
15861
|
});
|
|
15461
15862
|
|
|
15462
|
-
const METHOD_NAME$
|
|
15863
|
+
const METHOD_NAME$A = "function.commit.commitSystemMessage";
|
|
15463
15864
|
/**
|
|
15464
15865
|
* Commits a user message to the active agent's history in a swarm session without triggering a response.
|
|
15465
15866
|
*
|
|
@@ -15478,19 +15879,19 @@ const METHOD_NAME$I = "function.commit.commitSystemMessage";
|
|
|
15478
15879
|
const commitUserMessage = beginContext(async (content, mode, clientId, agentName, payload) => {
|
|
15479
15880
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15480
15881
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15481
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15882
|
+
swarm$1.loggerService.log(METHOD_NAME$A, {
|
|
15482
15883
|
content,
|
|
15483
15884
|
clientId,
|
|
15484
15885
|
agentName,
|
|
15485
15886
|
mode,
|
|
15486
15887
|
});
|
|
15487
15888
|
// Validate the agent, session, and swarm to ensure they exist and are accessible
|
|
15488
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
15489
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
15889
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$A);
|
|
15890
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$A);
|
|
15490
15891
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15491
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15892
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$A);
|
|
15492
15893
|
// Check if the specified agent is still the active agent in the swarm session
|
|
15493
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
15894
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$A, clientId, swarmName);
|
|
15494
15895
|
if (currentAgentName !== agentName) {
|
|
15495
15896
|
// Log a skip message if the agent has changed during the operation
|
|
15496
15897
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
@@ -15503,50 +15904,18 @@ const commitUserMessage = beginContext(async (content, mode, clientId, agentName
|
|
|
15503
15904
|
}
|
|
15504
15905
|
if (payload) {
|
|
15505
15906
|
return await PayloadContextService.runInContext(async () => {
|
|
15506
|
-
await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$
|
|
15907
|
+
await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$A, clientId, swarmName);
|
|
15507
15908
|
}, {
|
|
15508
15909
|
clientId,
|
|
15509
15910
|
payload,
|
|
15510
15911
|
});
|
|
15511
15912
|
}
|
|
15512
15913
|
// Commit the user message to the agent's history via the session public service
|
|
15513
|
-
return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$
|
|
15514
|
-
});
|
|
15515
|
-
|
|
15516
|
-
const METHOD_NAME$H = "function.commit.commitToolOutputForce";
|
|
15517
|
-
/**
|
|
15518
|
-
* Commits the output of a tool execution to the active agent in a swarm session without checking the active agent.
|
|
15519
|
-
*
|
|
15520
|
-
* This function forcefully commits the tool output to the session, bypassing the check for whether the agent is still active in the swarm session.
|
|
15521
|
-
* It performs validation on the session and swarm, logs the operation if enabled, and delegates the commit operation to the session public service.
|
|
15522
|
-
* The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
|
|
15523
|
-
*
|
|
15524
|
-
* @param {string} toolId - The unique identifier of the tool whose output is being committed.
|
|
15525
|
-
* @param {string} content - The content or result of the tool execution to be committed.
|
|
15526
|
-
* @param {string} clientId - The unique identifier of the client session associated with the operation.
|
|
15527
|
-
* @returns {Promise<void>} A promise that resolves when the tool output is successfully committed.
|
|
15528
|
-
* @throws {Error} If validation fails (e.g., invalid session or swarm) or if the session public service encounters an error during the commit operation.
|
|
15529
|
-
* @example
|
|
15530
|
-
* await commitToolOutputForce("tool-123", "Tool execution result", "client-456");
|
|
15531
|
-
*/
|
|
15532
|
-
const commitToolOutputForce = beginContext(async (toolId, content, clientId) => {
|
|
15533
|
-
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15534
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15535
|
-
swarm$1.loggerService.log(METHOD_NAME$H, {
|
|
15536
|
-
toolId,
|
|
15537
|
-
content,
|
|
15538
|
-
clientId,
|
|
15539
|
-
});
|
|
15540
|
-
// Validate the session and swarm to ensure they exist and are accessible
|
|
15541
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$H);
|
|
15542
|
-
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15543
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$H);
|
|
15544
|
-
// Commit the tool output to the session via the session public service without checking the active agent
|
|
15545
|
-
await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$H, clientId, swarmName);
|
|
15914
|
+
return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$A, clientId, swarmName);
|
|
15546
15915
|
});
|
|
15547
15916
|
|
|
15548
15917
|
/** @private Constant defining the method name for logging and validation context */
|
|
15549
|
-
const METHOD_NAME$
|
|
15918
|
+
const METHOD_NAME$z = "function.commit.commitSystemMessageForce";
|
|
15550
15919
|
/**
|
|
15551
15920
|
* Forcefully commits a system-generated message to a session in the swarm system, without checking the active agent.
|
|
15552
15921
|
* Validates the session and swarm, then proceeds with committing the message regardless of the current agent state.
|
|
@@ -15565,52 +15934,20 @@ const METHOD_NAME$G = "function.commit.commitSystemMessageForce";
|
|
|
15565
15934
|
const commitSystemMessageForce = beginContext(async (content, clientId) => {
|
|
15566
15935
|
// Log the commit attempt if enabled
|
|
15567
15936
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15568
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15937
|
+
swarm$1.loggerService.log(METHOD_NAME$z, {
|
|
15569
15938
|
content,
|
|
15570
15939
|
clientId,
|
|
15571
15940
|
});
|
|
15572
15941
|
// Validate the session exists and retrieve the associated swarm
|
|
15573
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
15942
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$z);
|
|
15574
15943
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15575
15944
|
// Validate the swarm configuration
|
|
15576
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15945
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$z);
|
|
15577
15946
|
// Commit the system message via SessionPublicService without agent checks
|
|
15578
|
-
await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$
|
|
15579
|
-
});
|
|
15580
|
-
|
|
15581
|
-
/** @private Constant defining the method name for logging and validation context */
|
|
15582
|
-
const METHOD_NAME$F = "function.commit.commitFlushForce";
|
|
15583
|
-
/**
|
|
15584
|
-
* Forcefully commits a flush of agent history for a specific client in the swarm system, without checking the active agent.
|
|
15585
|
-
* Validates the session and swarm, then proceeds with flushing the history regardless of the current agent state.
|
|
15586
|
-
* Runs within a beginContext wrapper for execution context management, logging operations via LoggerService.
|
|
15587
|
-
* Integrates with SessionValidationService (session and swarm retrieval), SwarmValidationService (swarm validation),
|
|
15588
|
-
* SessionPublicService (history flush), and LoggerService (logging).
|
|
15589
|
-
* Unlike commitFlush, this function skips agent validation and active agent checks, providing a more aggressive flush mechanism,
|
|
15590
|
-
* analogous to commitAssistantMessageForce vs. commitAssistantMessage.
|
|
15591
|
-
*
|
|
15592
|
-
* @param {string} clientId - The ID of the client associated with the session, validated against active sessions.
|
|
15593
|
-
* @param {string} agentName - The name of the agent (unused in this implementation, included for interface consistency with commitFlush).
|
|
15594
|
-
* @returns {Promise<void>} A promise that resolves when the history flush is committed.
|
|
15595
|
-
* @throws {Error} If session or swarm validation fails, propagated from respective validation services.
|
|
15596
|
-
*/
|
|
15597
|
-
const commitFlushForce = beginContext(async (clientId) => {
|
|
15598
|
-
// Log the flush attempt if enabled
|
|
15599
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15600
|
-
swarm$1.loggerService.log(METHOD_NAME$F, {
|
|
15601
|
-
clientId,
|
|
15602
|
-
METHOD_NAME: METHOD_NAME$F,
|
|
15603
|
-
});
|
|
15604
|
-
// Validate the session exists and retrieve the associated swarm
|
|
15605
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$F);
|
|
15606
|
-
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15607
|
-
// Validate the swarm configuration
|
|
15608
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$F);
|
|
15609
|
-
// Commit the flush of agent history via SessionPublicService without agent checks
|
|
15610
|
-
await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$F, clientId, swarmName);
|
|
15947
|
+
await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$z, clientId, swarmName);
|
|
15611
15948
|
});
|
|
15612
15949
|
|
|
15613
|
-
const METHOD_NAME$
|
|
15950
|
+
const METHOD_NAME$y = "function.commit.commitSystemMessage";
|
|
15614
15951
|
/**
|
|
15615
15952
|
* Commits a user message to the active agent's history in a swarm session without triggering a response and without checking the active agent.
|
|
15616
15953
|
*
|
|
@@ -15628,29 +15965,29 @@ const METHOD_NAME$E = "function.commit.commitSystemMessage";
|
|
|
15628
15965
|
const commitUserMessageForce = beginContext(async (content, mode, clientId, payload) => {
|
|
15629
15966
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15630
15967
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15631
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
15968
|
+
swarm$1.loggerService.log(METHOD_NAME$y, {
|
|
15632
15969
|
content,
|
|
15633
15970
|
clientId,
|
|
15634
15971
|
mode,
|
|
15635
15972
|
});
|
|
15636
15973
|
// Validate the session and swarm to ensure they exist and are accessible
|
|
15637
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
15974
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$y);
|
|
15638
15975
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15639
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15976
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$y);
|
|
15640
15977
|
if (payload) {
|
|
15641
15978
|
return await PayloadContextService.runInContext(async () => {
|
|
15642
|
-
await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$
|
|
15979
|
+
await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$y, clientId, swarmName);
|
|
15643
15980
|
}, {
|
|
15644
15981
|
clientId,
|
|
15645
15982
|
payload,
|
|
15646
15983
|
});
|
|
15647
15984
|
}
|
|
15648
15985
|
// Commit the user message to the agent's history via the session public service without checking the active agent
|
|
15649
|
-
return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$
|
|
15986
|
+
return await swarm$1.sessionPublicService.commitUserMessage(content, mode, METHOD_NAME$y, clientId, swarmName);
|
|
15650
15987
|
});
|
|
15651
15988
|
|
|
15652
15989
|
/** @private Constant defining the method name for logging and validation context */
|
|
15653
|
-
const METHOD_NAME$
|
|
15990
|
+
const METHOD_NAME$x = "function.commit.commitAssistantMessage";
|
|
15654
15991
|
/**
|
|
15655
15992
|
* Commits an assistant-generated message to the active agent in the swarm system.
|
|
15656
15993
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before committing the message.
|
|
@@ -15668,20 +16005,20 @@ const METHOD_NAME$D = "function.commit.commitAssistantMessage";
|
|
|
15668
16005
|
const commitAssistantMessage = beginContext(async (content, clientId, agentName) => {
|
|
15669
16006
|
// Log the commit attempt if enabled
|
|
15670
16007
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15671
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16008
|
+
swarm$1.loggerService.log(METHOD_NAME$x, {
|
|
15672
16009
|
content,
|
|
15673
16010
|
clientId,
|
|
15674
16011
|
agentName,
|
|
15675
16012
|
});
|
|
15676
16013
|
// Validate the agent exists
|
|
15677
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16014
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$x);
|
|
15678
16015
|
// Validate the session exists and retrieve the associated swarm
|
|
15679
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16016
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$x);
|
|
15680
16017
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15681
16018
|
// Validate the swarm configuration
|
|
15682
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16019
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$x);
|
|
15683
16020
|
// Check if the current agent matches the provided agent
|
|
15684
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16021
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$x, clientId, swarmName);
|
|
15685
16022
|
if (currentAgentName !== agentName) {
|
|
15686
16023
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15687
16024
|
swarm$1.loggerService.log('function "commitAssistantMessage" skipped due to the agent change', {
|
|
@@ -15692,11 +16029,11 @@ const commitAssistantMessage = beginContext(async (content, clientId, agentName)
|
|
|
15692
16029
|
return;
|
|
15693
16030
|
}
|
|
15694
16031
|
// Commit the assistant message via SessionPublicService
|
|
15695
|
-
await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$
|
|
16032
|
+
await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$x, clientId, swarmName);
|
|
15696
16033
|
});
|
|
15697
16034
|
|
|
15698
16035
|
/** @private Constant defining the method name for logging and validation context */
|
|
15699
|
-
const METHOD_NAME$
|
|
16036
|
+
const METHOD_NAME$w = "function.commit.commitAssistantMessageForce";
|
|
15700
16037
|
/**
|
|
15701
16038
|
* Forcefully commits an assistant-generated message to a session in the swarm system, without checking the active agent.
|
|
15702
16039
|
* Validates the session and swarm, then proceeds with committing the message regardless of the current agent state.
|
|
@@ -15715,21 +16052,21 @@ const METHOD_NAME$C = "function.commit.commitAssistantMessageForce";
|
|
|
15715
16052
|
const commitAssistantMessageForce = beginContext(async (content, clientId) => {
|
|
15716
16053
|
// Log the commit attempt if enabled
|
|
15717
16054
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15718
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16055
|
+
swarm$1.loggerService.log(METHOD_NAME$w, {
|
|
15719
16056
|
content,
|
|
15720
16057
|
clientId,
|
|
15721
16058
|
});
|
|
15722
16059
|
// Validate the session exists and retrieve the associated swarm
|
|
15723
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16060
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$w);
|
|
15724
16061
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15725
16062
|
// Validate the swarm configuration
|
|
15726
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16063
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$w);
|
|
15727
16064
|
// Commit the assistant message via SessionPublicService without agent checks
|
|
15728
|
-
await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$
|
|
16065
|
+
await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$w, clientId, swarmName);
|
|
15729
16066
|
});
|
|
15730
16067
|
|
|
15731
16068
|
/** @private Constant defining the method name for logging and validation context */
|
|
15732
|
-
const METHOD_NAME$
|
|
16069
|
+
const METHOD_NAME$v = "function.commit.cancelOutput";
|
|
15733
16070
|
/**
|
|
15734
16071
|
* Cancels the awaited output for a specific client and agent by emitting an empty string.
|
|
15735
16072
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before cancellation.
|
|
@@ -15745,19 +16082,19 @@ const METHOD_NAME$B = "function.commit.cancelOutput";
|
|
|
15745
16082
|
const cancelOutput = beginContext(async (clientId, agentName) => {
|
|
15746
16083
|
// Log the cancellation attempt if enabled
|
|
15747
16084
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15748
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16085
|
+
swarm$1.loggerService.log(METHOD_NAME$v, {
|
|
15749
16086
|
clientId,
|
|
15750
16087
|
agentName,
|
|
15751
16088
|
});
|
|
15752
16089
|
// Validate the agent exists
|
|
15753
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16090
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$v);
|
|
15754
16091
|
// Validate the session exists and retrieve the associated swarm
|
|
15755
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16092
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$v);
|
|
15756
16093
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15757
16094
|
// Validate the swarm configuration
|
|
15758
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16095
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$v);
|
|
15759
16096
|
// Check if the current agent matches the provided agent
|
|
15760
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16097
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$v, clientId, swarmName);
|
|
15761
16098
|
if (currentAgentName !== agentName) {
|
|
15762
16099
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15763
16100
|
swarm$1.loggerService.log('function "cancelOutput" skipped due to the agent change', {
|
|
@@ -15768,11 +16105,11 @@ const cancelOutput = beginContext(async (clientId, agentName) => {
|
|
|
15768
16105
|
return;
|
|
15769
16106
|
}
|
|
15770
16107
|
// Perform the output cancellation via SwarmPublicService
|
|
15771
|
-
await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$
|
|
16108
|
+
await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$v, clientId, swarmName);
|
|
15772
16109
|
});
|
|
15773
16110
|
|
|
15774
16111
|
/** @private Constant defining the method name for logging and validation context */
|
|
15775
|
-
const METHOD_NAME$
|
|
16112
|
+
const METHOD_NAME$u = "function.commit.cancelOutputForce";
|
|
15776
16113
|
/**
|
|
15777
16114
|
* Forcefully cancels the awaited output for a specific client by emitting an empty string, without checking the active agent.
|
|
15778
16115
|
* Validates the session and swarm, then proceeds with cancellation regardless of the current agent state.
|
|
@@ -15789,20 +16126,20 @@ const METHOD_NAME$A = "function.commit.cancelOutputForce";
|
|
|
15789
16126
|
const cancelOutputForce = beginContext(async (clientId) => {
|
|
15790
16127
|
// Log the cancellation attempt if enabled
|
|
15791
16128
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15792
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16129
|
+
swarm$1.loggerService.log(METHOD_NAME$u, {
|
|
15793
16130
|
clientId,
|
|
15794
16131
|
});
|
|
15795
16132
|
// Validate the session exists and retrieve the associated swarm
|
|
15796
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16133
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$u);
|
|
15797
16134
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15798
16135
|
// Validate the swarm configuration
|
|
15799
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16136
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$u);
|
|
15800
16137
|
// Perform the output cancellation via SwarmPublicService without agent checks
|
|
15801
|
-
await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$
|
|
16138
|
+
await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$u, clientId, swarmName);
|
|
15802
16139
|
});
|
|
15803
16140
|
|
|
15804
16141
|
/** @private Constant defining the method name for logging and validation context */
|
|
15805
|
-
const METHOD_NAME$
|
|
16142
|
+
const METHOD_NAME$t = "function.commit.commitStopTools";
|
|
15806
16143
|
/**
|
|
15807
16144
|
* Prevents the next tool from being executed for a specific client and agent in the swarm system.
|
|
15808
16145
|
* Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before stopping tool execution.
|
|
@@ -15819,19 +16156,19 @@ const METHOD_NAME$z = "function.commit.commitStopTools";
|
|
|
15819
16156
|
const commitStopTools = beginContext(async (clientId, agentName) => {
|
|
15820
16157
|
// Log the stop tools attempt if enabled
|
|
15821
16158
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15822
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16159
|
+
swarm$1.loggerService.log(METHOD_NAME$t, {
|
|
15823
16160
|
clientId,
|
|
15824
16161
|
agentName,
|
|
15825
16162
|
});
|
|
15826
16163
|
// Validate the agent exists
|
|
15827
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16164
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$t);
|
|
15828
16165
|
// Validate the session exists and retrieve the associated swarm
|
|
15829
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16166
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$t);
|
|
15830
16167
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15831
16168
|
// Validate the swarm configuration
|
|
15832
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16169
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$t);
|
|
15833
16170
|
// Check if the current agent matches the provided agent
|
|
15834
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16171
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$t, clientId, swarmName);
|
|
15835
16172
|
if (currentAgentName !== agentName) {
|
|
15836
16173
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15837
16174
|
swarm$1.loggerService.log('function "commitStopTools" skipped due to the agent change', {
|
|
@@ -15842,11 +16179,11 @@ const commitStopTools = beginContext(async (clientId, agentName) => {
|
|
|
15842
16179
|
return;
|
|
15843
16180
|
}
|
|
15844
16181
|
// Commit the stop of the next tool execution via SessionPublicService
|
|
15845
|
-
await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$
|
|
16182
|
+
await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$t, clientId, swarmName);
|
|
15846
16183
|
});
|
|
15847
16184
|
|
|
15848
16185
|
/** @private Constant defining the method name for logging and validation context */
|
|
15849
|
-
const METHOD_NAME$
|
|
16186
|
+
const METHOD_NAME$s = "function.commit.commitStopToolsForce";
|
|
15850
16187
|
/**
|
|
15851
16188
|
* Forcefully prevents the next tool from being executed for a specific client in the swarm system, without checking the active agent.
|
|
15852
16189
|
* Validates the session and swarm, then proceeds with stopping tool execution regardless of the current agent state.
|
|
@@ -15864,105 +16201,21 @@ const METHOD_NAME$y = "function.commit.commitStopToolsForce";
|
|
|
15864
16201
|
const commitStopToolsForce = beginContext(async (clientId) => {
|
|
15865
16202
|
// Log the stop tools attempt if enabled
|
|
15866
16203
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15867
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16204
|
+
swarm$1.loggerService.log(METHOD_NAME$s, {
|
|
15868
16205
|
clientId,
|
|
15869
|
-
METHOD_NAME: METHOD_NAME$
|
|
16206
|
+
METHOD_NAME: METHOD_NAME$s,
|
|
15870
16207
|
});
|
|
15871
16208
|
// Validate the session exists and retrieve the associated swarm
|
|
15872
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16209
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$s);
|
|
15873
16210
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15874
16211
|
// Validate the swarm configuration
|
|
15875
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16212
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$s);
|
|
15876
16213
|
// Commit the stop of the next tool execution via SessionPublicService without agent checks
|
|
15877
|
-
await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$
|
|
15878
|
-
});
|
|
15879
|
-
|
|
15880
|
-
const METHOD_NAME$x = "function.target.emitForce";
|
|
15881
|
-
/**
|
|
15882
|
-
* Emits a string as model output without executing an incoming message or checking the active agent.
|
|
15883
|
-
*
|
|
15884
|
-
* This function directly emits a provided string as output from the swarm session, bypassing message execution and agent activity checks.
|
|
15885
|
-
* It is designed exclusively for sessions established via `makeConnection`, ensuring compatibility with its connection model.
|
|
15886
|
-
* The execution is wrapped in `beginContext` for a clean environment, validates the session and swarm, and throws an error if the session mode
|
|
15887
|
-
* is not "makeConnection". The operation is logged if enabled, and resolves when the content is successfully emitted.
|
|
15888
|
-
*
|
|
15889
|
-
* @param {string} content - The content to be emitted as the model output.
|
|
15890
|
-
* @param {string} clientId - The unique identifier of the client session emitting the content.
|
|
15891
|
-
* @returns {Promise<void>} A promise that resolves when the content is emitted.
|
|
15892
|
-
* @throws {Error} If the session mode is not "makeConnection", or if session or swarm validation fails.
|
|
15893
|
-
* @example
|
|
15894
|
-
* await emitForce("Direct output", "client-123"); // Emits "Direct output" in a makeConnection session
|
|
15895
|
-
*/
|
|
15896
|
-
const emitForce = beginContext(async (content, clientId) => {
|
|
15897
|
-
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15898
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15899
|
-
swarm$1.loggerService.log(METHOD_NAME$x, {
|
|
15900
|
-
content,
|
|
15901
|
-
clientId,
|
|
15902
|
-
});
|
|
15903
|
-
// Validate the session and swarm
|
|
15904
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$x);
|
|
15905
|
-
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15906
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$x);
|
|
15907
|
-
// Emit the content directly via the session public service
|
|
15908
|
-
return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$x, clientId, swarmName);
|
|
15909
|
-
});
|
|
15910
|
-
|
|
15911
|
-
const METHOD_NAME$w = "function.target.executeForce";
|
|
15912
|
-
/**
|
|
15913
|
-
* 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.
|
|
15914
|
-
*
|
|
15915
|
-
* This function executes a command or message on behalf of the active agent within a swarm session, designed for scenarios like reviewing tool output
|
|
15916
|
-
* or initiating a model-to-client conversation. Unlike `execute`, it does not check if the agent is currently active, ensuring execution even if the
|
|
15917
|
-
* agent has changed or is inactive. It validates the session and swarm, executes the content with performance tracking and event bus notifications,
|
|
15918
|
-
* and is wrapped in `beginContext` for a clean environment and `ExecutionContextService` for metadata tracking.
|
|
15919
|
-
*
|
|
15920
|
-
* @param {string} content - The content or command to be executed by the active agent.
|
|
15921
|
-
* @param {string} clientId - The unique identifier of the client session requesting the execution.
|
|
15922
|
-
* @returns {Promise<string>} A promise that resolves to the result of the execution.
|
|
15923
|
-
* @throws {Error} If session or swarm validation fails, or if the execution process encounters an error.
|
|
15924
|
-
* @example
|
|
15925
|
-
* const result = await executeForce("Force this execution", "client-123");
|
|
15926
|
-
* console.log(result); // Outputs the agent's response regardless of its active state
|
|
15927
|
-
*/
|
|
15928
|
-
const executeForce = beginContext(async (content, clientId) => {
|
|
15929
|
-
const executionId = functoolsKit.randomString();
|
|
15930
|
-
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
15931
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15932
|
-
swarm$1.loggerService.log(METHOD_NAME$w, {
|
|
15933
|
-
content,
|
|
15934
|
-
clientId,
|
|
15935
|
-
executionId,
|
|
15936
|
-
});
|
|
15937
|
-
// Validate the session and swarm
|
|
15938
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$w);
|
|
15939
|
-
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15940
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$w);
|
|
15941
|
-
// Execute the command within an execution context with performance tracking
|
|
15942
|
-
return ExecutionContextService.runInContext(async () => {
|
|
15943
|
-
let isFinished = false;
|
|
15944
|
-
swarm$1.perfService.startExecution(executionId, clientId, content.length);
|
|
15945
|
-
try {
|
|
15946
|
-
swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
|
|
15947
|
-
const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$w, clientId, swarmName);
|
|
15948
|
-
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
15949
|
-
swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
|
|
15950
|
-
return result;
|
|
15951
|
-
}
|
|
15952
|
-
finally {
|
|
15953
|
-
if (!isFinished) {
|
|
15954
|
-
swarm$1.perfService.endExecution(executionId, clientId, 0);
|
|
15955
|
-
}
|
|
15956
|
-
}
|
|
15957
|
-
}, {
|
|
15958
|
-
clientId,
|
|
15959
|
-
executionId,
|
|
15960
|
-
processId: GLOBAL_CONFIG.CC_PROCESS_UUID,
|
|
15961
|
-
});
|
|
16214
|
+
await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$s, clientId, swarmName);
|
|
15962
16215
|
});
|
|
15963
16216
|
|
|
15964
16217
|
/** @constant {string} METHOD_NAME - The name of the method used for logging and validation */
|
|
15965
|
-
const METHOD_NAME$
|
|
16218
|
+
const METHOD_NAME$r = "function.target.question";
|
|
15966
16219
|
/**
|
|
15967
16220
|
* Initiates a question process within a chat context
|
|
15968
16221
|
* @function question
|
|
@@ -15974,21 +16227,21 @@ const METHOD_NAME$v = "function.target.question";
|
|
|
15974
16227
|
*/
|
|
15975
16228
|
const question = beginContext(async (message, clientId, agentName, wikiName) => {
|
|
15976
16229
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15977
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16230
|
+
swarm$1.loggerService.log(METHOD_NAME$r, {
|
|
15978
16231
|
message,
|
|
15979
16232
|
clientId,
|
|
15980
16233
|
agentName,
|
|
15981
16234
|
wikiName,
|
|
15982
16235
|
});
|
|
15983
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
15984
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16236
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$r);
|
|
16237
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$r);
|
|
15985
16238
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
15986
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
15987
|
-
swarm$1.wikiValidationService.validate(wikiName, METHOD_NAME$
|
|
16239
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$r);
|
|
16240
|
+
swarm$1.wikiValidationService.validate(wikiName, METHOD_NAME$r);
|
|
15988
16241
|
if (!swarm$1.agentValidationService.hasWiki(agentName, wikiName)) {
|
|
15989
|
-
throw new Error(`agent-swarm ${METHOD_NAME$
|
|
16242
|
+
throw new Error(`agent-swarm ${METHOD_NAME$r} ${wikiName} not registered in ${agentName}`);
|
|
15990
16243
|
}
|
|
15991
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16244
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$r, clientId, swarmName);
|
|
15992
16245
|
if (currentAgentName !== agentName) {
|
|
15993
16246
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
15994
16247
|
swarm$1.loggerService.log('function "question" skipped due to the agent change', {
|
|
@@ -16011,7 +16264,7 @@ const question = beginContext(async (message, clientId, agentName, wikiName) =>
|
|
|
16011
16264
|
});
|
|
16012
16265
|
|
|
16013
16266
|
/** @constant {string} METHOD_NAME - The name of the method used for logging and validation */
|
|
16014
|
-
const METHOD_NAME$
|
|
16267
|
+
const METHOD_NAME$q = "function.target.questionForce";
|
|
16015
16268
|
/**
|
|
16016
16269
|
* Initiates a forced question process within a chat context
|
|
16017
16270
|
* @function questionForce
|
|
@@ -16022,17 +16275,17 @@ const METHOD_NAME$u = "function.target.questionForce";
|
|
|
16022
16275
|
*/
|
|
16023
16276
|
const questionForce = beginContext(async (message, clientId, wikiName) => {
|
|
16024
16277
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16025
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16278
|
+
swarm$1.loggerService.log(METHOD_NAME$q, {
|
|
16026
16279
|
message,
|
|
16027
16280
|
clientId,
|
|
16028
16281
|
wikiName,
|
|
16029
16282
|
});
|
|
16030
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16283
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$q);
|
|
16031
16284
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16032
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16033
|
-
swarm$1.wikiValidationService.validate(wikiName, METHOD_NAME$
|
|
16285
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$q);
|
|
16286
|
+
swarm$1.wikiValidationService.validate(wikiName, METHOD_NAME$q);
|
|
16034
16287
|
const { getChat, callbacks } = swarm$1.wikiSchemaService.get(wikiName);
|
|
16035
|
-
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16288
|
+
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$q, clientId, swarmName);
|
|
16036
16289
|
const args = {
|
|
16037
16290
|
clientId,
|
|
16038
16291
|
message,
|
|
@@ -16044,7 +16297,7 @@ const questionForce = beginContext(async (message, clientId, wikiName) => {
|
|
|
16044
16297
|
return await getChat(args);
|
|
16045
16298
|
});
|
|
16046
16299
|
|
|
16047
|
-
const METHOD_NAME$
|
|
16300
|
+
const METHOD_NAME$p = "function.target.disposeConnection";
|
|
16048
16301
|
/**
|
|
16049
16302
|
* Disposes of a client session and all related resources within a swarm.
|
|
16050
16303
|
*
|
|
@@ -16061,10 +16314,10 @@ const METHOD_NAME$t = "function.target.disposeConnection";
|
|
|
16061
16314
|
* @example
|
|
16062
16315
|
* await disposeConnection("client-123", "TaskSwarm");
|
|
16063
16316
|
*/
|
|
16064
|
-
const disposeConnection = beginContext(async (clientId, swarmName, methodName = METHOD_NAME$
|
|
16317
|
+
const disposeConnection = beginContext(async (clientId, swarmName, methodName = METHOD_NAME$p) => {
|
|
16065
16318
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16066
16319
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16067
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16320
|
+
swarm$1.loggerService.log(METHOD_NAME$p, {
|
|
16068
16321
|
clientId,
|
|
16069
16322
|
swarmName,
|
|
16070
16323
|
});
|
|
@@ -16136,7 +16389,7 @@ const disposeConnection = beginContext(async (clientId, swarmName, methodName =
|
|
|
16136
16389
|
PersistMemoryAdapter.dispose(clientId);
|
|
16137
16390
|
});
|
|
16138
16391
|
|
|
16139
|
-
const METHOD_NAME$
|
|
16392
|
+
const METHOD_NAME$o = "function.target.makeAutoDispose";
|
|
16140
16393
|
/**
|
|
16141
16394
|
* Default timeout in seconds before auto-dispose is triggered.
|
|
16142
16395
|
* @constant {number}
|
|
@@ -16167,7 +16420,7 @@ const DEFAULT_TIMEOUT = 15 * 60;
|
|
|
16167
16420
|
const makeAutoDispose = beginContext((clientId, swarmName, { timeoutSeconds = DEFAULT_TIMEOUT, onDestroy, } = {}) => {
|
|
16168
16421
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16169
16422
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16170
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16423
|
+
swarm$1.loggerService.log(METHOD_NAME$o, {
|
|
16171
16424
|
clientId,
|
|
16172
16425
|
swarmName,
|
|
16173
16426
|
});
|
|
@@ -16200,7 +16453,7 @@ const makeAutoDispose = beginContext((clientId, swarmName, { timeoutSeconds = DE
|
|
|
16200
16453
|
};
|
|
16201
16454
|
});
|
|
16202
16455
|
|
|
16203
|
-
const METHOD_NAME$
|
|
16456
|
+
const METHOD_NAME$n = "function.target.execute";
|
|
16204
16457
|
/**
|
|
16205
16458
|
* Sends a message to the active agent in a swarm session as if it originated from the client side.
|
|
16206
16459
|
*
|
|
@@ -16222,19 +16475,19 @@ const execute = beginContext(async (content, clientId, agentName) => {
|
|
|
16222
16475
|
const executionId = functoolsKit.randomString();
|
|
16223
16476
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16224
16477
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16225
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16478
|
+
swarm$1.loggerService.log(METHOD_NAME$n, {
|
|
16226
16479
|
content,
|
|
16227
16480
|
clientId,
|
|
16228
16481
|
agentName,
|
|
16229
16482
|
executionId,
|
|
16230
16483
|
});
|
|
16231
16484
|
// Validate the agent, session, and swarm
|
|
16232
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16233
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16485
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$n);
|
|
16486
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$n);
|
|
16234
16487
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16235
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16488
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$n);
|
|
16236
16489
|
// Check if the specified agent is still the active agent
|
|
16237
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16490
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$n, clientId, swarmName);
|
|
16238
16491
|
if (currentAgentName !== agentName) {
|
|
16239
16492
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16240
16493
|
swarm$1.loggerService.log('function "execute" skipped due to the agent change', {
|
|
@@ -16253,7 +16506,7 @@ const execute = beginContext(async (content, clientId, agentName) => {
|
|
|
16253
16506
|
agentName,
|
|
16254
16507
|
swarmName,
|
|
16255
16508
|
});
|
|
16256
|
-
const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$
|
|
16509
|
+
const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$n, clientId, swarmName);
|
|
16257
16510
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
16258
16511
|
swarm$1.busService.commitExecutionEnd(clientId, {
|
|
16259
16512
|
agentName,
|
|
@@ -16273,7 +16526,7 @@ const execute = beginContext(async (content, clientId, agentName) => {
|
|
|
16273
16526
|
});
|
|
16274
16527
|
});
|
|
16275
16528
|
|
|
16276
|
-
const METHOD_NAME$
|
|
16529
|
+
const METHOD_NAME$m = "function.target.emit";
|
|
16277
16530
|
/**
|
|
16278
16531
|
* Emits a string as model output without executing an incoming message, with agent activity validation.
|
|
16279
16532
|
*
|
|
@@ -16293,18 +16546,18 @@ const METHOD_NAME$q = "function.target.emit";
|
|
|
16293
16546
|
const emit = beginContext(async (content, clientId, agentName) => {
|
|
16294
16547
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16295
16548
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16296
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16549
|
+
swarm$1.loggerService.log(METHOD_NAME$m, {
|
|
16297
16550
|
content,
|
|
16298
16551
|
clientId,
|
|
16299
16552
|
agentName,
|
|
16300
16553
|
});
|
|
16301
16554
|
// Validate the agent, session, and swarm
|
|
16302
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16303
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16555
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$m);
|
|
16556
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$m);
|
|
16304
16557
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16305
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16558
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$m);
|
|
16306
16559
|
// Check if the specified agent is still the active agent
|
|
16307
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16560
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$m, clientId, swarmName);
|
|
16308
16561
|
if (currentAgentName !== agentName) {
|
|
16309
16562
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16310
16563
|
swarm$1.loggerService.log('function "emit" skipped due to the agent change', {
|
|
@@ -16315,10 +16568,10 @@ const emit = beginContext(async (content, clientId, agentName) => {
|
|
|
16315
16568
|
return;
|
|
16316
16569
|
}
|
|
16317
16570
|
// Emit the content directly via the session public service
|
|
16318
|
-
return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$
|
|
16571
|
+
return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$m, clientId, swarmName);
|
|
16319
16572
|
});
|
|
16320
16573
|
|
|
16321
|
-
const METHOD_NAME$
|
|
16574
|
+
const METHOD_NAME$l = "function.target.notify";
|
|
16322
16575
|
/**
|
|
16323
16576
|
* Sends a notification message as output from the swarm session without executing an incoming message.
|
|
16324
16577
|
*
|
|
@@ -16338,23 +16591,23 @@ const METHOD_NAME$p = "function.target.notify";
|
|
|
16338
16591
|
const notify = beginContext(async (content, clientId, agentName) => {
|
|
16339
16592
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16340
16593
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16341
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16594
|
+
swarm$1.loggerService.log(METHOD_NAME$l, {
|
|
16342
16595
|
content,
|
|
16343
16596
|
clientId,
|
|
16344
16597
|
agentName,
|
|
16345
16598
|
});
|
|
16346
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16599
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$l);
|
|
16347
16600
|
// Check if the session mode is "makeConnection"
|
|
16348
16601
|
if (swarm$1.sessionValidationService.getSessionMode(clientId) !==
|
|
16349
16602
|
"makeConnection") {
|
|
16350
16603
|
throw new Error(`agent-swarm-kit notify session is not makeConnection clientId=${clientId}`);
|
|
16351
16604
|
}
|
|
16352
16605
|
// Validate the agent, session, and swarm
|
|
16353
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16606
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$l);
|
|
16354
16607
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16355
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16608
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$l);
|
|
16356
16609
|
// Check if the specified agent is still the active agent
|
|
16357
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16610
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$l, clientId, swarmName);
|
|
16358
16611
|
if (currentAgentName !== agentName) {
|
|
16359
16612
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16360
16613
|
swarm$1.loggerService.log('function "notify" skipped due to the agent change', {
|
|
@@ -16365,10 +16618,10 @@ const notify = beginContext(async (content, clientId, agentName) => {
|
|
|
16365
16618
|
return;
|
|
16366
16619
|
}
|
|
16367
16620
|
// Notify the content directly via the session public service
|
|
16368
|
-
return await swarm$1.sessionPublicService.notify(content, METHOD_NAME$
|
|
16621
|
+
return await swarm$1.sessionPublicService.notify(content, METHOD_NAME$l, clientId, swarmName);
|
|
16369
16622
|
});
|
|
16370
16623
|
|
|
16371
|
-
const METHOD_NAME$
|
|
16624
|
+
const METHOD_NAME$k = "function.target.notifyForce";
|
|
16372
16625
|
/**
|
|
16373
16626
|
* Sends a notification message as output from the swarm session without executing an incoming message.
|
|
16374
16627
|
*
|
|
@@ -16387,11 +16640,11 @@ const METHOD_NAME$o = "function.target.notifyForce";
|
|
|
16387
16640
|
const notifyForce = beginContext(async (content, clientId) => {
|
|
16388
16641
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16389
16642
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16390
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16643
|
+
swarm$1.loggerService.log(METHOD_NAME$k, {
|
|
16391
16644
|
content,
|
|
16392
16645
|
clientId,
|
|
16393
16646
|
});
|
|
16394
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16647
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$k);
|
|
16395
16648
|
// Check if the session mode is "makeConnection"
|
|
16396
16649
|
if (swarm$1.sessionValidationService.getSessionMode(clientId) !==
|
|
16397
16650
|
"makeConnection") {
|
|
@@ -16399,12 +16652,12 @@ const notifyForce = beginContext(async (content, clientId) => {
|
|
|
16399
16652
|
}
|
|
16400
16653
|
// Validate the agent, session, and swarm
|
|
16401
16654
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16402
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16655
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$k);
|
|
16403
16656
|
// Notify the content directly via the session public service
|
|
16404
|
-
return await swarm$1.sessionPublicService.notify(content, METHOD_NAME$
|
|
16657
|
+
return await swarm$1.sessionPublicService.notify(content, METHOD_NAME$k, clientId, swarmName);
|
|
16405
16658
|
});
|
|
16406
16659
|
|
|
16407
|
-
const METHOD_NAME$
|
|
16660
|
+
const METHOD_NAME$j = "function.target.runStateless";
|
|
16408
16661
|
/**
|
|
16409
16662
|
* Executes a message statelessly with an agent in a swarm session, bypassing chat history.
|
|
16410
16663
|
*
|
|
@@ -16427,19 +16680,19 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
|
|
|
16427
16680
|
const executionId = functoolsKit.randomString();
|
|
16428
16681
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16429
16682
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16430
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16683
|
+
swarm$1.loggerService.log(METHOD_NAME$j, {
|
|
16431
16684
|
content,
|
|
16432
16685
|
clientId,
|
|
16433
16686
|
agentName,
|
|
16434
16687
|
executionId,
|
|
16435
16688
|
});
|
|
16436
16689
|
// Validate the agent, session, and swarm
|
|
16437
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
16438
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16690
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$j);
|
|
16691
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$j);
|
|
16439
16692
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16440
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16693
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$j);
|
|
16441
16694
|
// Check if the specified agent is still the active agent
|
|
16442
|
-
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16695
|
+
const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$j, clientId, swarmName);
|
|
16443
16696
|
if (currentAgentName !== agentName) {
|
|
16444
16697
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16445
16698
|
swarm$1.loggerService.log('function "runStateless" skipped due to the agent change', {
|
|
@@ -16458,7 +16711,7 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
|
|
|
16458
16711
|
agentName,
|
|
16459
16712
|
swarmName,
|
|
16460
16713
|
});
|
|
16461
|
-
const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$
|
|
16714
|
+
const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$j, clientId, swarmName);
|
|
16462
16715
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
16463
16716
|
swarm$1.busService.commitExecutionEnd(clientId, {
|
|
16464
16717
|
agentName,
|
|
@@ -16478,7 +16731,7 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
|
|
|
16478
16731
|
});
|
|
16479
16732
|
});
|
|
16480
16733
|
|
|
16481
|
-
const METHOD_NAME$
|
|
16734
|
+
const METHOD_NAME$i = "function.target.runStatelessForce";
|
|
16482
16735
|
/**
|
|
16483
16736
|
* Executes a message statelessly with the active agent in a swarm session, bypassing chat history and forcing execution regardless of agent activity.
|
|
16484
16737
|
*
|
|
@@ -16499,22 +16752,22 @@ const runStatelessForce = beginContext(async (content, clientId) => {
|
|
|
16499
16752
|
const executionId = functoolsKit.randomString();
|
|
16500
16753
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16501
16754
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16502
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16755
|
+
swarm$1.loggerService.log(METHOD_NAME$i, {
|
|
16503
16756
|
content,
|
|
16504
16757
|
clientId,
|
|
16505
16758
|
executionId,
|
|
16506
16759
|
});
|
|
16507
16760
|
// Validate the session and swarm
|
|
16508
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16761
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$i);
|
|
16509
16762
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
16510
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16763
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$i);
|
|
16511
16764
|
// Execute the command statelessly within an execution context with performance tracking
|
|
16512
16765
|
return ExecutionContextService.runInContext(async () => {
|
|
16513
16766
|
let isFinished = false;
|
|
16514
16767
|
swarm$1.perfService.startExecution(executionId, clientId, content.length);
|
|
16515
16768
|
try {
|
|
16516
16769
|
swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
|
|
16517
|
-
const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$
|
|
16770
|
+
const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$i, clientId, swarmName);
|
|
16518
16771
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
16519
16772
|
swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
|
|
16520
16773
|
return result;
|
|
@@ -16541,7 +16794,7 @@ const SCHEDULED_DELAY$1 = 1000;
|
|
|
16541
16794
|
* @constant {number}
|
|
16542
16795
|
*/
|
|
16543
16796
|
const RATE_DELAY = 10000;
|
|
16544
|
-
const METHOD_NAME$
|
|
16797
|
+
const METHOD_NAME$h = "function.target.makeConnection";
|
|
16545
16798
|
/**
|
|
16546
16799
|
* Internal implementation of the connection factory for a client to a swarm.
|
|
16547
16800
|
*
|
|
@@ -16556,21 +16809,21 @@ const METHOD_NAME$l = "function.target.makeConnection";
|
|
|
16556
16809
|
const makeConnectionInternal = (connector, clientId, swarmName) => {
|
|
16557
16810
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16558
16811
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16559
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
16812
|
+
swarm$1.loggerService.log(METHOD_NAME$h, {
|
|
16560
16813
|
clientId,
|
|
16561
16814
|
swarmName,
|
|
16562
16815
|
});
|
|
16563
16816
|
// Validate the swarm and initialize the session
|
|
16564
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
16817
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$h);
|
|
16565
16818
|
swarm$1.sessionValidationService.addSession(clientId, swarmName, "makeConnection");
|
|
16566
16819
|
// Create a queued send function using the session public service
|
|
16567
|
-
const send = functoolsKit.queued(swarm$1.sessionPublicService.connect(connector, METHOD_NAME$
|
|
16820
|
+
const send = functoolsKit.queued(swarm$1.sessionPublicService.connect(connector, METHOD_NAME$h, clientId, swarmName));
|
|
16568
16821
|
// Return a wrapped send function with validation and agent context
|
|
16569
16822
|
return (async (outgoing) => {
|
|
16570
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
16823
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$h);
|
|
16571
16824
|
return await send({
|
|
16572
16825
|
data: outgoing,
|
|
16573
|
-
agentName: await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
16826
|
+
agentName: await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$h, clientId, swarmName),
|
|
16574
16827
|
clientId,
|
|
16575
16828
|
});
|
|
16576
16829
|
});
|
|
@@ -16653,13 +16906,13 @@ makeConnection.scheduled = (connector, clientId, swarmName, { delay = SCHEDULED_
|
|
|
16653
16906
|
await online();
|
|
16654
16907
|
if (payload) {
|
|
16655
16908
|
return await PayloadContextService.runInContext(async () => {
|
|
16656
|
-
await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$
|
|
16909
|
+
await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$h, clientId, swarmName);
|
|
16657
16910
|
}, {
|
|
16658
16911
|
clientId,
|
|
16659
16912
|
payload,
|
|
16660
16913
|
});
|
|
16661
16914
|
}
|
|
16662
|
-
await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$
|
|
16915
|
+
await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$h, clientId, swarmName);
|
|
16663
16916
|
}),
|
|
16664
16917
|
delay,
|
|
16665
16918
|
});
|
|
@@ -16722,7 +16975,7 @@ makeConnection.rate = (connector, clientId, swarmName, { delay = RATE_DELAY } =
|
|
|
16722
16975
|
};
|
|
16723
16976
|
};
|
|
16724
16977
|
|
|
16725
|
-
const METHOD_NAME$
|
|
16978
|
+
const METHOD_NAME$g = "function.target.complete";
|
|
16726
16979
|
/**
|
|
16727
16980
|
* Time-to-live for the complete function in milliseconds.
|
|
16728
16981
|
* Defines how long the cached complete function remains valid before expiring.
|
|
@@ -16764,7 +17017,7 @@ const createComplete = functoolsKit.ttl((clientId, swarmName) => functoolsKit.qu
|
|
|
16764
17017
|
*
|
|
16765
17018
|
* @returns {Promise<void>} A promise that resolves when the garbage collector is initialized.
|
|
16766
17019
|
*/
|
|
16767
|
-
const createGc$
|
|
17020
|
+
const createGc$2 = functoolsKit.singleshot(async () => {
|
|
16768
17021
|
setInterval(createComplete.gc, COMPLETE_GC);
|
|
16769
17022
|
});
|
|
16770
17023
|
/**
|
|
@@ -16788,7 +17041,7 @@ const complete = beginContext(async (content, clientId, swarmName, payload = nul
|
|
|
16788
17041
|
const executionId = functoolsKit.randomString();
|
|
16789
17042
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16790
17043
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16791
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17044
|
+
swarm$1.loggerService.log(METHOD_NAME$g, {
|
|
16792
17045
|
content,
|
|
16793
17046
|
clientId,
|
|
16794
17047
|
executionId,
|
|
@@ -16797,7 +17050,7 @@ const complete = beginContext(async (content, clientId, swarmName, payload = nul
|
|
|
16797
17050
|
await markOnline(clientId, swarmName);
|
|
16798
17051
|
// Set up the TTL-limited, queued execution function and garbage collector
|
|
16799
17052
|
const run = await createComplete(clientId, swarmName);
|
|
16800
|
-
createGc$
|
|
17053
|
+
createGc$2();
|
|
16801
17054
|
// Execute the command within an execution context with performance tracking
|
|
16802
17055
|
const handleRun = async () => {
|
|
16803
17056
|
return await ExecutionContextService.runInContext(async () => {
|
|
@@ -16806,7 +17059,7 @@ const complete = beginContext(async (content, clientId, swarmName, payload = nul
|
|
|
16806
17059
|
swarm$1.navigationValidationService.beginMonit(clientId, swarmName);
|
|
16807
17060
|
try {
|
|
16808
17061
|
swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
|
|
16809
|
-
const result = await run(METHOD_NAME$
|
|
17062
|
+
const result = await run(METHOD_NAME$g, content);
|
|
16810
17063
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
16811
17064
|
swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
|
|
16812
17065
|
return result;
|
|
@@ -16836,7 +17089,7 @@ const complete = beginContext(async (content, clientId, swarmName, payload = nul
|
|
|
16836
17089
|
* @constant {number}
|
|
16837
17090
|
*/
|
|
16838
17091
|
const SCHEDULED_DELAY = 1000;
|
|
16839
|
-
const METHOD_NAME$
|
|
17092
|
+
const METHOD_NAME$f = "function.target.session";
|
|
16840
17093
|
/**
|
|
16841
17094
|
* Internal implementation of the session factory for a client and swarm.
|
|
16842
17095
|
*
|
|
@@ -16851,23 +17104,23 @@ const sessionInternal = (clientId, swarmName, { onDispose = () => { } } = {}) =>
|
|
|
16851
17104
|
const executionId = functoolsKit.randomString();
|
|
16852
17105
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
16853
17106
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16854
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17107
|
+
swarm$1.loggerService.log(METHOD_NAME$f, {
|
|
16855
17108
|
clientId,
|
|
16856
17109
|
swarmName,
|
|
16857
17110
|
executionId,
|
|
16858
17111
|
});
|
|
16859
17112
|
// Validate the swarm and initialize the session
|
|
16860
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
17113
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$f);
|
|
16861
17114
|
swarm$1.sessionValidationService.addSession(clientId, swarmName, "session");
|
|
16862
17115
|
const complete = functoolsKit.queued(async (content) => {
|
|
16863
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17116
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$f);
|
|
16864
17117
|
return ExecutionContextService.runInContext(async () => {
|
|
16865
17118
|
let isFinished = false;
|
|
16866
17119
|
swarm$1.perfService.startExecution(executionId, clientId, content.length);
|
|
16867
17120
|
swarm$1.navigationValidationService.beginMonit(clientId, swarmName);
|
|
16868
17121
|
try {
|
|
16869
17122
|
swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
|
|
16870
|
-
const result = await swarm$1.sessionPublicService.execute(content, "user", METHOD_NAME$
|
|
17123
|
+
const result = await swarm$1.sessionPublicService.execute(content, "user", METHOD_NAME$f, clientId, swarmName);
|
|
16871
17124
|
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
16872
17125
|
swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
|
|
16873
17126
|
return result;
|
|
@@ -16888,7 +17141,7 @@ const sessionInternal = (clientId, swarmName, { onDispose = () => { } } = {}) =>
|
|
|
16888
17141
|
return await complete(content);
|
|
16889
17142
|
}),
|
|
16890
17143
|
dispose: async () => {
|
|
16891
|
-
await disposeConnection(clientId, swarmName, METHOD_NAME$
|
|
17144
|
+
await disposeConnection(clientId, swarmName, METHOD_NAME$f);
|
|
16892
17145
|
await onDispose();
|
|
16893
17146
|
},
|
|
16894
17147
|
};
|
|
@@ -16988,13 +17241,13 @@ session.scheduled = (clientId, swarmName, { delay = SCHEDULED_DELAY, onDispose }
|
|
|
16988
17241
|
await online();
|
|
16989
17242
|
if (payload) {
|
|
16990
17243
|
return await PayloadContextService.runInContext(async () => {
|
|
16991
|
-
return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$
|
|
17244
|
+
return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$f, clientId, swarmName);
|
|
16992
17245
|
}, {
|
|
16993
17246
|
clientId,
|
|
16994
17247
|
payload,
|
|
16995
17248
|
});
|
|
16996
17249
|
}
|
|
16997
|
-
return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$
|
|
17250
|
+
return await swarm$1.sessionPublicService.commitUserMessage(content, "user", METHOD_NAME$f, clientId, swarmName);
|
|
16998
17251
|
}),
|
|
16999
17252
|
delay,
|
|
17000
17253
|
});
|
|
@@ -17074,7 +17327,7 @@ session.rate = (clientId, swarmName, { delay = SCHEDULED_DELAY, onDispose } = {}
|
|
|
17074
17327
|
};
|
|
17075
17328
|
|
|
17076
17329
|
/** @private Constant defining the method name for logging purposes */
|
|
17077
|
-
const METHOD_NAME$
|
|
17330
|
+
const METHOD_NAME$e = "function.common.hasSession";
|
|
17078
17331
|
/**
|
|
17079
17332
|
* Checks if a session exists for the given client ID.
|
|
17080
17333
|
*
|
|
@@ -17086,35 +17339,11 @@ const METHOD_NAME$i = "function.common.hasSession";
|
|
|
17086
17339
|
*/
|
|
17087
17340
|
const hasSession = (clientId) => {
|
|
17088
17341
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17089
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17342
|
+
swarm$1.loggerService.log(METHOD_NAME$e, { clientId });
|
|
17090
17343
|
return swarm$1.sessionValidationService.hasSession(clientId);
|
|
17091
17344
|
};
|
|
17092
17345
|
|
|
17093
|
-
|
|
17094
|
-
* @private Constant defining the method name for logging and validation purposes.
|
|
17095
|
-
* Used as an identifier in log messages and validation checks to track calls to `hasNavigation`.
|
|
17096
|
-
*/
|
|
17097
|
-
const METHOD_NAME$h = "function.common.hasNavigation";
|
|
17098
|
-
/**
|
|
17099
|
-
* Checks if a specific agent is part of the navigation route for a given client.
|
|
17100
|
-
* Validates the agent and client session, retrieves the associated swarm, and queries the navigation route.
|
|
17101
|
-
* Logs the operation if enabled by global configuration.
|
|
17102
|
-
* @param {string} clientId - The unique identifier of the client whose navigation route is being checked.
|
|
17103
|
-
* @param {AgentName} agentName - The name of the agent to check within the navigation route.
|
|
17104
|
-
* @returns {Promise<boolean>} A promise resolving to true if the agent is in the navigation route, false otherwise.
|
|
17105
|
-
*/
|
|
17106
|
-
const hasNavigation = async (clientId, agentName) => {
|
|
17107
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17108
|
-
swarm$1.loggerService.log(METHOD_NAME$h, { clientId });
|
|
17109
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$h);
|
|
17110
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$h);
|
|
17111
|
-
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
17112
|
-
return swarm$1.navigationValidationService
|
|
17113
|
-
.getNavigationRoute(clientId, swarmName)
|
|
17114
|
-
.has(agentName);
|
|
17115
|
-
};
|
|
17116
|
-
|
|
17117
|
-
const METHOD_NAME$g = "function.common.getAgentName";
|
|
17346
|
+
const METHOD_NAME$d = "function.common.getAgentName";
|
|
17118
17347
|
/**
|
|
17119
17348
|
* Retrieves the name of the active agent for a given client session in a swarm.
|
|
17120
17349
|
*
|
|
@@ -17132,18 +17361,18 @@ const METHOD_NAME$g = "function.common.getAgentName";
|
|
|
17132
17361
|
const getAgentName = beginContext(async (clientId) => {
|
|
17133
17362
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17134
17363
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17135
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17364
|
+
swarm$1.loggerService.log(METHOD_NAME$d, {
|
|
17136
17365
|
clientId,
|
|
17137
17366
|
});
|
|
17138
17367
|
// Validate the session and swarm to ensure they exist and are accessible
|
|
17139
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17368
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$d);
|
|
17140
17369
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
17141
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
17370
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$d);
|
|
17142
17371
|
// Retrieve the active agent name via the swarm public service
|
|
17143
|
-
return await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
17372
|
+
return await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$d, clientId, swarmName);
|
|
17144
17373
|
});
|
|
17145
17374
|
|
|
17146
|
-
const METHOD_NAME$
|
|
17375
|
+
const METHOD_NAME$c = "function.common.getAgentHistory";
|
|
17147
17376
|
/**
|
|
17148
17377
|
* Retrieves the history prepared for a specific agent, incorporating rescue algorithm tweaks.
|
|
17149
17378
|
*
|
|
@@ -17162,22 +17391,22 @@ const METHOD_NAME$f = "function.common.getAgentHistory";
|
|
|
17162
17391
|
const getAgentHistory = beginContext(async (clientId, agentName) => {
|
|
17163
17392
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17164
17393
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17165
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17394
|
+
swarm$1.loggerService.log(METHOD_NAME$c, {
|
|
17166
17395
|
clientId,
|
|
17167
17396
|
agentName,
|
|
17168
17397
|
});
|
|
17169
17398
|
// Validate the session and agent to ensure they exist and are accessible
|
|
17170
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17171
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
17399
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$c);
|
|
17400
|
+
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$c);
|
|
17172
17401
|
// Retrieve the agent's prompt configuration from the agent schema service
|
|
17173
17402
|
const { prompt } = swarm$1.agentSchemaService.get(agentName);
|
|
17174
17403
|
// Fetch the agent's history using the prompt and rescue tweaks via the history public service
|
|
17175
|
-
const history = await swarm$1.historyPublicService.toArrayForAgent(prompt, METHOD_NAME$
|
|
17404
|
+
const history = await swarm$1.historyPublicService.toArrayForAgent(prompt, METHOD_NAME$c, clientId, agentName);
|
|
17176
17405
|
// Return a shallow copy of the history array
|
|
17177
17406
|
return [...history];
|
|
17178
17407
|
});
|
|
17179
17408
|
|
|
17180
|
-
const METHOD_NAME$
|
|
17409
|
+
const METHOD_NAME$b = "function.common.getSessionMode";
|
|
17181
17410
|
/**
|
|
17182
17411
|
* Retrieves the session mode for a given client session in a swarm.
|
|
17183
17412
|
*
|
|
@@ -17195,18 +17424,18 @@ const METHOD_NAME$e = "function.common.getSessionMode";
|
|
|
17195
17424
|
const getSessionMode = beginContext(async (clientId) => {
|
|
17196
17425
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17197
17426
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17198
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17427
|
+
swarm$1.loggerService.log(METHOD_NAME$b, {
|
|
17199
17428
|
clientId,
|
|
17200
17429
|
});
|
|
17201
17430
|
// Validate the session and swarm to ensure they exist and are accessible
|
|
17202
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17431
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$b);
|
|
17203
17432
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
17204
|
-
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$
|
|
17433
|
+
swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$b);
|
|
17205
17434
|
// Retrieve the session mode from the session validation service
|
|
17206
17435
|
return swarm$1.sessionValidationService.getSessionMode(clientId);
|
|
17207
17436
|
});
|
|
17208
17437
|
|
|
17209
|
-
const METHOD_NAME$
|
|
17438
|
+
const METHOD_NAME$a = "function.common.getSessionContext";
|
|
17210
17439
|
/**
|
|
17211
17440
|
* Retrieves the session context for the current execution environment.
|
|
17212
17441
|
*
|
|
@@ -17223,7 +17452,7 @@ const METHOD_NAME$d = "function.common.getSessionContext";
|
|
|
17223
17452
|
const getSessionContext = async () => {
|
|
17224
17453
|
// Log the operation if logging is enabled in GLOBAL_CONFIG
|
|
17225
17454
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17226
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17455
|
+
swarm$1.loggerService.log(METHOD_NAME$a);
|
|
17227
17456
|
// Determine the method context, if active
|
|
17228
17457
|
const methodContext = MethodContextService.hasContext()
|
|
17229
17458
|
? swarm$1.methodContextService.context
|
|
@@ -17247,7 +17476,7 @@ const getSessionContext = async () => {
|
|
|
17247
17476
|
* @private Constant defining the method name for logging purposes.
|
|
17248
17477
|
* Used as an identifier in log messages to track calls to `getNavigationRoute`.
|
|
17249
17478
|
*/
|
|
17250
|
-
const METHOD_NAME$
|
|
17479
|
+
const METHOD_NAME$9 = "function.common.getNavigationRoute";
|
|
17251
17480
|
/**
|
|
17252
17481
|
* Retrieves the navigation route for a given client and swarm.
|
|
17253
17482
|
* Delegates to `NavigationValidationService.getNavigationRoute` to obtain a `Set` of visited agent names,
|
|
@@ -17258,75 +17487,15 @@ const METHOD_NAME$c = "function.common.getNavigationRoute";
|
|
|
17258
17487
|
*/
|
|
17259
17488
|
const getNavigationRoute = (clientId, swarmName) => {
|
|
17260
17489
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17261
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17490
|
+
swarm$1.loggerService.log(METHOD_NAME$9, {
|
|
17262
17491
|
clientId,
|
|
17263
17492
|
swarmName,
|
|
17264
17493
|
});
|
|
17265
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17494
|
+
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$9);
|
|
17266
17495
|
return swarm$1.navigationValidationService.getNavigationRoute(clientId, swarmName);
|
|
17267
17496
|
};
|
|
17268
17497
|
|
|
17269
|
-
const METHOD_NAME$
|
|
17270
|
-
/**
|
|
17271
|
-
* Retrieves the raw, unmodified history for a given client session.
|
|
17272
|
-
*
|
|
17273
|
-
* This function fetches the complete history associated with a client’s active agent in a swarm session, without any filtering or modifications.
|
|
17274
|
-
* It is wrapped in `beginContext` for a clean execution environment and logs the operation if enabled via `GLOBAL_CONFIG`. The function validates
|
|
17275
|
-
* the session and swarm, retrieves the current agent, and uses `historyPublicService.toArrayForRaw` to obtain the raw history as an array.
|
|
17276
|
-
* The result is a fresh copy of the history array.
|
|
17277
|
-
*
|
|
17278
|
-
* @param {string} clientId - The unique identifier of the client session whose raw history is to be retrieved.
|
|
17279
|
-
* @param {string} [methodName="function.history.getRawHistory"] - The name of the calling method, used for validation and logging (defaults to `METHOD_NAME`).
|
|
17280
|
-
* @returns {Promise<object[]>} A promise that resolves to an array containing the raw history entries.
|
|
17281
|
-
* @throws {Error} If session or swarm validation fails, or if history retrieval encounters an issue.
|
|
17282
|
-
* @example
|
|
17283
|
-
* const rawHistory = await getRawHistory("client-123");
|
|
17284
|
-
* console.log(rawHistory); // Outputs the full raw history array
|
|
17285
|
-
*/
|
|
17286
|
-
const getRawHistory = beginContext(async (clientId, methodName = METHOD_NAME$b) => {
|
|
17287
|
-
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17288
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17289
|
-
swarm$1.loggerService.log(METHOD_NAME$b, {
|
|
17290
|
-
clientId,
|
|
17291
|
-
});
|
|
17292
|
-
// Validate the session and swarm
|
|
17293
|
-
swarm$1.sessionValidationService.validate(clientId, methodName);
|
|
17294
|
-
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
17295
|
-
swarm$1.swarmValidationService.validate(swarmName, methodName);
|
|
17296
|
-
// Get the current agent and fetch raw history
|
|
17297
|
-
const agentName = await swarm$1.swarmPublicService.getAgentName(methodName, clientId, swarmName);
|
|
17298
|
-
const history = await swarm$1.historyPublicService.toArrayForRaw(methodName, clientId, agentName);
|
|
17299
|
-
return [...history];
|
|
17300
|
-
});
|
|
17301
|
-
|
|
17302
|
-
const METHOD_NAME$a = "function.history.getLastUserMessage";
|
|
17303
|
-
/**
|
|
17304
|
-
* Retrieves the content of the most recent user message from a client's session history.
|
|
17305
|
-
*
|
|
17306
|
-
* This function fetches the raw history for a specified client using `getRawHistory` and finds the last entry where the role is "user" and the mode
|
|
17307
|
-
* is "user". It is wrapped in `beginContext` for a clean execution environment and logs the operation if enabled via `GLOBAL_CONFIG`. The result is
|
|
17308
|
-
* the content of the last user message as a string, or `null` if no matching user message exists in the history.
|
|
17309
|
-
*
|
|
17310
|
-
* @param {string} clientId - The unique identifier of the client session whose last user message is to be retrieved.
|
|
17311
|
-
* @returns {Promise<string | null>} A promise that resolves to the content of the last user message, or `null` if none is found.
|
|
17312
|
-
* @throws {Error} If `getRawHistory` fails due to session validation or history retrieval issues.
|
|
17313
|
-
* @example
|
|
17314
|
-
* const lastMessage = await getLastUserMessage("client-123");
|
|
17315
|
-
* console.log(lastMessage); // Outputs the last user message or null
|
|
17316
|
-
*/
|
|
17317
|
-
const getLastUserMessage = beginContext(async (clientId) => {
|
|
17318
|
-
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17319
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17320
|
-
swarm$1.loggerService.log(METHOD_NAME$a, {
|
|
17321
|
-
clientId,
|
|
17322
|
-
});
|
|
17323
|
-
// Fetch raw history and find the last user message
|
|
17324
|
-
const history = await getRawHistory(clientId, METHOD_NAME$a);
|
|
17325
|
-
const last = history.findLast(({ role, mode }) => role === "user" && mode === "user");
|
|
17326
|
-
return last ? last.content : null;
|
|
17327
|
-
});
|
|
17328
|
-
|
|
17329
|
-
const METHOD_NAME$9 = "function.history.getUserHistory";
|
|
17498
|
+
const METHOD_NAME$8 = "function.history.getUserHistory";
|
|
17330
17499
|
/**
|
|
17331
17500
|
* Retrieves the user-specific history entries for a given client session.
|
|
17332
17501
|
*
|
|
@@ -17344,15 +17513,15 @@ const METHOD_NAME$9 = "function.history.getUserHistory";
|
|
|
17344
17513
|
const getUserHistory = beginContext(async (clientId) => {
|
|
17345
17514
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17346
17515
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17347
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17516
|
+
swarm$1.loggerService.log(METHOD_NAME$8, {
|
|
17348
17517
|
clientId,
|
|
17349
17518
|
});
|
|
17350
17519
|
// Fetch raw history and filter for user role and mode
|
|
17351
|
-
const history = await getRawHistory(clientId, METHOD_NAME$
|
|
17520
|
+
const history = await getRawHistory(clientId, METHOD_NAME$8);
|
|
17352
17521
|
return history.filter(({ role, mode }) => role === "user" && mode === "user");
|
|
17353
17522
|
});
|
|
17354
17523
|
|
|
17355
|
-
const METHOD_NAME$
|
|
17524
|
+
const METHOD_NAME$7 = "function.history.getAssistantHistory";
|
|
17356
17525
|
/**
|
|
17357
17526
|
* Retrieves the assistant's history entries for a given client session.
|
|
17358
17527
|
*
|
|
@@ -17370,15 +17539,15 @@ const METHOD_NAME$8 = "function.history.getAssistantHistory";
|
|
|
17370
17539
|
const getAssistantHistory = beginContext(async (clientId) => {
|
|
17371
17540
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17372
17541
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17373
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17542
|
+
swarm$1.loggerService.log(METHOD_NAME$7, {
|
|
17374
17543
|
clientId,
|
|
17375
17544
|
});
|
|
17376
17545
|
// Fetch raw history and filter for assistant role
|
|
17377
|
-
const history = await getRawHistory(clientId, METHOD_NAME$
|
|
17546
|
+
const history = await getRawHistory(clientId, METHOD_NAME$7);
|
|
17378
17547
|
return history.filter(({ role }) => role === "assistant");
|
|
17379
17548
|
});
|
|
17380
17549
|
|
|
17381
|
-
const METHOD_NAME$
|
|
17550
|
+
const METHOD_NAME$6 = "function.history.getLastAssistantMessage";
|
|
17382
17551
|
/**
|
|
17383
17552
|
* Retrieves the content of the most recent assistant message from a client's session history.
|
|
17384
17553
|
*
|
|
@@ -17396,16 +17565,16 @@ const METHOD_NAME$7 = "function.history.getLastAssistantMessage";
|
|
|
17396
17565
|
const getLastAssistantMessage = beginContext(async (clientId) => {
|
|
17397
17566
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17398
17567
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17399
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17568
|
+
swarm$1.loggerService.log(METHOD_NAME$6, {
|
|
17400
17569
|
clientId,
|
|
17401
17570
|
});
|
|
17402
17571
|
// Fetch raw history and find the last assistant message
|
|
17403
|
-
const history = await getRawHistory(clientId, METHOD_NAME$
|
|
17572
|
+
const history = await getRawHistory(clientId, METHOD_NAME$6);
|
|
17404
17573
|
const last = history.findLast(({ role }) => role === "assistant");
|
|
17405
17574
|
return last ? last.content : null;
|
|
17406
17575
|
});
|
|
17407
17576
|
|
|
17408
|
-
const METHOD_NAME$
|
|
17577
|
+
const METHOD_NAME$5 = "function.history.getLastSystemMessage";
|
|
17409
17578
|
/**
|
|
17410
17579
|
* Retrieves the content of the most recent system message from a client's session history.
|
|
17411
17580
|
*
|
|
@@ -17423,16 +17592,16 @@ const METHOD_NAME$6 = "function.history.getLastSystemMessage";
|
|
|
17423
17592
|
const getLastSystemMessage = beginContext(async (clientId) => {
|
|
17424
17593
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17425
17594
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17426
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17595
|
+
swarm$1.loggerService.log(METHOD_NAME$5, {
|
|
17427
17596
|
clientId,
|
|
17428
17597
|
});
|
|
17429
17598
|
// Fetch raw history and find the last system message
|
|
17430
|
-
const history = await getRawHistory(clientId, METHOD_NAME$
|
|
17599
|
+
const history = await getRawHistory(clientId, METHOD_NAME$5);
|
|
17431
17600
|
const last = history.findLast(({ role }) => role === "system");
|
|
17432
17601
|
return last ? last.content : null;
|
|
17433
17602
|
});
|
|
17434
17603
|
|
|
17435
|
-
const METHOD_NAME$
|
|
17604
|
+
const METHOD_NAME$4 = "function.event.listenEvent";
|
|
17436
17605
|
/**
|
|
17437
17606
|
* Set of reserved event source names that cannot be used for custom events.
|
|
17438
17607
|
* @constant {Set<EventSource>}
|
|
@@ -17468,7 +17637,7 @@ const DISALLOWED_EVENT_SOURCE_LIST$2 = new Set([
|
|
|
17468
17637
|
const event = beginContext((clientId, topicName, payload) => {
|
|
17469
17638
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17470
17639
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17471
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17640
|
+
swarm$1.loggerService.log(METHOD_NAME$4, {
|
|
17472
17641
|
clientId,
|
|
17473
17642
|
});
|
|
17474
17643
|
// Check if the topic name is reserved
|
|
@@ -17483,7 +17652,7 @@ const event = beginContext((clientId, topicName, payload) => {
|
|
|
17483
17652
|
});
|
|
17484
17653
|
});
|
|
17485
17654
|
|
|
17486
|
-
const METHOD_NAME$
|
|
17655
|
+
const METHOD_NAME$3 = "function.event.listenEvent";
|
|
17487
17656
|
/**
|
|
17488
17657
|
* Set of reserved event source names that cannot be used for custom event topics.
|
|
17489
17658
|
* @constant {Set<EventSource>}
|
|
@@ -17535,7 +17704,7 @@ const validateClientId$g = (clientId) => {
|
|
|
17535
17704
|
const listenEvent = beginContext((clientId, topicName, fn) => {
|
|
17536
17705
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17537
17706
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17538
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17707
|
+
swarm$1.loggerService.log(METHOD_NAME$3, {
|
|
17539
17708
|
clientId,
|
|
17540
17709
|
});
|
|
17541
17710
|
// Check if the topic name is reserved
|
|
@@ -17548,7 +17717,7 @@ const listenEvent = beginContext((clientId, topicName, fn) => {
|
|
|
17548
17717
|
return swarm$1.busService.subscribe(clientId, topicName, functoolsKit.queued(async ({ payload }) => await fn(payload)));
|
|
17549
17718
|
});
|
|
17550
17719
|
|
|
17551
|
-
const METHOD_NAME$
|
|
17720
|
+
const METHOD_NAME$2 = "function.event.listenEventOnce";
|
|
17552
17721
|
/**
|
|
17553
17722
|
* Set of reserved event source names that cannot be used for custom event topics.
|
|
17554
17723
|
* @constant {Set<EventSource>}
|
|
@@ -17606,7 +17775,7 @@ const validateClientId$f = (clientId) => {
|
|
|
17606
17775
|
const listenEventOnce = beginContext((clientId, topicName, filterFn, fn) => {
|
|
17607
17776
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17608
17777
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17609
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17778
|
+
swarm$1.loggerService.log(METHOD_NAME$2, {
|
|
17610
17779
|
clientId,
|
|
17611
17780
|
});
|
|
17612
17781
|
// Check if the topic name is reserved
|
|
@@ -17619,19 +17788,19 @@ const listenEventOnce = beginContext((clientId, topicName, filterFn, fn) => {
|
|
|
17619
17788
|
return swarm$1.busService.once(clientId, topicName, ({ payload }) => filterFn(payload), functoolsKit.queued(async ({ payload }) => await fn(payload)));
|
|
17620
17789
|
});
|
|
17621
17790
|
|
|
17622
|
-
const METHOD_NAME$
|
|
17791
|
+
const METHOD_NAME$1 = "function.navigate.changeToAgent";
|
|
17623
17792
|
/**
|
|
17624
17793
|
* Time-to-live for the change agent function in milliseconds.
|
|
17625
17794
|
* Defines how long the cached change agent function remains valid before expiring.
|
|
17626
17795
|
* @constant {number}
|
|
17627
17796
|
*/
|
|
17628
|
-
const CHANGE_AGENT_TTL$
|
|
17797
|
+
const CHANGE_AGENT_TTL$1 = 15 * 60 * 1000;
|
|
17629
17798
|
/**
|
|
17630
17799
|
* Garbage collection interval for the change agent function in milliseconds.
|
|
17631
17800
|
* Specifies the frequency at which expired TTL entries are cleaned up.
|
|
17632
17801
|
* @constant {number}
|
|
17633
17802
|
*/
|
|
17634
|
-
const CHANGE_AGENT_GC$
|
|
17803
|
+
const CHANGE_AGENT_GC$1 = 60 * 1000;
|
|
17635
17804
|
/**
|
|
17636
17805
|
* Creates a change agent function with time-to-live (TTL) and queuing capabilities.
|
|
17637
17806
|
*
|
|
@@ -17655,7 +17824,7 @@ const createChangeToAgent = functoolsKit.ttl((clientId) => functoolsKit.queued(a
|
|
|
17655
17824
|
}));
|
|
17656
17825
|
{
|
|
17657
17826
|
// Dispose of the current agent's resources and set up the new agent
|
|
17658
|
-
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
17827
|
+
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$1, clientId, swarmName);
|
|
17659
17828
|
await swarm$1.agentPublicService.dispose(methodName, clientId, agentName);
|
|
17660
17829
|
await swarm$1.historyPublicService.dispose(methodName, clientId, agentName);
|
|
17661
17830
|
await swarm$1.swarmPublicService.setAgentRef(methodName, clientId, swarmName, agentName, await swarm$1.agentPublicService.createAgentRef(methodName, clientId, agentName));
|
|
@@ -17665,7 +17834,7 @@ const createChangeToAgent = functoolsKit.ttl((clientId) => functoolsKit.queued(a
|
|
|
17665
17834
|
return true;
|
|
17666
17835
|
}), {
|
|
17667
17836
|
key: ([clientId]) => `${clientId}`,
|
|
17668
|
-
timeout: CHANGE_AGENT_TTL$
|
|
17837
|
+
timeout: CHANGE_AGENT_TTL$1,
|
|
17669
17838
|
});
|
|
17670
17839
|
/**
|
|
17671
17840
|
* Creates a garbage collector for the change agent function.
|
|
@@ -17675,8 +17844,8 @@ const createChangeToAgent = functoolsKit.ttl((clientId) => functoolsKit.queued(a
|
|
|
17675
17844
|
* @function
|
|
17676
17845
|
* @returns {Promise<void>} A promise that resolves when the garbage collector is initialized.
|
|
17677
17846
|
*/
|
|
17678
|
-
const createGc$
|
|
17679
|
-
setInterval(createChangeToAgent.gc, CHANGE_AGENT_GC$
|
|
17847
|
+
const createGc$1 = functoolsKit.singleshot(async () => {
|
|
17848
|
+
setInterval(createChangeToAgent.gc, CHANGE_AGENT_GC$1);
|
|
17680
17849
|
});
|
|
17681
17850
|
/**
|
|
17682
17851
|
* Changes the active agent for a given client session in a swarm.
|
|
@@ -17695,16 +17864,16 @@ const createGc$2 = functoolsKit.singleshot(async () => {
|
|
|
17695
17864
|
const changeToAgent = beginContext(async (agentName, clientId) => {
|
|
17696
17865
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17697
17866
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17698
|
-
swarm$1.loggerService.log(METHOD_NAME$
|
|
17867
|
+
swarm$1.loggerService.log(METHOD_NAME$1, {
|
|
17699
17868
|
agentName,
|
|
17700
17869
|
clientId,
|
|
17701
17870
|
});
|
|
17702
17871
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
17703
17872
|
{
|
|
17704
17873
|
// Validate session, agent, and dependencies
|
|
17705
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$
|
|
17706
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$
|
|
17707
|
-
const activeAgent = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$
|
|
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);
|
|
17708
17877
|
if (!swarm$1.agentValidationService.hasDependency(activeAgent, agentName)) {
|
|
17709
17878
|
console.error(`agent-swarm missing dependency detected for activeAgent=${activeAgent} dependencyAgent=${agentName}`);
|
|
17710
17879
|
}
|
|
@@ -17721,23 +17890,23 @@ const changeToAgent = beginContext(async (agentName, clientId) => {
|
|
|
17721
17890
|
}
|
|
17722
17891
|
// Execute the agent change with TTL and queuing
|
|
17723
17892
|
const run = await createChangeToAgent(clientId);
|
|
17724
|
-
createGc$
|
|
17725
|
-
return await run(METHOD_NAME$
|
|
17893
|
+
createGc$1();
|
|
17894
|
+
return await run(METHOD_NAME$1, agentName, swarmName);
|
|
17726
17895
|
});
|
|
17727
17896
|
|
|
17728
|
-
const METHOD_NAME
|
|
17897
|
+
const METHOD_NAME = "function.navigate.changeToPrevAgent";
|
|
17729
17898
|
/**
|
|
17730
17899
|
* Time-to-live for the change agent function in milliseconds.
|
|
17731
17900
|
* Defines how long the cached change agent function remains valid before expiring.
|
|
17732
17901
|
* @constant {number}
|
|
17733
17902
|
*/
|
|
17734
|
-
const CHANGE_AGENT_TTL
|
|
17903
|
+
const CHANGE_AGENT_TTL = 15 * 60 * 1000;
|
|
17735
17904
|
/**
|
|
17736
17905
|
* Garbage collection interval for the change agent function in milliseconds.
|
|
17737
17906
|
* Specifies the frequency at which expired TTL entries are cleaned up.
|
|
17738
17907
|
* @constant {number}
|
|
17739
17908
|
*/
|
|
17740
|
-
const CHANGE_AGENT_GC
|
|
17909
|
+
const CHANGE_AGENT_GC = 60 * 1000;
|
|
17741
17910
|
/**
|
|
17742
17911
|
* Creates a change agent function with time-to-live (TTL) and queuing capabilities for switching to the previous agent.
|
|
17743
17912
|
*
|
|
@@ -17760,7 +17929,7 @@ const createChangeToPrevAgent = functoolsKit.ttl((clientId) => functoolsKit.queu
|
|
|
17760
17929
|
}));
|
|
17761
17930
|
{
|
|
17762
17931
|
// Dispose of the current agent's resources and set up the new agent
|
|
17763
|
-
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME
|
|
17932
|
+
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME, clientId, swarmName);
|
|
17764
17933
|
await swarm$1.agentPublicService.dispose(methodName, clientId, agentName);
|
|
17765
17934
|
await swarm$1.historyPublicService.dispose(methodName, clientId, agentName);
|
|
17766
17935
|
await swarm$1.swarmPublicService.setAgentRef(methodName, clientId, swarmName, agentName, await swarm$1.agentPublicService.createAgentRef(methodName, clientId, agentName));
|
|
@@ -17770,7 +17939,7 @@ const createChangeToPrevAgent = functoolsKit.ttl((clientId) => functoolsKit.queu
|
|
|
17770
17939
|
return true;
|
|
17771
17940
|
}), {
|
|
17772
17941
|
key: ([clientId]) => `${clientId}`,
|
|
17773
|
-
timeout: CHANGE_AGENT_TTL
|
|
17942
|
+
timeout: CHANGE_AGENT_TTL,
|
|
17774
17943
|
});
|
|
17775
17944
|
/**
|
|
17776
17945
|
* Creates a garbage collector for the change agent function.
|
|
@@ -17780,8 +17949,8 @@ const createChangeToPrevAgent = functoolsKit.ttl((clientId) => functoolsKit.queu
|
|
|
17780
17949
|
* @function
|
|
17781
17950
|
* @returns {Promise<void>} A promise that resolves when the garbage collector is initialized.
|
|
17782
17951
|
*/
|
|
17783
|
-
const createGc
|
|
17784
|
-
setInterval(createChangeToPrevAgent.gc, CHANGE_AGENT_GC
|
|
17952
|
+
const createGc = functoolsKit.singleshot(async () => {
|
|
17953
|
+
setInterval(createChangeToPrevAgent.gc, CHANGE_AGENT_GC);
|
|
17785
17954
|
});
|
|
17786
17955
|
/**
|
|
17787
17956
|
* Navigates back to the previous or default agent for a given client session in a swarm.
|
|
@@ -17797,110 +17966,20 @@ const createGc$1 = functoolsKit.singleshot(async () => {
|
|
|
17797
17966
|
* await changeToPrevAgent("client-123");
|
|
17798
17967
|
*/
|
|
17799
17968
|
const changeToPrevAgent = beginContext(async (clientId) => {
|
|
17800
|
-
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17801
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17802
|
-
swarm$1.loggerService.log(METHOD_NAME$1, {
|
|
17803
|
-
clientId,
|
|
17804
|
-
});
|
|
17805
|
-
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
17806
|
-
const agentName = await swarm$1.swarmPublicService.navigationPop(METHOD_NAME$1, clientId, swarmName);
|
|
17807
|
-
{
|
|
17808
|
-
// Validate session and the retrieved agent
|
|
17809
|
-
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$1);
|
|
17810
|
-
swarm$1.agentValidationService.validate(agentName, METHOD_NAME$1);
|
|
17811
|
-
}
|
|
17812
|
-
// Execute the agent change with TTL and queuing
|
|
17813
|
-
const run = await createChangeToPrevAgent(clientId);
|
|
17814
|
-
createGc$1();
|
|
17815
|
-
return await run(METHOD_NAME$1, agentName, swarmName);
|
|
17816
|
-
});
|
|
17817
|
-
|
|
17818
|
-
const METHOD_NAME = "function.navigate.changeToDefaultAgent";
|
|
17819
|
-
/**
|
|
17820
|
-
* Time-to-live for the change agent function in milliseconds.
|
|
17821
|
-
* Defines how long the cached change agent function remains valid before expiring.
|
|
17822
|
-
* @constant {number}
|
|
17823
|
-
*/
|
|
17824
|
-
const CHANGE_AGENT_TTL = 15 * 60 * 1000;
|
|
17825
|
-
/**
|
|
17826
|
-
* Garbage collection interval for the change agent function in milliseconds.
|
|
17827
|
-
* Specifies the frequency at which expired TTL entries are cleaned up.
|
|
17828
|
-
* @constant {number}
|
|
17829
|
-
*/
|
|
17830
|
-
const CHANGE_AGENT_GC = 60 * 1000;
|
|
17831
|
-
/**
|
|
17832
|
-
* Creates a change agent function with time-to-live (TTL) and queuing capabilities for switching to the default agent.
|
|
17833
|
-
*
|
|
17834
|
-
* This factory function generates a queued, TTL-limited function to handle agent changes to the default agent for a specific client session,
|
|
17835
|
-
* ensuring operations are executed sequentially and cached results are reused within the TTL period.
|
|
17836
|
-
*
|
|
17837
|
-
* @function
|
|
17838
|
-
* @param {string} clientId - The unique identifier of the client session.
|
|
17839
|
-
* @returns {TChangeToDefaultAgentRun} A function that performs the default agent change operation with queuing and TTL.
|
|
17840
|
-
*/
|
|
17841
|
-
const createChangeToDefaultAgent = functoolsKit.ttl((clientId) => functoolsKit.queued(async (methodName, agentName, swarmName) => {
|
|
17842
|
-
if (!swarm$1.navigationValidationService.shouldNavigate(agentName, clientId, swarmName)) {
|
|
17843
|
-
return false;
|
|
17844
|
-
}
|
|
17845
|
-
// Notify all agents in the swarm of the change
|
|
17846
|
-
await Promise.all(swarm$1.swarmValidationService
|
|
17847
|
-
.getAgentList(swarmName)
|
|
17848
|
-
.map(async (agentName) => {
|
|
17849
|
-
await swarm$1.agentPublicService.commitAgentChange(methodName, clientId, agentName);
|
|
17850
|
-
}));
|
|
17851
|
-
{
|
|
17852
|
-
// Dispose of the current agent's resources and set up the new default agent
|
|
17853
|
-
const agentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME, clientId, swarmName);
|
|
17854
|
-
await swarm$1.agentPublicService.dispose(methodName, clientId, agentName);
|
|
17855
|
-
await swarm$1.historyPublicService.dispose(methodName, clientId, agentName);
|
|
17856
|
-
await swarm$1.swarmPublicService.setAgentRef(methodName, clientId, swarmName, agentName, await swarm$1.agentPublicService.createAgentRef(methodName, clientId, agentName));
|
|
17857
|
-
}
|
|
17858
|
-
// Set the default agent as the active agent
|
|
17859
|
-
await swarm$1.swarmPublicService.setAgentName(agentName, methodName, clientId, swarmName);
|
|
17860
|
-
return true;
|
|
17861
|
-
}), {
|
|
17862
|
-
key: ([clientId]) => `${clientId}`,
|
|
17863
|
-
timeout: CHANGE_AGENT_TTL,
|
|
17864
|
-
});
|
|
17865
|
-
/**
|
|
17866
|
-
* Creates a garbage collector for the change agent function.
|
|
17867
|
-
*
|
|
17868
|
-
* This function sets up a singleton interval-based garbage collector to periodically clean up expired TTL entries from `createChangeToDefaultAgent`.
|
|
17869
|
-
*
|
|
17870
|
-
* @function
|
|
17871
|
-
* @returns {Promise<void>} A promise that resolves when the garbage collector is initialized.
|
|
17872
|
-
*/
|
|
17873
|
-
const createGc = functoolsKit.singleshot(async () => {
|
|
17874
|
-
setInterval(createChangeToDefaultAgent.gc, CHANGE_AGENT_GC);
|
|
17875
|
-
});
|
|
17876
|
-
/**
|
|
17877
|
-
* Navigates back to the default agent for a given client session in a swarm.
|
|
17878
|
-
*
|
|
17879
|
-
* This function switches the active agent to the default agent defined in the swarm schema for the specified client session.
|
|
17880
|
-
* It validates the session and default agent, logs the operation if enabled, and executes the change using a TTL-limited, queued runner.
|
|
17881
|
-
* The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts.
|
|
17882
|
-
*
|
|
17883
|
-
* @param {string} clientId - The unique identifier of the client session.
|
|
17884
|
-
* @returns {Promise<boolean>} A promise that resolves when the default agent change is complete. If navigation stack contains recursion being canceled
|
|
17885
|
-
* @throws {Error} If session or agent validation fails, or if the agent change process encounters an error.
|
|
17886
|
-
* @example
|
|
17887
|
-
* await changeToDefaultAgent("client-123");
|
|
17888
|
-
*/
|
|
17889
|
-
const changeToDefaultAgent = beginContext(async (clientId) => {
|
|
17890
17969
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
17891
17970
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
17892
17971
|
swarm$1.loggerService.log(METHOD_NAME, {
|
|
17893
17972
|
clientId,
|
|
17894
17973
|
});
|
|
17895
17974
|
const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
|
|
17896
|
-
const
|
|
17975
|
+
const agentName = await swarm$1.swarmPublicService.navigationPop(METHOD_NAME, clientId, swarmName);
|
|
17897
17976
|
{
|
|
17898
|
-
// Validate session and
|
|
17977
|
+
// Validate session and the retrieved agent
|
|
17899
17978
|
swarm$1.sessionValidationService.validate(clientId, METHOD_NAME);
|
|
17900
17979
|
swarm$1.agentValidationService.validate(agentName, METHOD_NAME);
|
|
17901
17980
|
}
|
|
17902
17981
|
// Execute the agent change with TTL and queuing
|
|
17903
|
-
const run = await
|
|
17982
|
+
const run = await createChangeToPrevAgent(clientId);
|
|
17904
17983
|
createGc();
|
|
17905
17984
|
return await run(METHOD_NAME, agentName, swarmName);
|
|
17906
17985
|
});
|
|
@@ -19962,6 +20041,7 @@ exports.commitToolOutputForce = commitToolOutputForce;
|
|
|
19962
20041
|
exports.commitUserMessage = commitUserMessage;
|
|
19963
20042
|
exports.commitUserMessageForce = commitUserMessageForce;
|
|
19964
20043
|
exports.complete = complete;
|
|
20044
|
+
exports.createNavigateToTriageAgent = createNavigateToTriageAgent;
|
|
19965
20045
|
exports.disposeConnection = disposeConnection;
|
|
19966
20046
|
exports.dumpAgent = dumpAgent;
|
|
19967
20047
|
exports.dumpClientPerformance = dumpClientPerformance;
|