AbstractAbstractrunQueues a callback to execute in a separate worker context.
The callback will be invoked either immediately or at a scheduled time in an isolated execution environment with limited resources. Use this for breaking up long-running operations into manageable chunks.
Callback created with this.callback()
Optionaloptions: { runAt?: Date }Optional configuration for the execution
OptionalrunAt?: DateIf provided, schedules execution at this time; otherwise runs immediately
Promise resolving to a cancellation token (only for scheduled executions)
AbstractcancelCancels a previously scheduled execution.
Prevents a scheduled function from executing. No error is thrown if the token is invalid or the execution has already completed.
The cancellation token returned by runTask() with runAt option
Promise that resolves when the cancellation is processed
AbstractcancelCancels all scheduled executions for this tool/twist.
Cancels all pending scheduled executions created by this tool or twist instance. Immediate executions cannot be cancelled.
Promise that resolves when all cancellations are processed
Run background tasks and scheduled jobs.
The Run tool enables twists and tools to queue callbacks. This is especially iportant for long-running operations and batch processing, since twists operate within runtime limits. Run callbacks also benefit from automatic retries on failure.
Note: Run methods are also available directly on Twist and Tool classes via
this.runTask(),this.cancelTask(), andthis.cancelAllTasks(). This is the recommended approach for most use cases.Best Practices:
this.callback()Example