[fix] Update data models to Pydantic v2 syntax to fix TypeError

This commit is contained in:
bymyself 2025-06-17 15:12:25 -07:00
parent ce3b2bab39
commit e8fc053a32

View File

@ -1,6 +1,6 @@
# generated by datamodel-codegen: # generated by datamodel-codegen:
# filename: openapi.yaml # filename: openapi.yaml
# timestamp: 2025-06-17T21:37:15+00:00 # timestamp: 2025-06-17T22:03:51+00:00
from __future__ import annotations from __future__ import annotations
@ -8,158 +8,114 @@ from datetime import datetime
from enum import Enum from enum import Enum
from typing import Any, Dict, List, Optional, Union from typing import Any, Dict, List, Optional, Union
from pydantic import BaseModel, Field from pydantic import BaseModel, Field, RootModel
class OperationType(Enum): class OperationType(str, Enum):
""" install = "install"
Type of operation or task being performed uninstall = "uninstall"
""" update = "update"
update_comfyui = "update-comfyui"
install = 'install' fix = "fix"
uninstall = 'uninstall' disable = "disable"
update = 'update' enable = "enable"
update_comfyui = 'update-comfyui' install_model = "install-model"
fix = 'fix'
disable = 'disable'
enable = 'enable'
install_model = 'install-model'
class OperationResult(Enum): class OperationResult(str, Enum):
""" success = "success"
Result status of an operation (failed/error and skipped/skip are aliases) failed = "failed"
""" skipped = "skipped"
error = "error"
success = 'success' skip = "skip"
failed = 'failed'
skipped = 'skipped'
error = 'error'
skip = 'skip'
class TaskExecutionStatus(BaseModel): class TaskExecutionStatus(BaseModel):
status_str: OperationResult status_str: OperationResult
completed: bool = Field(..., description='Whether the task completed') completed: bool = Field(..., description="Whether the task completed")
messages: List[str] = Field(..., description='Additional status messages') messages: List[str] = Field(..., description="Additional status messages")
class ManagerMessageName(Enum): class ManagerMessageName(str, Enum):
""" cm_task_completed = "cm-task-completed"
WebSocket message type constants for manager events cm_task_started = "cm-task-started"
""" cm_queue_status = "cm-queue-status"
cm_task_completed = 'cm-task-completed'
cm_task_started = 'cm-task-started'
cm_queue_status = 'cm-queue-status'
class ManagerPackInfo(BaseModel): class ManagerPackInfo(BaseModel):
id: str = Field( id: str = Field(
..., ...,
description='Either github-author/github-repo or name of pack from the registry', description="Either github-author/github-repo or name of pack from the registry",
) )
version: str = Field(..., description='Semantic version or Git commit hash') version: str = Field(..., description="Semantic version or Git commit hash")
ui_id: Optional[str] = Field(None, description='Task ID - generated internally') ui_id: Optional[str] = Field(None, description="Task ID - generated internally")
class ManagerPackInstalled(BaseModel): class ManagerPackInstalled(BaseModel):
ver: str = Field( ver: str = Field(
..., ...,
description='The version of the pack that is installed (Git commit hash or semantic version)', description="The version of the pack that is installed (Git commit hash or semantic version)",
) )
cnr_id: Optional[str] = Field( cnr_id: Optional[str] = Field(
None, description='The name of the pack if installed from the registry' None, description="The name of the pack if installed from the registry"
) )
aux_id: Optional[str] = Field( aux_id: Optional[str] = Field(
None, None,
description='The name of the pack if installed from github (author/repo-name format)', description="The name of the pack if installed from github (author/repo-name format)",
) )
enabled: bool = Field(..., description='Whether the pack is enabled') enabled: bool = Field(..., description="Whether the pack is enabled")
class SelectedVersion(Enum): class SelectedVersion(str, Enum):
""" latest = "latest"
Version selection for pack installation nightly = "nightly"
"""
latest = 'latest'
nightly = 'nightly'
class ManagerChannel(Enum): class ManagerChannel(str, Enum):
""" default = "default"
Channel for pack sources recent = "recent"
""" legacy = "legacy"
forked = "forked"
default = 'default' dev = "dev"
recent = 'recent' tutorial = "tutorial"
legacy = 'legacy'
forked = 'forked'
dev = 'dev'
tutorial = 'tutorial'
class ManagerDatabaseSource(Enum): class ManagerDatabaseSource(str, Enum):
""" remote = "remote"
Source for pack information local = "local"
""" cache = "cache"
remote = 'remote'
local = 'local'
cache = 'cache'
class ManagerPackState(Enum): class ManagerPackState(str, Enum):
""" installed = "installed"
Current state of a pack disabled = "disabled"
""" not_installed = "not_installed"
import_failed = "import_failed"
installed = 'installed' needs_update = "needs_update"
disabled = 'disabled'
not_installed = 'not_installed'
import_failed = 'import_failed'
needs_update = 'needs_update'
class ManagerPackInstallType(Enum): class ManagerPackInstallType(str, Enum):
""" git_clone = "git-clone"
Type of installation used for the pack copy = "copy"
""" cnr = "cnr"
git_clone = 'git-clone'
copy = 'copy'
cnr = 'cnr'
class SecurityLevel(Enum): class SecurityLevel(str, Enum):
""" strong = "strong"
Security level configuration (from most to least restrictive) normal = "normal"
""" normal_ = "normal-"
weak = "weak"
strong = 'strong'
normal = 'normal'
normal_ = 'normal-'
weak = 'weak'
class RiskLevel(Enum): class RiskLevel(str, Enum):
""" block = "block"
Risk classification for operations high = "high"
""" middle = "middle"
block = 'block'
high = 'high'
middle = 'middle'
class UpdateState(Enum): class UpdateState(Enum):
""" false = "false"
Update availability status true = "true"
"""
false = 'false'
true = 'true'
class ManagerPack(ManagerPackInfo): class ManagerPack(ManagerPackInfo):
@ -168,339 +124,333 @@ class ManagerPack(ManagerPackInfo):
) )
files: Optional[List[str]] = Field( files: Optional[List[str]] = Field(
None, None,
description='Repository URLs for installation (typically contains one GitHub URL)', description="Repository URLs for installation (typically contains one GitHub URL)",
) )
reference: Optional[str] = Field( reference: Optional[str] = Field(
None, description='The type of installation reference' None, description="The type of installation reference"
) )
title: Optional[str] = Field(None, description='The display name of the pack') title: Optional[str] = Field(None, description="The display name of the pack")
cnr_latest: Optional[SelectedVersion] = None cnr_latest: Optional[SelectedVersion] = None
repository: Optional[str] = Field(None, description='GitHub repository URL') repository: Optional[str] = Field(None, description="GitHub repository URL")
state: Optional[ManagerPackState] = None state: Optional[ManagerPackState] = None
update_state: Optional[UpdateState] = Field( update_state: Optional[UpdateState] = Field(
None, alias='update-state', description='Update availability status' None, alias="update-state", description="Update availability status"
) )
stars: Optional[int] = Field(None, description='GitHub stars count') stars: Optional[int] = Field(None, description="GitHub stars count")
last_update: Optional[datetime] = Field(None, description='Last update timestamp') last_update: Optional[datetime] = Field(None, description="Last update timestamp")
health: Optional[str] = Field(None, description='Health status of the pack') health: Optional[str] = Field(None, description="Health status of the pack")
description: Optional[str] = Field(None, description='Pack description') description: Optional[str] = Field(None, description="Pack description")
trust: Optional[bool] = Field(None, description='Whether the pack is trusted') trust: Optional[bool] = Field(None, description="Whether the pack is trusted")
install_type: Optional[ManagerPackInstallType] = None install_type: Optional[ManagerPackInstallType] = None
class InstallPackParams(ManagerPackInfo): class InstallPackParams(ManagerPackInfo):
selected_version: Union[str, SelectedVersion] = Field( selected_version: Union[str, SelectedVersion] = Field(
..., description='Semantic version, Git commit hash, latest, or nightly' ..., description="Semantic version, Git commit hash, latest, or nightly"
) )
repository: Optional[str] = Field( repository: Optional[str] = Field(
None, None,
description='GitHub repository URL (required if selected_version is nightly)', description="GitHub repository URL (required if selected_version is nightly)",
) )
pip: Optional[List[str]] = Field(None, description='PyPi dependency names') pip: Optional[List[str]] = Field(None, description="PyPi dependency names")
mode: ManagerDatabaseSource mode: ManagerDatabaseSource
channel: ManagerChannel channel: ManagerChannel
skip_post_install: Optional[bool] = Field( skip_post_install: Optional[bool] = Field(
None, description='Whether to skip post-installation steps' None, description="Whether to skip post-installation steps"
) )
class UpdateAllPacksParams(BaseModel): class UpdateAllPacksParams(BaseModel):
mode: Optional[ManagerDatabaseSource] = None mode: Optional[ManagerDatabaseSource] = None
ui_id: Optional[str] = Field(None, description='Task ID - generated internally') ui_id: Optional[str] = Field(None, description="Task ID - generated internally")
class UpdatePackParams(BaseModel): class UpdatePackParams(BaseModel):
node_name: str = Field(..., description='Name of the node package to update') node_name: str = Field(..., description="Name of the node package to update")
node_ver: Optional[str] = Field( node_ver: Optional[str] = Field(
None, description='Current version of the node package' None, description="Current version of the node package"
) )
class UpdateComfyUIParams(BaseModel): class UpdateComfyUIParams(BaseModel):
is_stable: Optional[bool] = Field( is_stable: Optional[bool] = Field(
True, True,
description='Whether to update to stable version (true) or nightly (false)', description="Whether to update to stable version (true) or nightly (false)",
) )
target_version: Optional[str] = Field( target_version: Optional[str] = Field(
None, None,
description='Specific version to switch to (for version switching operations)', description="Specific version to switch to (for version switching operations)",
) )
class FixPackParams(BaseModel): class FixPackParams(BaseModel):
node_name: str = Field(..., description='Name of the node package to fix') node_name: str = Field(..., description="Name of the node package to fix")
node_ver: str = Field(..., description='Version of the node package') node_ver: str = Field(..., description="Version of the node package")
class UninstallPackParams(BaseModel): class UninstallPackParams(BaseModel):
node_name: str = Field(..., description='Name of the node package to uninstall') node_name: str = Field(..., description="Name of the node package to uninstall")
is_unknown: Optional[bool] = Field( is_unknown: Optional[bool] = Field(
False, description='Whether this is an unknown/unregistered package' False, description="Whether this is an unknown/unregistered package"
) )
class DisablePackParams(BaseModel): class DisablePackParams(BaseModel):
node_name: str = Field(..., description='Name of the node package to disable') node_name: str = Field(..., description="Name of the node package to disable")
is_unknown: Optional[bool] = Field( is_unknown: Optional[bool] = Field(
False, description='Whether this is an unknown/unregistered package' False, description="Whether this is an unknown/unregistered package"
) )
class EnablePackParams(BaseModel): class EnablePackParams(BaseModel):
cnr_id: str = Field( cnr_id: str = Field(
..., description='ComfyUI Node Registry ID of the package to enable' ..., description="ComfyUI Node Registry ID of the package to enable"
) )
class UpdateAllQueryParams(BaseModel): class UpdateAllQueryParams(BaseModel):
client_id: str = Field( client_id: str = Field(
..., description='Client identifier that initiated the request' ..., description="Client identifier that initiated the request"
) )
ui_id: str = Field(..., description='Base UI identifier for task tracking') ui_id: str = Field(..., description="Base UI identifier for task tracking")
mode: Optional[ManagerDatabaseSource] = None mode: Optional[ManagerDatabaseSource] = None
class UpdateComfyUIQueryParams(BaseModel): class UpdateComfyUIQueryParams(BaseModel):
client_id: str = Field( client_id: str = Field(
..., description='Client identifier that initiated the request' ..., description="Client identifier that initiated the request"
) )
ui_id: str = Field(..., description='UI identifier for task tracking') ui_id: str = Field(..., description="UI identifier for task tracking")
stable: Optional[bool] = Field( stable: Optional[bool] = Field(
True, True,
description='Whether to update to stable version (true) or nightly (false)', description="Whether to update to stable version (true) or nightly (false)",
) )
class ComfyUISwitchVersionQueryParams(BaseModel): class ComfyUISwitchVersionQueryParams(BaseModel):
ver: str = Field(..., description='Version to switch to') ver: str = Field(..., description="Version to switch to")
client_id: str = Field( client_id: str = Field(
..., description='Client identifier that initiated the request' ..., description="Client identifier that initiated the request"
) )
ui_id: str = Field(..., description='UI identifier for task tracking') ui_id: str = Field(..., description="UI identifier for task tracking")
class QueueStatus(BaseModel): class QueueStatus(BaseModel):
total_count: int = Field( total_count: int = Field(
..., description='Total number of tasks (pending + running)' ..., description="Total number of tasks (pending + running)"
) )
done_count: int = Field(..., description='Number of completed tasks') done_count: int = Field(..., description="Number of completed tasks")
in_progress_count: int = Field(..., description='Number of tasks currently running') in_progress_count: int = Field(..., description="Number of tasks currently running")
pending_count: Optional[int] = Field( pending_count: Optional[int] = Field(
None, description='Number of tasks waiting to be executed' None, description="Number of tasks waiting to be executed"
) )
is_processing: bool = Field(..., description='Whether the task worker is active') is_processing: bool = Field(..., description="Whether the task worker is active")
client_id: Optional[str] = Field( client_id: Optional[str] = Field(
None, description='Client ID (when filtered by client)' None, description="Client ID (when filtered by client)"
) )
class ManagerMappings1(BaseModel): class ManagerMappings1(BaseModel):
title_aux: Optional[str] = Field(None, description='The display name of the pack') title_aux: Optional[str] = Field(None, description="The display name of the pack")
class ManagerMappings(BaseModel): class ManagerMappings(
__root__: Optional[Dict[str, List[Union[List[str], ManagerMappings1]]]] = Field( RootModel[Optional[Dict[str, List[Union[List[str], ManagerMappings1]]]]]
None, description='Tuple of [node_names, metadata]' ):
root: Optional[Dict[str, List[Union[List[str], ManagerMappings1]]]] = Field(
None, description="Tuple of [node_names, metadata]"
) )
class ModelMetadata(BaseModel): class ModelMetadata(BaseModel):
name: str = Field(..., description='Name of the model') name: str = Field(..., description="Name of the model")
type: str = Field(..., description='Type of model') type: str = Field(..., description="Type of model")
base: Optional[str] = Field(None, description='Base model type') base: Optional[str] = Field(None, description="Base model type")
save_path: Optional[str] = Field(None, description='Path for saving the model') save_path: Optional[str] = Field(None, description="Path for saving the model")
url: str = Field(..., description='Download URL') url: str = Field(..., description="Download URL")
filename: str = Field(..., description='Target filename') filename: str = Field(..., description="Target filename")
ui_id: Optional[str] = Field(None, description='ID for UI reference') ui_id: Optional[str] = Field(None, description="ID for UI reference")
class InstallType(Enum): class InstallType(str, Enum):
""" git = "git"
Installation method copy = "copy"
""" pip = "pip"
git = 'git'
copy = 'copy'
pip = 'pip'
class NodePackageMetadata(BaseModel): class NodePackageMetadata(BaseModel):
title: Optional[str] = Field(None, description='Display name of the node package') title: Optional[str] = Field(None, description="Display name of the node package")
name: Optional[str] = Field(None, description='Repository/package name') name: Optional[str] = Field(None, description="Repository/package name")
files: Optional[List[str]] = Field(None, description='Source URLs for the package') files: Optional[List[str]] = Field(None, description="Source URLs for the package")
description: Optional[str] = Field( description: Optional[str] = Field(
None, description='Description of the node package functionality' None, description="Description of the node package functionality"
) )
install_type: Optional[InstallType] = Field(None, description='Installation method') install_type: Optional[InstallType] = Field(None, description="Installation method")
version: Optional[str] = Field(None, description='Version identifier') version: Optional[str] = Field(None, description="Version identifier")
id: Optional[str] = Field( id: Optional[str] = Field(
None, description='Unique identifier for the node package' None, description="Unique identifier for the node package"
) )
ui_id: Optional[str] = Field(None, description='ID for UI reference') ui_id: Optional[str] = Field(None, description="ID for UI reference")
channel: Optional[str] = Field(None, description='Source channel') channel: Optional[str] = Field(None, description="Source channel")
mode: Optional[str] = Field(None, description='Source mode') mode: Optional[str] = Field(None, description="Source mode")
class SnapshotItem(BaseModel): class SnapshotItem(RootModel[str]):
__root__: str = Field(..., description='Name of the snapshot') root: str = Field(..., description="Name of the snapshot")
class Error(BaseModel): class Error(BaseModel):
error: str = Field(..., description='Error message') error: str = Field(..., description="Error message")
class InstalledPacksResponse(BaseModel): class InstalledPacksResponse(RootModel[Optional[Dict[str, ManagerPackInstalled]]]):
""" root: Optional[Dict[str, ManagerPackInstalled]] = None
Map of pack names to their installation info
"""
__root__: Optional[Dict[str, ManagerPackInstalled]] = None
class HistoryListResponse(BaseModel): class HistoryListResponse(BaseModel):
ids: Optional[List[str]] = Field( ids: Optional[List[str]] = Field(
None, description='List of available batch history IDs' None, description="List of available batch history IDs"
) )
class InstalledNodeInfo(BaseModel): class InstalledNodeInfo(BaseModel):
name: str = Field(..., description='Node package name') name: str = Field(..., description="Node package name")
version: str = Field(..., description='Installed version') version: str = Field(..., description="Installed version")
repository_url: Optional[str] = Field(None, description='Git repository URL') repository_url: Optional[str] = Field(None, description="Git repository URL")
install_method: str = Field( install_method: str = Field(
..., description='Installation method (cnr, git, pip, etc.)' ..., description="Installation method (cnr, git, pip, etc.)"
) )
enabled: Optional[bool] = Field( enabled: Optional[bool] = Field(
True, description='Whether the node is currently enabled' True, description="Whether the node is currently enabled"
) )
install_date: Optional[datetime] = Field( install_date: Optional[datetime] = Field(
None, description='ISO timestamp of installation' None, description="ISO timestamp of installation"
) )
class InstalledModelInfo(BaseModel): class InstalledModelInfo(BaseModel):
name: str = Field(..., description='Model filename') name: str = Field(..., description="Model filename")
path: str = Field(..., description='Full path to model file') path: str = Field(..., description="Full path to model file")
type: str = Field(..., description='Model type (checkpoint, lora, vae, etc.)') type: str = Field(..., description="Model type (checkpoint, lora, vae, etc.)")
size_bytes: Optional[int] = Field(None, description='File size in bytes', ge=0) size_bytes: Optional[int] = Field(None, description="File size in bytes", ge=0)
hash: Optional[str] = Field(None, description='Model file hash for verification') hash: Optional[str] = Field(None, description="Model file hash for verification")
install_date: Optional[datetime] = Field( install_date: Optional[datetime] = Field(
None, description='ISO timestamp when added' None, description="ISO timestamp when added"
) )
class ComfyUIVersionInfo(BaseModel): class ComfyUIVersionInfo(BaseModel):
version: str = Field(..., description='ComfyUI version string') version: str = Field(..., description="ComfyUI version string")
commit_hash: Optional[str] = Field(None, description='Git commit hash') commit_hash: Optional[str] = Field(None, description="Git commit hash")
branch: Optional[str] = Field(None, description='Git branch name') branch: Optional[str] = Field(None, description="Git branch name")
is_stable: Optional[bool] = Field( is_stable: Optional[bool] = Field(
False, description='Whether this is a stable release' False, description="Whether this is a stable release"
) )
last_updated: Optional[datetime] = Field( last_updated: Optional[datetime] = Field(
None, description='ISO timestamp of last update' None, description="ISO timestamp of last update"
) )
class BatchOperation(BaseModel): class BatchOperation(BaseModel):
operation_id: str = Field(..., description='Unique operation identifier') operation_id: str = Field(..., description="Unique operation identifier")
operation_type: OperationType operation_type: OperationType
target: str = Field( target: str = Field(
..., description='Target of the operation (node name, model name, etc.)' ..., description="Target of the operation (node name, model name, etc.)"
) )
target_version: Optional[str] = Field( target_version: Optional[str] = Field(
None, description='Target version for the operation' None, description="Target version for the operation"
) )
result: OperationResult result: OperationResult
error_message: Optional[str] = Field( error_message: Optional[str] = Field(
None, description='Error message if operation failed' None, description="Error message if operation failed"
) )
start_time: datetime = Field( start_time: datetime = Field(
..., description='ISO timestamp when operation started' ..., description="ISO timestamp when operation started"
) )
end_time: Optional[datetime] = Field( end_time: Optional[datetime] = Field(
None, description='ISO timestamp when operation completed' None, description="ISO timestamp when operation completed"
) )
client_id: Optional[str] = Field( client_id: Optional[str] = Field(
None, description='Client that initiated the operation' None, description="Client that initiated the operation"
) )
class ComfyUISystemState(BaseModel): class ComfyUISystemState(BaseModel):
snapshot_time: datetime = Field( snapshot_time: datetime = Field(
..., description='ISO timestamp when snapshot was taken' ..., description="ISO timestamp when snapshot was taken"
) )
comfyui_version: ComfyUIVersionInfo comfyui_version: ComfyUIVersionInfo
frontend_version: Optional[str] = Field( frontend_version: Optional[str] = Field(
None, description='ComfyUI frontend version if available' None, description="ComfyUI frontend version if available"
) )
python_version: str = Field(..., description='Python interpreter version') python_version: str = Field(..., description="Python interpreter version")
platform_info: str = Field( platform_info: str = Field(
..., description='Operating system and platform information' ..., description="Operating system and platform information"
) )
installed_nodes: Optional[Dict[str, InstalledNodeInfo]] = Field( installed_nodes: Optional[Dict[str, InstalledNodeInfo]] = Field(
None, description='Map of installed node packages by name' None, description="Map of installed node packages by name"
) )
installed_models: Optional[Dict[str, InstalledModelInfo]] = Field( installed_models: Optional[Dict[str, InstalledModelInfo]] = Field(
None, description='Map of installed models by name' None, description="Map of installed models by name"
) )
manager_config: Optional[Dict[str, Any]] = Field( manager_config: Optional[Dict[str, Any]] = Field(
None, description='ComfyUI Manager configuration settings' None, description="ComfyUI Manager configuration settings"
) )
comfyui_root_path: Optional[str] = Field( comfyui_root_path: Optional[str] = Field(
None, description='ComfyUI root installation directory' None, description="ComfyUI root installation directory"
) )
model_paths: Optional[Dict[str, List[str]]] = Field( model_paths: Optional[Dict[str, List[str]]] = Field(
None, description='Map of model types to their configured paths' None, description="Map of model types to their configured paths"
) )
manager_version: Optional[str] = Field(None, description='ComfyUI Manager version') manager_version: Optional[str] = Field(None, description="ComfyUI Manager version")
security_level: Optional[SecurityLevel] = None security_level: Optional[SecurityLevel] = None
network_mode: Optional[str] = Field( network_mode: Optional[str] = Field(
None, description='Network mode (online, offline, private)' None, description="Network mode (online, offline, private)"
) )
cli_args: Optional[Dict[str, Any]] = Field( cli_args: Optional[Dict[str, Any]] = Field(
None, description='Selected ComfyUI CLI arguments' None, description="Selected ComfyUI CLI arguments"
) )
custom_nodes_count: Optional[int] = Field( custom_nodes_count: Optional[int] = Field(
None, description='Total number of custom node packages', ge=0 None, description="Total number of custom node packages", ge=0
) )
failed_imports: Optional[List[str]] = Field( failed_imports: Optional[List[str]] = Field(
None, description='List of custom nodes that failed to import' None, description="List of custom nodes that failed to import"
) )
pip_packages: Optional[Dict[str, str]] = Field( pip_packages: Optional[Dict[str, str]] = Field(
None, description='Map of installed pip packages to their versions' None, description="Map of installed pip packages to their versions"
) )
class BatchExecutionRecord(BaseModel): class BatchExecutionRecord(BaseModel):
batch_id: str = Field(..., description='Unique batch identifier') batch_id: str = Field(..., description="Unique batch identifier")
start_time: datetime = Field(..., description='ISO timestamp when batch started') start_time: datetime = Field(..., description="ISO timestamp when batch started")
end_time: Optional[datetime] = Field( end_time: Optional[datetime] = Field(
None, description='ISO timestamp when batch completed' None, description="ISO timestamp when batch completed"
) )
state_before: ComfyUISystemState state_before: ComfyUISystemState
state_after: Optional[ComfyUISystemState] = Field( state_after: Optional[ComfyUISystemState] = Field(
None, description='System state after batch execution' None, description="System state after batch execution"
) )
operations: Optional[List[BatchOperation]] = Field( operations: Optional[List[BatchOperation]] = Field(
None, description='List of operations performed in this batch' None, description="List of operations performed in this batch"
) )
total_operations: Optional[int] = Field( total_operations: Optional[int] = Field(
0, description='Total number of operations in batch', ge=0 0, description="Total number of operations in batch", ge=0
) )
successful_operations: Optional[int] = Field( successful_operations: Optional[int] = Field(
0, description='Number of successful operations', ge=0 0, description="Number of successful operations", ge=0
) )
failed_operations: Optional[int] = Field( failed_operations: Optional[int] = Field(
0, description='Number of failed operations', ge=0 0, description="Number of failed operations", ge=0
) )
skipped_operations: Optional[int] = Field( skipped_operations: Optional[int] = Field(
0, description='Number of skipped operations', ge=0 0, description="Number of skipped operations", ge=0
) )
class QueueTaskItem(BaseModel): class QueueTaskItem(BaseModel):
ui_id: str = Field(..., description='Unique identifier for the task') ui_id: str = Field(..., description="Unique identifier for the task")
client_id: str = Field(..., description='Client identifier that initiated the task') client_id: str = Field(..., description="Client identifier that initiated the task")
kind: OperationType kind: OperationType
params: Union[ params: Union[
InstallPackParams, InstallPackParams,
@ -516,60 +466,62 @@ class QueueTaskItem(BaseModel):
class TaskHistoryItem(BaseModel): class TaskHistoryItem(BaseModel):
ui_id: str = Field(..., description='Unique identifier for the task') ui_id: str = Field(..., description="Unique identifier for the task")
client_id: str = Field(..., description='Client identifier that initiated the task') client_id: str = Field(..., description="Client identifier that initiated the task")
kind: str = Field(..., description='Type of task that was performed') kind: str = Field(..., description="Type of task that was performed")
timestamp: datetime = Field(..., description='ISO timestamp when task completed') timestamp: datetime = Field(..., description="ISO timestamp when task completed")
result: str = Field(..., description='Task result message or details') result: str = Field(..., description="Task result message or details")
status: Optional[TaskExecutionStatus] = None status: Optional[TaskExecutionStatus] = None
class TaskStateMessage(BaseModel): class TaskStateMessage(BaseModel):
history: Dict[str, TaskHistoryItem] = Field( history: Dict[str, TaskHistoryItem] = Field(
..., description='Map of task IDs to their history items' ..., description="Map of task IDs to their history items"
) )
running_queue: List[QueueTaskItem] = Field( running_queue: List[QueueTaskItem] = Field(
..., description='Currently executing tasks' ..., description="Currently executing tasks"
) )
pending_queue: List[QueueTaskItem] = Field( pending_queue: List[QueueTaskItem] = Field(
..., description='Tasks waiting to be executed' ..., description="Tasks waiting to be executed"
) )
installed_packs: Dict[str, ManagerPackInstalled] = Field( installed_packs: Dict[str, ManagerPackInstalled] = Field(
..., description='Map of currently installed node packages by name' ..., description="Map of currently installed node packages by name"
) )
class MessageTaskDone(BaseModel): class MessageTaskDone(BaseModel):
ui_id: str = Field(..., description='Task identifier') ui_id: str = Field(..., description="Task identifier")
result: str = Field(..., description='Task result message') result: str = Field(..., description="Task result message")
kind: str = Field(..., description='Type of task') kind: str = Field(..., description="Type of task")
status: Optional[TaskExecutionStatus] = None status: Optional[TaskExecutionStatus] = None
timestamp: datetime = Field(..., description='ISO timestamp when task completed') timestamp: datetime = Field(..., description="ISO timestamp when task completed")
state: TaskStateMessage state: TaskStateMessage
class MessageTaskStarted(BaseModel): class MessageTaskStarted(BaseModel):
ui_id: str = Field(..., description='Task identifier') ui_id: str = Field(..., description="Task identifier")
kind: str = Field(..., description='Type of task') kind: str = Field(..., description="Type of task")
timestamp: datetime = Field(..., description='ISO timestamp when task started') timestamp: datetime = Field(..., description="ISO timestamp when task started")
state: TaskStateMessage state: TaskStateMessage
class MessageTaskFailed(BaseModel): class MessageTaskFailed(BaseModel):
ui_id: str = Field(..., description='Task identifier') ui_id: str = Field(..., description="Task identifier")
error: str = Field(..., description='Error message') error: str = Field(..., description="Error message")
kind: str = Field(..., description='Type of task') kind: str = Field(..., description="Type of task")
timestamp: datetime = Field(..., description='ISO timestamp when task failed') timestamp: datetime = Field(..., description="ISO timestamp when task failed")
state: TaskStateMessage state: TaskStateMessage
class MessageUpdate(BaseModel): class MessageUpdate(
__root__: Union[MessageTaskDone, MessageTaskStarted, MessageTaskFailed] = Field( RootModel[Union[MessageTaskDone, MessageTaskStarted, MessageTaskFailed]]
..., description='Union type for all possible WebSocket message updates' ):
root: Union[MessageTaskDone, MessageTaskStarted, MessageTaskFailed] = Field(
..., description="Union type for all possible WebSocket message updates"
) )
class HistoryResponse(BaseModel): class HistoryResponse(BaseModel):
history: Optional[Dict[str, TaskHistoryItem]] = Field( history: Optional[Dict[str, TaskHistoryItem]] = Field(
None, description='Map of task IDs to their history items' None, description="Map of task IDs to their history items"
) )