@voltagent/core 0.1.78 → 0.1.79

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/dist/index.d.mts CHANGED
@@ -1906,6 +1906,23 @@ type ProviderOptions = {
1906
1906
  /**
1907
1907
  * Configuration for supervisor agents that have subagents
1908
1908
  */
1909
+ /**
1910
+ * Configuration for forwarding events from subagents to the parent agent's stream
1911
+ */
1912
+ type FullStreamEventForwardingConfig = {
1913
+ /**
1914
+ * Array of event types to forward from subagents
1915
+ * Uses StreamEventType which includes: 'text-delta', 'reasoning', 'source', 'tool-call', 'tool-result', 'finish', 'error'
1916
+ * @default ['tool-call', 'tool-result']
1917
+ * @example ['tool-call', 'tool-result', 'text-delta', 'reasoning', 'source']
1918
+ */
1919
+ types?: StreamEventType[];
1920
+ /**
1921
+ * Whether to add the subagent name as a prefix to tool names in forwarded events
1922
+ * @default true
1923
+ */
1924
+ addSubAgentPrefix?: boolean;
1925
+ };
1909
1926
  type SupervisorConfig = {
1910
1927
  /**
1911
1928
  * Complete custom system message for the supervisor agent
@@ -1922,6 +1939,12 @@ type SupervisorConfig = {
1922
1939
  * Additional custom guidelines for the supervisor agent
1923
1940
  */
1924
1941
  customGuidelines?: string[];
1942
+ /**
1943
+ * Configuration for forwarding events from subagents to the parent agent's full stream
1944
+ * Controls which event types are forwarded and how they are formatted
1945
+ * @default { types: ['tool-call', 'tool-result'], addSubAgentPrefix: true }
1946
+ */
1947
+ fullStreamEventForwarding?: FullStreamEventForwardingConfig;
1925
1948
  };
1926
1949
  /**
1927
1950
  * Agent configuration options
@@ -4494,13 +4517,18 @@ declare class SubAgentManager {
4494
4517
  * Can be either direct Agent instances or SubAgentConfigObject instances
4495
4518
  */
4496
4519
  private subAgentConfigs;
4520
+ /**
4521
+ * Supervisor configuration including event forwarding settings
4522
+ */
4523
+ private supervisorConfig?;
4497
4524
  /**
4498
4525
  * Creates a new SubAgentManager instance
4499
4526
  *
4500
4527
  * @param agentName - The name of the agent that owns this sub-agent manager
4501
4528
  * @param subAgents - Initial sub-agent configurations to add
4529
+ * @param supervisorConfig - Optional supervisor configuration including event forwarding
4502
4530
  */
4503
- constructor(agentName: string, subAgents?: SubAgentConfig[]);
4531
+ constructor(agentName: string, subAgents?: SubAgentConfig[], supervisorConfig?: SupervisorConfig);
4504
4532
  /**
4505
4533
  * Add a sub-agent that the parent agent can delegate tasks to
4506
4534
  */
package/dist/index.d.ts CHANGED
@@ -1906,6 +1906,23 @@ type ProviderOptions = {
1906
1906
  /**
1907
1907
  * Configuration for supervisor agents that have subagents
1908
1908
  */
1909
+ /**
1910
+ * Configuration for forwarding events from subagents to the parent agent's stream
1911
+ */
1912
+ type FullStreamEventForwardingConfig = {
1913
+ /**
1914
+ * Array of event types to forward from subagents
1915
+ * Uses StreamEventType which includes: 'text-delta', 'reasoning', 'source', 'tool-call', 'tool-result', 'finish', 'error'
1916
+ * @default ['tool-call', 'tool-result']
1917
+ * @example ['tool-call', 'tool-result', 'text-delta', 'reasoning', 'source']
1918
+ */
1919
+ types?: StreamEventType[];
1920
+ /**
1921
+ * Whether to add the subagent name as a prefix to tool names in forwarded events
1922
+ * @default true
1923
+ */
1924
+ addSubAgentPrefix?: boolean;
1925
+ };
1909
1926
  type SupervisorConfig = {
1910
1927
  /**
1911
1928
  * Complete custom system message for the supervisor agent
@@ -1922,6 +1939,12 @@ type SupervisorConfig = {
1922
1939
  * Additional custom guidelines for the supervisor agent
1923
1940
  */
1924
1941
  customGuidelines?: string[];
1942
+ /**
1943
+ * Configuration for forwarding events from subagents to the parent agent's full stream
1944
+ * Controls which event types are forwarded and how they are formatted
1945
+ * @default { types: ['tool-call', 'tool-result'], addSubAgentPrefix: true }
1946
+ */
1947
+ fullStreamEventForwarding?: FullStreamEventForwardingConfig;
1925
1948
  };
1926
1949
  /**
1927
1950
  * Agent configuration options
@@ -4494,13 +4517,18 @@ declare class SubAgentManager {
4494
4517
  * Can be either direct Agent instances or SubAgentConfigObject instances
4495
4518
  */
4496
4519
  private subAgentConfigs;
4520
+ /**
4521
+ * Supervisor configuration including event forwarding settings
4522
+ */
4523
+ private supervisorConfig?;
4497
4524
  /**
4498
4525
  * Creates a new SubAgentManager instance
4499
4526
  *
4500
4527
  * @param agentName - The name of the agent that owns this sub-agent manager
4501
4528
  * @param subAgents - Initial sub-agent configurations to add
4529
+ * @param supervisorConfig - Optional supervisor configuration including event forwarding
4502
4530
  */
4503
- constructor(agentName: string, subAgents?: SubAgentConfig[]);
4531
+ constructor(agentName: string, subAgents?: SubAgentConfig[], supervisorConfig?: SupervisorConfig);
4504
4532
  /**
4505
4533
  * Add a sub-agent that the parent agent can delegate tasks to
4506
4534
  */
package/dist/index.js CHANGED
@@ -11623,14 +11623,20 @@ var SubAgentManager = class {
11623
11623
  * Can be either direct Agent instances or SubAgentConfigObject instances
11624
11624
  */
11625
11625
  subAgentConfigs = [];
11626
+ /**
11627
+ * Supervisor configuration including event forwarding settings
11628
+ */
11629
+ supervisorConfig;
11626
11630
  /**
11627
11631
  * Creates a new SubAgentManager instance
11628
11632
  *
11629
11633
  * @param agentName - The name of the agent that owns this sub-agent manager
11630
11634
  * @param subAgents - Initial sub-agent configurations to add
11635
+ * @param supervisorConfig - Optional supervisor configuration including event forwarding
11631
11636
  */
11632
- constructor(agentName, subAgents = []) {
11637
+ constructor(agentName, subAgents = [], supervisorConfig) {
11633
11638
  this.agentName = agentName;
11639
+ this.supervisorConfig = supervisorConfig;
11634
11640
  this.subAgentConfigs = [];
11635
11641
  subAgents.forEach((agentConfig) => this.addSubAgent(agentConfig));
11636
11642
  }
@@ -11886,7 +11892,15 @@ Context: ${(0, import_utils18.safeStringify)(context, { indentation: 2 })}`;
11886
11892
  callOptions
11887
11893
  );
11888
11894
  finalResult = "";
11889
- if (streamResponse.fullStream) {
11895
+ if (streamResponse.fullStream && forwardEvent) {
11896
+ const eventForwardingConfig = {
11897
+ forwarder: forwardEvent,
11898
+ types: this.supervisorConfig?.fullStreamEventForwarding?.types || [
11899
+ "tool-call",
11900
+ "tool-result"
11901
+ ],
11902
+ addSubAgentPrefix: this.supervisorConfig?.fullStreamEventForwarding?.addSubAgentPrefix ?? true
11903
+ };
11890
11904
  for await (const part of streamResponse.fullStream) {
11891
11905
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
11892
11906
  switch (part.type) {
@@ -11901,9 +11915,7 @@ Context: ${(0, import_utils18.safeStringify)(context, { indentation: 2 })}`;
11901
11915
  subAgentId: targetAgent.id,
11902
11916
  subAgentName: targetAgent.name
11903
11917
  };
11904
- if (forwardEvent) {
11905
- await forwardEvent(eventData);
11906
- }
11918
+ await streamEventForwarder(eventData, eventForwardingConfig);
11907
11919
  break;
11908
11920
  }
11909
11921
  case "reasoning": {
@@ -11916,9 +11928,7 @@ Context: ${(0, import_utils18.safeStringify)(context, { indentation: 2 })}`;
11916
11928
  subAgentId: targetAgent.id,
11917
11929
  subAgentName: targetAgent.name
11918
11930
  };
11919
- if (forwardEvent) {
11920
- await forwardEvent(eventData);
11921
- }
11931
+ await streamEventForwarder(eventData, eventForwardingConfig);
11922
11932
  break;
11923
11933
  }
11924
11934
  case "source": {
@@ -11931,9 +11941,7 @@ Context: ${(0, import_utils18.safeStringify)(context, { indentation: 2 })}`;
11931
11941
  subAgentId: targetAgent.id,
11932
11942
  subAgentName: targetAgent.name
11933
11943
  };
11934
- if (forwardEvent) {
11935
- await forwardEvent(eventData);
11936
- }
11944
+ await streamEventForwarder(eventData, eventForwardingConfig);
11937
11945
  break;
11938
11946
  }
11939
11947
  case "tool-call": {
@@ -11948,9 +11956,7 @@ Context: ${(0, import_utils18.safeStringify)(context, { indentation: 2 })}`;
11948
11956
  subAgentId: targetAgent.id,
11949
11957
  subAgentName: targetAgent.name
11950
11958
  };
11951
- if (forwardEvent) {
11952
- await forwardEvent(eventData);
11953
- }
11959
+ await streamEventForwarder(eventData, eventForwardingConfig);
11954
11960
  break;
11955
11961
  }
11956
11962
  case "tool-result": {
@@ -11965,9 +11971,7 @@ Context: ${(0, import_utils18.safeStringify)(context, { indentation: 2 })}`;
11965
11971
  subAgentId: targetAgent.id,
11966
11972
  subAgentName: targetAgent.name
11967
11973
  };
11968
- if (forwardEvent) {
11969
- await forwardEvent(eventData);
11970
- }
11974
+ await streamEventForwarder(eventData, eventForwardingConfig);
11971
11975
  break;
11972
11976
  }
11973
11977
  case "error": {
@@ -11982,9 +11986,7 @@ Context: ${(0, import_utils18.safeStringify)(context, { indentation: 2 })}`;
11982
11986
  subAgentId: targetAgent.id,
11983
11987
  subAgentName: targetAgent.name
11984
11988
  };
11985
- if (forwardEvent) {
11986
- await forwardEvent(eventData);
11987
- }
11989
+ await streamEventForwarder(eventData, eventForwardingConfig);
11988
11990
  break;
11989
11991
  }
11990
11992
  }
@@ -12345,7 +12347,11 @@ var Agent = class {
12345
12347
  );
12346
12348
  const staticTools = typeof options.tools === "function" ? [] : options.tools || [];
12347
12349
  this.toolManager = new ToolManager(staticTools, this.logger);
12348
- this.subAgentManager = new SubAgentManager(this.name, options.subAgents || []);
12350
+ this.subAgentManager = new SubAgentManager(
12351
+ this.name,
12352
+ options.subAgents || [],
12353
+ this.supervisorConfig
12354
+ );
12349
12355
  let chosenExporter;
12350
12356
  if (options.voltOpsClient) {
12351
12357
  if (options.voltOpsClient.observability) {
@@ -12799,8 +12805,11 @@ ${retrieverContext}`;
12799
12805
  if (internalStreamForwarder) {
12800
12806
  await streamEventForwarder(event, {
12801
12807
  forwarder: internalStreamForwarder,
12802
- types: ["tool-call", "tool-result"],
12803
- addSubAgentPrefix: true
12808
+ types: this.supervisorConfig?.fullStreamEventForwarding?.types || [
12809
+ "tool-call",
12810
+ "tool-result"
12811
+ ],
12812
+ addSubAgentPrefix: this.supervisorConfig?.fullStreamEventForwarding?.addSubAgentPrefix ?? true
12804
12813
  });
12805
12814
  }
12806
12815
  }, "forwardEvent");