Phase 3.5: Automation & Agents Plugin
Neues automation Plugin (app/plugins/builtins/automation/): - 7 DB-Modelle: AgentDefinition, AgentVersion, AutomationDefinition, AutomationVersion, AutomationCronJob, AgentRun, AutomationRun - Migration 0001_initial.sql mit allen Tabellen + RLS - PluginManifest erweitert: agent_definitions, automation_templates, cron_jobs, heartbeat_configs, miniapps Contribution-Felder - 21 API-Endpoints: /api/v1/automation (CRUD, execute, dry-run, runs, versions, restore, settings, miniapps) + /api/v1/agents (CRUD, execute, test-run, runs, versions, restore, tools, send-message) Backend Features: - Cron-Scheduler (scheduler.py): ARQ-basiert, liest CronJob-Tabelle, enqueued run_agent/run_automation, croniter fuer next_run_at - Workflow-Timeout-Worker (workflow_timeout.py): prueft abgelaufene WorkflowInstances, setzt cancelled, sendet Notification - Agent Runner (agent_runner.py): LiteLLM + ToolRegistry, proactive/ reactive mode, Rate-Limiting, Budget-Limit, Infinite-Loop-Detection - Automation Execution Engine (execution_engine.py): Condition evaluation (eq/ne/gt/lt/contains/exists), Actions (api_call/ notification/workflow_start), Dry-Run mode - Agent-to-Agent Communication (agent_comm.py): send_agent_message tool, kommunikation plugin integration - Plugin-Beitraege: register/unregister on activate/deactivate, Konfliktloesung mit Plugin-Name als Prefix - Heartbeat-Migration: ai_proactive heartbeat als Cron-Job - Versionshistorie: Auto-Versioning bei Updates, Restore-Endpoint - Settings: GET/PATCH /api/v1/automation/settings - ARQ Worker: 11 functions, 2 cron_jobs (scheduler_tick 30s, check_workflow_timeouts 5min) Frontend: - AutomationDashboard.tsx: Automation Builder UI mit Trigger, Conditions, Actions, Execute, Dry-Run, Run-History, Versions - AgentDashboard.tsx: Agent Builder UI mit Model, Tools, Prompt, Heartbeat, Rate-Limits, Execute, Test-Run, Agent-Chat - AutomationSettings.tsx: Settings + MiniApp-Builder - automation.ts: 24 React Query Hooks - automation.ts types: TypeScript Interfaces - routes/index.tsx: /automation, /agents, /settings/automation Tests: - 22 Frontend-Tests (AutomationDashboard, AgentDashboard, API) — alle bestanden - Backend-Tests: test_automation.py (CRUD, versions, conditions, dry-run, rate-limiting) - TSC: keine neuen Errors (nur pre-existing Dms.tsx) - croniter dependency installiert
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
|
||||
|
||||
@@ -78,6 +80,50 @@ class FrontendSettingsPage(BaseModel):
|
||||
permission: str = Field(default="", description="Optional permission required")
|
||||
|
||||
|
||||
class AgentDefinitionContribution(BaseModel):
|
||||
"""An agent definition contributed by a plugin manifest."""
|
||||
|
||||
name: str = Field(..., min_length=1, max_length=120)
|
||||
description: str = Field(default="", max_length=500)
|
||||
llm_model: str = Field(default="ollama/deepseek-v4-flash", max_length=100)
|
||||
system_prompt: str = Field(default="")
|
||||
tool_ids: list[str] = Field(default_factory=list)
|
||||
heartbeat_interval_seconds: int = Field(default=0, ge=0)
|
||||
mode: str = Field(default="reactive", pattern="^(proactive|reactive)$")
|
||||
max_executions_per_hour: int = Field(default=10, ge=1, le=1000)
|
||||
max_duration_seconds: int = Field(default=300, ge=1, le=86400)
|
||||
budget_limit_usd: float = Field(default=1.0, ge=0.0, le=10000.0)
|
||||
|
||||
|
||||
class AutomationTemplateContribution(BaseModel):
|
||||
"""An automation template contributed by a plugin manifest."""
|
||||
|
||||
name: str = Field(..., min_length=1, max_length=120)
|
||||
description: str = Field(default="", max_length=500)
|
||||
trigger_type: str = Field(default="event", pattern="^(event|schedule|manual)$")
|
||||
trigger_config: dict = Field(default_factory=dict)
|
||||
conditions: list[dict] = Field(default_factory=list)
|
||||
actions: list[dict] = Field(default_factory=list)
|
||||
|
||||
|
||||
class CronJobContribution(BaseModel):
|
||||
"""A cron job contributed by a plugin manifest."""
|
||||
|
||||
name: str = Field(..., min_length=1, max_length=120)
|
||||
cron_expression: str = Field(..., min_length=1, max_length=100)
|
||||
job_type: str = Field(..., pattern="^(agent_heartbeat|automation_trigger|custom)$")
|
||||
target_name: str = Field(default="", description="Reference agent/automation by name")
|
||||
plugin_name: str = Field(default="")
|
||||
|
||||
|
||||
class HeartbeatConfigContribution(BaseModel):
|
||||
"""A heartbeat config contributed by a plugin manifest."""
|
||||
|
||||
agent_name: str = Field(..., min_length=1, max_length=120)
|
||||
interval_seconds: int = Field(..., ge=1)
|
||||
target_room: str = Field(default="")
|
||||
|
||||
|
||||
class FrontendDashboardWidget(BaseModel):
|
||||
"""A dashboard widget contributed by a plugin."""
|
||||
|
||||
@@ -92,6 +138,16 @@ class FrontendDashboardWidget(BaseModel):
|
||||
permission: str = Field(default="", description="Optional permission required")
|
||||
|
||||
|
||||
class MiniAppContribution(BaseModel):
|
||||
"""A MiniApp contributed by a plugin manifest."""
|
||||
|
||||
app_id: str = Field(..., min_length=1, max_length=80)
|
||||
name: str = Field(..., min_length=1, max_length=120)
|
||||
icon: str = Field(default="AppWindow")
|
||||
description: str = Field(default="")
|
||||
render_schema: dict[str, Any] = Field(default_factory=dict)
|
||||
|
||||
|
||||
class PluginManifest(BaseModel):
|
||||
"""Manifest describing a plugin's metadata, dependencies, and capabilities."""
|
||||
|
||||
@@ -142,6 +198,23 @@ class PluginManifest(BaseModel):
|
||||
dashboard_widgets: list[FrontendDashboardWidget] = Field(
|
||||
default_factory=list, description="Dashboard widgets contributed by this plugin"
|
||||
)
|
||||
# ── Plugin Contribution fields (Phase 3.5C) ──
|
||||
agent_definitions: list[AgentDefinitionContribution] = Field(
|
||||
default_factory=list, description="Agent definitions contributed by this plugin"
|
||||
)
|
||||
automation_templates: list[AutomationTemplateContribution] = Field(
|
||||
default_factory=list, description="Automation templates contributed by this plugin"
|
||||
)
|
||||
cron_jobs: list[CronJobContribution] = Field(
|
||||
default_factory=list, description="Cron jobs contributed by this plugin"
|
||||
)
|
||||
heartbeat_configs: list[HeartbeatConfigContribution] = Field(
|
||||
default_factory=list, description="Heartbeat configs contributed by this plugin"
|
||||
)
|
||||
miniapps: list[MiniAppContribution] = Field(
|
||||
default_factory=list, description="MiniApps contributed by this plugin"
|
||||
)
|
||||
|
||||
|
||||
@field_validator("name")
|
||||
@classmethod
|
||||
@@ -153,6 +226,9 @@ class PluginManifest(BaseModel):
|
||||
model_config = {"extra": "forbid"}
|
||||
|
||||
|
||||
PluginManifest.model_rebuild()
|
||||
|
||||
|
||||
class ManifestSchemaResponse(BaseModel):
|
||||
"""Response model describing the manifest schema for API consumers."""
|
||||
|
||||
@@ -258,3 +334,6 @@ MANIFEST_SCHEMA_DOC = ManifestSchemaResponse(
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
PluginManifest.model_rebuild()
|
||||
|
||||
Reference in New Issue
Block a user