| 873 | } |
| 874 | |
| 875 | static create(options: TaskOptions): [Task, Promise<void>] { |
| 876 | const instance = new Task({ ...options, startTask: false }) |
| 877 | const { images, task, historyItem } = options |
| 878 | let promise |
| 879 | |
| 880 | if (images || task) { |
| 881 | promise = instance.startTask(task, images) |
| 882 | } else if (historyItem) { |
| 883 | promise = instance.resumeTaskFromHistory() |
| 884 | } else { |
| 885 | throw new Error("Either historyItem or task/images must be provided") |
| 886 | } |
| 887 | |
| 888 | return [instance, promise] |
| 889 | } |
| 890 | |
| 891 | // API Messages |
| 892 | |