"""Shared dataclasses for the PAM deploy agent.""" from __future__ import annotations from dataclasses import dataclass, field from typing import Any, Literal BackendName = Literal["mcp", "script", "fake"] ExecutionStrategy = Literal["hybrid_node_mcp", "script_only", "fake"] @dataclass(slots=True) class ActionResult: action: str backend: BackendName ok: bool values: dict[str, Any] = field(default_factory=dict) exit_code: int = 0 tool_name: str = "" stdout: str = "" stderr: str = "" raw_output: str = "" error_summary: str = "" @dataclass(slots=True) class SkillPolicy: name: str source_path: str description: str = "" allowed_modes: tuple[str, ...] = ("MCP", "API脚本") allowed_actions: tuple[str, ...] = () required_confirmations: tuple[str, ...] = ( "params", "target_scope", "rollback", ) required_params: tuple[str, ...] = () optional_params: dict[str, Any] = field(default_factory=dict) action_sequence: tuple[str, ...] = () ip_action_sequence: tuple[str, ...] = () forbidden_actions: tuple[str, ...] = ( "script-main-flow", "auto-rollback", "modify-deploy-scripts", ) @dataclass(slots=True) class AgentState: run_id: str params: dict[str, Any] execution_strategy: ExecutionStrategy action_backends: dict[str, BackendName] script_entry: str = "" script_base_dir: str = "." config_path: str = "" trace_file_path: str = "" node_mcp_server_name: str = "" node_mcp_tool_names: dict[str, str] = field(default_factory=dict) completed_global_steps: list[str] = field(default_factory=list) hash_code: str = "" node_url: str = "" online_ips: list[str] = field(default_factory=list) target_ips: list[str] = field(default_factory=list) ip_states: dict[str, dict[str, Any]] = field(default_factory=dict) pending_confirmation: str = "" last_success_step: str = "" last_failed_step: str = "" events: list[dict[str, Any]] = field(default_factory=list)