agent-builder-agentic-mcp-aws-transform 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. agent_builder_agentic_mcp/__init__.py +3 -0
  2. agent_builder_agentic_mcp/__main__.py +30 -0
  3. agent_builder_agentic_mcp/_auth_refresher.py +166 -0
  4. agent_builder_agentic_mcp/client.py +89 -0
  5. agent_builder_agentic_mcp/custom_types/__init__.py +2 -0
  6. agent_builder_agentic_mcp/custom_types/hitl/__init__.py +2 -0
  7. agent_builder_agentic_mcp/custom_types/hitl/auto_form.py +337 -0
  8. agent_builder_agentic_mcp/custom_types/hitl/table.py +58 -0
  9. agent_builder_agentic_mcp/custom_types/message_types.py +34 -0
  10. agent_builder_agentic_mcp/datamodels.py +298 -0
  11. agent_builder_agentic_mcp/env_var.py +80 -0
  12. agent_builder_agentic_mcp/main.py +140 -0
  13. agent_builder_agentic_mcp/py.typed +1 -0
  14. agent_builder_agentic_mcp/server/__init__.py +25 -0
  15. agent_builder_agentic_mcp/server/_advanced_tools.py +406 -0
  16. agent_builder_agentic_mcp/server/_agent_instance_tools.py +253 -0
  17. agent_builder_agentic_mcp/server/_artifact_store_tools.py +582 -0
  18. agent_builder_agentic_mcp/server/_auth_handler.py +102 -0
  19. agent_builder_agentic_mcp/server/_hitl_tools.py +300 -0
  20. agent_builder_agentic_mcp/server/_inject_qt_request_context.py +40 -0
  21. agent_builder_agentic_mcp/server/_job_tools.py +410 -0
  22. agent_builder_agentic_mcp/server/_kb_tools.py +60 -0
  23. agent_builder_agentic_mcp/server/_message_tools.py +126 -0
  24. agent_builder_agentic_mcp/server/_server.py +11 -0
  25. agent_builder_agentic_mcp/utils.py +26 -0
  26. agent_builder_agentic_mcp_aws_transform-1.0.0.dist-info/METADATA +81 -0
  27. agent_builder_agentic_mcp_aws_transform-1.0.0.dist-info/RECORD +33 -0
  28. agent_builder_agentic_mcp_aws_transform-1.0.0.dist-info/WHEEL +5 -0
  29. agent_builder_agentic_mcp_aws_transform-1.0.0.dist-info/entry_points.txt +2 -0
  30. agent_builder_agentic_mcp_aws_transform-1.0.0.dist-info/licenses/LICENSE.txt +175 -0
  31. agent_builder_agentic_mcp_aws_transform-1.0.0.dist-info/licenses/NOTICE +1 -0
  32. agent_builder_agentic_mcp_aws_transform-1.0.0.dist-info/licenses/THIRD-PARTY-NOTICES.txt +848 -0
  33. agent_builder_agentic_mcp_aws_transform-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,3 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """Agent Builder Agentic MCP server for AWS Transform."""
@@ -0,0 +1,30 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """
4
+ Main entry point for the package when run as a module.
5
+
6
+ This allows the package to be run with:
7
+ python -m agent_builder_agentic_mcp
8
+ """
9
+
10
+ import logging
11
+ import sys
12
+
13
+ from agent_builder_agentic_mcp.main import main
14
+
15
+ logging.basicConfig(
16
+ level=logging.INFO,
17
+ format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
18
+ filename="/tmp/atx-mcp-server.log", # Log to file to avoid interfering with stdio
19
+ )
20
+ logger = logging.getLogger(__name__)
21
+
22
+ if __name__ == "__main__":
23
+ try:
24
+ main()
25
+ sys.exit(0)
26
+ except Exception as e:
27
+ logger.error(
28
+ f"Unhandled exception in main: {str(e)}",
29
+ )
30
+ sys.exit(1)
@@ -0,0 +1,166 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ import datetime
4
+ import functools
5
+ import logging
6
+ import os
7
+ import time
8
+ from multiprocessing import Process
9
+ from typing import Any, Dict
10
+
11
+ from agent_builder_agentic_mcp.client import atx_agenticapi_client
12
+ from agent_builder_agentic_mcp.env_var import ENV_KEY_QT_AUTH_TOKEN_FILE
13
+ from agent_builder_agentic_mcp.server._inject_qt_request_context import _inject_qt_request_context
14
+
15
+ # Configure logging
16
+ logging.basicConfig(
17
+ level=logging.INFO,
18
+ format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
19
+ filename="/tmp/qt-mcp-server.log", # Log to file to avoid interfering with stdio
20
+ )
21
+ logger = logging.getLogger(__name__)
22
+
23
+ SAFETY_FACTOR = 0.5 # Refresh at 50% of token lifetime
24
+ MIN_SLEEP_SECONDS = 60
25
+ ERROR_RETRY_SECONDS = 60
26
+ SESSION_DURATION = 43200
27
+
28
+
29
+ class AuthTokenRefresher:
30
+ def __init__(self) -> None:
31
+ """Initialize the AuthTokenRefresher and start the token refresh process."""
32
+ logger.info("Initializing AuthTokenRefresher")
33
+ self._child_process = self.start_child_process_for_token_refresh()
34
+
35
+ def start_child_process_for_token_refresh(self) -> Process:
36
+ """
37
+ Start a child process that handles token refreshing.
38
+
39
+ Returns:
40
+ Process: The started child process
41
+ """
42
+ logger.info("Starting token refresh child process")
43
+ process = Process(target=self._auth_process_main, daemon=True)
44
+ process.start()
45
+ logger.info(f"Token refresh process started with PID {process.pid}")
46
+ return process
47
+
48
+ @property
49
+ def child_process(self) -> Process:
50
+ """
51
+ Get the child process that handles token refreshing.
52
+
53
+ Returns:
54
+ Process: The token refresh child process
55
+ """
56
+ return self._child_process
57
+
58
+ def _auth_process_main(self) -> None:
59
+ """
60
+ Main function for the token refresh process.
61
+ Continuously refreshes the token and sleeps until next refresh.
62
+ """
63
+ logger.info("Starting token refresh process")
64
+
65
+ while True:
66
+ try:
67
+ time_to_sleep = self._refresh_token()
68
+ logger.info(f"Sleeping for {time_to_sleep} seconds before next token refresh")
69
+ time.sleep(time_to_sleep)
70
+ except KeyboardInterrupt:
71
+ logger.info("Token refresh process interrupted, shutting down gracefully")
72
+ break
73
+ except Exception:
74
+ logger.warning("Token refresh process error, retrying: ", exc_info=True)
75
+ time.sleep(ERROR_RETRY_SECONDS)
76
+ logger.info("Token refresh process stopped")
77
+
78
+ def _refresh_token(self) -> int:
79
+ """
80
+ Refresh the authentication token and calculate time to sleep until next refresh.
81
+
82
+ Returns:
83
+ int: Number of seconds to sleep before next refresh
84
+ """
85
+ logger.info("Refreshing authentication token")
86
+
87
+ try:
88
+ refresh_token_response = self._refresh_auth_token_from_agentic_api()
89
+ refreshed_auth_token = refresh_token_response["authorizationToken"]
90
+ expiration_timestamp = refresh_token_response["authorizationExpiration"]
91
+
92
+ # Write token back to the file
93
+ self._write_token_to_file(refreshed_auth_token)
94
+
95
+ # Calculate time to sleep based on expiration timestamp
96
+ now = datetime.datetime.now(datetime.timezone.utc)
97
+
98
+ # Refresh at 50% of remaining lifetime to provide hours of retry
99
+ # headroom instead of seconds. For a 12h token this means refreshing
100
+ # at ~6h, giving plenty of time to retry on transient failures.
101
+ remaining = (expiration_timestamp - now).total_seconds()
102
+ time_diff = remaining * SAFETY_FACTOR
103
+
104
+ seconds_to_sleep = max(MIN_SLEEP_SECONDS, time_diff)
105
+
106
+ logger.info(f"Token will expire at {expiration_timestamp.isoformat()}")
107
+ logger.info(f"Next token refresh in {seconds_to_sleep:.2f} seconds")
108
+
109
+ # Return time to sleep in seconds
110
+ return int(seconds_to_sleep)
111
+
112
+ except Exception as e:
113
+ logger.error(f"Error refreshing token: {str(e)}")
114
+ # If there's an error, retry after a short delay
115
+ return ERROR_RETRY_SECONDS
116
+
117
+ def _write_token_to_file(self, auth_token: str) -> None:
118
+ """
119
+ Write the authentication token to the token file.
120
+
121
+ Args:
122
+ auth_token: The authentication token to write
123
+ """
124
+ logger.info("Writing token to file")
125
+
126
+ try:
127
+ auth_token_file_path = os.environ.get(ENV_KEY_QT_AUTH_TOKEN_FILE)
128
+ if auth_token_file_path is None:
129
+ logger.error(f"Environment variable {ENV_KEY_QT_AUTH_TOKEN_FILE} not set")
130
+ return
131
+
132
+ with open(auth_token_file_path, "w") as file:
133
+ file.write(f"ATX_AUTHZ_TOKEN={auth_token}")
134
+ file.flush()
135
+
136
+ logger.info("Token successfully written to file")
137
+ except Exception as e:
138
+ logger.error(f"Error writing token to file: {str(e)}")
139
+
140
+ def _refresh_auth_token_from_agentic_api(self) -> Dict[str, Any]:
141
+ """
142
+ Call the Agentic API to refresh the authentication token.
143
+
144
+ Returns:
145
+ Dict[str, Any]: Response containing the new token and expiration
146
+ """
147
+ logger.info("Calling Agentic API to refresh token")
148
+
149
+ client = atx_agenticapi_client()
150
+ kwargs: Dict[str, Any] = {"sessionDuration": SESSION_DURATION} # 12 hours in seconds
151
+ response = client.refresh_auth_token(**_inject_qt_request_context(kwargs=kwargs))
152
+
153
+ logger.info("Successfully refreshed token from Agentic API")
154
+ return dict(response)
155
+
156
+
157
+ @functools.lru_cache(maxsize=1)
158
+ def get_auth_token_refresher() -> AuthTokenRefresher:
159
+ """
160
+ Start the authentication token refresher as a singleton.
161
+
162
+ Returns:
163
+ AuthTokenRefresher: Singleton instance of the AuthTokenRefresher
164
+ """
165
+ logger.info("Starting AuthTokenRefresher singleton")
166
+ return AuthTokenRefresher()
@@ -0,0 +1,89 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """
4
+ Client utilities for the AWS Transform Agentic API.
5
+
6
+ This module provides utility functions for creating and configuring
7
+ boto3 clients for the AWS Transform Agentic API.
8
+ """
9
+
10
+ import functools
11
+ import logging
12
+ import os
13
+ from typing import Optional
14
+
15
+ import boto3
16
+ from botocore.client import BaseClient
17
+ from botocore.config import Config as BotocoreConfig
18
+
19
+ from agent_builder_agentic_mcp import env_var
20
+
21
+ logging.basicConfig(
22
+ level=logging.INFO,
23
+ format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
24
+ filename="/tmp/atx-mcp-server.log", # Log to file to avoid interfering with stdio
25
+ )
26
+ logger = logging.getLogger(__name__)
27
+
28
+ ATX_AGENTIC_API_SERVICE_NAME = "transformagenticservice"
29
+ ATX_EXTERNAL_AGENTIC_API_SERVICE_NAME = "transformagenticservice"
30
+
31
+
32
+ @functools.lru_cache(maxsize=1)
33
+ def atx_agenticapi_client() -> BaseClient:
34
+ return create_atx_agenticapi_client()
35
+
36
+
37
+ def create_atx_agenticapi_client(
38
+ endpoint_url: Optional[str] = None,
39
+ region: Optional[str] = None,
40
+ max_retries: int = 3,
41
+ timeout: int = 30,
42
+ use_external_agentic_api: Optional[bool] = None,
43
+ ) -> BaseClient:
44
+ """
45
+ Create a boto3 client for the AWS Transform Agentic API.
46
+
47
+ Args:
48
+ endpoint_url: Custom endpoint URL (defaults to environment variable or standard endpoint)
49
+ region: AWS region (defaults to environment variable or us-west-2)
50
+ max_retries: Maximum number of retries for API calls
51
+ timeout: Timeout in seconds for API calls
52
+ use_external_agentic_api: flag to use external_agentic_api(service_name: transformagents)
53
+
54
+ Returns:
55
+ A configured boto3 client
56
+ """
57
+ region = region or os.environ.get("AWS_REGION", "us-east-1")
58
+ use_external_agentic_api = use_external_agentic_api or (
59
+ os.environ.get(env_var.ENV_KEY_USE_EXTERNAL_AGENTIC_API, "False").lower() == "true"
60
+ )
61
+ endpoint_url = endpoint_url or os.environ[env_var.ENV_KEY_QT_AGENTIC_API_ENDPOINT]
62
+
63
+ boto_config = BotocoreConfig(
64
+ retries={"max_attempts": max_retries, "mode": "standard"},
65
+ connect_timeout=timeout,
66
+ read_timeout=timeout,
67
+ )
68
+
69
+ boto3_service_name = (
70
+ ATX_EXTERNAL_AGENTIC_API_SERVICE_NAME
71
+ if use_external_agentic_api
72
+ else ATX_AGENTIC_API_SERVICE_NAME
73
+ )
74
+ logger.info(
75
+ f"Inside MCP package - endpoint url: {endpoint_url}, service-name: {boto3_service_name}"
76
+ )
77
+
78
+ client = boto3.client(
79
+ service_name=boto3_service_name,
80
+ region_name=region,
81
+ endpoint_url=endpoint_url,
82
+ config=boto_config,
83
+ )
84
+
85
+ logger.info(
86
+ f"Client created, service: {boto3_service_name}, region: {region}, endpoint: {endpoint_url}"
87
+ )
88
+
89
+ return client
@@ -0,0 +1,2 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
@@ -0,0 +1,2 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
@@ -0,0 +1,337 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from enum import Enum
4
+ from typing import List, Literal, Optional, Union
5
+
6
+ from pydantic import BaseModel, Field
7
+
8
+
9
+ # flake8: noqa: N815
10
+ class FieldType(str, Enum):
11
+ """Enumeration of supported field types."""
12
+
13
+ TEXT = "text"
14
+ TEXTAREA = "textarea"
15
+ SELECT = "select"
16
+ RADIOGROUP = "radiogroup"
17
+ MULTISELECT = "multiselect"
18
+ CHECKBOX = "checkbox"
19
+ INFOCONTAINER = "infocontainer"
20
+ JSONBLOCK = "jsonBlock"
21
+ FILEUPLOAD = "fileUploadV2"
22
+
23
+
24
+ class FilteringType(str, Enum):
25
+ """Enumeration of supported filtering type."""
26
+
27
+ AUTO = "auto"
28
+ NONE = "none"
29
+
30
+
31
+ class InfoContainerVariantType(str, Enum):
32
+ """Enumeration of supported info container variant type."""
33
+
34
+ DEFAULT = "default"
35
+ STACKED = "stacked"
36
+
37
+
38
+ class TextFieldVariantType(str, Enum):
39
+ """Enumeration of supported text field variant type."""
40
+
41
+ TEXT = "text"
42
+ NUMBER = "number"
43
+
44
+
45
+ class SelectOption(BaseModel):
46
+ """Configuration for select/multiselect options."""
47
+
48
+ label: str = Field(..., description="Display text for the option")
49
+ value: str = Field(..., description="Value returned when option is selected")
50
+ description: Optional[str] = Field(None, description="Description for the option")
51
+
52
+
53
+ class LabelValueItem(BaseModel):
54
+ """Configuration for select/multiselect options."""
55
+
56
+ label: str = Field(..., description="The label/key for this item")
57
+ value: str = Field(..., description="The value for this item")
58
+
59
+
60
+ class RadioOption(BaseModel):
61
+ """Configuration for radio button options."""
62
+
63
+ label: str = Field(..., description="Display text for the radio option")
64
+ value: str = Field(..., description="Value returned when option is selected")
65
+ description: Optional[str] = Field(None, description="Description for the option")
66
+ disabled: Optional[bool] = Field(False, description="Whether the option is disabled")
67
+
68
+
69
+ class TextValidation(BaseModel):
70
+ """Validation rules for text and textarea fields."""
71
+
72
+ pattern: Optional[str] = Field(
73
+ None, description="Regular expression pattern for text field validation"
74
+ )
75
+ minLength: Optional[int] = Field(
76
+ None, alias="minLength", description="Minimum character length for text fields"
77
+ )
78
+ maxLength: Optional[int] = Field(
79
+ None, alias="maxLength", description="Maximum character length for text fields"
80
+ )
81
+ errorMessage: Optional[str] = Field(
82
+ None,
83
+ alias="errorMessage",
84
+ description="Custom error message displayed when validation fails",
85
+ )
86
+
87
+
88
+ class TextField(BaseModel):
89
+ """Text input field configuration."""
90
+
91
+ name: str = Field(..., description="Unique identifier for the field")
92
+ label: str = Field(..., description="Display label for the input field")
93
+ description: Optional[str] = Field(
94
+ None, description="Optional description text displayed below the label"
95
+ )
96
+ type: Literal[FieldType.TEXT]
97
+ required: bool = Field(False, description="Whether the field is required for form submission")
98
+ placeholder: Optional[str] = Field(
99
+ None, description="Placeholder text shown when field is empty"
100
+ )
101
+ validation: Optional[TextValidation] = Field(None, description="Validation rules for the field")
102
+ variant: TextFieldVariantType = Field(
103
+ TextFieldVariantType.TEXT,
104
+ description="Specifies the type of control to render (text, number).",
105
+ )
106
+
107
+
108
+ class TextareaField(BaseModel):
109
+ """Multi-line text input field configuration."""
110
+
111
+ name: str = Field(..., description="Unique identifier for the field")
112
+ label: str = Field(..., description="Display label for the textarea field")
113
+ description: Optional[str] = Field(
114
+ None, description="Optional description text displayed below the label"
115
+ )
116
+ type: Literal[FieldType.TEXTAREA]
117
+ required: bool = Field(False, description="Whether the field is required for form submission")
118
+ placeholder: Optional[str] = Field(
119
+ None, description="Placeholder text shown when field is empty"
120
+ )
121
+ rows: int = Field(3, description="Number of visible text lines for the textarea", ge=1)
122
+ validation: Optional[TextValidation] = Field(None, description="Validation rules for the field")
123
+
124
+
125
+ class SelectField(BaseModel):
126
+ """Select dropdown field configuration."""
127
+
128
+ name: str = Field(..., description="Unique identifier for the field")
129
+ label: str = Field(..., description="Display label for the select field")
130
+ description: Optional[str] = Field(
131
+ None, description="Optional description text displayed below the label"
132
+ )
133
+ type: Literal[FieldType.SELECT]
134
+ required: bool = Field(False, description="Whether the field is required for form submission")
135
+ placeholder: Optional[str] = Field(
136
+ None, description="Placeholder text shown when no option is selected"
137
+ )
138
+ options: List[SelectOption] = Field(
139
+ ..., description="Array of selectable options", min_length=1
140
+ )
141
+
142
+
143
+ class RadioGroupField(BaseModel):
144
+ """Radio group field configuration for single selection."""
145
+
146
+ name: str = Field(..., description="Unique identifier for the field")
147
+ label: str = Field(..., description="Display label for the radio group")
148
+ description: Optional[str] = Field(
149
+ None, description="Optional description text displayed below the label"
150
+ )
151
+ type: Literal[FieldType.RADIOGROUP]
152
+ required: bool = Field(False, description="Whether the field is required for form submission")
153
+ options: List[RadioOption] = Field(
154
+ ..., description="Array of radio button options", min_length=1
155
+ )
156
+ aria_label: Optional[str] = Field(
157
+ None, alias="ariaLabel", description="Accessibility label for screen readers"
158
+ )
159
+
160
+
161
+ class MultiselectField(BaseModel):
162
+ """Multiselect field configuration for multiple option selection."""
163
+
164
+ name: str = Field(..., description="Unique identifier for the field")
165
+ label: str = Field(..., description="Display label for the multiselect field")
166
+ description: Optional[str] = Field(
167
+ None, description="Optional description text displayed below the label"
168
+ )
169
+ type: Literal[FieldType.MULTISELECT]
170
+ required: bool = Field(False, description="Whether the field is required for form submission")
171
+ placeholder: Optional[str] = Field(
172
+ None, description="Placeholder text for the multiselect field"
173
+ )
174
+ options: List[SelectOption] = Field(
175
+ ..., description="Array of selectable options", min_length=1
176
+ )
177
+ filteringType: FilteringType = Field(
178
+ FilteringType.NONE,
179
+ description="Determines how filtering is applied to the list of options. 'auto' enables automatic filtering, 'none' disables filtering.",
180
+ )
181
+ enableSelectAll: bool = Field(
182
+ False,
183
+ description="Enables users to select and deselect all options with a special extra checkbox which is displayed at the start of the dropdown.",
184
+ )
185
+
186
+
187
+ class CheckboxField(BaseModel):
188
+ """Checkbox field configuration for boolean selection."""
189
+
190
+ name: str = Field(..., description="Unique identifier for the field")
191
+ label: str = Field(..., description="Display label for the checkbox field")
192
+ description: Optional[str] = Field(
193
+ None, description="Optional description text displayed below the label"
194
+ )
195
+ type: Literal[FieldType.CHECKBOX]
196
+ required: bool = Field(False, description="Whether the field is required")
197
+ default_checked: bool = Field(
198
+ False, alias="defaultChecked", description="Default checked state of the checkbox"
199
+ )
200
+
201
+
202
+ class InfoContainerField(BaseModel):
203
+ """InfoContainer field configuration for displays structured key-value information"""
204
+
205
+ name: str = Field(..., description="Unique identifier for the field")
206
+ label: Optional[str] = Field(None, description="Display label for the info container field")
207
+ type: Literal[FieldType.INFOCONTAINER]
208
+ category: Literal["display"]
209
+ header: Optional[str] = Field(None, description="Optional header text for the container")
210
+ variant: InfoContainerVariantType = Field(
211
+ InfoContainerVariantType.STACKED, description="Visual variant of the info container"
212
+ )
213
+ columns: int = Field(
214
+ 1, description="Number of columns to display the key-value pairs in", ge=1, le=4
215
+ )
216
+ items: List[LabelValueItem] = Field(
217
+ ..., description="Array of key-value pairs to display", min_length=1
218
+ )
219
+
220
+
221
+ class JsonBlockValidation(BaseModel):
222
+ """Validation configuration for JSON block field"""
223
+
224
+ errorMessage: str = Field(
225
+ "Invalid JSON format. Please check your syntax.",
226
+ description="Custom error message to display when JSON is invalid",
227
+ )
228
+
229
+
230
+ class JsonBlockField(BaseModel):
231
+ """JSON input field with validation"""
232
+
233
+ name: str = Field(
234
+ ..., description="Internal identifier for the field used for data binding and processing"
235
+ )
236
+ label: str = Field(..., description="The label text displayed for the JSON input field")
237
+ type: Literal[FieldType.JSONBLOCK]
238
+ description: Optional[str] = Field(
239
+ None,
240
+ description="The description text for the JSON field. Provides detailed information about the form field that's displayed below the label.",
241
+ )
242
+ required: bool = Field(False, description="Whether the field is required for form submission")
243
+ placeholder: str = Field(
244
+ "Enter valid JSON...", description="Placeholder text shown when field is empty"
245
+ )
246
+ rows: int = Field(6, description="Number of visible text lines for the JSON textarea", ge=1)
247
+ validation: Optional[JsonBlockValidation] = Field(None, description="Validation configuration")
248
+ initialValue: Optional[str] = Field(
249
+ None, description="Initial JSON value for the field when no data is provided"
250
+ )
251
+
252
+
253
+ class FileUploadValidation(BaseModel):
254
+ """File upload field validation rules"""
255
+
256
+ maxFileSize: Optional[int] = Field(
257
+ None, description="Maximum file size in bytes (default: 50MB)", ge=1
258
+ )
259
+ acceptedFileTypes: Optional[List[str]] = Field(
260
+ None,
261
+ description="Array of accepted MIME types (e.g., ['image/jpeg', 'image/png', 'application/pdf']). Empty array allows all types.",
262
+ )
263
+ maxFiles: Optional[int] = Field(
264
+ None, description="Maximum number of files that can be uploaded (default: 1)", ge=1
265
+ )
266
+
267
+
268
+ class FileUploadInitialValue(BaseModel):
269
+ """Initial value for file upload field"""
270
+
271
+ artifactId: str = Field(..., description="The artifact ID of the uploaded file")
272
+ name: str = Field(..., description="The name of the file")
273
+ mimeType: str = Field(..., description="The MIME type of the file")
274
+
275
+
276
+ class FileUploadField(BaseModel):
277
+ """File upload field configuration"""
278
+
279
+ name: str = Field(
280
+ ..., description="Internal identifier for the field used for data binding and processing"
281
+ )
282
+ label: str = Field(..., description="The label text displayed for the file upload field")
283
+ type: Literal[FieldType.FILEUPLOAD]
284
+ description: Optional[str] = Field(
285
+ None,
286
+ description="The description text for the file upload field. Provides detailed information about the form field that's displayed below the label.",
287
+ )
288
+ required: bool = Field(False, description="Whether the field is required for form submission")
289
+ validation: Optional[FileUploadValidation] = Field(
290
+ None, description="File upload field validation rules"
291
+ )
292
+ initialValue: Optional[List[FileUploadInitialValue]] = Field(
293
+ None, description="Initial file values for the field when data is provided"
294
+ )
295
+
296
+
297
+ class Alert(BaseModel):
298
+ """Alert configuration for form notifications."""
299
+
300
+ type: str = Field(..., description="Alert type (info, success, warning, error)")
301
+ message: str = Field(..., description="Alert message content")
302
+ dismissible: bool = Field(True, description="Whether the alert can be dismissed")
303
+
304
+
305
+ class AutoFormHitlTaskProperties(BaseModel):
306
+ """Properties for the Autoform component"""
307
+
308
+ title: Optional[str] = Field(None, description="Optional form title displayed at the top")
309
+ description: Optional[str] = Field(
310
+ None, description="Optional form description displayed below the title"
311
+ )
312
+ fields: List[
313
+ Union[
314
+ TextField,
315
+ TextareaField,
316
+ SelectField,
317
+ RadioGroupField,
318
+ MultiselectField,
319
+ CheckboxField,
320
+ InfoContainerField,
321
+ JsonBlockField,
322
+ FileUploadField,
323
+ ]
324
+ ] = Field(
325
+ ..., description="Array of form fields to render in the order they appear", min_length=1
326
+ )
327
+ alerts: Optional[List[Alert]] = Field(
328
+ None, description="Optional alerts to display with the form"
329
+ )
330
+
331
+
332
+ class AutoFormHitlTaskArguments(BaseModel):
333
+ """Configuration for the AutoForm component."""
334
+
335
+ properties: AutoFormHitlTaskProperties = Field(
336
+ ..., description="The properties of the AutoForm component"
337
+ )