Build task management and user interaction tools. Args: task_board: The TaskBoard instance for persistence. user_input_fn: Callback that prompts the user and returns their answer. Signature: (question, optional_options) -> answer_string
(
task_board: TaskBoard,
user_input_fn: Callable[[str, Optional[list[str]]], str],
)
| 23 | |
| 24 | |
| 25 | def build_task_management_tools( |
| 26 | task_board: TaskBoard, |
| 27 | user_input_fn: Callable[[str, Optional[list[str]]], str], |
| 28 | ) -> list[OrchestratorTool]: |
| 29 | """Build task management and user interaction tools. |
| 30 | |
| 31 | Args: |
| 32 | task_board: The TaskBoard instance for persistence. |
| 33 | user_input_fn: Callback that prompts the user and returns their answer. |
| 34 | Signature: (question, optional_options) -> answer_string |
| 35 | """ |
| 36 | |
| 37 | def handle_task_create(args: dict) -> str: |
| 38 | task = task_board.create_task( |
| 39 | description=args["description"], |
| 40 | parent_id=args.get("parent_task_id"), |
| 41 | ) |
| 42 | return f"Created {task.id}: {task.description}" |
| 43 | |
| 44 | def handle_task_update(args: dict) -> str: |
| 45 | try: |
| 46 | task = task_board.update_task( |
| 47 | task_id=args["task_id"], |
| 48 | status=args.get("status"), |
| 49 | result_summary=args.get("result_summary"), |
| 50 | ) |
| 51 | return f"Updated {task.id}: status={task.status.value}" |
| 52 | except ValueError as e: |
| 53 | return f"Error: {e}" |
| 54 | |
| 55 | def handle_task_list(args: dict) -> str: |
| 56 | return task_board.get_summary() |
| 57 | |
| 58 | def handle_ask_user(args: dict) -> str: |
| 59 | return user_input_fn(args["question"], args.get("options")) |
| 60 | |
| 61 | return [ |
| 62 | OrchestratorTool( |
| 63 | name="task_create", |
| 64 | description="Create a new task on the task board to track work.", |
| 65 | parameters={ |
| 66 | "type": "object", |
| 67 | "properties": { |
| 68 | "description": { |
| 69 | "type": "string", |
| 70 | "description": "What this task should accomplish", |
| 71 | }, |
| 72 | "parent_task_id": { |
| 73 | "type": "string", |
| 74 | "description": "Parent task ID if this is a subtask", |
| 75 | }, |
| 76 | }, |
| 77 | "required": ["description"], |
| 78 | }, |
| 79 | handler=handle_task_create, |
| 80 | ), |
| 81 | OrchestratorTool( |
| 82 | name="task_update", |