AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(blocks): Add Slant 3D printing via API service (#8805)
Nicholas Tindled4edb9371d6e
diff --git a/autogpt_platform/backend/backend/blocks/__init__.py b/autogpt_platform/backend/backend/blocks/__init__.pyindex 03b4a97017..11c5f3d5d6 100644--- a/autogpt_platform/backend/backend/blocks/__init__.py+++ b/autogpt_platform/backend/backend/blocks/__init__.py@@ -15,10 +15,10 @@ modules = [if f.is_file() and f.name != "__init__.py"]for module in modules:- if not re.match("^[a-z_.]+$", module):+ if not re.match("^[a-z0-9_.]+$", module):raise ValueError(f"Block module {module} error: module name must be lowercase, "- "separated by underscores, and contain only alphabet characters"+ "and contain only alphanumeric characters and underscores.")importlib.import_module(f".{module}", package=__name__)diff --git a/autogpt_platform/backend/backend/blocks/slant3d/_api.py b/autogpt_platform/backend/backend/blocks/slant3d/_api.pynew file mode 100644index 0000000000..f8f3211047--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/slant3d/_api.py@@ -0,0 +1,71 @@+from enum import Enum+from typing import Literal++from pydantic import BaseModel, SecretStr++from backend.data.model import APIKeyCredentials, CredentialsField, CredentialsMetaInput++Slant3DCredentialsInput = CredentialsMetaInput[Literal["slant3d"], Literal["api_key"]]+++def Slant3DCredentialsField() -> Slant3DCredentialsInput:+ return CredentialsField(+ provider="slant3d",+ supported_credential_types={"api_key"},+ description="Slant3D API key for authentication",+ )+++TEST_CREDENTIALS = APIKeyCredentials(+ id="01234567-89ab-cdef-0123-456789abcdef",+ provider="slant3d",+ api_key=SecretStr("mock-slant3d-api-key"),+ title="Mock Slant3D API key",+ expires_at=None,+)++TEST_CREDENTIALS_INPUT = {+ "provider": TEST_CREDENTIALS.provider,+ "id": TEST_CREDENTIALS.id,+ "type": TEST_CREDENTIALS.type,+ "title": TEST_CREDENTIALS.title,+}+++class CustomerDetails(BaseModel):+ name: str+ email: str+ phone: str+ address: str+ city: str+ state: str+ zip: str+ country_iso: str = "US"+ is_residential: bool = True+++class Color(Enum):+ WHITE = "white"+ BLACK = "black"+++class Profile(Enum):+ PLA = "PLA"+ PETG = "PETG"+++class OrderItem(BaseModel):+ # filename: str+ file_url: str+ quantity: str # String as per API spec+ color: Color = Color.WHITE+ profile: Profile = Profile.PLA+ # image_url: str = ""+ # sku: str = ""+++class Filament(BaseModel):+ filament: str+ hexColor: str+ colorTag: str+ profile: strdiff --git a/autogpt_platform/backend/backend/blocks/slant3d/base.py b/autogpt_platform/backend/backend/blocks/slant3d/base.pynew file mode 100644index 0000000000..d5d1681e1d--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/slant3d/base.py@@ -0,0 +1,94 @@+from typing import Any, Dict++from backend.data.block import Block+from backend.util.request import requests++from ._api import Color, CustomerDetails, OrderItem, Profile+++class Slant3DBlockBase(Block):+ """Base block class for Slant3D API interactions"""++ BASE_URL = "https://www.slant3dapi.com/api"++ def _get_headers(self, api_key: str) -> Dict[str, str]:+ return {"api-key": api_key, "Content-Type": "application/json"}++ def _make_request(self, method: str, endpoint: str, api_key: str, **kwargs) -> Dict:+ url = f"{self.BASE_URL}/{endpoint}"+ response = requests.request(+ method=method, url=url, headers=self._get_headers(api_key), **kwargs+ )++ if not response.ok:+ error_msg = response.json().get("error", "Unknown error")+ raise RuntimeError(f"API request failed: {error_msg}")++ return response.json()++ def _check_valid_color(self, profile: Profile, color: Color, api_key: str) -> str:+ response = self._make_request(+ "GET",+ "filament",+ api_key,+ params={"profile": profile.value, "color": color.value},+ )+ if profile == Profile.PLA:+ color_tag = color.value+ else:+ color_tag = f"{profile.value.lower()}{color.value.capitalize()}"+ valid_tags = [filament["colorTag"] for filament in response["filaments"]]++ if color_tag not in valid_tags:+ raise ValueError(+ f"""Invalid color profile combination {color_tag}.+Valid colors for {profile.value} are:+{','.join([filament['colorTag'].replace(profile.value.lower(), '') for filament in response['filaments'] if filament['profile'] == profile.value])}+"""+ )+ return color_tag++ def _convert_to_color(self, profile: Profile, color: Color, api_key: str) -> str:+ return self._check_valid_color(profile, color, api_key)++ def _format_order_data(+ self,+ customer: CustomerDetails,+ order_number: str,+ items: list[OrderItem],+ api_key: str,+ ) -> list[dict[str, Any]]:+ """Helper function to format order data for API requests"""+ orders = []+ for item in items:+ order_data = {+ "email": customer.email,+ "phone": customer.phone,+ "name": customer.name,+ "orderNumber": order_number,+ "filename": item.file_url,+ "fileURL": item.file_url,+ "bill_to_street_1": customer.address,+ "bill_to_city": customer.city,+ "bill_to_state": customer.state,+ "bill_to_zip": customer.zip,+ "bill_to_country_as_iso": customer.country_iso,+ "bill_to_is_US_residential": str(customer.is_residential).lower(),+ "ship_to_name": customer.name,+ "ship_to_street_1": customer.address,+ "ship_to_city": customer.city,+ "ship_to_state": customer.state,+ "ship_to_zip": customer.zip,+ "ship_to_country_as_iso": customer.country_iso,+ "ship_to_is_US_residential": str(customer.is_residential).lower(),+ "order_item_name": item.file_url,+ "order_quantity": item.quantity,+ "order_image_url": "",+ "order_sku": "NOT_USED",+ "order_item_color": self._convert_to_color(+ item.profile, item.color, api_key+ ),+ "profile": item.profile.value,+ }+ orders.append(order_data)+ return ordersdiff --git a/autogpt_platform/backend/backend/blocks/slant3d/filament.py b/autogpt_platform/backend/backend/blocks/slant3d/filament.pynew file mode 100644index 0000000000..c232c2ba8d--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/slant3d/filament.py@@ -0,0 +1,85 @@+from typing import List++from backend.data.block import BlockOutput, BlockSchema+from backend.data.model import APIKeyCredentials, SchemaField++from ._api import (+ TEST_CREDENTIALS,+ TEST_CREDENTIALS_INPUT,+ Filament,+ Slant3DCredentialsField,+ Slant3DCredentialsInput,+)+from .base import Slant3DBlockBase+++class Slant3DFilamentBlock(Slant3DBlockBase):+ """Block for retrieving available filaments"""++ class Input(BlockSchema):+ credentials: Slant3DCredentialsInput = Slant3DCredentialsField()++ class Output(BlockSchema):+ filaments: List[Filament] = SchemaField(+ description="List of available filaments"+ )+ error: str = SchemaField(description="Error message if request failed")++ def __init__(self):+ super().__init__(+ id="7cc416f4-f305-4606-9b3b-452b8a81031c",+ description="Get list of available filaments",+ input_schema=self.Input,+ output_schema=self.Output,+ test_input={"credentials": TEST_CREDENTIALS_INPUT},+ test_credentials=TEST_CREDENTIALS,+ test_output=[+ (+ "filaments",+ [+ {+ "filament": "PLA BLACK",+ "hexColor": "000000",+ "colorTag": "black",+ "profile": "PLA",+ },+ {+ "filament": "PLA WHITE",+ "hexColor": "ffffff",+ "colorTag": "white",+ "profile": "PLA",+ },+ ],+ )+ ],+ test_mock={+ "_make_request": lambda *args, **kwargs: {+ "filaments": [+ {+ "filament": "PLA BLACK",+ "hexColor": "000000",+ "colorTag": "black",+ "profile": "PLA",+ },+ {+ "filament": "PLA WHITE",+ "hexColor": "ffffff",+ "colorTag": "white",+ "profile": "PLA",+ },+ ]+ }+ },+ )++ def run(+ self, input_data: Input, *, credentials: APIKeyCredentials, **kwargs+ ) -> BlockOutput:+ try:+ result = self._make_request(+ "GET", "filament", credentials.api_key.get_secret_value()+ )+ yield "filaments", result["filaments"]+ except Exception as e:+ yield "error", str(e)+ raisediff --git a/autogpt_platform/backend/backend/blocks/slant3d/order.py b/autogpt_platform/backend/backend/blocks/slant3d/order.pynew file mode 100644index 0000000000..a1a342a98e--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/slant3d/order.py@@ -0,0 +1,418 @@+import uuid+from typing import List++import requests as baserequests++from backend.data.block import BlockOutput, BlockSchema+from backend.data.model import APIKeyCredentials, SchemaField+from backend.util import settings+from backend.util.settings import BehaveAs++from ._api import (+ TEST_CREDENTIALS,+ TEST_CREDENTIALS_INPUT,+ CustomerDetails,+ OrderItem,+ Slant3DCredentialsField,+ Slant3DCredentialsInput,+)+from .base import Slant3DBlockBase+++class Slant3DCreateOrderBlock(Slant3DBlockBase):+ """Block for creating new orders"""++ class Input(BlockSchema):+ credentials: Slant3DCredentialsInput = Slant3DCredentialsField()+ order_number: str = SchemaField(+ description="Your custom order number (or leave blank for a random one)",+ default_factory=lambda: str(uuid.uuid4()),+ )+ customer: CustomerDetails = SchemaField(+ description="Customer details for where to ship the item",+ advanced=False,+ )+ items: List[OrderItem] = SchemaField(+ description="List of items to print",+ advanced=False,+ )++ class Output(BlockSchema):+ order_id: str = SchemaField(description="Slant3D order ID")+ error: str = SchemaField(description="Error message if order failed")++ def __init__(self):+ super().__init__(+ id="f73007d6-f48f-4aaf-9e6b-6883998a09b4",+ description="Create a new print order",+ input_schema=self.Input,+ output_schema=self.Output,+ test_input={+ "credentials": TEST_CREDENTIALS_INPUT,+ "order_number": "TEST-001",+ "customer": {+ "name": "John Doe",+ "email": "[email protected]",+ "phone": "123-456-7890",+ "address": "123 Test St",+ "city": "Test City",+ "state": "TS",+ "zip": "12345",+ },+ "items": [+ {+ "file_url": "https://example.com/model.stl",+ "quantity": "1",+ "color": "black",+ "profile": "PLA",+ }+ ],+ },+ test_credentials=TEST_CREDENTIALS,+ test_output=[("order_id", "314144241")],+ test_mock={+ "_make_request": lambda *args, **kwargs: {"orderId": "314144241"},+ "_convert_to_color": lambda *args, **kwargs: "black",+ },+ )++ def run(+ self, input_data: Input, *, credentials: APIKeyCredentials, **kwargs+ ) -> BlockOutput:+ try:+ order_data = self._format_order_data(+ input_data.customer,+ input_data.order_number,+ input_data.items,+ credentials.api_key.get_secret_value(),+ )+ result = self._make_request(+ "POST", "order", credentials.api_key.get_secret_value(), json=order_data+ )+ yield "order_id", result["orderId"]+ except Exception as e:+ yield "error", str(e)+ raise+++class Slant3DEstimateOrderBlock(Slant3DBlockBase):+ """Block for getting order cost estimates"""++ class Input(BlockSchema):+ credentials: Slant3DCredentialsInput = Slant3DCredentialsField()+ order_number: str = SchemaField(+ description="Your custom order number (or leave blank for a random one)",+ default_factory=lambda: str(uuid.uuid4()),+ )+ customer: CustomerDetails = SchemaField(+ description="Customer details for where to ship the item",+ advanced=False,+ )+ items: List[OrderItem] = SchemaField(+ description="List of items to print",+ advanced=False,+ )++ class Output(BlockSchema):+ total_price: float = SchemaField(description="Total price in USD")+ shipping_cost: float = SchemaField(description="Shipping cost")+ printing_cost: float = SchemaField(description="Printing cost")+ error: str = SchemaField(description="Error message if estimation failed")++ def __init__(self):+ super().__init__(+ id="bf8823d6-b42a-48c7-b558-d7c117f2ae85",+ description="Get order cost estimate",+ input_schema=self.Input,+ output_schema=self.Output,+ test_input={+ "credentials": TEST_CREDENTIALS_INPUT,+ "order_number": "TEST-001",+ "customer": {+ "name": "John Doe",+ "email": "[email protected]",+ "phone": "123-456-7890",+ "address": "123 Test St",+ "city": "Test City",+ "state": "TS",+ "zip": "12345",+ },+ "items": [+ {+ "file_url": "https://example.com/model.stl",+ "quantity": "1",+ "color": "black",+ "profile": "PLA",+ }+ ],+ },+ test_credentials=TEST_CREDENTIALS,+ test_output=[+ ("total_price", 9.31),+ ("shipping_cost", 5.56),+ ("printing_cost", 3.75),+ ],+ test_mock={+ "_make_request": lambda *args, **kwargs: {+ "totalPrice": 9.31,+ "shippingCost": 5.56,+ "printingCost": 3.75,+ },+ "_convert_to_color": lambda *args, **kwargs: "black",+ },+ )++ def run(+ self, input_data: Input, *, credentials: APIKeyCredentials, **kwargs+ ) -> BlockOutput:+ order_data = self._format_order_data(+ input_data.customer,+ input_data.order_number,+ input_data.items,+ credentials.api_key.get_secret_value(),+ )+ try:+ result = self._make_request(+ "POST",+ "order/estimate",+ credentials.api_key.get_secret_value(),+ json=order_data,+ )+ yield "total_price", result["totalPrice"]+ yield "shipping_cost", result["shippingCost"]+ yield "printing_cost", result["printingCost"]+ except baserequests.HTTPError as e:+ yield "error", str(f"Error estimating order: {e} {e.response.text}")+ raise+++class Slant3DEstimateShippingBlock(Slant3DBlockBase):+ """Block for getting shipping cost estimates"""++ class Input(BlockSchema):+ credentials: Slant3DCredentialsInput = Slant3DCredentialsField()+ order_number: str = SchemaField(+ description="Your custom order number (or leave blank for a random one)",+ default_factory=lambda: str(uuid.uuid4()),+ )+ customer: CustomerDetails = SchemaField(+ description="Customer details for where to ship the item"+ )+ items: List[OrderItem] = SchemaField(+ description="List of items to print",+ advanced=False,+ )++ class Output(BlockSchema):+ shipping_cost: float = SchemaField(description="Estimated shipping cost")+ currency_code: str = SchemaField(description="Currency code (e.g., 'usd')")+ error: str = SchemaField(description="Error message if estimation failed")++ def __init__(self):+ super().__init__(+ id="00aae2a1-caf6-4a74-8175-39a0615d44e1",+ description="Get shipping cost estimate",+ input_schema=self.Input,+ output_schema=self.Output,+ test_input={+ "credentials": TEST_CREDENTIALS_INPUT,+ "order_number": "TEST-001",+ "customer": {+ "name": "John Doe",+ "email": "[email protected]",+ "phone": "123-456-7890",+ "address": "123 Test St",+ "city": "Test City",+ "state": "TS",+ "zip": "12345",+ },+ "items": [+ {+ "file_url": "https://example.com/model.stl",+ "quantity": "1",+ "color": "black",+ "profile": "PLA",+ }+ ],+ },+ test_credentials=TEST_CREDENTIALS,+ test_output=[("shipping_cost", 4.81), ("currency_code", "usd")],+ test_mock={+ "_make_request": lambda *args, **kwargs: {+ "shippingCost": 4.81,+ "currencyCode": "usd",+ },+ "_convert_to_color": lambda *args, **kwargs: "black",+ },+ )++ def run(+ self, input_data: Input, *, credentials: APIKeyCredentials, **kwargs+ ) -> BlockOutput:+ try:+ order_data = self._format_order_data(+ input_data.customer,+ input_data.order_number,+ input_data.items,+ credentials.api_key.get_secret_value(),+ )+ result = self._make_request(+ "POST",+ "order/estimateShipping",+ credentials.api_key.get_secret_value(),+ json=order_data,+ )+ yield "shipping_cost", result["shippingCost"]+ yield "currency_code", result["currencyCode"]+ except Exception as e:+ yield "error", str(e)+ raise+++class Slant3DGetOrdersBlock(Slant3DBlockBase):+ """Block for retrieving all orders"""++ class Input(BlockSchema):+ credentials: Slant3DCredentialsInput = Slant3DCredentialsField()++ class Output(BlockSchema):+ orders: List[str] = SchemaField(description="List of orders with their details")+ error: str = SchemaField(description="Error message if request failed")++ def __init__(self):+ super().__init__(+ id="42283bf5-8a32-4fb4-92a2-60a9ea48e105",+ description="Get all orders for the account",+ input_schema=self.Input,+ output_schema=self.Output,+ # This block is disabled for cloud hosted because it allows access to all orders for the account+ disabled=settings.Settings().config.behave_as == BehaveAs.CLOUD,+ test_input={"credentials": TEST_CREDENTIALS_INPUT},+ test_credentials=TEST_CREDENTIALS,+ test_output=[+ (+ "orders",+ [+ "1234567890",+ ],+ )+ ],+ test_mock={+ "_make_request": lambda *args, **kwargs: {+ "ordersData": [+ {+ "orderId": 1234567890,+ "orderTimestamp": {+ "_seconds": 1719510986,+ "_nanoseconds": 710000000,+ },+ }+ ]+ }+ },+ )++ def run(+ self, input_data: Input, *, credentials: APIKeyCredentials, **kwargs+ ) -> BlockOutput:+ try:+ result = self._make_request(+ "GET", "order", credentials.api_key.get_secret_value()+ )+ yield "orders", [str(order["orderId"]) for order in result["ordersData"]]+ except Exception as e:+ yield "error", str(e)+ raise+++class Slant3DTrackingBlock(Slant3DBlockBase):+ """Block for tracking order status and shipping"""++ class Input(BlockSchema):+ credentials: Slant3DCredentialsInput = Slant3DCredentialsField()+ order_id: str = SchemaField(description="Slant3D order ID to track")++ class Output(BlockSchema):+ status: str = SchemaField(description="Order status")+ tracking_numbers: List[str] = SchemaField(+ description="List of tracking numbers"+ )+ error: str = SchemaField(description="Error message if tracking failed")++ def __init__(self):+ super().__init__(+ id="dd7c0293-c5af-4551-ba3e-fc162fb1fb89",+ description="Track order status and shipping",+ input_schema=self.Input,+ output_schema=self.Output,+ test_input={+ "credentials": TEST_CREDENTIALS_INPUT,+ "order_id": "314144241",+ },+ test_credentials=TEST_CREDENTIALS,+ test_output=[("status", "awaiting_shipment"), ("tracking_numbers", [])],+ test_mock={+ "_make_request": lambda *args, **kwargs: {+ "status": "awaiting_shipment",+ "trackingNumbers": [],+ }+ },+ )++ def run(+ self, input_data: Input, *, credentials: APIKeyCredentials, **kwargs+ ) -> BlockOutput:+ try:+ result = self._make_request(+ "GET",+ f"order/{input_data.order_id}/get-tracking",+ credentials.api_key.get_secret_value(),+ )+ yield "status", result["status"]+ yield "tracking_numbers", result["trackingNumbers"]+ except Exception as e:+ yield "error", str(e)+ raise+++class Slant3DCancelOrderBlock(Slant3DBlockBase):+ """Block for canceling orders"""++ class Input(BlockSchema):+ credentials: Slant3DCredentialsInput = Slant3DCredentialsField()+ order_id: str = SchemaField(description="Slant3D order ID to cancel")++ class Output(BlockSchema):+ status: str = SchemaField(description="Cancellation status message")+ error: str = SchemaField(description="Error message if cancellation failed")++ def __init__(self):+ super().__init__(+ id="54de35e1-407f-450b-b5fa-3b5e2eba8185",+ description="Cancel an existing order",+ input_schema=self.Input,+ output_schema=self.Output,+ test_input={+ "credentials": TEST_CREDENTIALS_INPUT,+ "order_id": "314144241",+ },+ test_credentials=TEST_CREDENTIALS,+ test_output=[("status", "Order cancelled")],+ test_mock={+ "_make_request": lambda *args, **kwargs: {"status": "Order cancelled"}+ },+ )++ def run(+ self, input_data: Input, *, credentials: APIKeyCredentials, **kwargs+ ) -> BlockOutput:+ try:+ result = self._make_request(+ "DELETE",+ f"order/{input_data.order_id}",+ credentials.api_key.get_secret_value(),+ )+ yield "status", result["status"]+ except Exception as e:+ yield "error", str(e)+ raisediff --git a/autogpt_platform/backend/backend/blocks/slant3d/slicing.py b/autogpt_platform/backend/backend/blocks/slant3d/slicing.pynew file mode 100644index 0000000000..1b868efc9e--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/slant3d/slicing.py@@ -0,0 +1,61 @@+from backend.data.block import BlockOutput, BlockSchema+from backend.data.model import APIKeyCredentials, SchemaField++from ._api import (+ TEST_CREDENTIALS,+ TEST_CREDENTIALS_INPUT,+ Slant3DCredentialsField,+ Slant3DCredentialsInput,+)+from .base import Slant3DBlockBase+++class Slant3DSlicerBlock(Slant3DBlockBase):+ """Block for slicing 3D model files"""++ class Input(BlockSchema):+ credentials: Slant3DCredentialsInput = Slant3DCredentialsField()+ file_url: str = SchemaField(+ description="URL of the 3D model file to slice (STL)"+ )++ class Output(BlockSchema):+ message: str = SchemaField(description="Response message")+ price: float = SchemaField(description="Calculated price for printing")+ error: str = SchemaField(description="Error message if slicing failed")++ def __init__(self):+ super().__init__(+ id="f8a12c8d-3e4b-4d5f-b6a7-8c9d0e1f2g3h",+ description="Slice a 3D model file and get pricing information",+ input_schema=self.Input,+ output_schema=self.Output,+ test_input={+ "credentials": TEST_CREDENTIALS_INPUT,+ "file_url": "https://example.com/model.stl",+ },+ test_credentials=TEST_CREDENTIALS,+ test_output=[("message", "Slicing successful"), ("price", 8.23)],+ test_mock={+ "_make_request": lambda *args, **kwargs: {+ "message": "Slicing successful",+ "data": {"price": 8.23},+ }+ },+ )++ def run(+ self, input_data: Input, *, credentials: APIKeyCredentials, **kwargs+ ) -> BlockOutput:+ try:+ result = self._make_request(+ "POST",+ "slicer",+ credentials.api_key.get_secret_value(),+ json={"fileURL": input_data.file_url},+ )+ yield "message", result["message"]+ yield "price", result["data"]["price"]+ except Exception as e:+ yield "error", str(e)+ raisediff --git a/autogpt_platform/backend/backend/blocks/slant3d/webhook.py b/autogpt_platform/backend/backend/blocks/slant3d/webhook.pynew file mode 100644index 0000000000..5726790f99--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/slant3d/webhook.py@@ -0,0 +1,125 @@+from pydantic import BaseModel++from backend.data.block import (+ Block,+ BlockCategory,+ BlockOutput,+ BlockSchema,+ BlockWebhookConfig,+)+from backend.data.model import SchemaField+from backend.util import settings+from backend.util.settings import AppEnvironment, BehaveAs++from ._api import (+ TEST_CREDENTIALS,+ TEST_CREDENTIALS_INPUT,+ Slant3DCredentialsField,+ Slant3DCredentialsInput,+)+++class Slant3DTriggerBase:+ """Base class for Slant3D webhook triggers"""++ class Input(BlockSchema):+ credentials: Slant3DCredentialsInput = Slant3DCredentialsField()+ # Webhook URL is handled by the webhook system+ payload: dict = SchemaField(hidden=True, default={})++ class Output(BlockSchema):+ payload: dict = SchemaField(+ description="The complete webhook payload received from Slant3D"+ )+ order_id: str = SchemaField(description="The ID of the affected order")+ error: str = SchemaField(+ description="Error message if payload processing failed"+ )++ def run(self, input_data: Input, **kwargs) -> BlockOutput:+ yield "payload", input_data.payload+ yield "order_id", input_data.payload["orderId"]+++class Slant3DOrderWebhookBlock(Slant3DTriggerBase, Block):+ """Block for handling Slant3D order webhooks"""++ class Input(Slant3DTriggerBase.Input):+ class EventsFilter(BaseModel):+ """+ Currently Slant3D only supports 'SHIPPED' status updates+ Could be expanded in the future with more status types+ """++ shipped: bool = True++ events: EventsFilter = SchemaField(+ title="Events",+ description="Order status events to subscribe to",+ default=EventsFilter(shipped=True),+ )++ class Output(Slant3DTriggerBase.Output):+ status: str = SchemaField(description="The new status of the order")+ tracking_number: str = SchemaField(+ description="The tracking number for the shipment"+ )+ carrier_code: str = SchemaField(description="The carrier code (e.g., 'usps')")++ def __init__(self):+ super().__init__(+ id="8a74c2ad-0104-4640-962f-26c6b69e58cd",+ description=(+ "This block triggers on Slant3D order status updates and outputs "+ "the event details, including tracking information when orders are shipped."+ ),+ # All webhooks are currently subscribed to for all orders. This works for self hosted, but not for cloud hosted prod+ disabled=(+ settings.Settings().config.behave_as == BehaveAs.CLOUD+ and settings.Settings().config.app_env != AppEnvironment.LOCAL+ ),+ categories={BlockCategory.DEVELOPER_TOOLS},+ input_schema=self.Input,+ output_schema=self.Output,+ webhook_config=BlockWebhookConfig(+ provider="slant3d",+ webhook_type="orders", # Only one type for now+ resource_format="", # No resource format needed+ event_filter_input="events",+ event_format="order.{event}",+ ),+ test_input={+ "credentials": TEST_CREDENTIALS_INPUT,+ "events": {"shipped": True},+ "payload": {+ "orderId": "1234567890",+ "status": "SHIPPED",+ "trackingNumber": "ABCDEF123456",+ "carrierCode": "usps",+ },+ },+ test_credentials=TEST_CREDENTIALS,+ test_output=[+ (+ "payload",+ {+ "orderId": "1234567890",+ "status": "SHIPPED",+ "trackingNumber": "ABCDEF123456",+ "carrierCode": "usps",+ },+ ),+ ("order_id", "1234567890"),+ ("status", "SHIPPED"),+ ("tracking_number", "ABCDEF123456"),+ ("carrier_code", "usps"),+ ],+ )++ def run(self, input_data: Input, **kwargs) -> BlockOutput: # type: ignore+ yield from super().run(input_data, **kwargs)++ # Extract and normalize values from the payload+ yield "status", input_data.payload["status"]+ yield "tracking_number", input_data.payload["trackingNumber"]+ yield "carrier_code", input_data.payload["carrierCode"]diff --git a/autogpt_platform/backend/backend/data/cost.py b/autogpt_platform/backend/backend/data/cost.pyindex 2318d72d7a..3e3e9bae65 100644--- a/autogpt_platform/backend/backend/data/cost.py+++ b/autogpt_platform/backend/backend/data/cost.py@@ -10,6 +10,7 @@ class BlockCostType(str, Enum):RUN = "run" # cost X credits per runBYTE = "byte" # cost X credits per byteSECOND = "second" # cost X credits per second+ DOLLAR = "dollar" # cost X dollars per runclass BlockCost(BaseModel):diff --git a/autogpt_platform/backend/backend/integrations/webhooks/__init__.py b/autogpt_platform/backend/backend/integrations/webhooks/__init__.pyindex 14d1f72165..ebfeea7637 100644--- a/autogpt_platform/backend/backend/integrations/webhooks/__init__.py+++ b/autogpt_platform/backend/backend/integrations/webhooks/__init__.py@@ -1,6 +1,7 @@from typing import TYPE_CHECKINGfrom .github import GithubWebhooksManager+from .slant3d import Slant3DWebhooksManagerif TYPE_CHECKING:from .base import BaseWebhooksManager@@ -10,6 +11,7 @@ WEBHOOK_MANAGERS_BY_NAME: dict[str, type["BaseWebhooksManager"]] = {handler.PROVIDER_NAME: handlerfor handler in [GithubWebhooksManager,+ Slant3DWebhooksManager,]}# --8<-- [end:WEBHOOK_MANAGERS_BY_NAME]diff --git a/autogpt_platform/backend/backend/integrations/webhooks/slant3d.py b/autogpt_platform/backend/backend/integrations/webhooks/slant3d.pynew file mode 100644index 0000000000..316bca0166--- /dev/null+++ b/autogpt_platform/backend/backend/integrations/webhooks/slant3d.py@@ -0,0 +1,99 @@+import logging+from typing import ClassVar++import requests+from fastapi import Request++from backend.data import integrations+from backend.data.model import APIKeyCredentials, Credentials+from backend.integrations.webhooks.base import BaseWebhooksManager++logger = logging.getLogger(__name__)+++class Slant3DWebhooksManager(BaseWebhooksManager):+ """Manager for Slant3D webhooks"""++ PROVIDER_NAME: ClassVar[str] = "slant3d"+ BASE_URL = "https://www.slant3dapi.com/api"++ async def _register_webhook(+ self,+ credentials: Credentials,+ webhook_type: str,+ resource: str,+ events: list[str],+ ingress_url: str,+ secret: str,+ ) -> tuple[str, dict]:+ """Register a new webhook with Slant3D"""++ if not isinstance(credentials, APIKeyCredentials):+ raise ValueError("API key is required to register a webhook")++ headers = {+ "api-key": credentials.api_key.get_secret_value(),+ "Content-Type": "application/json",+ }++ # Slant3D's API doesn't use events list, just register for all order updates+ payload = {"endPoint": ingress_url}++ response = requests.post(+ f"{self.BASE_URL}/customer/webhookSubscribe", headers=headers, json=payload+ )++ if not response.ok:+ error = response.json().get("error", "Unknown error")+ raise RuntimeError(f"Failed to register webhook: {error}")++ webhook_config = {+ "endpoint": ingress_url,+ "provider": self.PROVIDER_NAME,+ "events": ["order.shipped"], # Currently the only supported event+ "type": webhook_type,+ }++ return "", webhook_config++ @classmethod+ async def validate_payload(+ cls, webhook: integrations.Webhook, request: Request+ ) -> tuple[dict, str]:+ """Validate incoming webhook payload from Slant3D"""++ payload = await request.json()++ # Validate required fields from Slant3D API spec+ required_fields = ["orderId", "status", "trackingNumber", "carrierCode"]+ missing_fields = [field for field in required_fields if field not in payload]++ if missing_fields:+ raise ValueError(f"Missing required fields: {', '.join(missing_fields)}")++ # Normalize payload structure+ normalized_payload = {+ "orderId": payload["orderId"],+ "status": payload["status"],+ "trackingNumber": payload["trackingNumber"],+ "carrierCode": payload["carrierCode"],+ }++ # Currently Slant3D only sends shipping notifications+ # Convert status to lowercase for event format compatibility+ event_type = f"order.{payload['status'].lower()}"++ return normalized_payload, event_type++ async def _deregister_webhook(+ self, webhook: integrations.Webhook, credentials: Credentials+ ) -> None:+ """+ Note: Slant3D API currently doesn't provide a deregistration endpoint.+ This would need to be handled through support.+ """+ # Log warning since we can't properly deregister+ logger.warning(+ f"Warning: Manual deregistration required for webhook {webhook.id}"+ )+ passdiff --git a/autogpt_platform/frontend/src/components/integrations/credentials-input.tsx b/autogpt_platform/frontend/src/components/integrations/credentials-input.tsxindex 010bbb1f78..05c54ddc57 100644--- a/autogpt_platform/frontend/src/components/integrations/credentials-input.tsx+++ b/autogpt_platform/frontend/src/components/integrations/credentials-input.tsx@@ -63,6 +63,7 @@ export const providerIcons: Record<openweathermap: fallbackIcon,open_router: fallbackIcon,pinecone: fallbackIcon,+ slant3d: fallbackIcon,replicate: fallbackIcon,fal: fallbackIcon,revid: fallbackIcon,diff --git a/autogpt_platform/frontend/src/components/integrations/credentials-provider.tsx b/autogpt_platform/frontend/src/components/integrations/credentials-provider.tsxindex 993329d228..8cf03d4baf 100644--- a/autogpt_platform/frontend/src/components/integrations/credentials-provider.tsx+++ b/autogpt_platform/frontend/src/components/integrations/credentials-provider.tsx@@ -37,6 +37,7 @@ const providerDisplayNames: Record<CredentialsProviderName, string> = {openweathermap: "OpenWeatherMap",open_router: "Open Router",pinecone: "Pinecone",+ slant3d: "Slant3D",replicate: "Replicate",fal: "FAL",revid: "Rev.ID",diff --git a/autogpt_platform/frontend/src/lib/autogpt-server-api/types.ts b/autogpt_platform/frontend/src/lib/autogpt-server-api/types.tsindex 30fa71bd45..db822ec4ed 100644--- a/autogpt_platform/frontend/src/lib/autogpt-server-api/types.ts+++ b/autogpt_platform/frontend/src/lib/autogpt-server-api/types.ts@@ -115,6 +115,7 @@ export const PROVIDER_NAMES = {OPENWEATHERMAP: "openweathermap",OPEN_ROUTER: "open_router",PINECONE: "pinecone",+ SLANT3D: "slant3d",REPLICATE: "replicate",FAL: "fal",REVID: "revid",