@voltagent/core 0.1.78 → 0.1.80
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 +143 -2
- package/dist/index.d.ts +143 -2
- package/dist/index.js +766 -506
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +766 -506
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -269,6 +269,11 @@ interface WorkflowExecuteContext<INPUT, DATA, SUSPEND_DATA, RESUME_DATA> {
|
|
|
269
269
|
* Provides execution-scoped logging with full context (userId, conversationId, executionId).
|
|
270
270
|
*/
|
|
271
271
|
logger: Logger;
|
|
272
|
+
/**
|
|
273
|
+
* Stream writer for emitting events during streaming execution.
|
|
274
|
+
* Always available for writing custom events.
|
|
275
|
+
*/
|
|
276
|
+
writer: WorkflowStreamWriter;
|
|
272
277
|
}
|
|
273
278
|
/**
|
|
274
279
|
* A function that can be executed by the workflow
|
|
@@ -371,6 +376,8 @@ type WorkflowState<INPUT, RESULT> = {
|
|
|
371
376
|
error: Error | null;
|
|
372
377
|
/** suspension metadata when workflow is suspended */
|
|
373
378
|
suspension?: WorkflowSuspensionMetadata;
|
|
379
|
+
/** accumulated usage from andAgent calls */
|
|
380
|
+
usage: UsageInfo;
|
|
374
381
|
};
|
|
375
382
|
|
|
376
383
|
interface WorkflowSuspensionMetadata<SUSPEND_DATA = DangerouslyAllowAny> {
|
|
@@ -441,6 +448,10 @@ interface WorkflowExecutionResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCH
|
|
|
441
448
|
* The result data if workflow completed successfully
|
|
442
449
|
*/
|
|
443
450
|
result: z.infer<RESULT_SCHEMA> | null;
|
|
451
|
+
/**
|
|
452
|
+
* Stream of workflow events for real-time monitoring
|
|
453
|
+
*/
|
|
454
|
+
stream: AsyncIterableIterator<WorkflowStreamEvent>;
|
|
444
455
|
/**
|
|
445
456
|
* Suspension metadata if workflow was suspended
|
|
446
457
|
*/
|
|
@@ -449,6 +460,10 @@ interface WorkflowExecutionResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCH
|
|
|
449
460
|
* Error information if workflow failed
|
|
450
461
|
*/
|
|
451
462
|
error?: unknown;
|
|
463
|
+
/**
|
|
464
|
+
* Total token usage from all andAgent steps in the workflow
|
|
465
|
+
*/
|
|
466
|
+
usage: UsageInfo;
|
|
452
467
|
/**
|
|
453
468
|
* Resume a suspended workflow execution
|
|
454
469
|
* @param input - Optional new input data for resuming (validated against resumeSchema if provided)
|
|
@@ -650,7 +665,8 @@ type Workflow<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema, RESULT_SCHEM
|
|
|
650
665
|
/**
|
|
651
666
|
* Execute the workflow with the given input
|
|
652
667
|
* @param input - The input to the workflow
|
|
653
|
-
* @
|
|
668
|
+
* @param options - Options for the workflow execution
|
|
669
|
+
* @returns Execution result with stream and final result
|
|
654
670
|
*/
|
|
655
671
|
run: (input: WorkflowInput<INPUT_SCHEMA>, options?: WorkflowRunOptions) => Promise<WorkflowExecutionResult<RESULT_SCHEMA, RESUME_SCHEMA>>;
|
|
656
672
|
/**
|
|
@@ -744,6 +760,80 @@ interface WorkflowStats {
|
|
|
744
760
|
averageExecutionTime: number;
|
|
745
761
|
lastExecutionTime?: Date;
|
|
746
762
|
}
|
|
763
|
+
/**
|
|
764
|
+
* Event emitted during workflow streaming
|
|
765
|
+
*/
|
|
766
|
+
interface WorkflowStreamEvent {
|
|
767
|
+
/**
|
|
768
|
+
* Type of the event (e.g., "step-start", "step-complete", "custom", "agent-stream")
|
|
769
|
+
*/
|
|
770
|
+
type: string;
|
|
771
|
+
/**
|
|
772
|
+
* Unique execution ID for this workflow run
|
|
773
|
+
*/
|
|
774
|
+
executionId: string;
|
|
775
|
+
/**
|
|
776
|
+
* Source of the event (step ID or name)
|
|
777
|
+
*/
|
|
778
|
+
from: string;
|
|
779
|
+
/**
|
|
780
|
+
* Input data for the step/event
|
|
781
|
+
*/
|
|
782
|
+
input?: Record<string, DangerouslyAllowAny>;
|
|
783
|
+
/**
|
|
784
|
+
* Output data from the step/event
|
|
785
|
+
*/
|
|
786
|
+
output?: Record<string, DangerouslyAllowAny>;
|
|
787
|
+
/**
|
|
788
|
+
* Current status of the step/event
|
|
789
|
+
*/
|
|
790
|
+
status: "pending" | "running" | "success" | "error" | "suspended";
|
|
791
|
+
/**
|
|
792
|
+
* User context passed through the workflow
|
|
793
|
+
*/
|
|
794
|
+
userContext?: UserContext;
|
|
795
|
+
/**
|
|
796
|
+
* Timestamp of the event
|
|
797
|
+
*/
|
|
798
|
+
timestamp: string;
|
|
799
|
+
/**
|
|
800
|
+
* Current step index in the workflow
|
|
801
|
+
*/
|
|
802
|
+
stepIndex?: number;
|
|
803
|
+
/**
|
|
804
|
+
* Step type for step events
|
|
805
|
+
*/
|
|
806
|
+
stepType?: "agent" | "func" | "conditional-when" | "parallel-all" | "parallel-race" | "tap" | "workflow";
|
|
807
|
+
/**
|
|
808
|
+
* Additional metadata
|
|
809
|
+
*/
|
|
810
|
+
metadata?: Record<string, DangerouslyAllowAny>;
|
|
811
|
+
/**
|
|
812
|
+
* Error information if status is "error"
|
|
813
|
+
*/
|
|
814
|
+
error?: DangerouslyAllowAny;
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Writer interface for emitting stream events from workflow steps
|
|
818
|
+
*/
|
|
819
|
+
interface WorkflowStreamWriter {
|
|
820
|
+
/**
|
|
821
|
+
* Write a custom event to the stream
|
|
822
|
+
*/
|
|
823
|
+
write(event: Partial<WorkflowStreamEvent> & {
|
|
824
|
+
type: string;
|
|
825
|
+
}): void;
|
|
826
|
+
/**
|
|
827
|
+
* Pipe events from an agent's fullStream to the workflow stream
|
|
828
|
+
* @param fullStream - The agent's fullStream async iterable
|
|
829
|
+
* @param options - Optional configuration for piping
|
|
830
|
+
*/
|
|
831
|
+
pipeFrom(fullStream: AsyncIterable<DangerouslyAllowAny>, options?: {
|
|
832
|
+
prefix?: string;
|
|
833
|
+
agentId?: string;
|
|
834
|
+
filter?: (part: DangerouslyAllowAny) => boolean;
|
|
835
|
+
}): Promise<void>;
|
|
836
|
+
}
|
|
747
837
|
/**
|
|
748
838
|
* Options for creating workflow execution
|
|
749
839
|
*/
|
|
@@ -842,6 +932,11 @@ interface WorkflowExecutionContext {
|
|
|
842
932
|
* Provides execution-scoped logging with full context (userId, conversationId, executionId)
|
|
843
933
|
*/
|
|
844
934
|
logger: Logger;
|
|
935
|
+
/**
|
|
936
|
+
* Stream writer for emitting events during streaming execution
|
|
937
|
+
* Always available for writing custom events
|
|
938
|
+
*/
|
|
939
|
+
streamWriter: WorkflowStreamWriter;
|
|
845
940
|
}
|
|
846
941
|
/**
|
|
847
942
|
* Workflow step context for individual step tracking
|
|
@@ -1906,6 +2001,23 @@ type ProviderOptions = {
|
|
|
1906
2001
|
/**
|
|
1907
2002
|
* Configuration for supervisor agents that have subagents
|
|
1908
2003
|
*/
|
|
2004
|
+
/**
|
|
2005
|
+
* Configuration for forwarding events from subagents to the parent agent's stream
|
|
2006
|
+
*/
|
|
2007
|
+
type FullStreamEventForwardingConfig = {
|
|
2008
|
+
/**
|
|
2009
|
+
* Array of event types to forward from subagents
|
|
2010
|
+
* Uses StreamEventType which includes: 'text-delta', 'reasoning', 'source', 'tool-call', 'tool-result', 'finish', 'error'
|
|
2011
|
+
* @default ['tool-call', 'tool-result']
|
|
2012
|
+
* @example ['tool-call', 'tool-result', 'text-delta', 'reasoning', 'source']
|
|
2013
|
+
*/
|
|
2014
|
+
types?: StreamEventType[];
|
|
2015
|
+
/**
|
|
2016
|
+
* Whether to add the subagent name as a prefix to tool names in forwarded events
|
|
2017
|
+
* @default true
|
|
2018
|
+
*/
|
|
2019
|
+
addSubAgentPrefix?: boolean;
|
|
2020
|
+
};
|
|
1909
2021
|
type SupervisorConfig = {
|
|
1910
2022
|
/**
|
|
1911
2023
|
* Complete custom system message for the supervisor agent
|
|
@@ -1922,6 +2034,12 @@ type SupervisorConfig = {
|
|
|
1922
2034
|
* Additional custom guidelines for the supervisor agent
|
|
1923
2035
|
*/
|
|
1924
2036
|
customGuidelines?: string[];
|
|
2037
|
+
/**
|
|
2038
|
+
* Configuration for forwarding events from subagents to the parent agent's full stream
|
|
2039
|
+
* Controls which event types are forwarded and how they are formatted
|
|
2040
|
+
* @default { types: ['tool-call', 'tool-result'], addSubAgentPrefix: true }
|
|
2041
|
+
*/
|
|
2042
|
+
fullStreamEventForwarding?: FullStreamEventForwardingConfig;
|
|
1925
2043
|
};
|
|
1926
2044
|
/**
|
|
1927
2045
|
* Agent configuration options
|
|
@@ -4494,13 +4612,18 @@ declare class SubAgentManager {
|
|
|
4494
4612
|
* Can be either direct Agent instances or SubAgentConfigObject instances
|
|
4495
4613
|
*/
|
|
4496
4614
|
private subAgentConfigs;
|
|
4615
|
+
/**
|
|
4616
|
+
* Supervisor configuration including event forwarding settings
|
|
4617
|
+
*/
|
|
4618
|
+
private supervisorConfig?;
|
|
4497
4619
|
/**
|
|
4498
4620
|
* Creates a new SubAgentManager instance
|
|
4499
4621
|
*
|
|
4500
4622
|
* @param agentName - The name of the agent that owns this sub-agent manager
|
|
4501
4623
|
* @param subAgents - Initial sub-agent configurations to add
|
|
4624
|
+
* @param supervisorConfig - Optional supervisor configuration including event forwarding
|
|
4502
4625
|
*/
|
|
4503
|
-
constructor(agentName: string, subAgents?: SubAgentConfig[]);
|
|
4626
|
+
constructor(agentName: string, subAgents?: SubAgentConfig[], supervisorConfig?: SupervisorConfig);
|
|
4504
4627
|
/**
|
|
4505
4628
|
* Add a sub-agent that the parent agent can delegate tasks to
|
|
4506
4629
|
*/
|
|
@@ -5436,6 +5559,8 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5436
5559
|
} | undefined;
|
|
5437
5560
|
suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
|
|
5438
5561
|
resumeData?: RS extends z.ZodTypeAny ? z.infer<RS> : z.infer<RESUME_SCHEMA>;
|
|
5562
|
+
logger: Logger;
|
|
5563
|
+
writer: WorkflowStreamWriter;
|
|
5439
5564
|
}) => Promise<z.infer<OS>>;
|
|
5440
5565
|
id: string;
|
|
5441
5566
|
name?: string;
|
|
@@ -5460,6 +5585,8 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5460
5585
|
} | undefined;
|
|
5461
5586
|
suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
|
|
5462
5587
|
resumeData?: RS extends z.ZodTypeAny ? z.infer<RS> : z.infer<RESUME_SCHEMA>;
|
|
5588
|
+
logger: Logger;
|
|
5589
|
+
writer: WorkflowStreamWriter;
|
|
5463
5590
|
}) => Promise<NEW_DATA>;
|
|
5464
5591
|
id: string;
|
|
5465
5592
|
name?: string;
|
|
@@ -5484,6 +5611,8 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5484
5611
|
} | undefined;
|
|
5485
5612
|
suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
|
|
5486
5613
|
resumeData?: RS extends z.ZodTypeAny ? z.infer<RS> : z.infer<RESUME_SCHEMA>;
|
|
5614
|
+
logger: Logger;
|
|
5615
|
+
writer: WorkflowStreamWriter;
|
|
5487
5616
|
}) => Promise<z.infer<OS>>;
|
|
5488
5617
|
id: string;
|
|
5489
5618
|
name?: string;
|
|
@@ -5508,6 +5637,8 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5508
5637
|
} | undefined;
|
|
5509
5638
|
suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
|
|
5510
5639
|
resumeData?: z.infer<RS>;
|
|
5640
|
+
logger: Logger;
|
|
5641
|
+
writer: WorkflowStreamWriter;
|
|
5511
5642
|
}) => Promise<NEW_DATA>;
|
|
5512
5643
|
id: string;
|
|
5513
5644
|
name?: string;
|
|
@@ -5548,6 +5679,8 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5548
5679
|
} | undefined;
|
|
5549
5680
|
suspend: (reason?: string, suspendData?: z.infer<SUSPEND_SCHEMA>) => Promise<never>;
|
|
5550
5681
|
resumeData?: z.infer<RESUME_SCHEMA>;
|
|
5682
|
+
logger: Logger;
|
|
5683
|
+
writer: WorkflowStreamWriter;
|
|
5551
5684
|
}) => Promise<NEW_DATA>;
|
|
5552
5685
|
id: string;
|
|
5553
5686
|
name?: string;
|
|
@@ -5576,6 +5709,8 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5576
5709
|
} | undefined;
|
|
5577
5710
|
suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
|
|
5578
5711
|
resumeData?: RS extends z.ZodTypeAny ? z.infer<RS> : z.infer<RESUME_SCHEMA>;
|
|
5712
|
+
logger: Logger;
|
|
5713
|
+
writer: WorkflowStreamWriter;
|
|
5579
5714
|
}) => Promise<boolean>;
|
|
5580
5715
|
}): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, z.infer<OS> | z.infer<IS>, SUSPEND_SCHEMA, RESUME_SCHEMA>;
|
|
5581
5716
|
/**
|
|
@@ -5635,6 +5770,8 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5635
5770
|
} | undefined;
|
|
5636
5771
|
suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
|
|
5637
5772
|
resumeData?: RS extends z.ZodTypeAny ? z.infer<RS> : z.infer<RESUME_SCHEMA>;
|
|
5773
|
+
logger: Logger;
|
|
5774
|
+
writer: WorkflowStreamWriter;
|
|
5638
5775
|
}) => Promise<void>;
|
|
5639
5776
|
id: string;
|
|
5640
5777
|
name?: string;
|
|
@@ -5674,6 +5811,8 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5674
5811
|
} | undefined;
|
|
5675
5812
|
suspend: (reason?: string, suspendData?: z.infer<SUSPEND_SCHEMA>) => Promise<never>;
|
|
5676
5813
|
resumeData?: z.infer<RESUME_SCHEMA>;
|
|
5814
|
+
logger: Logger;
|
|
5815
|
+
writer: WorkflowStreamWriter;
|
|
5677
5816
|
}) => Promise<void>;
|
|
5678
5817
|
id: string;
|
|
5679
5818
|
name?: string;
|
|
@@ -6102,6 +6241,8 @@ declare class WorkflowRegistry extends EventEmitter {
|
|
|
6102
6241
|
endAt: Date;
|
|
6103
6242
|
status: "completed" | "suspended" | "error";
|
|
6104
6243
|
result: any;
|
|
6244
|
+
stream: AsyncIterableIterator<WorkflowStreamEvent>;
|
|
6245
|
+
usage: UsageInfo;
|
|
6105
6246
|
suspension?: any;
|
|
6106
6247
|
error?: unknown;
|
|
6107
6248
|
} | null>;
|
package/dist/index.d.ts
CHANGED
|
@@ -269,6 +269,11 @@ interface WorkflowExecuteContext<INPUT, DATA, SUSPEND_DATA, RESUME_DATA> {
|
|
|
269
269
|
* Provides execution-scoped logging with full context (userId, conversationId, executionId).
|
|
270
270
|
*/
|
|
271
271
|
logger: Logger;
|
|
272
|
+
/**
|
|
273
|
+
* Stream writer for emitting events during streaming execution.
|
|
274
|
+
* Always available for writing custom events.
|
|
275
|
+
*/
|
|
276
|
+
writer: WorkflowStreamWriter;
|
|
272
277
|
}
|
|
273
278
|
/**
|
|
274
279
|
* A function that can be executed by the workflow
|
|
@@ -371,6 +376,8 @@ type WorkflowState<INPUT, RESULT> = {
|
|
|
371
376
|
error: Error | null;
|
|
372
377
|
/** suspension metadata when workflow is suspended */
|
|
373
378
|
suspension?: WorkflowSuspensionMetadata;
|
|
379
|
+
/** accumulated usage from andAgent calls */
|
|
380
|
+
usage: UsageInfo;
|
|
374
381
|
};
|
|
375
382
|
|
|
376
383
|
interface WorkflowSuspensionMetadata<SUSPEND_DATA = DangerouslyAllowAny> {
|
|
@@ -441,6 +448,10 @@ interface WorkflowExecutionResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCH
|
|
|
441
448
|
* The result data if workflow completed successfully
|
|
442
449
|
*/
|
|
443
450
|
result: z.infer<RESULT_SCHEMA> | null;
|
|
451
|
+
/**
|
|
452
|
+
* Stream of workflow events for real-time monitoring
|
|
453
|
+
*/
|
|
454
|
+
stream: AsyncIterableIterator<WorkflowStreamEvent>;
|
|
444
455
|
/**
|
|
445
456
|
* Suspension metadata if workflow was suspended
|
|
446
457
|
*/
|
|
@@ -449,6 +460,10 @@ interface WorkflowExecutionResult<RESULT_SCHEMA extends z.ZodTypeAny, RESUME_SCH
|
|
|
449
460
|
* Error information if workflow failed
|
|
450
461
|
*/
|
|
451
462
|
error?: unknown;
|
|
463
|
+
/**
|
|
464
|
+
* Total token usage from all andAgent steps in the workflow
|
|
465
|
+
*/
|
|
466
|
+
usage: UsageInfo;
|
|
452
467
|
/**
|
|
453
468
|
* Resume a suspended workflow execution
|
|
454
469
|
* @param input - Optional new input data for resuming (validated against resumeSchema if provided)
|
|
@@ -650,7 +665,8 @@ type Workflow<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema, RESULT_SCHEM
|
|
|
650
665
|
/**
|
|
651
666
|
* Execute the workflow with the given input
|
|
652
667
|
* @param input - The input to the workflow
|
|
653
|
-
* @
|
|
668
|
+
* @param options - Options for the workflow execution
|
|
669
|
+
* @returns Execution result with stream and final result
|
|
654
670
|
*/
|
|
655
671
|
run: (input: WorkflowInput<INPUT_SCHEMA>, options?: WorkflowRunOptions) => Promise<WorkflowExecutionResult<RESULT_SCHEMA, RESUME_SCHEMA>>;
|
|
656
672
|
/**
|
|
@@ -744,6 +760,80 @@ interface WorkflowStats {
|
|
|
744
760
|
averageExecutionTime: number;
|
|
745
761
|
lastExecutionTime?: Date;
|
|
746
762
|
}
|
|
763
|
+
/**
|
|
764
|
+
* Event emitted during workflow streaming
|
|
765
|
+
*/
|
|
766
|
+
interface WorkflowStreamEvent {
|
|
767
|
+
/**
|
|
768
|
+
* Type of the event (e.g., "step-start", "step-complete", "custom", "agent-stream")
|
|
769
|
+
*/
|
|
770
|
+
type: string;
|
|
771
|
+
/**
|
|
772
|
+
* Unique execution ID for this workflow run
|
|
773
|
+
*/
|
|
774
|
+
executionId: string;
|
|
775
|
+
/**
|
|
776
|
+
* Source of the event (step ID or name)
|
|
777
|
+
*/
|
|
778
|
+
from: string;
|
|
779
|
+
/**
|
|
780
|
+
* Input data for the step/event
|
|
781
|
+
*/
|
|
782
|
+
input?: Record<string, DangerouslyAllowAny>;
|
|
783
|
+
/**
|
|
784
|
+
* Output data from the step/event
|
|
785
|
+
*/
|
|
786
|
+
output?: Record<string, DangerouslyAllowAny>;
|
|
787
|
+
/**
|
|
788
|
+
* Current status of the step/event
|
|
789
|
+
*/
|
|
790
|
+
status: "pending" | "running" | "success" | "error" | "suspended";
|
|
791
|
+
/**
|
|
792
|
+
* User context passed through the workflow
|
|
793
|
+
*/
|
|
794
|
+
userContext?: UserContext;
|
|
795
|
+
/**
|
|
796
|
+
* Timestamp of the event
|
|
797
|
+
*/
|
|
798
|
+
timestamp: string;
|
|
799
|
+
/**
|
|
800
|
+
* Current step index in the workflow
|
|
801
|
+
*/
|
|
802
|
+
stepIndex?: number;
|
|
803
|
+
/**
|
|
804
|
+
* Step type for step events
|
|
805
|
+
*/
|
|
806
|
+
stepType?: "agent" | "func" | "conditional-when" | "parallel-all" | "parallel-race" | "tap" | "workflow";
|
|
807
|
+
/**
|
|
808
|
+
* Additional metadata
|
|
809
|
+
*/
|
|
810
|
+
metadata?: Record<string, DangerouslyAllowAny>;
|
|
811
|
+
/**
|
|
812
|
+
* Error information if status is "error"
|
|
813
|
+
*/
|
|
814
|
+
error?: DangerouslyAllowAny;
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Writer interface for emitting stream events from workflow steps
|
|
818
|
+
*/
|
|
819
|
+
interface WorkflowStreamWriter {
|
|
820
|
+
/**
|
|
821
|
+
* Write a custom event to the stream
|
|
822
|
+
*/
|
|
823
|
+
write(event: Partial<WorkflowStreamEvent> & {
|
|
824
|
+
type: string;
|
|
825
|
+
}): void;
|
|
826
|
+
/**
|
|
827
|
+
* Pipe events from an agent's fullStream to the workflow stream
|
|
828
|
+
* @param fullStream - The agent's fullStream async iterable
|
|
829
|
+
* @param options - Optional configuration for piping
|
|
830
|
+
*/
|
|
831
|
+
pipeFrom(fullStream: AsyncIterable<DangerouslyAllowAny>, options?: {
|
|
832
|
+
prefix?: string;
|
|
833
|
+
agentId?: string;
|
|
834
|
+
filter?: (part: DangerouslyAllowAny) => boolean;
|
|
835
|
+
}): Promise<void>;
|
|
836
|
+
}
|
|
747
837
|
/**
|
|
748
838
|
* Options for creating workflow execution
|
|
749
839
|
*/
|
|
@@ -842,6 +932,11 @@ interface WorkflowExecutionContext {
|
|
|
842
932
|
* Provides execution-scoped logging with full context (userId, conversationId, executionId)
|
|
843
933
|
*/
|
|
844
934
|
logger: Logger;
|
|
935
|
+
/**
|
|
936
|
+
* Stream writer for emitting events during streaming execution
|
|
937
|
+
* Always available for writing custom events
|
|
938
|
+
*/
|
|
939
|
+
streamWriter: WorkflowStreamWriter;
|
|
845
940
|
}
|
|
846
941
|
/**
|
|
847
942
|
* Workflow step context for individual step tracking
|
|
@@ -1906,6 +2001,23 @@ type ProviderOptions = {
|
|
|
1906
2001
|
/**
|
|
1907
2002
|
* Configuration for supervisor agents that have subagents
|
|
1908
2003
|
*/
|
|
2004
|
+
/**
|
|
2005
|
+
* Configuration for forwarding events from subagents to the parent agent's stream
|
|
2006
|
+
*/
|
|
2007
|
+
type FullStreamEventForwardingConfig = {
|
|
2008
|
+
/**
|
|
2009
|
+
* Array of event types to forward from subagents
|
|
2010
|
+
* Uses StreamEventType which includes: 'text-delta', 'reasoning', 'source', 'tool-call', 'tool-result', 'finish', 'error'
|
|
2011
|
+
* @default ['tool-call', 'tool-result']
|
|
2012
|
+
* @example ['tool-call', 'tool-result', 'text-delta', 'reasoning', 'source']
|
|
2013
|
+
*/
|
|
2014
|
+
types?: StreamEventType[];
|
|
2015
|
+
/**
|
|
2016
|
+
* Whether to add the subagent name as a prefix to tool names in forwarded events
|
|
2017
|
+
* @default true
|
|
2018
|
+
*/
|
|
2019
|
+
addSubAgentPrefix?: boolean;
|
|
2020
|
+
};
|
|
1909
2021
|
type SupervisorConfig = {
|
|
1910
2022
|
/**
|
|
1911
2023
|
* Complete custom system message for the supervisor agent
|
|
@@ -1922,6 +2034,12 @@ type SupervisorConfig = {
|
|
|
1922
2034
|
* Additional custom guidelines for the supervisor agent
|
|
1923
2035
|
*/
|
|
1924
2036
|
customGuidelines?: string[];
|
|
2037
|
+
/**
|
|
2038
|
+
* Configuration for forwarding events from subagents to the parent agent's full stream
|
|
2039
|
+
* Controls which event types are forwarded and how they are formatted
|
|
2040
|
+
* @default { types: ['tool-call', 'tool-result'], addSubAgentPrefix: true }
|
|
2041
|
+
*/
|
|
2042
|
+
fullStreamEventForwarding?: FullStreamEventForwardingConfig;
|
|
1925
2043
|
};
|
|
1926
2044
|
/**
|
|
1927
2045
|
* Agent configuration options
|
|
@@ -4494,13 +4612,18 @@ declare class SubAgentManager {
|
|
|
4494
4612
|
* Can be either direct Agent instances or SubAgentConfigObject instances
|
|
4495
4613
|
*/
|
|
4496
4614
|
private subAgentConfigs;
|
|
4615
|
+
/**
|
|
4616
|
+
* Supervisor configuration including event forwarding settings
|
|
4617
|
+
*/
|
|
4618
|
+
private supervisorConfig?;
|
|
4497
4619
|
/**
|
|
4498
4620
|
* Creates a new SubAgentManager instance
|
|
4499
4621
|
*
|
|
4500
4622
|
* @param agentName - The name of the agent that owns this sub-agent manager
|
|
4501
4623
|
* @param subAgents - Initial sub-agent configurations to add
|
|
4624
|
+
* @param supervisorConfig - Optional supervisor configuration including event forwarding
|
|
4502
4625
|
*/
|
|
4503
|
-
constructor(agentName: string, subAgents?: SubAgentConfig[]);
|
|
4626
|
+
constructor(agentName: string, subAgents?: SubAgentConfig[], supervisorConfig?: SupervisorConfig);
|
|
4504
4627
|
/**
|
|
4505
4628
|
* Add a sub-agent that the parent agent can delegate tasks to
|
|
4506
4629
|
*/
|
|
@@ -5436,6 +5559,8 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5436
5559
|
} | undefined;
|
|
5437
5560
|
suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
|
|
5438
5561
|
resumeData?: RS extends z.ZodTypeAny ? z.infer<RS> : z.infer<RESUME_SCHEMA>;
|
|
5562
|
+
logger: Logger;
|
|
5563
|
+
writer: WorkflowStreamWriter;
|
|
5439
5564
|
}) => Promise<z.infer<OS>>;
|
|
5440
5565
|
id: string;
|
|
5441
5566
|
name?: string;
|
|
@@ -5460,6 +5585,8 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5460
5585
|
} | undefined;
|
|
5461
5586
|
suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
|
|
5462
5587
|
resumeData?: RS extends z.ZodTypeAny ? z.infer<RS> : z.infer<RESUME_SCHEMA>;
|
|
5588
|
+
logger: Logger;
|
|
5589
|
+
writer: WorkflowStreamWriter;
|
|
5463
5590
|
}) => Promise<NEW_DATA>;
|
|
5464
5591
|
id: string;
|
|
5465
5592
|
name?: string;
|
|
@@ -5484,6 +5611,8 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5484
5611
|
} | undefined;
|
|
5485
5612
|
suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
|
|
5486
5613
|
resumeData?: RS extends z.ZodTypeAny ? z.infer<RS> : z.infer<RESUME_SCHEMA>;
|
|
5614
|
+
logger: Logger;
|
|
5615
|
+
writer: WorkflowStreamWriter;
|
|
5487
5616
|
}) => Promise<z.infer<OS>>;
|
|
5488
5617
|
id: string;
|
|
5489
5618
|
name?: string;
|
|
@@ -5508,6 +5637,8 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5508
5637
|
} | undefined;
|
|
5509
5638
|
suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
|
|
5510
5639
|
resumeData?: z.infer<RS>;
|
|
5640
|
+
logger: Logger;
|
|
5641
|
+
writer: WorkflowStreamWriter;
|
|
5511
5642
|
}) => Promise<NEW_DATA>;
|
|
5512
5643
|
id: string;
|
|
5513
5644
|
name?: string;
|
|
@@ -5548,6 +5679,8 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5548
5679
|
} | undefined;
|
|
5549
5680
|
suspend: (reason?: string, suspendData?: z.infer<SUSPEND_SCHEMA>) => Promise<never>;
|
|
5550
5681
|
resumeData?: z.infer<RESUME_SCHEMA>;
|
|
5682
|
+
logger: Logger;
|
|
5683
|
+
writer: WorkflowStreamWriter;
|
|
5551
5684
|
}) => Promise<NEW_DATA>;
|
|
5552
5685
|
id: string;
|
|
5553
5686
|
name?: string;
|
|
@@ -5576,6 +5709,8 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5576
5709
|
} | undefined;
|
|
5577
5710
|
suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
|
|
5578
5711
|
resumeData?: RS extends z.ZodTypeAny ? z.infer<RS> : z.infer<RESUME_SCHEMA>;
|
|
5712
|
+
logger: Logger;
|
|
5713
|
+
writer: WorkflowStreamWriter;
|
|
5579
5714
|
}) => Promise<boolean>;
|
|
5580
5715
|
}): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, z.infer<OS> | z.infer<IS>, SUSPEND_SCHEMA, RESUME_SCHEMA>;
|
|
5581
5716
|
/**
|
|
@@ -5635,6 +5770,8 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5635
5770
|
} | undefined;
|
|
5636
5771
|
suspend: (reason?: string, suspendData?: SS extends z.ZodTypeAny ? z.infer<SS> : z.infer<SUSPEND_SCHEMA>) => Promise<never>;
|
|
5637
5772
|
resumeData?: RS extends z.ZodTypeAny ? z.infer<RS> : z.infer<RESUME_SCHEMA>;
|
|
5773
|
+
logger: Logger;
|
|
5774
|
+
writer: WorkflowStreamWriter;
|
|
5638
5775
|
}) => Promise<void>;
|
|
5639
5776
|
id: string;
|
|
5640
5777
|
name?: string;
|
|
@@ -5674,6 +5811,8 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
|
|
|
5674
5811
|
} | undefined;
|
|
5675
5812
|
suspend: (reason?: string, suspendData?: z.infer<SUSPEND_SCHEMA>) => Promise<never>;
|
|
5676
5813
|
resumeData?: z.infer<RESUME_SCHEMA>;
|
|
5814
|
+
logger: Logger;
|
|
5815
|
+
writer: WorkflowStreamWriter;
|
|
5677
5816
|
}) => Promise<void>;
|
|
5678
5817
|
id: string;
|
|
5679
5818
|
name?: string;
|
|
@@ -6102,6 +6241,8 @@ declare class WorkflowRegistry extends EventEmitter {
|
|
|
6102
6241
|
endAt: Date;
|
|
6103
6242
|
status: "completed" | "suspended" | "error";
|
|
6104
6243
|
result: any;
|
|
6244
|
+
stream: AsyncIterableIterator<WorkflowStreamEvent>;
|
|
6245
|
+
usage: UsageInfo;
|
|
6105
6246
|
suspension?: any;
|
|
6106
6247
|
error?: unknown;
|
|
6107
6248
|
} | null>;
|