({
provider,
apiConfiguration,
enableCheckpoints = true,
checkpointTimeout = DEFAULT_CHECKPOINT_TIMEOUT_SECONDS,
consecutiveMistakeLimit = DEFAULT_CONSECUTIVE_MISTAKE_LIMIT,
taskId,
task,
images,
historyItem,
experiments: experimentsConfig,
startTask = true,
rootTask,
parentTask,
taskNumber = -1,
onCreated,
initialTodos,
workspacePath,
initialStatus,
rateLimitClock,
diffFuzzyThreshold,
}: TaskOptions)
| 437 | private _messageManager?: MessageManager |
| 438 | |
| 439 | constructor({ |
| 440 | provider, |
| 441 | apiConfiguration, |
| 442 | enableCheckpoints = true, |
| 443 | checkpointTimeout = DEFAULT_CHECKPOINT_TIMEOUT_SECONDS, |
| 444 | consecutiveMistakeLimit = DEFAULT_CONSECUTIVE_MISTAKE_LIMIT, |
| 445 | taskId, |
| 446 | task, |
| 447 | images, |
| 448 | historyItem, |
| 449 | experiments: experimentsConfig, |
| 450 | startTask = true, |
| 451 | rootTask, |
| 452 | parentTask, |
| 453 | taskNumber = -1, |
| 454 | onCreated, |
| 455 | initialTodos, |
| 456 | workspacePath, |
| 457 | initialStatus, |
| 458 | rateLimitClock, |
| 459 | diffFuzzyThreshold, |
| 460 | }: TaskOptions) { |
| 461 | super() |
| 462 | |
| 463 | if (startTask && !task && !images && !historyItem) { |
| 464 | throw new Error("Either historyItem or task/images must be provided") |
| 465 | } |
| 466 | |
| 467 | if ( |
| 468 | !checkpointTimeout || |
| 469 | checkpointTimeout > MAX_CHECKPOINT_TIMEOUT_SECONDS || |
| 470 | checkpointTimeout < MIN_CHECKPOINT_TIMEOUT_SECONDS |
| 471 | ) { |
| 472 | throw new Error( |
| 473 | "checkpointTimeout must be between " + |
| 474 | MIN_CHECKPOINT_TIMEOUT_SECONDS + |
| 475 | " and " + |
| 476 | MAX_CHECKPOINT_TIMEOUT_SECONDS + |
| 477 | " seconds", |
| 478 | ) |
| 479 | } |
| 480 | |
| 481 | this.taskId = historyItem ? historyItem.id : (taskId ?? uuidv7()) |
| 482 | this.rootTaskId = historyItem ? historyItem.rootTaskId : rootTask?.taskId |
| 483 | this.parentTaskId = historyItem ? historyItem.parentTaskId : parentTask?.taskId |
| 484 | this.childTaskId = undefined |
| 485 | |
| 486 | this.metadata = { |
| 487 | task: historyItem ? historyItem.task : task, |
| 488 | images: historyItem ? [] : images, |
| 489 | } |
| 490 | |
| 491 | // Normal use-case is usually retry similar history task with new workspace. |
| 492 | this.workspacePath = parentTask |
| 493 | ? parentTask.workspacePath |
| 494 | : (workspacePath ?? getWorkspacePath(path.join(os.homedir(), "Desktop"))) |
| 495 | |
| 496 | this.instanceId = crypto.randomUUID().slice(0, 8) |
nothing calls this directly
no test coverage detected