mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-29 19:35:20 +02:00
feat(automation): register agent_task action and schedule/manual triggers
This commit is contained in:
parent
56b3e1bfc4
commit
99fd1a1338
5 changed files with 71 additions and 0 deletions
|
|
@ -12,3 +12,6 @@ __all__ = [
|
|||
"get_action",
|
||||
"register_action",
|
||||
]
|
||||
|
||||
# Built-in actions self-register at import time.
|
||||
from . import agent_task # noqa: E402, F401
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
"""Built-in ``agent_task`` action. Self-registers at import time."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from app.automations.schemas.actions import AgentTaskActionParams
|
||||
|
||||
from .store import register_action
|
||||
from .types import ActionDefinition
|
||||
|
||||
|
||||
async def _handle_agent_task(args: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Stub. Validates params; real wiring lands with the executor."""
|
||||
AgentTaskActionParams.model_validate(args)
|
||||
return {"status": "stubbed"}
|
||||
|
||||
|
||||
AGENT_TASK_ACTION = ActionDefinition(
|
||||
type="agent_task",
|
||||
name="Agent task",
|
||||
description="Run an agent task with a scoped tool allowlist.",
|
||||
params_schema=AgentTaskActionParams.model_json_schema(),
|
||||
handler=_handle_agent_task,
|
||||
)
|
||||
|
||||
register_action(AGENT_TASK_ACTION)
|
||||
|
|
@ -11,3 +11,6 @@ __all__ = [
|
|||
"get_trigger",
|
||||
"register_trigger",
|
||||
]
|
||||
|
||||
# Built-in triggers self-register at import time.
|
||||
from . import manual, schedule # noqa: E402, F401
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
"""Built-in ``manual`` trigger. Self-registers at import time."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app.automations.schemas.triggers import ManualTriggerParams
|
||||
|
||||
from .store import register_trigger
|
||||
from .types import TriggerDefinition
|
||||
|
||||
MANUAL_TRIGGER = TriggerDefinition(
|
||||
type="manual",
|
||||
description="Fire on a user-initiated 'Run now' invocation.",
|
||||
params_schema=ManualTriggerParams.model_json_schema(),
|
||||
payload_schema={"type": "object"},
|
||||
)
|
||||
|
||||
register_trigger(MANUAL_TRIGGER)
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
"""Built-in ``schedule`` trigger. Self-registers at import time."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app.automations.schemas.triggers import ScheduleTriggerParams
|
||||
|
||||
from .store import register_trigger
|
||||
from .types import TriggerDefinition
|
||||
|
||||
SCHEDULE_TRIGGER = TriggerDefinition(
|
||||
type="schedule",
|
||||
description="Fire on a cron schedule in a given timezone.",
|
||||
params_schema=ScheduleTriggerParams.model_json_schema(),
|
||||
payload_schema={
|
||||
"type": "object",
|
||||
"additionalProperties": False,
|
||||
"properties": {},
|
||||
},
|
||||
)
|
||||
|
||||
register_trigger(SCHEDULE_TRIGGER)
|
||||
Loading…
Add table
Add a link
Reference in a new issue