(params: unknown)
| 274 | } |
| 275 | |
| 276 | function turnParams(params: unknown): OpenADETurnStartRequest { |
| 277 | const record = asRecord(params) |
| 278 | const repoId = record.repoId |
| 279 | const input = record.input |
| 280 | if (typeof repoId !== "string" || repoId.length < 1) throw new Error("repoId is invalid") |
| 281 | if (typeof input !== "string" || input.length > 200_000) throw new Error("input is invalid") |
| 282 | const isExistingTurn = typeof record.inTaskId === "string" && record.inTaskId.length > 0 |
| 283 | if (!isExistingTurn && input.trim().length < 1) throw new Error("input is invalid") |
| 284 | if ( |
| 285 | record.type !== "plan" && |
| 286 | record.type !== "do" && |
| 287 | record.type !== "ask" && |
| 288 | record.type !== "revise" && |
| 289 | record.type !== "run_plan" && |
| 290 | record.type !== "hyperplan" |
| 291 | ) { |
| 292 | throw new Error("type is invalid") |
| 293 | } |
| 294 | |
| 295 | return { |
| 296 | repoId, |
| 297 | type: record.type, |
| 298 | input, |
| 299 | clientRequestId: typeof record.clientRequestId === "string" ? record.clientRequestId : undefined, |
| 300 | appendSystemPrompt: typeof record.appendSystemPrompt === "string" ? record.appendSystemPrompt : undefined, |
| 301 | inTaskId: record.inTaskId === null ? null : typeof record.inTaskId === "string" ? record.inTaskId : undefined, |
| 302 | isolationStrategy: record.isolationStrategy as OpenADETurnStartRequest["isolationStrategy"], |
| 303 | enabledMcpServerIds: Array.isArray(record.enabledMcpServerIds) ? record.enabledMcpServerIds.filter((id): id is string => typeof id === "string") : undefined, |
| 304 | harnessId: typeof record.harnessId === "string" ? record.harnessId : undefined, |
| 305 | modelId: typeof record.modelId === "string" ? record.modelId : undefined, |
| 306 | label: typeof record.label === "string" ? record.label : undefined, |
| 307 | includeComments: typeof record.includeComments === "boolean" ? record.includeComments : undefined, |
| 308 | images: Array.isArray(record.images) ? record.images : undefined, |
| 309 | thinking: record.thinking === "low" || record.thinking === "med" || record.thinking === "high" || record.thinking === "max" ? record.thinking : undefined, |
| 310 | fastMode: typeof record.fastMode === "boolean" ? record.fastMode : undefined, |
| 311 | title: typeof record.title === "string" ? record.title : undefined, |
| 312 | hyperplanStrategy: hyperplanStrategyParam(record.hyperplanStrategy), |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | function reviewStartParams(params: unknown): OpenADEReviewStartRequest { |
| 317 | const record = asRecord(params) |
no test coverage detected