from __future__ import annotations from dataclasses import dataclass @dataclass(frozen=True) class TaskToolDefinition: code: str name: str description: str launch_url: str | None = None _TASK_TOOLS: tuple[TaskToolDefinition, ...] = ( TaskToolDefinition(code="NONE", name="None", description="Normal task workflow without an attached ERP tool."), TaskToolDefinition( code="ACCOUNTING_OPENING_BALANCE", name="Opening Balance Review", description="Launch the existing Tally opening-balance comparison and verification tool.", launch_url="/tools/accounting/opening-balances", ), TaskToolDefinition( code="ACCOUNTING_BANK_RECONCILIATION", name="Bank Reconciliation", description="Launch the existing accounting bank-reconciliation workspace.", launch_url="/tools/accounting/bank-reconciliation", ), ) def list_task_tools() -> list[TaskToolDefinition]: return list(_TASK_TOOLS) def get_task_tool(code: str | None) -> TaskToolDefinition: normalized = normalize_task_tool_code(code) for tool in _TASK_TOOLS: if tool.code == normalized: return tool return _TASK_TOOLS[0] def normalize_task_tool_code(code: str | None) -> str: value = (code or "NONE").strip().upper() or "NONE" valid = {tool.code for tool in _TASK_TOOLS} if value not in valid: raise ValueError(f"Unsupported task tool: {value}") return value