Skip to content

Commit 66c3a3c

Browse files
ramanv0cursoragent
andcommitted
feat: add workflow rollback and execution replay commands
New API methods: - RollbackWorkflow(workflowID, version) - roll back to a previous version - ReplayExecution(id, mode) - replay failed executions (full or from_failed) - ListWorkflowVersions(workflowID, page, pageSize) - list version history New types: ReplayResponse, WorkflowVersion, VersionListResponse Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent dc065cc commit 66c3a3c

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

pkg/api/client.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,29 @@ func (c *Client) CancelExecution(id string) error {
169169
return c.post("/api/workflow-executions/"+id+"/cancel", nil, nil)
170170
}
171171

172+
func (c *Client) ReplayExecution(id, mode string) (*ReplayResponse, error) {
173+
body := map[string]string{"mode": mode}
174+
var out ReplayResponse
175+
if err := c.post("/api/workflow-executions/"+id+"/replay", body, &out); err != nil {
176+
return nil, err
177+
}
178+
return &out, nil
179+
}
180+
181+
func (c *Client) RollbackWorkflow(workflowID string, version int) error {
182+
path := fmt.Sprintf("/api/workflows/%s/rollback?version=%d", workflowID, version)
183+
return c.post(path, nil, nil)
184+
}
185+
186+
func (c *Client) ListWorkflowVersions(workflowID string, page, pageSize int) (*VersionListResponse, error) {
187+
path := fmt.Sprintf("/api/workflows/%s/versions?page=%d&page_size=%d", workflowID, page, pageSize)
188+
var out VersionListResponse
189+
if err := c.get(path, nil, &out); err != nil {
190+
return nil, err
191+
}
192+
return &out, nil
193+
}
194+
172195
// --- Approvals ---
173196

174197
func (c *Client) ListPendingApprovals() ([]WorkflowApproval, error) {

pkg/api/types.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,25 @@ type CreateAPIKeyRequest struct {
243243
Scopes []string `json:"scopes"`
244244
ExpiresIn string `json:"expires_in,omitempty"`
245245
}
246+
247+
type ReplayResponse struct {
248+
ExecutionID string `json:"execution_id"`
249+
}
250+
251+
type WorkflowVersion struct {
252+
ID string `json:"id"`
253+
WorkflowID string `json:"workflow_id"`
254+
VersionNumber int `json:"version_number"`
255+
Name string `json:"name"`
256+
Description string `json:"description,omitempty"`
257+
CreatedByEmail string `json:"created_by_email,omitempty"`
258+
CreatedAt string `json:"created_at"`
259+
ChangeSummary string `json:"change_summary,omitempty"`
260+
}
261+
262+
type VersionListResponse struct {
263+
Versions []WorkflowVersion `json:"versions"`
264+
Total int `json:"total"`
265+
Page int `json:"page"`
266+
PageSize int `json:"page_size"`
267+
}

0 commit comments

Comments
 (0)