74 lines
2.0 KiB
Python
74 lines
2.0 KiB
Python
"""Extended task payload schemas for SysAdmin Agent automation.
|
|
|
|
These schemas define the expected payload structure for each task type.
|
|
Validation is performed agent-side; the orchestrator accepts any dict payload.
|
|
"""
|
|
|
|
from typing import Any
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class FileWritePayload(BaseModel):
|
|
"""
|
|
Payload for FILE_WRITE task type.
|
|
|
|
Instructs the agent to write content to a file at the specified path.
|
|
"""
|
|
|
|
path: str = Field(..., description="Absolute path to the target file")
|
|
content: str = Field(..., description="Content to write to the file")
|
|
|
|
|
|
class EnvUpdatePayload(BaseModel):
|
|
"""
|
|
Payload for ENV_UPDATE task type.
|
|
|
|
Instructs the agent to update key/value pairs in an .env file.
|
|
Existing keys are updated; new keys are appended.
|
|
"""
|
|
|
|
path: str = Field(..., description="Absolute path to the .env file")
|
|
updates: dict[str, str] = Field(
|
|
..., description="Key-value pairs to update or add"
|
|
)
|
|
|
|
|
|
class DockerReloadPayload(BaseModel):
|
|
"""
|
|
Payload for DOCKER_RELOAD task type.
|
|
|
|
Instructs the agent to reload a Docker Compose stack.
|
|
Equivalent to: docker compose down && docker compose up -d
|
|
"""
|
|
|
|
compose_dir: str = Field(
|
|
..., description="Directory containing docker-compose.yml"
|
|
)
|
|
|
|
|
|
class CompositeSubTask(BaseModel):
|
|
"""
|
|
A single sub-task within a COMPOSITE task.
|
|
|
|
Represents one step in a multi-step automation sequence.
|
|
"""
|
|
|
|
task: str = Field(..., description="Task type (e.g., FILE_WRITE, ENV_UPDATE)")
|
|
payload: dict[str, Any] = Field(
|
|
default_factory=dict, description="Payload for this sub-task"
|
|
)
|
|
|
|
|
|
class CompositePayload(BaseModel):
|
|
"""
|
|
Payload for COMPOSITE task type.
|
|
|
|
Instructs the agent to execute a sequence of sub-tasks in order.
|
|
If any sub-task fails, the sequence stops and the composite task fails.
|
|
"""
|
|
|
|
sequence: list[CompositeSubTask] = Field(
|
|
..., description="Ordered list of sub-tasks to execute"
|
|
)
|