File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,9 +67,10 @@ class InstanceImpl implements WorkflowInstance {
6767 } ) ;
6868 }
6969
70- async restart ( ) : Promise < void > {
70+ async restart ( options ?: WorkflowInstanceRestartOptions ) : Promise < void > {
7171 await callFetcher ( this . fetcher , '/restart' , {
7272 id : this . id ,
73+ step : options ?. from ,
7374 } ) ;
7475 }
7576
Original file line number Diff line number Diff line change @@ -108,6 +108,21 @@ interface WorkflowError {
108108 message : string ;
109109}
110110
111+ interface WorkflowInstanceRestartOptions {
112+ /**
113+ * Restart from a specific step. If omitted, the instance restarts from the beginning.
114+ * The step must exist in the instance's execution history.
115+ */
116+ from ?: {
117+ /** The step name as defined in your workflow code. */
118+ name : string ;
119+ /** 1-indexed occurrence of this step name. Defaults to 1. Use when the same step name appears multiple times (e.g. in a loop). */
120+ count ?: number ;
121+ /** Step type filter. Use when different step types share the same name. */
122+ type ?: 'do' | 'sleep' | 'waitForEvent' ;
123+ } ;
124+ }
125+
111126declare abstract class WorkflowInstance {
112127 id : string ;
113128
@@ -127,9 +142,11 @@ declare abstract class WorkflowInstance {
127142 terminate ( ) : Promise < void > ;
128143
129144 /**
130- * Restart the instance.
145+ * Restart the instance. Optionally restart from a specific step, preserving
146+ * cached results for all steps before it.
147+ * @param options Options for the restart, including an optional step to restart from.
131148 */
132- restart ( ) : Promise < void > ;
149+ restart ( options ?: WorkflowInstanceRestartOptions ) : Promise < void > ;
133150
134151 /**
135152 * Returns the current status of the instance.
You can’t perform that action at this time.
0 commit comments