agent-swarm-kit 1.0.169 → 1.0.170

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 CHANGED
@@ -39,6 +39,7 @@ const baseServices$1 = {
39
39
  };
40
40
  const contextServices$1 = {
41
41
  methodContextService: Symbol('methodContextService'),
42
+ payloadContextService: Symbol('payloadContextService'),
42
43
  executionContextService: Symbol('executionContextService'),
43
44
  };
44
45
  const connectionServices$1 = {
@@ -12458,6 +12459,21 @@ class PolicyConnectionService {
12458
12459
  }
12459
12460
  }
12460
12461
 
12462
+ /**
12463
+ * A scoped service class that encapsulates a payload context for dependency injection.
12464
+ * Provides a way to access execution metadata and payload data within a specific scope.
12465
+ * Scoped using `di-scoped` to ensure instance isolation per scope.
12466
+ */
12467
+ const PayloadContextService = diScoped.scoped(class {
12468
+ /**
12469
+ * Creates a new instance of PayloadContextService with the provided context.
12470
+ * @param context - The payload context containing client, execution, process IDs, and payload data.
12471
+ */
12472
+ constructor(context) {
12473
+ this.context = context;
12474
+ }
12475
+ });
12476
+
12461
12477
  {
12462
12478
  provide(TYPES.docService, () => new DocService());
12463
12479
  provide(TYPES.busService, () => new BusService());
@@ -12466,6 +12482,7 @@ class PolicyConnectionService {
12466
12482
  }
12467
12483
  {
12468
12484
  provide(TYPES.methodContextService, () => new MethodContextService());
12485
+ provide(TYPES.payloadContextService, () => new PayloadContextService());
12469
12486
  provide(TYPES.executionContextService, () => new ExecutionContextService());
12470
12487
  }
12471
12488
  {
@@ -12524,6 +12541,7 @@ const baseServices = {
12524
12541
  };
12525
12542
  const contextServices = {
12526
12543
  methodContextService: inject(TYPES.methodContextService),
12544
+ payloadContextService: inject(TYPES.payloadContextService),
12527
12545
  executionContextService: inject(TYPES.executionContextService),
12528
12546
  };
12529
12547
  const connectionServices = {
@@ -12585,7 +12603,7 @@ const swarm = {
12585
12603
  init();
12586
12604
  var swarm$1 = swarm;
12587
12605
 
12588
- const METHOD_NAME$R = "cli.dumpDocs";
12606
+ const METHOD_NAME$S = "cli.dumpDocs";
12589
12607
  /**
12590
12608
  * Dumps the documentation for the agents and swarms.
12591
12609
  *
@@ -12595,7 +12613,7 @@ const METHOD_NAME$R = "cli.dumpDocs";
12595
12613
  */
12596
12614
  const dumpDocs = beginContext((dirName = "./docs/chat", PlantUML) => {
12597
12615
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
12598
- swarm$1.loggerService.log(METHOD_NAME$R, {
12616
+ swarm$1.loggerService.log(METHOD_NAME$S, {
12599
12617
  dirName,
12600
12618
  });
12601
12619
  if (PlantUML) {
@@ -12605,10 +12623,10 @@ const dumpDocs = beginContext((dirName = "./docs/chat", PlantUML) => {
12605
12623
  }
12606
12624
  swarm$1.agentValidationService
12607
12625
  .getAgentList()
12608
- .forEach((agentName) => swarm$1.agentValidationService.validate(agentName, METHOD_NAME$R));
12626
+ .forEach((agentName) => swarm$1.agentValidationService.validate(agentName, METHOD_NAME$S));
12609
12627
  swarm$1.swarmValidationService
12610
12628
  .getSwarmList()
12611
- .forEach((swarmName) => swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$R));
12629
+ .forEach((swarmName) => swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$S));
12612
12630
  swarm$1.agentValidationService.getAgentList().forEach((agentName) => {
12613
12631
  const { dependsOn } = swarm$1.agentSchemaService.get(agentName);
12614
12632
  if (!dependsOn) {
@@ -12618,7 +12636,7 @@ const dumpDocs = beginContext((dirName = "./docs/chat", PlantUML) => {
12618
12636
  return swarm$1.docService.dumpDocs(dirName);
12619
12637
  });
12620
12638
 
12621
- const METHOD_NAME$Q = "cli.dumpAgent";
12639
+ const METHOD_NAME$R = "cli.dumpAgent";
12622
12640
  /**
12623
12641
  * Dumps the agent information into PlantUML format.
12624
12642
  *
@@ -12627,14 +12645,14 @@ const METHOD_NAME$Q = "cli.dumpAgent";
12627
12645
  */
12628
12646
  const dumpAgent = beginContext((agentName, { withSubtree = false } = {}) => {
12629
12647
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
12630
- swarm$1.loggerService.log(METHOD_NAME$Q, {
12648
+ swarm$1.loggerService.log(METHOD_NAME$R, {
12631
12649
  agentName,
12632
12650
  });
12633
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$Q);
12651
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$R);
12634
12652
  return swarm$1.agentMetaService.toUML(agentName, withSubtree);
12635
12653
  });
12636
12654
 
12637
- const METHOD_NAME$P = "cli.dumpSwarm";
12655
+ const METHOD_NAME$Q = "cli.dumpSwarm";
12638
12656
  /**
12639
12657
  * Dumps the swarm information into PlantUML format.
12640
12658
  *
@@ -12643,14 +12661,14 @@ const METHOD_NAME$P = "cli.dumpSwarm";
12643
12661
  */
12644
12662
  const dumpSwarm = beginContext((swarmName) => {
12645
12663
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
12646
- swarm$1.loggerService.log(METHOD_NAME$P, {
12664
+ swarm$1.loggerService.log(METHOD_NAME$Q, {
12647
12665
  swarmName,
12648
12666
  });
12649
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$P);
12667
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$Q);
12650
12668
  return swarm$1.swarmMetaService.toUML(swarmName);
12651
12669
  });
12652
12670
 
12653
- const METHOD_NAME$O = "cli.dumpPerfomance";
12671
+ const METHOD_NAME$P = "cli.dumpPerfomance";
12654
12672
  const METHOD_NAME_INTERNAL$1 = "cli.dumpPerfomance.internal";
12655
12673
  const METHOD_NAME_INTERVAL = "cli.dumpPerfomance.interval";
12656
12674
  /**
@@ -12669,7 +12687,7 @@ const dumpPerfomanceInternal = beginContext(async (dirName = "./logs/meta") => {
12669
12687
  * @returns {Promise<void>} A promise that resolves when the performance data has been dumped.
12670
12688
  */
12671
12689
  const dumpPerfomance = async (dirName = "./logs/meta") => {
12672
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$O);
12690
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$P);
12673
12691
  await dumpPerfomanceInternal(dirName);
12674
12692
  };
12675
12693
  /**
@@ -12727,7 +12745,7 @@ const listenExecutionEvent = beginContext((clientId, fn) => {
12727
12745
  return swarm$1.busService.subscribe(clientId, "execution-bus", functoolsKit.queued(async (e) => await fn(e)));
12728
12746
  });
12729
12747
 
12730
- const METHOD_NAME$N = "cli.dumpClientPerformance";
12748
+ const METHOD_NAME$O = "cli.dumpClientPerformance";
12731
12749
  const METHOD_NAME_INTERNAL = "cli.dumpClientPerformance.internal";
12732
12750
  const METHOD_NAME_EXECUTE = "cli.dumpClientPerformance.execute";
12733
12751
  /**
@@ -12751,7 +12769,7 @@ const dumpClientPerformanceInternal = beginContext(async (clientId, dirName = ".
12751
12769
  * @returns {Promise<void>} A promise that resolves when the performance data has been dumped.
12752
12770
  */
12753
12771
  const dumpClientPerformance = async (clientId, dirName = "./logs/client") => {
12754
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$N);
12772
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$O);
12755
12773
  await dumpClientPerformanceInternal(clientId, dirName);
12756
12774
  };
12757
12775
  /**
@@ -12771,7 +12789,7 @@ dumpClientPerformance.runAfterExecute = beginContext(async (dirName = "./logs/cl
12771
12789
  });
12772
12790
  });
12773
12791
 
12774
- const METHOD_NAME$M = "function.setup.addAgent";
12792
+ const METHOD_NAME$N = "function.setup.addAgent";
12775
12793
  /**
12776
12794
  * Adds a new agent to the agent registry for use within the swarm system.
12777
12795
  *
@@ -12791,7 +12809,7 @@ const METHOD_NAME$M = "function.setup.addAgent";
12791
12809
  const addAgent = beginContext((agentSchema) => {
12792
12810
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
12793
12811
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
12794
- swarm$1.loggerService.log(METHOD_NAME$M, {
12812
+ swarm$1.loggerService.log(METHOD_NAME$N, {
12795
12813
  agentSchema,
12796
12814
  });
12797
12815
  // Register the agent in the validation and schema services
@@ -12801,7 +12819,7 @@ const addAgent = beginContext((agentSchema) => {
12801
12819
  return agentSchema.agentName;
12802
12820
  });
12803
12821
 
12804
- const METHOD_NAME$L = "function.setup.addCompletion";
12822
+ const METHOD_NAME$M = "function.setup.addCompletion";
12805
12823
  /**
12806
12824
  * Adds a completion engine to the registry for use by agents in the swarm system.
12807
12825
  *
@@ -12821,7 +12839,7 @@ const METHOD_NAME$L = "function.setup.addCompletion";
12821
12839
  const addCompletion = beginContext((completionSchema) => {
12822
12840
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
12823
12841
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
12824
- swarm$1.loggerService.log(METHOD_NAME$L, {
12842
+ swarm$1.loggerService.log(METHOD_NAME$M, {
12825
12843
  completionSchema,
12826
12844
  });
12827
12845
  // Register the completion in the validation and schema services
@@ -12831,7 +12849,7 @@ const addCompletion = beginContext((completionSchema) => {
12831
12849
  return completionSchema.completionName;
12832
12850
  });
12833
12851
 
12834
- const METHOD_NAME$K = "function.setup.addSwarm";
12852
+ const METHOD_NAME$L = "function.setup.addSwarm";
12835
12853
  /**
12836
12854
  * Adds a new swarm to the system for managing client sessions.
12837
12855
  *
@@ -12851,7 +12869,7 @@ const METHOD_NAME$K = "function.setup.addSwarm";
12851
12869
  const addSwarm = beginContext((swarmSchema) => {
12852
12870
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
12853
12871
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
12854
- swarm$1.loggerService.log(METHOD_NAME$K, {
12872
+ swarm$1.loggerService.log(METHOD_NAME$L, {
12855
12873
  swarmSchema,
12856
12874
  });
12857
12875
  // Register the swarm in the validation and schema services
@@ -12861,7 +12879,7 @@ const addSwarm = beginContext((swarmSchema) => {
12861
12879
  return swarmSchema.swarmName;
12862
12880
  });
12863
12881
 
12864
- const METHOD_NAME$J = "function.setup.addTool";
12882
+ const METHOD_NAME$K = "function.setup.addTool";
12865
12883
  /**
12866
12884
  * Adds a new tool to the tool registry for use by agents in the swarm system.
12867
12885
  *
@@ -12883,7 +12901,7 @@ const METHOD_NAME$J = "function.setup.addTool";
12883
12901
  const addTool = beginContext((toolSchema) => {
12884
12902
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
12885
12903
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
12886
- swarm$1.loggerService.log(METHOD_NAME$J, {
12904
+ swarm$1.loggerService.log(METHOD_NAME$K, {
12887
12905
  toolSchema,
12888
12906
  });
12889
12907
  // Register the tool in the validation and schema services
@@ -12893,7 +12911,7 @@ const addTool = beginContext((toolSchema) => {
12893
12911
  return toolSchema.toolName;
12894
12912
  });
12895
12913
 
12896
- const METHOD_NAME$I = "function.setup.addState";
12914
+ const METHOD_NAME$J = "function.setup.addState";
12897
12915
  /**
12898
12916
  * Adds a new state to the state registry for use within the swarm system.
12899
12917
  *
@@ -12915,7 +12933,7 @@ const METHOD_NAME$I = "function.setup.addState";
12915
12933
  const addState = beginContext((stateSchema) => {
12916
12934
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
12917
12935
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
12918
- swarm$1.loggerService.log(METHOD_NAME$I, {
12936
+ swarm$1.loggerService.log(METHOD_NAME$J, {
12919
12937
  stateSchema,
12920
12938
  });
12921
12939
  // Register the state in the schema service
@@ -12930,7 +12948,7 @@ const addState = beginContext((stateSchema) => {
12930
12948
  return stateSchema.stateName;
12931
12949
  });
12932
12950
 
12933
- const METHOD_NAME$H = "function.setup.addEmbedding";
12951
+ const METHOD_NAME$I = "function.setup.addEmbedding";
12934
12952
  /**
12935
12953
  * Adds a new embedding engine to the embedding registry for use within the swarm system.
12936
12954
  *
@@ -12950,7 +12968,7 @@ const METHOD_NAME$H = "function.setup.addEmbedding";
12950
12968
  const addEmbedding = beginContext((embeddingSchema) => {
12951
12969
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
12952
12970
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
12953
- swarm$1.loggerService.log(METHOD_NAME$H, {
12971
+ swarm$1.loggerService.log(METHOD_NAME$I, {
12954
12972
  embeddingSchema,
12955
12973
  });
12956
12974
  // Register the embedding in the validation and schema services
@@ -12960,7 +12978,7 @@ const addEmbedding = beginContext((embeddingSchema) => {
12960
12978
  return embeddingSchema.embeddingName;
12961
12979
  });
12962
12980
 
12963
- const METHOD_NAME$G = "function.setup.addStorage";
12981
+ const METHOD_NAME$H = "function.setup.addStorage";
12964
12982
  /**
12965
12983
  * Adds a new storage engine to the storage registry for use within the swarm system.
12966
12984
  *
@@ -12982,7 +13000,7 @@ const METHOD_NAME$G = "function.setup.addStorage";
12982
13000
  const addStorage = beginContext((storageSchema) => {
12983
13001
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
12984
13002
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
12985
- swarm$1.loggerService.log(METHOD_NAME$G, {
13003
+ swarm$1.loggerService.log(METHOD_NAME$H, {
12986
13004
  storageSchema,
12987
13005
  });
12988
13006
  // Register the storage in the validation and schema services
@@ -12999,7 +13017,7 @@ const addStorage = beginContext((storageSchema) => {
12999
13017
  });
13000
13018
 
13001
13019
  /** @private Constant defining the method name for logging and validation context */
13002
- const METHOD_NAME$F = "function.setup.addPolicy";
13020
+ const METHOD_NAME$G = "function.setup.addPolicy";
13003
13021
  /**
13004
13022
  * Adds a new policy for agents in the swarm system by registering it with validation and schema services.
13005
13023
  * Registers the policy with PolicyValidationService for runtime validation and PolicySchemaService for schema management.
@@ -13015,7 +13033,7 @@ const METHOD_NAME$F = "function.setup.addPolicy";
13015
13033
  const addPolicy = beginContext((policySchema) => {
13016
13034
  // Log the policy addition attempt if enabled
13017
13035
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13018
- swarm$1.loggerService.log(METHOD_NAME$F, {
13036
+ swarm$1.loggerService.log(METHOD_NAME$G, {
13019
13037
  policySchema,
13020
13038
  });
13021
13039
  // Register the policy with PolicyValidationService for runtime validation
@@ -13026,7 +13044,7 @@ const addPolicy = beginContext((policySchema) => {
13026
13044
  return policySchema.policyName;
13027
13045
  });
13028
13046
 
13029
- const METHOD_NAME$E = "function.commit.commitToolOutput";
13047
+ const METHOD_NAME$F = "function.commit.commitToolOutput";
13030
13048
  /**
13031
13049
  * Commits the output of a tool execution to the active agent in a swarm session.
13032
13050
  *
@@ -13046,19 +13064,19 @@ const METHOD_NAME$E = "function.commit.commitToolOutput";
13046
13064
  const commitToolOutput = beginContext(async (toolId, content, clientId, agentName) => {
13047
13065
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
13048
13066
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13049
- swarm$1.loggerService.log(METHOD_NAME$E, {
13067
+ swarm$1.loggerService.log(METHOD_NAME$F, {
13050
13068
  toolId,
13051
13069
  content,
13052
13070
  clientId,
13053
13071
  agentName,
13054
13072
  });
13055
13073
  // Validate the agent, session, and swarm to ensure they exist and are accessible
13056
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$E);
13057
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$E);
13074
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$F);
13075
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$F);
13058
13076
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13059
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$E);
13077
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$F);
13060
13078
  // Check if the specified agent is still the active agent in the swarm session
13061
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$E, clientId, swarmName);
13079
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$F, clientId, swarmName);
13062
13080
  if (currentAgentName !== agentName) {
13063
13081
  // Log a skip message if the agent has changed during the operation
13064
13082
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
@@ -13071,11 +13089,11 @@ const commitToolOutput = beginContext(async (toolId, content, clientId, agentNam
13071
13089
  return;
13072
13090
  }
13073
13091
  // Commit the tool output to the session via the session public service
13074
- await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$E, clientId, swarmName);
13092
+ await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$F, clientId, swarmName);
13075
13093
  });
13076
13094
 
13077
13095
  /** @private Constant defining the method name for logging and validation context */
13078
- const METHOD_NAME$D = "function.commit.commitSystemMessage";
13096
+ const METHOD_NAME$E = "function.commit.commitSystemMessage";
13079
13097
  /**
13080
13098
  * Commits a system-generated message to the active agent in the swarm system.
13081
13099
  * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before committing the message.
@@ -13094,20 +13112,20 @@ const METHOD_NAME$D = "function.commit.commitSystemMessage";
13094
13112
  const commitSystemMessage = beginContext(async (content, clientId, agentName) => {
13095
13113
  // Log the commit attempt if enabled
13096
13114
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13097
- swarm$1.loggerService.log(METHOD_NAME$D, {
13115
+ swarm$1.loggerService.log(METHOD_NAME$E, {
13098
13116
  content,
13099
13117
  clientId,
13100
13118
  agentName,
13101
13119
  });
13102
13120
  // Validate the agent exists
13103
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$D);
13121
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$E);
13104
13122
  // Validate the session exists and retrieve the associated swarm
13105
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$D);
13123
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$E);
13106
13124
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13107
13125
  // Validate the swarm configuration
13108
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$D);
13126
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$E);
13109
13127
  // Check if the current agent matches the provided agent
13110
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$D, clientId, swarmName);
13128
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$E, clientId, swarmName);
13111
13129
  if (currentAgentName !== agentName) {
13112
13130
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13113
13131
  swarm$1.loggerService.log('function "commitSystemMessage" skipped due to the agent change', {
@@ -13118,11 +13136,11 @@ const commitSystemMessage = beginContext(async (content, clientId, agentName) =>
13118
13136
  return;
13119
13137
  }
13120
13138
  // Commit the system message via SessionPublicService
13121
- await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$D, clientId, swarmName);
13139
+ await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$E, clientId, swarmName);
13122
13140
  });
13123
13141
 
13124
13142
  /** @private Constant defining the method name for logging and validation context */
13125
- const METHOD_NAME$C = "function.commit.commitFlush";
13143
+ const METHOD_NAME$D = "function.commit.commitFlush";
13126
13144
  /**
13127
13145
  * Commits a flush of agent history for a specific client and agent in the swarm system.
13128
13146
  * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before flushing the history.
@@ -13139,19 +13157,19 @@ const METHOD_NAME$C = "function.commit.commitFlush";
13139
13157
  const commitFlush = beginContext(async (clientId, agentName) => {
13140
13158
  // Log the flush attempt if enabled
13141
13159
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13142
- swarm$1.loggerService.log(METHOD_NAME$C, {
13160
+ swarm$1.loggerService.log(METHOD_NAME$D, {
13143
13161
  clientId,
13144
13162
  agentName,
13145
13163
  });
13146
13164
  // Validate the agent exists
13147
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$C);
13165
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$D);
13148
13166
  // Validate the session exists and retrieve the associated swarm
13149
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$C);
13167
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$D);
13150
13168
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13151
13169
  // Validate the swarm configuration
13152
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$C);
13170
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$D);
13153
13171
  // Check if the current agent matches the provided agent
13154
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$C, clientId, swarmName);
13172
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$D, clientId, swarmName);
13155
13173
  if (currentAgentName !== agentName) {
13156
13174
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13157
13175
  swarm$1.loggerService.log('function "commitFlush" skipped due to the agent change', {
@@ -13162,10 +13180,10 @@ const commitFlush = beginContext(async (clientId, agentName) => {
13162
13180
  return;
13163
13181
  }
13164
13182
  // Commit the flush of agent history via SessionPublicService
13165
- await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$C, clientId, swarmName);
13183
+ await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$D, clientId, swarmName);
13166
13184
  });
13167
13185
 
13168
- const METHOD_NAME$B = "function.commit.commitSystemMessage";
13186
+ const METHOD_NAME$C = "function.commit.commitSystemMessage";
13169
13187
  /**
13170
13188
  * Commits a user message to the active agent's history in a swarm session without triggering a response.
13171
13189
  *
@@ -13184,18 +13202,18 @@ const METHOD_NAME$B = "function.commit.commitSystemMessage";
13184
13202
  const commitUserMessage = beginContext(async (content, clientId, agentName) => {
13185
13203
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
13186
13204
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13187
- swarm$1.loggerService.log(METHOD_NAME$B, {
13205
+ swarm$1.loggerService.log(METHOD_NAME$C, {
13188
13206
  content,
13189
13207
  clientId,
13190
13208
  agentName,
13191
13209
  });
13192
13210
  // Validate the agent, session, and swarm to ensure they exist and are accessible
13193
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$B);
13194
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$B);
13211
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$C);
13212
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$C);
13195
13213
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13196
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$B);
13214
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$C);
13197
13215
  // Check if the specified agent is still the active agent in the swarm session
13198
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$B, clientId, swarmName);
13216
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$C, clientId, swarmName);
13199
13217
  if (currentAgentName !== agentName) {
13200
13218
  // Log a skip message if the agent has changed during the operation
13201
13219
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
@@ -13207,10 +13225,10 @@ const commitUserMessage = beginContext(async (content, clientId, agentName) => {
13207
13225
  return;
13208
13226
  }
13209
13227
  // Commit the user message to the agent's history via the session public service
13210
- await swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$B, clientId, swarmName);
13228
+ await swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$C, clientId, swarmName);
13211
13229
  });
13212
13230
 
13213
- const METHOD_NAME$A = "function.commit.commitToolOutputForce";
13231
+ const METHOD_NAME$B = "function.commit.commitToolOutputForce";
13214
13232
  /**
13215
13233
  * Commits the output of a tool execution to the active agent in a swarm session without checking the active agent.
13216
13234
  *
@@ -13229,21 +13247,21 @@ const METHOD_NAME$A = "function.commit.commitToolOutputForce";
13229
13247
  const commitToolOutputForce = beginContext(async (toolId, content, clientId) => {
13230
13248
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
13231
13249
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13232
- swarm$1.loggerService.log(METHOD_NAME$A, {
13250
+ swarm$1.loggerService.log(METHOD_NAME$B, {
13233
13251
  toolId,
13234
13252
  content,
13235
13253
  clientId,
13236
13254
  });
13237
13255
  // Validate the session and swarm to ensure they exist and are accessible
13238
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$A);
13256
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$B);
13239
13257
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13240
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$A);
13258
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$B);
13241
13259
  // Commit the tool output to the session via the session public service without checking the active agent
13242
- await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$A, clientId, swarmName);
13260
+ await swarm$1.sessionPublicService.commitToolOutput(toolId, content, METHOD_NAME$B, clientId, swarmName);
13243
13261
  });
13244
13262
 
13245
13263
  /** @private Constant defining the method name for logging and validation context */
13246
- const METHOD_NAME$z = "function.commit.commitSystemMessageForce";
13264
+ const METHOD_NAME$A = "function.commit.commitSystemMessageForce";
13247
13265
  /**
13248
13266
  * Forcefully commits a system-generated message to a session in the swarm system, without checking the active agent.
13249
13267
  * Validates the session and swarm, then proceeds with committing the message regardless of the current agent state.
@@ -13262,21 +13280,21 @@ const METHOD_NAME$z = "function.commit.commitSystemMessageForce";
13262
13280
  const commitSystemMessageForce = beginContext(async (content, clientId) => {
13263
13281
  // Log the commit attempt if enabled
13264
13282
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13265
- swarm$1.loggerService.log(METHOD_NAME$z, {
13283
+ swarm$1.loggerService.log(METHOD_NAME$A, {
13266
13284
  content,
13267
13285
  clientId,
13268
13286
  });
13269
13287
  // Validate the session exists and retrieve the associated swarm
13270
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$z);
13288
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$A);
13271
13289
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13272
13290
  // Validate the swarm configuration
13273
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$z);
13291
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$A);
13274
13292
  // Commit the system message via SessionPublicService without agent checks
13275
- await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$z, clientId, swarmName);
13293
+ await swarm$1.sessionPublicService.commitSystemMessage(content, METHOD_NAME$A, clientId, swarmName);
13276
13294
  });
13277
13295
 
13278
13296
  /** @private Constant defining the method name for logging and validation context */
13279
- const METHOD_NAME$y = "function.commit.commitFlushForce";
13297
+ const METHOD_NAME$z = "function.commit.commitFlushForce";
13280
13298
  /**
13281
13299
  * Forcefully commits a flush of agent history for a specific client in the swarm system, without checking the active agent.
13282
13300
  * Validates the session and swarm, then proceeds with flushing the history regardless of the current agent state.
@@ -13294,20 +13312,20 @@ const METHOD_NAME$y = "function.commit.commitFlushForce";
13294
13312
  const commitFlushForce = beginContext(async (clientId) => {
13295
13313
  // Log the flush attempt if enabled
13296
13314
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13297
- swarm$1.loggerService.log(METHOD_NAME$y, {
13315
+ swarm$1.loggerService.log(METHOD_NAME$z, {
13298
13316
  clientId,
13299
- METHOD_NAME: METHOD_NAME$y,
13317
+ METHOD_NAME: METHOD_NAME$z,
13300
13318
  });
13301
13319
  // Validate the session exists and retrieve the associated swarm
13302
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$y);
13320
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$z);
13303
13321
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13304
13322
  // Validate the swarm configuration
13305
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$y);
13323
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$z);
13306
13324
  // Commit the flush of agent history via SessionPublicService without agent checks
13307
- await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$y, clientId, swarmName);
13325
+ await swarm$1.sessionPublicService.commitFlush(METHOD_NAME$z, clientId, swarmName);
13308
13326
  });
13309
13327
 
13310
- const METHOD_NAME$x = "function.commit.commitSystemMessage";
13328
+ const METHOD_NAME$y = "function.commit.commitSystemMessage";
13311
13329
  /**
13312
13330
  * Commits a user message to the active agent's history in a swarm session without triggering a response and without checking the active agent.
13313
13331
  *
@@ -13325,20 +13343,20 @@ const METHOD_NAME$x = "function.commit.commitSystemMessage";
13325
13343
  const commitUserMessageForce = beginContext(async (content, clientId) => {
13326
13344
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
13327
13345
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13328
- swarm$1.loggerService.log(METHOD_NAME$x, {
13346
+ swarm$1.loggerService.log(METHOD_NAME$y, {
13329
13347
  content,
13330
13348
  clientId,
13331
13349
  });
13332
13350
  // Validate the session and swarm to ensure they exist and are accessible
13333
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$x);
13351
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$y);
13334
13352
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13335
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$x);
13353
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$y);
13336
13354
  // Commit the user message to the agent's history via the session public service without checking the active agent
13337
- await swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$x, clientId, swarmName);
13355
+ await swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$y, clientId, swarmName);
13338
13356
  });
13339
13357
 
13340
13358
  /** @private Constant defining the method name for logging and validation context */
13341
- const METHOD_NAME$w = "function.commit.commitAssistantMessage";
13359
+ const METHOD_NAME$x = "function.commit.commitAssistantMessage";
13342
13360
  /**
13343
13361
  * Commits an assistant-generated message to the active agent in the swarm system.
13344
13362
  * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before committing the message.
@@ -13356,20 +13374,20 @@ const METHOD_NAME$w = "function.commit.commitAssistantMessage";
13356
13374
  const commitAssistantMessage = beginContext(async (content, clientId, agentName) => {
13357
13375
  // Log the commit attempt if enabled
13358
13376
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13359
- swarm$1.loggerService.log(METHOD_NAME$w, {
13377
+ swarm$1.loggerService.log(METHOD_NAME$x, {
13360
13378
  content,
13361
13379
  clientId,
13362
13380
  agentName,
13363
13381
  });
13364
13382
  // Validate the agent exists
13365
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$w);
13383
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$x);
13366
13384
  // Validate the session exists and retrieve the associated swarm
13367
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$w);
13385
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$x);
13368
13386
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13369
13387
  // Validate the swarm configuration
13370
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$w);
13388
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$x);
13371
13389
  // Check if the current agent matches the provided agent
13372
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$w, clientId, swarmName);
13390
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$x, clientId, swarmName);
13373
13391
  if (currentAgentName !== agentName) {
13374
13392
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13375
13393
  swarm$1.loggerService.log('function "commitAssistantMessage" skipped due to the agent change', {
@@ -13380,11 +13398,11 @@ const commitAssistantMessage = beginContext(async (content, clientId, agentName)
13380
13398
  return;
13381
13399
  }
13382
13400
  // Commit the assistant message via SessionPublicService
13383
- await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$w, clientId, swarmName);
13401
+ await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$x, clientId, swarmName);
13384
13402
  });
13385
13403
 
13386
13404
  /** @private Constant defining the method name for logging and validation context */
13387
- const METHOD_NAME$v = "function.commit.commitAssistantMessageForce";
13405
+ const METHOD_NAME$w = "function.commit.commitAssistantMessageForce";
13388
13406
  /**
13389
13407
  * Forcefully commits an assistant-generated message to a session in the swarm system, without checking the active agent.
13390
13408
  * Validates the session and swarm, then proceeds with committing the message regardless of the current agent state.
@@ -13403,21 +13421,21 @@ const METHOD_NAME$v = "function.commit.commitAssistantMessageForce";
13403
13421
  const commitAssistantMessageForce = beginContext(async (content, clientId) => {
13404
13422
  // Log the commit attempt if enabled
13405
13423
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13406
- swarm$1.loggerService.log(METHOD_NAME$v, {
13424
+ swarm$1.loggerService.log(METHOD_NAME$w, {
13407
13425
  content,
13408
13426
  clientId,
13409
13427
  });
13410
13428
  // Validate the session exists and retrieve the associated swarm
13411
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$v);
13429
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$w);
13412
13430
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13413
13431
  // Validate the swarm configuration
13414
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$v);
13432
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$w);
13415
13433
  // Commit the assistant message via SessionPublicService without agent checks
13416
- await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$v, clientId, swarmName);
13434
+ await swarm$1.sessionPublicService.commitAssistantMessage(content, METHOD_NAME$w, clientId, swarmName);
13417
13435
  });
13418
13436
 
13419
13437
  /** @private Constant defining the method name for logging and validation context */
13420
- const METHOD_NAME$u = "function.commit.cancelOutput";
13438
+ const METHOD_NAME$v = "function.commit.cancelOutput";
13421
13439
  /**
13422
13440
  * Cancels the awaited output for a specific client and agent by emitting an empty string.
13423
13441
  * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before cancellation.
@@ -13433,19 +13451,19 @@ const METHOD_NAME$u = "function.commit.cancelOutput";
13433
13451
  const cancelOutput = beginContext(async (clientId, agentName) => {
13434
13452
  // Log the cancellation attempt if enabled
13435
13453
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13436
- swarm$1.loggerService.log(METHOD_NAME$u, {
13454
+ swarm$1.loggerService.log(METHOD_NAME$v, {
13437
13455
  clientId,
13438
13456
  agentName,
13439
13457
  });
13440
13458
  // Validate the agent exists
13441
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$u);
13459
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$v);
13442
13460
  // Validate the session exists and retrieve the associated swarm
13443
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$u);
13461
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$v);
13444
13462
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13445
13463
  // Validate the swarm configuration
13446
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$u);
13464
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$v);
13447
13465
  // Check if the current agent matches the provided agent
13448
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$u, clientId, swarmName);
13466
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$v, clientId, swarmName);
13449
13467
  if (currentAgentName !== agentName) {
13450
13468
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13451
13469
  swarm$1.loggerService.log('function "cancelOutput" skipped due to the agent change', {
@@ -13456,11 +13474,11 @@ const cancelOutput = beginContext(async (clientId, agentName) => {
13456
13474
  return;
13457
13475
  }
13458
13476
  // Perform the output cancellation via SwarmPublicService
13459
- await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$u, clientId, swarmName);
13477
+ await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$v, clientId, swarmName);
13460
13478
  });
13461
13479
 
13462
13480
  /** @private Constant defining the method name for logging and validation context */
13463
- const METHOD_NAME$t = "function.commit.cancelOutputForce";
13481
+ const METHOD_NAME$u = "function.commit.cancelOutputForce";
13464
13482
  /**
13465
13483
  * Forcefully cancels the awaited output for a specific client by emitting an empty string, without checking the active agent.
13466
13484
  * Validates the session and swarm, then proceeds with cancellation regardless of the current agent state.
@@ -13477,20 +13495,20 @@ const METHOD_NAME$t = "function.commit.cancelOutputForce";
13477
13495
  const cancelOutputForce = beginContext(async (clientId) => {
13478
13496
  // Log the cancellation attempt if enabled
13479
13497
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13480
- swarm$1.loggerService.log(METHOD_NAME$t, {
13498
+ swarm$1.loggerService.log(METHOD_NAME$u, {
13481
13499
  clientId,
13482
13500
  });
13483
13501
  // Validate the session exists and retrieve the associated swarm
13484
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$t);
13502
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$u);
13485
13503
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13486
13504
  // Validate the swarm configuration
13487
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$t);
13505
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$u);
13488
13506
  // Perform the output cancellation via SwarmPublicService without agent checks
13489
- await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$t, clientId, swarmName);
13507
+ await swarm$1.swarmPublicService.cancelOutput(METHOD_NAME$u, clientId, swarmName);
13490
13508
  });
13491
13509
 
13492
13510
  /** @private Constant defining the method name for logging and validation context */
13493
- const METHOD_NAME$s = "function.commit.commitStopTools";
13511
+ const METHOD_NAME$t = "function.commit.commitStopTools";
13494
13512
  /**
13495
13513
  * Prevents the next tool from being executed for a specific client and agent in the swarm system.
13496
13514
  * Validates the agent, session, and swarm, ensuring the current agent matches the provided agent before stopping tool execution.
@@ -13507,19 +13525,19 @@ const METHOD_NAME$s = "function.commit.commitStopTools";
13507
13525
  const commitStopTools = beginContext(async (clientId, agentName) => {
13508
13526
  // Log the stop tools attempt if enabled
13509
13527
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13510
- swarm$1.loggerService.log(METHOD_NAME$s, {
13528
+ swarm$1.loggerService.log(METHOD_NAME$t, {
13511
13529
  clientId,
13512
13530
  agentName,
13513
13531
  });
13514
13532
  // Validate the agent exists
13515
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$s);
13533
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$t);
13516
13534
  // Validate the session exists and retrieve the associated swarm
13517
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$s);
13535
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$t);
13518
13536
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13519
13537
  // Validate the swarm configuration
13520
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$s);
13538
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$t);
13521
13539
  // Check if the current agent matches the provided agent
13522
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$s, clientId, swarmName);
13540
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$t, clientId, swarmName);
13523
13541
  if (currentAgentName !== agentName) {
13524
13542
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13525
13543
  swarm$1.loggerService.log('function "commitStopTools" skipped due to the agent change', {
@@ -13530,11 +13548,11 @@ const commitStopTools = beginContext(async (clientId, agentName) => {
13530
13548
  return;
13531
13549
  }
13532
13550
  // Commit the stop of the next tool execution via SessionPublicService
13533
- await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$s, clientId, swarmName);
13551
+ await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$t, clientId, swarmName);
13534
13552
  });
13535
13553
 
13536
13554
  /** @private Constant defining the method name for logging and validation context */
13537
- const METHOD_NAME$r = "function.commit.commitStopToolsForce";
13555
+ const METHOD_NAME$s = "function.commit.commitStopToolsForce";
13538
13556
  /**
13539
13557
  * Forcefully prevents the next tool from being executed for a specific client in the swarm system, without checking the active agent.
13540
13558
  * Validates the session and swarm, then proceeds with stopping tool execution regardless of the current agent state.
@@ -13552,20 +13570,20 @@ const METHOD_NAME$r = "function.commit.commitStopToolsForce";
13552
13570
  const commitStopToolsForce = beginContext(async (clientId) => {
13553
13571
  // Log the stop tools attempt if enabled
13554
13572
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13555
- swarm$1.loggerService.log(METHOD_NAME$r, {
13573
+ swarm$1.loggerService.log(METHOD_NAME$s, {
13556
13574
  clientId,
13557
- METHOD_NAME: METHOD_NAME$r,
13575
+ METHOD_NAME: METHOD_NAME$s,
13558
13576
  });
13559
13577
  // Validate the session exists and retrieve the associated swarm
13560
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$r);
13578
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$s);
13561
13579
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13562
13580
  // Validate the swarm configuration
13563
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$r);
13581
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$s);
13564
13582
  // Commit the stop of the next tool execution via SessionPublicService without agent checks
13565
- await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$r, clientId, swarmName);
13583
+ await swarm$1.sessionPublicService.commitStopTools(METHOD_NAME$s, clientId, swarmName);
13566
13584
  });
13567
13585
 
13568
- const METHOD_NAME$q = "function.target.emitForce";
13586
+ const METHOD_NAME$r = "function.target.emitForce";
13569
13587
  /**
13570
13588
  * Emits a string as model output without executing an incoming message or checking the active agent.
13571
13589
  *
@@ -13584,7 +13602,7 @@ const METHOD_NAME$q = "function.target.emitForce";
13584
13602
  const emitForce = beginContext(async (content, clientId) => {
13585
13603
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
13586
13604
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13587
- swarm$1.loggerService.log(METHOD_NAME$q, {
13605
+ swarm$1.loggerService.log(METHOD_NAME$r, {
13588
13606
  content,
13589
13607
  clientId,
13590
13608
  });
@@ -13594,14 +13612,14 @@ const emitForce = beginContext(async (content, clientId) => {
13594
13612
  throw new Error(`agent-swarm-kit emitForce session is not makeConnection clientId=${clientId}`);
13595
13613
  }
13596
13614
  // Validate the session and swarm
13597
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$q);
13615
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$r);
13598
13616
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13599
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$q);
13617
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$r);
13600
13618
  // Emit the content directly via the session public service
13601
- return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$q, clientId, swarmName);
13619
+ return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$r, clientId, swarmName);
13602
13620
  });
13603
13621
 
13604
- const METHOD_NAME$p = "function.target.executeForce";
13622
+ const METHOD_NAME$q = "function.target.executeForce";
13605
13623
  /**
13606
13624
  * 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.
13607
13625
  *
@@ -13622,22 +13640,22 @@ const executeForce = beginContext(async (content, clientId) => {
13622
13640
  const executionId = functoolsKit.randomString();
13623
13641
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
13624
13642
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13625
- swarm$1.loggerService.log(METHOD_NAME$p, {
13643
+ swarm$1.loggerService.log(METHOD_NAME$q, {
13626
13644
  content,
13627
13645
  clientId,
13628
13646
  executionId,
13629
13647
  });
13630
13648
  // Validate the session and swarm
13631
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$p);
13649
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$q);
13632
13650
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13633
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$p);
13651
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$q);
13634
13652
  // Execute the command within an execution context with performance tracking
13635
13653
  return ExecutionContextService.runInContext(async () => {
13636
13654
  let isFinished = false;
13637
13655
  swarm$1.perfService.startExecution(executionId, clientId, content.length);
13638
13656
  try {
13639
13657
  swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
13640
- const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$p, clientId, swarmName);
13658
+ const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$q, clientId, swarmName);
13641
13659
  isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
13642
13660
  swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
13643
13661
  return result;
@@ -13654,7 +13672,7 @@ const executeForce = beginContext(async (content, clientId) => {
13654
13672
  });
13655
13673
  });
13656
13674
 
13657
- const METHOD_NAME$o = "function.target.disposeConnection";
13675
+ const METHOD_NAME$p = "function.target.disposeConnection";
13658
13676
  /**
13659
13677
  * Disposes of a client session and all related resources within a swarm.
13660
13678
  *
@@ -13671,10 +13689,10 @@ const METHOD_NAME$o = "function.target.disposeConnection";
13671
13689
  * @example
13672
13690
  * await disposeConnection("client-123", "TaskSwarm");
13673
13691
  */
13674
- const disposeConnection = beginContext(async (clientId, swarmName, methodName = METHOD_NAME$o) => {
13692
+ const disposeConnection = beginContext(async (clientId, swarmName, methodName = METHOD_NAME$p) => {
13675
13693
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
13676
13694
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13677
- swarm$1.loggerService.log(METHOD_NAME$o, {
13695
+ swarm$1.loggerService.log(METHOD_NAME$p, {
13678
13696
  clientId,
13679
13697
  swarmName,
13680
13698
  });
@@ -13741,7 +13759,7 @@ const disposeConnection = beginContext(async (clientId, swarmName, methodName =
13741
13759
  PersistMemoryAdapter.dispose(clientId);
13742
13760
  });
13743
13761
 
13744
- const METHOD_NAME$n = "function.target.makeAutoDispose";
13762
+ const METHOD_NAME$o = "function.target.makeAutoDispose";
13745
13763
  /**
13746
13764
  * Default timeout in seconds before auto-dispose is triggered.
13747
13765
  * @constant {number}
@@ -13772,7 +13790,7 @@ const DEFAULT_TIMEOUT = 15 * 60;
13772
13790
  const makeAutoDispose = beginContext((clientId, swarmName, { timeoutSeconds = DEFAULT_TIMEOUT, onDestroy, } = {}) => {
13773
13791
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
13774
13792
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13775
- swarm$1.loggerService.log(METHOD_NAME$n, {
13793
+ swarm$1.loggerService.log(METHOD_NAME$o, {
13776
13794
  clientId,
13777
13795
  swarmName,
13778
13796
  });
@@ -13805,7 +13823,7 @@ const makeAutoDispose = beginContext((clientId, swarmName, { timeoutSeconds = DE
13805
13823
  };
13806
13824
  });
13807
13825
 
13808
- const METHOD_NAME$m = "function.target.execute";
13826
+ const METHOD_NAME$n = "function.target.execute";
13809
13827
  /**
13810
13828
  * Sends a message to the active agent in a swarm session as if it originated from the client side.
13811
13829
  *
@@ -13827,19 +13845,19 @@ const execute = beginContext(async (content, clientId, agentName) => {
13827
13845
  const executionId = functoolsKit.randomString();
13828
13846
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
13829
13847
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13830
- swarm$1.loggerService.log(METHOD_NAME$m, {
13848
+ swarm$1.loggerService.log(METHOD_NAME$n, {
13831
13849
  content,
13832
13850
  clientId,
13833
13851
  agentName,
13834
13852
  executionId,
13835
13853
  });
13836
13854
  // Validate the agent, session, and swarm
13837
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$m);
13838
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$m);
13855
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$n);
13856
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$n);
13839
13857
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13840
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$m);
13858
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$n);
13841
13859
  // Check if the specified agent is still the active agent
13842
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$m, clientId, swarmName);
13860
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$n, clientId, swarmName);
13843
13861
  if (currentAgentName !== agentName) {
13844
13862
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13845
13863
  swarm$1.loggerService.log('function "execute" skipped due to the agent change', {
@@ -13858,7 +13876,7 @@ const execute = beginContext(async (content, clientId, agentName) => {
13858
13876
  agentName,
13859
13877
  swarmName,
13860
13878
  });
13861
- const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$m, clientId, swarmName);
13879
+ const result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$n, clientId, swarmName);
13862
13880
  isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
13863
13881
  swarm$1.busService.commitExecutionEnd(clientId, {
13864
13882
  agentName,
@@ -13878,7 +13896,7 @@ const execute = beginContext(async (content, clientId, agentName) => {
13878
13896
  });
13879
13897
  });
13880
13898
 
13881
- const METHOD_NAME$l = "function.target.emit";
13899
+ const METHOD_NAME$m = "function.target.emit";
13882
13900
  /**
13883
13901
  * Emits a string as model output without executing an incoming message, with agent activity validation.
13884
13902
  *
@@ -13898,7 +13916,7 @@ const METHOD_NAME$l = "function.target.emit";
13898
13916
  const emit = beginContext(async (content, clientId, agentName) => {
13899
13917
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
13900
13918
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13901
- swarm$1.loggerService.log(METHOD_NAME$l, {
13919
+ swarm$1.loggerService.log(METHOD_NAME$m, {
13902
13920
  content,
13903
13921
  clientId,
13904
13922
  agentName,
@@ -13909,12 +13927,12 @@ const emit = beginContext(async (content, clientId, agentName) => {
13909
13927
  throw new Error(`agent-swarm-kit emit session is not makeConnection clientId=${clientId}`);
13910
13928
  }
13911
13929
  // Validate the agent, session, and swarm
13912
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$l);
13913
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$l);
13930
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$m);
13931
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$m);
13914
13932
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13915
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$l);
13933
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$m);
13916
13934
  // Check if the specified agent is still the active agent
13917
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$l, clientId, swarmName);
13935
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$m, clientId, swarmName);
13918
13936
  if (currentAgentName !== agentName) {
13919
13937
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13920
13938
  swarm$1.loggerService.log('function "emit" skipped due to the agent change', {
@@ -13925,10 +13943,10 @@ const emit = beginContext(async (content, clientId, agentName) => {
13925
13943
  return;
13926
13944
  }
13927
13945
  // Emit the content directly via the session public service
13928
- return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$l, clientId, swarmName);
13946
+ return await swarm$1.sessionPublicService.emit(content, METHOD_NAME$m, clientId, swarmName);
13929
13947
  });
13930
13948
 
13931
- const METHOD_NAME$k = "function.target.runStateless";
13949
+ const METHOD_NAME$l = "function.target.runStateless";
13932
13950
  /**
13933
13951
  * Executes a message statelessly with an agent in a swarm session, bypassing chat history.
13934
13952
  *
@@ -13951,19 +13969,19 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
13951
13969
  const executionId = functoolsKit.randomString();
13952
13970
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
13953
13971
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13954
- swarm$1.loggerService.log(METHOD_NAME$k, {
13972
+ swarm$1.loggerService.log(METHOD_NAME$l, {
13955
13973
  content,
13956
13974
  clientId,
13957
13975
  agentName,
13958
13976
  executionId,
13959
13977
  });
13960
13978
  // Validate the agent, session, and swarm
13961
- swarm$1.agentValidationService.validate(agentName, METHOD_NAME$k);
13962
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$k);
13979
+ swarm$1.agentValidationService.validate(agentName, METHOD_NAME$l);
13980
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$l);
13963
13981
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
13964
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$k);
13982
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$l);
13965
13983
  // Check if the specified agent is still the active agent
13966
- const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$k, clientId, swarmName);
13984
+ const currentAgentName = await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$l, clientId, swarmName);
13967
13985
  if (currentAgentName !== agentName) {
13968
13986
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
13969
13987
  swarm$1.loggerService.log('function "runStateless" skipped due to the agent change', {
@@ -13982,7 +14000,7 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
13982
14000
  agentName,
13983
14001
  swarmName,
13984
14002
  });
13985
- const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$k, clientId, swarmName);
14003
+ const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$l, clientId, swarmName);
13986
14004
  isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
13987
14005
  swarm$1.busService.commitExecutionEnd(clientId, {
13988
14006
  agentName,
@@ -14002,7 +14020,7 @@ const runStateless = beginContext(async (content, clientId, agentName) => {
14002
14020
  });
14003
14021
  });
14004
14022
 
14005
- const METHOD_NAME$j = "function.target.runStatelessForce";
14023
+ const METHOD_NAME$k = "function.target.runStatelessForce";
14006
14024
  /**
14007
14025
  * Executes a message statelessly with the active agent in a swarm session, bypassing chat history and forcing execution regardless of agent activity.
14008
14026
  *
@@ -14023,22 +14041,22 @@ const runStatelessForce = beginContext(async (content, clientId) => {
14023
14041
  const executionId = functoolsKit.randomString();
14024
14042
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
14025
14043
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
14026
- swarm$1.loggerService.log(METHOD_NAME$j, {
14044
+ swarm$1.loggerService.log(METHOD_NAME$k, {
14027
14045
  content,
14028
14046
  clientId,
14029
14047
  executionId,
14030
14048
  });
14031
14049
  // Validate the session and swarm
14032
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$j);
14050
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$k);
14033
14051
  const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
14034
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$j);
14052
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$k);
14035
14053
  // Execute the command statelessly within an execution context with performance tracking
14036
14054
  return ExecutionContextService.runInContext(async () => {
14037
14055
  let isFinished = false;
14038
14056
  swarm$1.perfService.startExecution(executionId, clientId, content.length);
14039
14057
  try {
14040
14058
  swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
14041
- const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$j, clientId, swarmName);
14059
+ const result = await swarm$1.sessionPublicService.run(content, METHOD_NAME$k, clientId, swarmName);
14042
14060
  isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
14043
14061
  swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
14044
14062
  return result;
@@ -14055,35 +14073,6 @@ const runStatelessForce = beginContext(async (content, clientId) => {
14055
14073
  });
14056
14074
  });
14057
14075
 
14058
- const METHOD_NAME$i = "function.common.getAgentName";
14059
- /**
14060
- * Retrieves the name of the active agent for a given client session in a swarm.
14061
- *
14062
- * This function fetches the name of the currently active agent associated with the specified client session within a swarm.
14063
- * It validates the client session and swarm, logs the operation if enabled, and delegates the retrieval to the swarm public service.
14064
- * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
14065
- *
14066
- * @param {string} clientId - The unique identifier of the client session whose active agent name is being retrieved.
14067
- * @returns {Promise<string>} A promise that resolves to the name of the active agent (`AgentName`) associated with the client session.
14068
- * @throws {Error} If the client session is invalid, the swarm validation fails, or the swarm public service encounters an error during retrieval.
14069
- * @example
14070
- * const agentName = await getAgentName("client-123");
14071
- * console.log(agentName); // Outputs "AgentX"
14072
- */
14073
- const getAgentName = beginContext(async (clientId) => {
14074
- // Log the operation details if logging is enabled in GLOBAL_CONFIG
14075
- GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
14076
- swarm$1.loggerService.log(METHOD_NAME$i, {
14077
- clientId,
14078
- });
14079
- // Validate the session and swarm to ensure they exist and are accessible
14080
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$i);
14081
- const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
14082
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$i);
14083
- // Retrieve the active agent name via the swarm public service
14084
- return await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$i, clientId, swarmName);
14085
- });
14086
-
14087
14076
  /**
14088
14077
  * Delay in milliseconds for scheduled message sending.
14089
14078
  * @constant {number}
@@ -14094,7 +14083,7 @@ const SCHEDULED_DELAY$1 = 1000;
14094
14083
  * @constant {number}
14095
14084
  */
14096
14085
  const RATE_DELAY = 10000;
14097
- const METHOD_NAME$h = "function.target.makeConnection";
14086
+ const METHOD_NAME$j = "function.target.makeConnection";
14098
14087
  /**
14099
14088
  * Internal implementation of the connection factory for a client to a swarm.
14100
14089
  *
@@ -14106,28 +14095,28 @@ const METHOD_NAME$h = "function.target.makeConnection";
14106
14095
  * @param {SwarmName} swarmName - The name of the swarm to connect to.
14107
14096
  * @returns {SendMessageFn} A function to send messages to the swarm.
14108
14097
  */
14109
- const makeConnectionInternal = beginContext((connector, clientId, swarmName) => {
14098
+ const makeConnectionInternal = (connector, clientId, swarmName) => {
14110
14099
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
14111
14100
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
14112
- swarm$1.loggerService.log(METHOD_NAME$h, {
14101
+ swarm$1.loggerService.log(METHOD_NAME$j, {
14113
14102
  clientId,
14114
14103
  swarmName,
14115
14104
  });
14116
14105
  // Validate the swarm and initialize the session
14117
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$h);
14106
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$j);
14118
14107
  swarm$1.sessionValidationService.addSession(clientId, swarmName, "makeConnection");
14119
14108
  // Create a queued send function using the session public service
14120
- const send = functoolsKit.queued(swarm$1.sessionPublicService.connect(connector, METHOD_NAME$h, clientId, swarmName));
14109
+ const send = functoolsKit.queued(swarm$1.sessionPublicService.connect(connector, METHOD_NAME$j, clientId, swarmName));
14121
14110
  // Return a wrapped send function with validation and agent context
14122
- return beginContext(async (outgoing) => {
14123
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$h);
14111
+ return (async (outgoing) => {
14112
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$j);
14124
14113
  return await send({
14125
14114
  data: outgoing,
14126
- agentName: await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$h, clientId, swarmName),
14115
+ agentName: await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$j, clientId, swarmName),
14127
14116
  clientId,
14128
14117
  });
14129
14118
  });
14130
- });
14119
+ };
14131
14120
  /**
14132
14121
  * A connection factory for establishing a client connection to a swarm, returning a function to send messages.
14133
14122
  *
@@ -14143,7 +14132,20 @@ const makeConnectionInternal = beginContext((connector, clientId, swarmName) =>
14143
14132
  * const sendMessage = makeConnection((msg) => console.log(msg), "client-123", "TaskSwarm");
14144
14133
  * await sendMessage("Hello, swarm!");
14145
14134
  */
14146
- const makeConnection = (connector, clientId, swarmName) => makeConnectionInternal(connector, clientId, swarmName);
14135
+ const makeConnection = (connector, clientId, swarmName) => {
14136
+ const send = makeConnectionInternal(connector, clientId, swarmName);
14137
+ return beginContext(async (content, payload = null) => {
14138
+ if (payload) {
14139
+ return await PayloadContextService.runInContext(async () => {
14140
+ return await send(content);
14141
+ }, {
14142
+ clientId,
14143
+ payload,
14144
+ });
14145
+ }
14146
+ return await send(content);
14147
+ });
14148
+ };
14147
14149
  /**
14148
14150
  * A scheduled connection factory for a client to a swarm, returning a function to send delayed messages.
14149
14151
  *
@@ -14160,26 +14162,42 @@ const makeConnection = (connector, clientId, swarmName) => makeConnectionInterna
14160
14162
  * const sendScheduled = makeConnection.scheduled((msg) => console.log(msg), "client-123", "TaskSwarm", { delay: 2000 });
14161
14163
  * await sendScheduled("Delayed message"); // Sent after 2 seconds
14162
14164
  */
14163
- makeConnection.scheduled = beginContext((connector, clientId, swarmName, { delay = SCHEDULED_DELAY$1 } = {}) => {
14164
- const send = makeConnection(connector, clientId, swarmName);
14165
- const wrappedSend = functoolsKit.schedule(beginContext(async (content) => {
14165
+ makeConnection.scheduled = (connector, clientId, swarmName, { delay = SCHEDULED_DELAY$1 } = {}) => {
14166
+ const send = makeConnectionInternal(connector, clientId, swarmName);
14167
+ const wrappedSend = functoolsKit.schedule(beginContext(async (content, payload) => {
14166
14168
  if (!swarm$1.sessionValidationService.hasSession(clientId)) {
14167
14169
  return;
14168
14170
  }
14171
+ if (payload) {
14172
+ return await PayloadContextService.runInContext(async () => {
14173
+ return await send(content);
14174
+ }, {
14175
+ clientId,
14176
+ payload,
14177
+ });
14178
+ }
14169
14179
  return await send(content);
14170
14180
  }), {
14171
- onSchedule: beginContext(async ([content]) => {
14181
+ onSchedule: beginContext(async ([content, payload]) => {
14172
14182
  if (!swarm$1.sessionValidationService.hasSession(clientId)) {
14173
14183
  return;
14174
14184
  }
14175
- await commitUserMessage(content, clientId, await getAgentName(clientId));
14185
+ if (payload) {
14186
+ return await PayloadContextService.runInContext(async () => {
14187
+ await swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$j, clientId, swarmName);
14188
+ }, {
14189
+ clientId,
14190
+ payload,
14191
+ });
14192
+ }
14193
+ await swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$j, clientId, swarmName);
14176
14194
  }),
14177
14195
  delay,
14178
14196
  });
14179
- return async (content) => {
14180
- return await wrappedSend(content);
14197
+ return async (content, payload = null) => {
14198
+ return await wrappedSend(content, payload);
14181
14199
  };
14182
- });
14200
+ };
14183
14201
  /**
14184
14202
  * A rate-limited connection factory for a client to a swarm, returning a function to send throttled messages.
14185
14203
  *
@@ -14196,21 +14214,29 @@ makeConnection.scheduled = beginContext((connector, clientId, swarmName, { delay
14196
14214
  * const sendRateLimited = makeConnection.rate((msg) => console.log(msg), "client-123", "TaskSwarm", { delay: 5000 });
14197
14215
  * await sendRateLimited("Throttled message"); // Limited to one send every 5 seconds
14198
14216
  */
14199
- makeConnection.rate = beginContext((connector, clientId, swarmName, { delay = RATE_DELAY } = {}) => {
14200
- const send = makeConnection(connector, clientId, swarmName);
14201
- const wrappedSend = functoolsKit.rate(beginContext(async (content) => {
14217
+ makeConnection.rate = (connector, clientId, swarmName, { delay = RATE_DELAY } = {}) => {
14218
+ const send = makeConnectionInternal(connector, clientId, swarmName);
14219
+ const wrappedSend = functoolsKit.rate(beginContext(async (content, payload) => {
14202
14220
  if (!swarm$1.sessionValidationService.hasSession(clientId)) {
14203
14221
  return;
14204
14222
  }
14223
+ if (payload) {
14224
+ return await PayloadContextService.runInContext(async () => {
14225
+ return await send(content);
14226
+ }, {
14227
+ clientId,
14228
+ payload,
14229
+ });
14230
+ }
14205
14231
  return await send(content);
14206
14232
  }), {
14207
14233
  key: () => clientId,
14208
14234
  rateName: `makeConnection.rate clientId=${clientId}`,
14209
14235
  delay,
14210
14236
  });
14211
- return async (content) => {
14237
+ return async (content, payload = null) => {
14212
14238
  try {
14213
- return await wrappedSend(content);
14239
+ return await wrappedSend(content, payload);
14214
14240
  }
14215
14241
  catch (error) {
14216
14242
  if (error?.type === "rate-error") {
@@ -14220,9 +14246,9 @@ makeConnection.rate = beginContext((connector, clientId, swarmName, { delay = RA
14220
14246
  throw error;
14221
14247
  }
14222
14248
  };
14223
- });
14249
+ };
14224
14250
 
14225
- const METHOD_NAME$g = "function.target.complete";
14251
+ const METHOD_NAME$i = "function.target.complete";
14226
14252
  /**
14227
14253
  * Time-to-live for the complete function in milliseconds.
14228
14254
  * Defines how long the cached complete function remains valid before expiring.
@@ -14284,11 +14310,11 @@ const createGc$3 = functoolsKit.singleshot(async () => {
14284
14310
  * const result = await complete("Calculate 2 + 2", "client-123", "MathSwarm");
14285
14311
  * console.log(result); // Outputs "4"
14286
14312
  */
14287
- const complete = beginContext(async (content, clientId, swarmName) => {
14313
+ const complete = beginContext(async (content, clientId, swarmName, payload = null) => {
14288
14314
  const executionId = functoolsKit.randomString();
14289
14315
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
14290
14316
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
14291
- swarm$1.loggerService.log(METHOD_NAME$g, {
14317
+ swarm$1.loggerService.log(METHOD_NAME$i, {
14292
14318
  content,
14293
14319
  clientId,
14294
14320
  executionId,
@@ -14298,26 +14324,35 @@ const complete = beginContext(async (content, clientId, swarmName) => {
14298
14324
  const run = await createComplete(clientId, swarmName);
14299
14325
  createGc$3();
14300
14326
  // Execute the command within an execution context with performance tracking
14301
- return ExecutionContextService.runInContext(async () => {
14302
- let isFinished = false;
14303
- swarm$1.perfService.startExecution(executionId, clientId, content.length);
14304
- try {
14305
- swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
14306
- const result = await run(METHOD_NAME$g, content);
14307
- isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
14308
- swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
14309
- return result;
14310
- }
14311
- finally {
14312
- if (!isFinished) {
14313
- swarm$1.perfService.endExecution(executionId, clientId, 0);
14327
+ const handleRun = async () => {
14328
+ return await ExecutionContextService.runInContext(async () => {
14329
+ let isFinished = false;
14330
+ swarm$1.perfService.startExecution(executionId, clientId, content.length);
14331
+ try {
14332
+ swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
14333
+ const result = await run(METHOD_NAME$i, content);
14334
+ isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
14335
+ swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
14336
+ return result;
14314
14337
  }
14315
- }
14316
- }, {
14317
- clientId,
14318
- executionId,
14319
- processId: GLOBAL_CONFIG.CC_PROCESS_UUID,
14320
- });
14338
+ finally {
14339
+ if (!isFinished) {
14340
+ swarm$1.perfService.endExecution(executionId, clientId, 0);
14341
+ }
14342
+ }
14343
+ }, {
14344
+ clientId,
14345
+ executionId,
14346
+ processId: GLOBAL_CONFIG.CC_PROCESS_UUID,
14347
+ });
14348
+ };
14349
+ if (payload) {
14350
+ return await PayloadContextService.runInContext(handleRun, {
14351
+ clientId,
14352
+ payload,
14353
+ });
14354
+ }
14355
+ return await handleRun();
14321
14356
  });
14322
14357
 
14323
14358
  /**
@@ -14325,7 +14360,7 @@ const complete = beginContext(async (content, clientId, swarmName) => {
14325
14360
  * @constant {number}
14326
14361
  */
14327
14362
  const SCHEDULED_DELAY = 1000;
14328
- const METHOD_NAME$f = "function.target.session";
14363
+ const METHOD_NAME$h = "function.target.session";
14329
14364
  /**
14330
14365
  * Internal implementation of the session factory for a client and swarm.
14331
14366
  *
@@ -14336,26 +14371,26 @@ const METHOD_NAME$f = "function.target.session";
14336
14371
  * @param {SwarmName} swarmName - The name of the swarm to connect to.
14337
14372
  * @returns {Object} An object containing `complete` and `dispose` methods for session management.
14338
14373
  */
14339
- const sessionInternal = beginContext((clientId, swarmName) => {
14374
+ const sessionInternal = (clientId, swarmName) => {
14340
14375
  const executionId = functoolsKit.randomString();
14341
14376
  // Log the operation details if logging is enabled in GLOBAL_CONFIG
14342
14377
  GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
14343
- swarm$1.loggerService.log(METHOD_NAME$f, {
14378
+ swarm$1.loggerService.log(METHOD_NAME$h, {
14344
14379
  clientId,
14345
14380
  swarmName,
14346
14381
  executionId,
14347
14382
  });
14348
14383
  // Validate the swarm and initialize the session
14349
- swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$f);
14384
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$h);
14350
14385
  swarm$1.sessionValidationService.addSession(clientId, swarmName, "session");
14351
14386
  const complete = functoolsKit.queued(async (content) => {
14352
- swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$f);
14387
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$h);
14353
14388
  return ExecutionContextService.runInContext(async () => {
14354
14389
  let isFinished = false;
14355
14390
  swarm$1.perfService.startExecution(executionId, clientId, content.length);
14356
14391
  try {
14357
14392
  swarm$1.busService.commitExecutionBegin(clientId, { swarmName });
14358
- const result = await swarm$1.sessionPublicService.execute(content, "user", METHOD_NAME$f, clientId, swarmName);
14393
+ const result = await swarm$1.sessionPublicService.execute(content, "user", METHOD_NAME$h, clientId, swarmName);
14359
14394
  isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
14360
14395
  swarm$1.busService.commitExecutionEnd(clientId, { swarmName });
14361
14396
  return result;
@@ -14372,12 +14407,12 @@ const sessionInternal = beginContext((clientId, swarmName) => {
14372
14407
  });
14373
14408
  });
14374
14409
  return {
14375
- complete: beginContext(complete),
14376
- dispose: beginContext(async () => {
14377
- return await disposeConnection(clientId, swarmName, METHOD_NAME$f);
14410
+ complete: (async (content) => {
14411
+ return await complete(content);
14378
14412
  }),
14413
+ dispose: async () => await disposeConnection(clientId, swarmName, METHOD_NAME$h),
14379
14414
  };
14380
- });
14415
+ };
14381
14416
  /**
14382
14417
  * Creates a session for a client and swarm, providing methods to complete and dispose of it.
14383
14418
  *
@@ -14394,7 +14429,25 @@ const sessionInternal = beginContext((clientId, swarmName) => {
14394
14429
  * console.log(result); // Outputs the swarm's response
14395
14430
  * await dispose();
14396
14431
  */
14397
- const session = (clientId, swarmName) => sessionInternal(clientId, swarmName);
14432
+ const session = (clientId, swarmName) => {
14433
+ const { complete, dispose } = sessionInternal(clientId, swarmName);
14434
+ return {
14435
+ complete: beginContext(async (content, payload = null) => {
14436
+ if (payload) {
14437
+ return await PayloadContextService.runInContext(async () => {
14438
+ return await complete(content);
14439
+ }, {
14440
+ clientId,
14441
+ payload,
14442
+ });
14443
+ }
14444
+ return await complete(content);
14445
+ }),
14446
+ dispose: beginContext(async () => {
14447
+ await dispose();
14448
+ }),
14449
+ };
14450
+ };
14398
14451
  /**
14399
14452
  * Creates a scheduled session for a client and swarm, delaying content execution.
14400
14453
  *
@@ -14413,30 +14466,46 @@ const session = (clientId, swarmName) => sessionInternal(clientId, swarmName);
14413
14466
  * await dispose();
14414
14467
  */
14415
14468
  session.scheduled = (clientId, swarmName, { delay = SCHEDULED_DELAY } = {}) => {
14416
- const { complete, dispose } = session(clientId, swarmName);
14469
+ const { complete, dispose } = sessionInternal(clientId, swarmName);
14417
14470
  let isMounted = true;
14418
- const wrappedComplete = functoolsKit.schedule(beginContext(async (content) => {
14471
+ const wrappedComplete = functoolsKit.schedule(beginContext(async (content, payload) => {
14419
14472
  if (!isMounted) {
14420
14473
  return;
14421
14474
  }
14475
+ if (payload) {
14476
+ return await PayloadContextService.runInContext(async () => {
14477
+ return await complete(content);
14478
+ }, {
14479
+ clientId,
14480
+ payload,
14481
+ });
14482
+ }
14422
14483
  return await complete(content);
14423
14484
  }), {
14424
- onSchedule: beginContext(async ([content]) => {
14485
+ onSchedule: beginContext(async ([content, payload]) => {
14425
14486
  if (!isMounted) {
14426
14487
  return;
14427
14488
  }
14428
- await commitUserMessage(content, clientId, await getAgentName(clientId));
14489
+ if (payload) {
14490
+ return await PayloadContextService.runInContext(async () => {
14491
+ return await swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$h, clientId, swarmName);
14492
+ }, {
14493
+ clientId,
14494
+ payload,
14495
+ });
14496
+ }
14497
+ return await swarm$1.sessionPublicService.commitUserMessage(content, METHOD_NAME$h, clientId, swarmName);
14429
14498
  }),
14430
14499
  delay,
14431
14500
  });
14432
14501
  return {
14433
- async complete(content) {
14434
- return await wrappedComplete(content);
14502
+ complete: async (content, payload = null) => {
14503
+ return await wrappedComplete(content, payload);
14435
14504
  },
14436
- async dispose() {
14505
+ dispose: beginContext(async () => {
14437
14506
  isMounted = false;
14438
14507
  return await dispose();
14439
- },
14508
+ }),
14440
14509
  };
14441
14510
  };
14442
14511
  /**
@@ -14457,12 +14526,20 @@ session.scheduled = (clientId, swarmName, { delay = SCHEDULED_DELAY } = {}) => {
14457
14526
  * await dispose();
14458
14527
  */
14459
14528
  session.rate = (clientId, swarmName, { delay = SCHEDULED_DELAY } = {}) => {
14460
- const { complete, dispose } = session(clientId, swarmName);
14529
+ const { complete, dispose } = sessionInternal(clientId, swarmName);
14461
14530
  let isMounted = true;
14462
- const wrappedComplete = functoolsKit.rate(beginContext(async (content) => {
14531
+ const wrappedComplete = functoolsKit.rate(beginContext(async (content, payload) => {
14463
14532
  if (!isMounted) {
14464
14533
  return;
14465
14534
  }
14535
+ if (payload) {
14536
+ return await PayloadContextService.runInContext(async () => {
14537
+ return await complete(content);
14538
+ }, {
14539
+ clientId,
14540
+ payload,
14541
+ });
14542
+ }
14466
14543
  return await complete(content);
14467
14544
  }), {
14468
14545
  key: () => clientId,
@@ -14470,9 +14547,9 @@ session.rate = (clientId, swarmName, { delay = SCHEDULED_DELAY } = {}) => {
14470
14547
  delay,
14471
14548
  });
14472
14549
  return {
14473
- async complete(content) {
14550
+ async complete(content, payload = null) {
14474
14551
  try {
14475
- return await wrappedComplete(content);
14552
+ return await wrappedComplete(content, payload);
14476
14553
  }
14477
14554
  catch (error) {
14478
14555
  if (error?.type === "rate-error") {
@@ -14482,13 +14559,61 @@ session.rate = (clientId, swarmName, { delay = SCHEDULED_DELAY } = {}) => {
14482
14559
  throw error;
14483
14560
  }
14484
14561
  },
14485
- async dispose() {
14562
+ dispose: beginContext(async () => {
14486
14563
  isMounted = false;
14487
14564
  return await dispose();
14488
- },
14565
+ }),
14489
14566
  };
14490
14567
  };
14491
14568
 
14569
+ /** @private Constant defining the method name for logging purposes */
14570
+ const METHOD_NAME$g = "function.common.getPayload";
14571
+ /**
14572
+ * Retrieves the payload from the current PayloadContextService context.
14573
+ * Returns null if no context is available. Logs the operation if logging is enabled.
14574
+ * @template Payload - The type of the payload object, defaults to a generic object.
14575
+ * @returns A promise resolving to the payload data from the context, or null if no context exists.
14576
+ * @example
14577
+ * const payload = await getPayload<{ id: number }>();
14578
+ * console.log(payload); // { id: number } or {}
14579
+ */
14580
+ const getPayload = async () => {
14581
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG && swarm$1.loggerService.log(METHOD_NAME$g);
14582
+ const result = PayloadContextService.hasContext()
14583
+ ? swarm$1.payloadContextService.context
14584
+ : null;
14585
+ return result;
14586
+ };
14587
+
14588
+ const METHOD_NAME$f = "function.common.getAgentName";
14589
+ /**
14590
+ * Retrieves the name of the active agent for a given client session in a swarm.
14591
+ *
14592
+ * This function fetches the name of the currently active agent associated with the specified client session within a swarm.
14593
+ * It validates the client session and swarm, logs the operation if enabled, and delegates the retrieval to the swarm public service.
14594
+ * The execution is wrapped in `beginContext` to ensure it runs outside of existing method and execution contexts, providing a clean execution environment.
14595
+ *
14596
+ * @param {string} clientId - The unique identifier of the client session whose active agent name is being retrieved.
14597
+ * @returns {Promise<string>} A promise that resolves to the name of the active agent (`AgentName`) associated with the client session.
14598
+ * @throws {Error} If the client session is invalid, the swarm validation fails, or the swarm public service encounters an error during retrieval.
14599
+ * @example
14600
+ * const agentName = await getAgentName("client-123");
14601
+ * console.log(agentName); // Outputs "AgentX"
14602
+ */
14603
+ const getAgentName = beginContext(async (clientId) => {
14604
+ // Log the operation details if logging is enabled in GLOBAL_CONFIG
14605
+ GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
14606
+ swarm$1.loggerService.log(METHOD_NAME$f, {
14607
+ clientId,
14608
+ });
14609
+ // Validate the session and swarm to ensure they exist and are accessible
14610
+ swarm$1.sessionValidationService.validate(clientId, METHOD_NAME$f);
14611
+ const swarmName = swarm$1.sessionValidationService.getSwarm(clientId);
14612
+ swarm$1.swarmValidationService.validate(swarmName, METHOD_NAME$f);
14613
+ // Retrieve the active agent name via the swarm public service
14614
+ return await swarm$1.swarmPublicService.getAgentName(METHOD_NAME$f, clientId, swarmName);
14615
+ });
14616
+
14492
14617
  const METHOD_NAME$e = "function.common.getAgentHistory";
14493
14618
  /**
14494
14619
  * Retrieves the history prepared for a specific agent, incorporating rescue algorithm tweaks.
@@ -16832,6 +16957,7 @@ exports.getAssistantHistory = getAssistantHistory;
16832
16957
  exports.getLastAssistantMessage = getLastAssistantMessage;
16833
16958
  exports.getLastSystemMessage = getLastSystemMessage;
16834
16959
  exports.getLastUserMessage = getLastUserMessage;
16960
+ exports.getPayload = getPayload;
16835
16961
  exports.getRawHistory = getRawHistory;
16836
16962
  exports.getSessionContext = getSessionContext;
16837
16963
  exports.getSessionMode = getSessionMode;