UNPKG

@mastra/core

Version:

Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.

35 lines (24 loc) 933 B
# Workflow\.sleepUntil() The `.sleepUntil()` method pauses execution until a specified date. ## Usage example ```typescript workflow.sleepUntil(new Date(Date.now() + 5000)) ``` ## Parameters **dateOrCallback** (`Date | ((params: ExecuteFunctionParams) => Promise<Date>)`): Either a Date object or a callback function that returns a Date. The callback receives execution context and can compute the target time dynamically based on input data. ## Returns **workflow** (`Workflow`): The workflow instance for method chaining ## Extended usage example ```typescript import { createWorkflow, createStep } from "@mastra/core/workflows"; const step1 = createStep({...}); const step2 = createStep({...}); export const testWorkflow = createWorkflow({...}) .then(step1) .sleepUntil(async ({ inputData }) => { const { delayInMs } = inputData; return new Date(Date.now() + delayInMs); }) .then(step2) .commit(); ```