(plan: Any)
| 97 | |
| 98 | |
| 99 | def _task_plan_from_input(plan: Any) -> tuple[TaskPlan | None, str]: |
| 100 | if isinstance(plan, dict): |
| 101 | try: |
| 102 | return parse_task_plan(plan), "" |
| 103 | except Exception as exc: |
| 104 | return None, f"Invalid plan: {exc}" |
| 105 | |
| 106 | if not isinstance(plan, list): |
| 107 | return None, "Plan must be an array of ISO datetimes." |
| 108 | |
| 109 | todo: list[datetime] = [] |
| 110 | for item in plan: |
| 111 | dt = parse_datetime(str(item)) |
| 112 | if dt is None: |
| 113 | return None, f"Invalid datetime: {item}" |
| 114 | todo.append(dt) |
| 115 | |
| 116 | return TaskPlan.create(todo=todo, in_progress=None, done=[]), "" |
| 117 | |
| 118 | |
| 119 | class SchedulerTool(Tool): |
no test coverage detected