({
params,
task,
project,
strategy,
context,
}: {
params: OpenADETurnStartRequest
task: OpenADETask
project: { path: string }
strategy: OpenADEHyperPlanStrategy
context?: { runtimeId?: string }
})
| 570 | } |
| 571 | |
| 572 | async function startHyperPlan({ |
| 573 | params, |
| 574 | task, |
| 575 | project, |
| 576 | strategy, |
| 577 | context, |
| 578 | }: { |
| 579 | params: OpenADETurnStartRequest |
| 580 | task: OpenADETask |
| 581 | project: { path: string } |
| 582 | strategy: OpenADEHyperPlanStrategy |
| 583 | context?: { runtimeId?: string } |
| 584 | }): Promise<{ taskId: string; eventId: string }> { |
| 585 | const errors = validateOpenADEHyperPlanStrategy(strategy) |
| 586 | if (errors.length > 0) throw new Error(`Invalid HyperPlan strategy: ${errors.join(", ")}`) |
| 587 | const terminalStep = strategy.steps.find((step) => step.id === strategy.terminalStepId) |
| 588 | if (!terminalStep) throw new Error(`Terminal HyperPlan step ${strategy.terminalStepId} not found`) |
| 589 | |
| 590 | const executionId = executionIdForTask(task.id) |
| 591 | const action = await writer.createActionEvent({ |
| 592 | taskId: task.id, |
| 593 | userInput: params.input, |
| 594 | executionId, |
| 595 | harnessId: terminalStep.agent.harnessId, |
| 596 | source: { type: "hyperplan", userLabel: params.label ?? "HyperPlan", strategyId: strategy.id }, |
| 597 | images: params.images, |
| 598 | includesCommentIds: [], |
| 599 | modelId: terminalStep.agent.modelId, |
| 600 | fastMode: params.fastMode, |
| 601 | }) |
| 602 | |
| 603 | for (const step of strategy.steps) { |
| 604 | if (step.id === strategy.terminalStepId) continue |
| 605 | await writer.addHyperPlanSubExecution({ |
| 606 | taskId: task.id, |
| 607 | eventId: action.eventId, |
| 608 | subExecution: { |
| 609 | stepId: step.id, |
| 610 | primitive: step.primitive, |
| 611 | harnessId: step.agent.harnessId, |
| 612 | modelId: step.agent.modelId, |
| 613 | executionId: "", |
| 614 | status: "in_progress", |
| 615 | events: [], |
| 616 | }, |
| 617 | }) |
| 618 | } |
| 619 | |
| 620 | const runtimeId = context?.runtimeId ?? `openade-turn:${task.id}` |
| 621 | if (server) { |
| 622 | const runtimePatch = { |
| 623 | status: "running" as const, |
| 624 | scope: { |
| 625 | ownerType: "openade-task", |
| 626 | ownerId: task.id, |
| 627 | repoPath: project.path, |
| 628 | rootPath: project.path, |
| 629 | labels: { |
no test coverage detected