(params: OpenADETurnStartRequest, context?: { runtimeId?: string })
| 288 | } |
| 289 | |
| 290 | async function startTurn(params: OpenADETurnStartRequest, context?: { runtimeId?: string }): Promise<{ taskId: string; eventId: string }> { |
| 291 | let taskId = params.inTaskId || "" |
| 292 | if (!taskId) { |
| 293 | const createdAt = now() |
| 294 | const request: OpenADETaskCreateRequest = { |
| 295 | repoId: params.repoId, |
| 296 | input: params.input, |
| 297 | createdBy: { id: "headless-runtime", email: "headless@openade.local" }, |
| 298 | deviceId: "headless-runtime", |
| 299 | title: params.title ?? fallbackTitle(params.input), |
| 300 | taskId: taskIdForClientRequest(params.repoId, params.clientRequestId), |
| 301 | createdAt, |
| 302 | isolationStrategy: params.isolationStrategy, |
| 303 | enabledMcpServerIds: params.enabledMcpServerIds, |
| 304 | } |
| 305 | const result = await writer.createTask(request) |
| 306 | taskId = result.taskId |
| 307 | } |
| 308 | |
| 309 | const task = await projection.readTask(params.repoId, taskId) |
| 310 | const project = (await projection.readProjects()).find((candidate) => candidate.id === params.repoId) |
| 311 | if (!project) throw new Error(`Repository ${params.repoId} not found`) |
| 312 | |
| 313 | if (params.type === "hyperplan") { |
| 314 | const strategy = params.hyperplanStrategy |
| 315 | if (!strategy) { |
| 316 | return startTurn({ ...params, type: "plan", label: params.label ?? "HyperPlan", inTaskId: taskId }, context) |
| 317 | } |
| 318 | if (isStandardOpenADEHyperPlanStrategy(strategy)) { |
| 319 | const step = strategy.steps[0] |
| 320 | return startTurn( |
| 321 | { |
| 322 | ...params, |
| 323 | type: "plan", |
| 324 | harnessId: step.agent.harnessId, |
| 325 | modelId: step.agent.modelId, |
| 326 | label: params.label ?? "HyperPlan", |
| 327 | inTaskId: taskId, |
| 328 | }, |
| 329 | context |
| 330 | ) |
| 331 | } |
| 332 | return startHyperPlan({ params, task, project, strategy, context }) |
| 333 | } |
| 334 | |
| 335 | let promptType = params.type |
| 336 | let planEventId = latestCompletedPlanEventId(task.events) |
| 337 | if (promptType === "revise" && !planEventId) { |
| 338 | promptType = "plan" |
| 339 | planEventId = undefined |
| 340 | } |
| 341 | if (promptType === "run_plan" && !planEventId) { |
| 342 | throw new Error("Run Plan requires a completed plan event") |
| 343 | } |
| 344 | |
| 345 | const prompt = buildOpenADEPrompt({ |
| 346 | type: promptType as "plan" | "do" | "ask" | "revise" | "run_plan", |
| 347 | input: params.input, |
nothing calls this directly
no test coverage detected