Files
agent-zero/tests/test_scheduler_tool_ui.py
linkliti 6f345d4ec6 feat(plugins): extract scheduler tool into _scheduler plugin
Move the scheduler tool, prompts, and DOX into a _scheduler plugin so agent-side scheduling ships as a standard plugin. Invalid task states and dedicated context values return repairable messages rendered from plugin prompt files, and a regression test covers the state response. Cron validation accepts range steps such as `1-5/2` alongside the existing patterns. The tool logs its message as its own `scheduler` type with an `icon://calendar_month Schedule: <action>` headline rendered through an SCH badge handler with slate accent styles from the waiting family shared with the hold badge. The Tasks UI and CRUD endpoints stay in core for now.

Validation: pytest tests/test_tool_action_contracts.py tests/test_scheduler_tool_ui.py
2026-10-21 19:04:33 +03:00

37 lines
964 B
Python

from types import SimpleNamespace
from plugins._scheduler.tools.scheduler import SchedulerTool
class _FakeLog:
def log(self, **kwargs) -> dict:
return kwargs
class _FakeAgent:
def __init__(self) -> None:
self.context = SimpleNamespace(log=_FakeLog())
def _make_tool(args: dict) -> SchedulerTool:
return SchedulerTool(
agent=_FakeAgent(), name="scheduler", method="execute", args=args, message="", loop_data=None
)
def test_log_object_passes_action_through():
tool = _make_tool({"action": "find-task", "name": "backup"})
entry = tool.get_log_object()
assert entry["type"] == "scheduler"
assert entry["heading"] == "icon://calendar_month Schedule: Find Task"
assert entry["kvps"]["action"] == "find-task"
assert entry["kvps"]["name"] == "backup"
def test_get_heading_falls_back_without_action():
tool = _make_tool({})
assert tool.get_heading() == "icon://calendar_month Schedule"