"""Workflow data models.
Defines structures for workflow parameters and tool definitions.
Supports the workflow template system with PARAM_ placeholders.
"""
from collections import OrderedDict
from collections.abc import Sequence
from dataclasses import dataclass, field
from typing import Any
@dataclass
class WorkflowParameter:
"""Parameter definition for a workflow template.
Represents a single parameter that can be bound to workflow nodes.
Supports type hints via placeholder naming (e.g., PARAM_INT_STEPS).
Attributes:
name: Parameter name (e.g., "prompt", "steps")
placeholder: Template placeholder (e.g., "PARAM_STR_PROMPT")
annotation: Python type (str, int, float, bool)
description: Human-readable parameter description
bindings: List of (node_id, input_field) pairs where param is used
required: Whether parameter must be provided
"""
name: str
placeholder: str
annotation: type
description: str
bindings: list[tuple[str, str]] = field(default_factory=list)
required: bool = True
@dataclass
class WorkflowToolDefinition:
"""Complete workflow tool definition.
Represents a workflow that can be exposed as an MCP tool.
Contains template, parameters, and metadata for tool registration.
Attributes:
workflow_id: Unique workflow identifier (e.g., "generate_image")
tool_name: MCP tool name (e.g., "generate_image")
description: Tool description for LLM
template: Workflow JSON template with PARAM_ placeholders
parameters: Ordered dict of parameter definitions
output_preferences: Preferred output node keys (for asset extraction)
"""
workflow_id: str
tool_name: str
description: str
template: dict[str, Any]
parameters: "OrderedDict[str, WorkflowParameter]"
output_preferences: Sequence[str]