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.
refactor(backend/api): Clean up API file structure (#11629)
Reinier van der Leerde78d062a9e9
diff --git a/autogpt_platform/autogpt_libs/autogpt_libs/auth/helpers.py b/autogpt_platform/autogpt_libs/autogpt_libs/auth/helpers.pyindex d3d571d73c..10101778e7 100644--- a/autogpt_platform/autogpt_libs/autogpt_libs/auth/helpers.py+++ b/autogpt_platform/autogpt_libs/autogpt_libs/auth/helpers.py@@ -1,29 +1,25 @@from fastapi import FastAPI-from fastapi.openapi.utils import get_openapifrom .jwt_utils import bearer_jwt_authdef add_auth_responses_to_openapi(app: FastAPI) -> None:"""- Set up custom OpenAPI schema generation that adds 401 responses+ Patch a FastAPI instance's `openapi()` method to add 401 responsesto all authenticated endpoints.This is needed when using HTTPBearer with auto_error=False to get proper401 responses instead of 403, but FastAPI only automatically adds securityresponses when auto_error=True."""+ # Wrap current method to allow stacking OpenAPI schema modifiers like this+ wrapped_openapi = app.openapidef custom_openapi():if app.openapi_schema:return app.openapi_schema- openapi_schema = get_openapi(- title=app.title,- version=app.version,- description=app.description,- routes=app.routes,- )+ openapi_schema = wrapped_openapi()# Add 401 response to all endpoints that have security requirementsfor path, methods in openapi_schema["paths"].items():diff --git a/autogpt_platform/backend/TESTING.md b/autogpt_platform/backend/TESTING.mdindex 39fe4611b4..a3a5db68ef 100644--- a/autogpt_platform/backend/TESTING.md+++ b/autogpt_platform/backend/TESTING.md@@ -108,7 +108,7 @@ import fastapi.testclientimport pytestfrom pytest_snapshot.plugin import Snapshot-from backend.server.v2.myroute import router+from backend.api.features.myroute import routerapp = fastapi.FastAPI()app.include_router(router)@@ -149,7 +149,7 @@ These provide the easiest way to set up authentication mocking in test modules:import fastapiimport fastapi.testclientimport pytest-from backend.server.v2.myroute import router+from backend.api.features.myroute import routerapp = fastapi.FastAPI()app.include_router(router)diff --git a/autogpt_platform/backend/backend/server/__init__.py b/autogpt_platform/backend/backend/api/__init__.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/__init__.pyrename to autogpt_platform/backend/backend/api/__init__.pydiff --git a/autogpt_platform/backend/backend/server/conftest.py b/autogpt_platform/backend/backend/api/conftest.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/conftest.pyrename to autogpt_platform/backend/backend/api/conftest.pydiff --git a/autogpt_platform/backend/backend/server/conn_manager.py b/autogpt_platform/backend/backend/api/conn_manager.pysimilarity index 98%rename from autogpt_platform/backend/backend/server/conn_manager.pyrename to autogpt_platform/backend/backend/api/conn_manager.pyindex 8d65117564..52e0f50f69 100644--- a/autogpt_platform/backend/backend/server/conn_manager.py+++ b/autogpt_platform/backend/backend/api/conn_manager.py@@ -3,12 +3,12 @@ from typing import Dict, Setfrom fastapi import WebSocket+from backend.api.model import NotificationPayload, WSMessage, WSMethodfrom backend.data.execution import (ExecutionEventType,GraphExecutionEvent,NodeExecutionEvent,)-from backend.server.model import NotificationPayload, WSMessage, WSMethod_EVENT_TYPE_TO_METHOD_MAP: dict[ExecutionEventType, WSMethod] = {ExecutionEventType.GRAPH_EXEC_UPDATE: WSMethod.GRAPH_EXECUTION_EVENT,diff --git a/autogpt_platform/backend/backend/server/conn_manager_test.py b/autogpt_platform/backend/backend/api/conn_manager_test.pysimilarity index 98%rename from autogpt_platform/backend/backend/server/conn_manager_test.pyrename to autogpt_platform/backend/backend/api/conn_manager_test.pyindex 379928fae7..71dbc0ffee 100644--- a/autogpt_platform/backend/backend/server/conn_manager_test.py+++ b/autogpt_platform/backend/backend/api/conn_manager_test.py@@ -4,13 +4,13 @@ from unittest.mock import AsyncMockimport pytestfrom fastapi import WebSocket+from backend.api.conn_manager import ConnectionManager+from backend.api.model import NotificationPayload, WSMessage, WSMethodfrom backend.data.execution import (ExecutionStatus,GraphExecutionEvent,NodeExecutionEvent,)-from backend.server.conn_manager import ConnectionManager-from backend.server.model import NotificationPayload, WSMessage, WSMethod@pytest.fixturediff --git a/autogpt_platform/backend/backend/api/external/fastapi_app.py b/autogpt_platform/backend/backend/api/external/fastapi_app.pynew file mode 100644index 0000000000..b55c918a74--- /dev/null+++ b/autogpt_platform/backend/backend/api/external/fastapi_app.py@@ -0,0 +1,25 @@+from fastapi import FastAPI++from backend.api.middleware.security import SecurityHeadersMiddleware+from backend.monitoring.instrumentation import instrument_fastapi++from .v1.routes import v1_router++external_api = FastAPI(+ title="AutoGPT External API",+ description="External API for AutoGPT integrations",+ docs_url="/docs",+ version="1.0",+)++external_api.add_middleware(SecurityHeadersMiddleware)+external_api.include_router(v1_router, prefix="/v1")++# Add Prometheus instrumentation+instrument_fastapi(+ external_api,+ service_name="external-api",+ expose_endpoint=True,+ endpoint="/metrics",+ include_in_schema=True,+)diff --git a/autogpt_platform/backend/backend/server/external/middleware.py b/autogpt_platform/backend/backend/api/external/middleware.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/external/middleware.pyrename to autogpt_platform/backend/backend/api/external/middleware.pydiff --git a/autogpt_platform/backend/backend/server/external/routes/__init__.py b/autogpt_platform/backend/backend/api/external/v1/__init__.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/external/routes/__init__.pyrename to autogpt_platform/backend/backend/api/external/v1/__init__.pydiff --git a/autogpt_platform/backend/backend/server/external/routes/integrations.py b/autogpt_platform/backend/backend/api/external/v1/integrations.pysimilarity index 99%rename from autogpt_platform/backend/backend/server/external/routes/integrations.pyrename to autogpt_platform/backend/backend/api/external/v1/integrations.pyindex f9a8875ada..a3df481a67 100644--- a/autogpt_platform/backend/backend/server/external/routes/integrations.py+++ b/autogpt_platform/backend/backend/api/external/v1/integrations.py@@ -16,6 +16,8 @@ from fastapi import APIRouter, Body, HTTPException, Path, Security, statusfrom prisma.enums import APIKeyPermissionfrom pydantic import BaseModel, Field, SecretStr+from backend.api.external.middleware import require_permission+from backend.api.features.integrations.models import get_all_provider_namesfrom backend.data.auth.base import APIAuthorizationInfofrom backend.data.model import (APIKeyCredentials,@@ -28,8 +30,6 @@ from backend.data.model import (from backend.integrations.creds_manager import IntegrationCredentialsManagerfrom backend.integrations.oauth import CREDENTIALS_BY_PROVIDER, HANDLERS_BY_NAMEfrom backend.integrations.providers import ProviderName-from backend.server.external.middleware import require_permission-from backend.server.integrations.models import get_all_provider_namesfrom backend.util.settings import Settingsif TYPE_CHECKING:diff --git a/autogpt_platform/backend/backend/server/external/routes/v1.py b/autogpt_platform/backend/backend/api/external/v1/routes.pysimilarity index 96%rename from autogpt_platform/backend/backend/server/external/routes/v1.pyrename to autogpt_platform/backend/backend/api/external/v1/routes.pyindex f83673465a..58e15dc6a3 100644--- a/autogpt_platform/backend/backend/server/external/routes/v1.py+++ b/autogpt_platform/backend/backend/api/external/v1/routes.py@@ -8,23 +8,29 @@ from prisma.enums import AgentExecutionStatus, APIKeyPermissionfrom pydantic import BaseModel, Fieldfrom typing_extensions import TypedDict+import backend.api.features.store.cache as store_cache+import backend.api.features.store.model as store_modelimport backend.data.block-import backend.server.v2.store.cache as store_cache-import backend.server.v2.store.model as store_model+from backend.api.external.middleware import require_permissionfrom backend.data import execution as execution_dbfrom backend.data import graph as graph_dbfrom backend.data import user as user_dbfrom backend.data.auth.base import APIAuthorizationInfofrom backend.data.block import BlockInput, CompletedBlockOutputfrom backend.executor.utils import add_graph_execution-from backend.server.external.middleware import require_permissionfrom backend.util.settings import Settings+from .integrations import integrations_router+from .tools import tools_router+settings = Settings()logger = logging.getLogger(__name__)v1_router = APIRouter()+v1_router.include_router(integrations_router)+v1_router.include_router(tools_router)+class UserInfoResponse(BaseModel):id: strdiff --git a/autogpt_platform/backend/backend/server/external/routes/tools.py b/autogpt_platform/backend/backend/api/external/v1/tools.pysimilarity index 94%rename from autogpt_platform/backend/backend/server/external/routes/tools.pyrename to autogpt_platform/backend/backend/api/external/v1/tools.pyindex 8e3f4cbfdb..9e362fb32c 100644--- a/autogpt_platform/backend/backend/server/external/routes/tools.py+++ b/autogpt_platform/backend/backend/api/external/v1/tools.py@@ -14,11 +14,11 @@ from fastapi import APIRouter, Securityfrom prisma.enums import APIKeyPermissionfrom pydantic import BaseModel, Field+from backend.api.external.middleware import require_permission+from backend.api.features.chat.model import ChatSession+from backend.api.features.chat.tools import find_agent_tool, run_agent_tool+from backend.api.features.chat.tools.models import ToolResponseBasefrom backend.data.auth.base import APIAuthorizationInfo-from backend.server.external.middleware import require_permission-from backend.server.v2.chat.model import ChatSession-from backend.server.v2.chat.tools import find_agent_tool, run_agent_tool-from backend.server.v2.chat.tools.models import ToolResponseBaselogger = logging.getLogger(__name__)diff --git a/autogpt_platform/backend/backend/server/routers/postmark/__init__.py b/autogpt_platform/backend/backend/api/features/__init__.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/routers/postmark/__init__.pyrename to autogpt_platform/backend/backend/api/features/__init__.pydiff --git a/autogpt_platform/backend/backend/server/v2/library/__init__.py b/autogpt_platform/backend/backend/api/features/admin/__init__.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/library/__init__.pyrename to autogpt_platform/backend/backend/api/features/admin/__init__.pydiff --git a/autogpt_platform/backend/backend/server/v2/admin/credit_admin_routes.py b/autogpt_platform/backend/backend/api/features/admin/credit_admin_routes.pysimilarity index 96%rename from autogpt_platform/backend/backend/server/v2/admin/credit_admin_routes.pyrename to autogpt_platform/backend/backend/api/features/admin/credit_admin_routes.pyindex e4ea2c7f32..8930172c7f 100644--- a/autogpt_platform/backend/backend/server/v2/admin/credit_admin_routes.py+++ b/autogpt_platform/backend/backend/api/features/admin/credit_admin_routes.py@@ -6,9 +6,10 @@ from fastapi import APIRouter, Body, Securityfrom prisma.enums import CreditTransactionTypefrom backend.data.credit import admin_get_user_history, get_user_credit_model-from backend.server.v2.admin.model import AddUserCreditsResponse, UserHistoryResponsefrom backend.util.json import SafeJson+from .model import AddUserCreditsResponse, UserHistoryResponse+logger = logging.getLogger(__name__)diff --git a/autogpt_platform/backend/backend/server/v2/admin/credit_admin_routes_test.py b/autogpt_platform/backend/backend/api/features/admin/credit_admin_routes_test.pysimilarity index 90%rename from autogpt_platform/backend/backend/server/v2/admin/credit_admin_routes_test.pyrename to autogpt_platform/backend/backend/api/features/admin/credit_admin_routes_test.pyindex 0248da352f..db2d3cb41a 100644--- a/autogpt_platform/backend/backend/server/v2/admin/credit_admin_routes_test.py+++ b/autogpt_platform/backend/backend/api/features/admin/credit_admin_routes_test.py@@ -9,14 +9,15 @@ import pytest_mockfrom autogpt_libs.auth.jwt_utils import get_jwt_payloadfrom pytest_snapshot.plugin import Snapshot-import backend.server.v2.admin.credit_admin_routes as credit_admin_routes-import backend.server.v2.admin.model as admin_modelfrom backend.data.model import UserTransactionfrom backend.util.json import SafeJsonfrom backend.util.models import Pagination+from .credit_admin_routes import router as credit_admin_router+from .model import UserHistoryResponse+app = fastapi.FastAPI()-app.include_router(credit_admin_routes.router)+app.include_router(credit_admin_router)client = fastapi.testclient.TestClient(app)@@ -30,7 +31,7 @@ def setup_app_admin_auth(mock_jwt_admin):def test_add_user_credits_success(- mocker: pytest_mock.MockFixture,+ mocker: pytest_mock.MockerFixture,configured_snapshot: Snapshot,admin_user_id: str,target_user_id: str,@@ -42,7 +43,7 @@ def test_add_user_credits_success(return_value=(1500, "transaction-123-uuid"))mocker.patch(- "backend.server.v2.admin.credit_admin_routes.get_user_credit_model",+ "backend.api.features.admin.credit_admin_routes.get_user_credit_model",return_value=mock_credit_model,)@@ -84,7 +85,7 @@ def test_add_user_credits_success(def test_add_user_credits_negative_amount(- mocker: pytest_mock.MockFixture,+ mocker: pytest_mock.MockerFixture,snapshot: Snapshot,) -> None:"""Test credit deduction by admin (negative amount)"""@@ -94,7 +95,7 @@ def test_add_user_credits_negative_amount(return_value=(200, "transaction-456-uuid"))mocker.patch(- "backend.server.v2.admin.credit_admin_routes.get_user_credit_model",+ "backend.api.features.admin.credit_admin_routes.get_user_credit_model",return_value=mock_credit_model,)@@ -119,12 +120,12 @@ def test_add_user_credits_negative_amount(def test_get_user_history_success(- mocker: pytest_mock.MockFixture,+ mocker: pytest_mock.MockerFixture,snapshot: Snapshot,) -> None:"""Test successful retrieval of user credit history"""# Mock the admin_get_user_history function- mock_history_response = admin_model.UserHistoryResponse(+ mock_history_response = UserHistoryResponse(history=[UserTransaction(user_id="user-1",@@ -150,7 +151,7 @@ def test_get_user_history_success()mocker.patch(- "backend.server.v2.admin.credit_admin_routes.admin_get_user_history",+ "backend.api.features.admin.credit_admin_routes.admin_get_user_history",return_value=mock_history_response,)@@ -170,12 +171,12 @@ def test_get_user_history_success(def test_get_user_history_with_filters(- mocker: pytest_mock.MockFixture,+ mocker: pytest_mock.MockerFixture,snapshot: Snapshot,) -> None:"""Test user credit history with search and filter parameters"""# Mock the admin_get_user_history function- mock_history_response = admin_model.UserHistoryResponse(+ mock_history_response = UserHistoryResponse(history=[UserTransaction(user_id="user-3",@@ -194,7 +195,7 @@ def test_get_user_history_with_filters()mock_get_history = mocker.patch(- "backend.server.v2.admin.credit_admin_routes.admin_get_user_history",+ "backend.api.features.admin.credit_admin_routes.admin_get_user_history",return_value=mock_history_response,)@@ -230,12 +231,12 @@ def test_get_user_history_with_filters(def test_get_user_history_empty_results(- mocker: pytest_mock.MockFixture,+ mocker: pytest_mock.MockerFixture,snapshot: Snapshot,) -> None:"""Test user credit history with no results"""# Mock empty history response- mock_history_response = admin_model.UserHistoryResponse(+ mock_history_response = UserHistoryResponse(history=[],pagination=Pagination(total_items=0,@@ -246,7 +247,7 @@ def test_get_user_history_empty_results()mocker.patch(- "backend.server.v2.admin.credit_admin_routes.admin_get_user_history",+ "backend.api.features.admin.credit_admin_routes.admin_get_user_history",return_value=mock_history_response,)diff --git a/autogpt_platform/backend/backend/server/v2/admin/execution_analytics_routes.py b/autogpt_platform/backend/backend/api/features/admin/execution_analytics_routes.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/admin/execution_analytics_routes.pyrename to autogpt_platform/backend/backend/api/features/admin/execution_analytics_routes.pydiff --git a/autogpt_platform/backend/backend/server/v2/admin/model.py b/autogpt_platform/backend/backend/api/features/admin/model.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/admin/model.pyrename to autogpt_platform/backend/backend/api/features/admin/model.pydiff --git a/autogpt_platform/backend/backend/server/v2/admin/store_admin_routes.py b/autogpt_platform/backend/backend/api/features/admin/store_admin_routes.pysimilarity index 84%rename from autogpt_platform/backend/backend/server/v2/admin/store_admin_routes.pyrename to autogpt_platform/backend/backend/api/features/admin/store_admin_routes.pyindex c611c43f5a..9c4b89fee6 100644--- a/autogpt_platform/backend/backend/server/v2/admin/store_admin_routes.py+++ b/autogpt_platform/backend/backend/api/features/admin/store_admin_routes.py@@ -7,9 +7,9 @@ import fastapiimport fastapi.responsesimport prisma.enums-import backend.server.v2.store.cache as store_cache-import backend.server.v2.store.db-import backend.server.v2.store.model+import backend.api.features.store.cache as store_cache+import backend.api.features.store.db as store_db+import backend.api.features.store.model as store_modelimport backend.util.jsonlogger = logging.getLogger(__name__)@@ -24,7 +24,7 @@ router = fastapi.APIRouter(@router.get("/listings",summary="Get Admin Listings History",- response_model=backend.server.v2.store.model.StoreListingsWithVersionsResponse,+ response_model=store_model.StoreListingsWithVersionsResponse,)async def get_admin_listings_with_versions(status: typing.Optional[prisma.enums.SubmissionStatus] = None,@@ -48,7 +48,7 @@ async def get_admin_listings_with_versions(StoreListingsWithVersionsResponse with listings and their versions"""try:- listings = await backend.server.v2.store.db.get_admin_listings_with_versions(+ listings = await store_db.get_admin_listings_with_versions(status=status,search_query=search,page=page,@@ -68,11 +68,11 @@ async def get_admin_listings_with_versions(@router.post("/submissions/{store_listing_version_id}/review",summary="Review Store Submission",- response_model=backend.server.v2.store.model.StoreSubmission,+ response_model=store_model.StoreSubmission,)async def review_submission(store_listing_version_id: str,- request: backend.server.v2.store.model.ReviewSubmissionRequest,+ request: store_model.ReviewSubmissionRequest,user_id: str = fastapi.Security(autogpt_libs.auth.get_user_id),):"""@@ -87,12 +87,10 @@ async def review_submission(StoreSubmission with updated review information"""try:- already_approved = (- await backend.server.v2.store.db.check_submission_already_approved(- store_listing_version_id=store_listing_version_id,- )+ already_approved = await store_db.check_submission_already_approved(+ store_listing_version_id=store_listing_version_id,)- submission = await backend.server.v2.store.db.review_store_submission(+ submission = await store_db.review_store_submission(store_listing_version_id=store_listing_version_id,is_approved=request.is_approved,external_comments=request.comments,@@ -136,7 +134,7 @@ async def admin_download_agent_file(Raises:HTTPException: If the agent is not found or an unexpected error occurs."""- graph_data = await backend.server.v2.store.db.get_agent_as_admin(+ graph_data = await store_db.get_agent_as_admin(user_id=user_id,store_listing_version_id=store_listing_version_id,)diff --git a/autogpt_platform/backend/backend/server/routers/analytics.py b/autogpt_platform/backend/backend/api/features/analytics.pysimilarity index 94%rename from autogpt_platform/backend/backend/server/routers/analytics.pyrename to autogpt_platform/backend/backend/api/features/analytics.pyindex 98c2dd8e96..73a4590dcb 100644--- a/autogpt_platform/backend/backend/server/routers/analytics.py+++ b/autogpt_platform/backend/backend/api/features/analytics.py@@ -6,10 +6,11 @@ from typing import Annotatedimport fastapiimport pydanticfrom autogpt_libs.auth import get_user_id+from autogpt_libs.auth.dependencies import requires_userimport backend.data.analytics-router = fastapi.APIRouter()+router = fastapi.APIRouter(dependencies=[fastapi.Security(requires_user)])logger = logging.getLogger(__name__)diff --git a/autogpt_platform/backend/backend/api/features/analytics_test.py b/autogpt_platform/backend/backend/api/features/analytics_test.pynew file mode 100644index 0000000000..2493bdb7e4--- /dev/null+++ b/autogpt_platform/backend/backend/api/features/analytics_test.py@@ -0,0 +1,340 @@+"""Tests for analytics API endpoints."""++import json+from unittest.mock import AsyncMock, Mock++import fastapi+import fastapi.testclient+import pytest+import pytest_mock+from pytest_snapshot.plugin import Snapshot++from .analytics import router as analytics_router++app = fastapi.FastAPI()+app.include_router(analytics_router)++client = fastapi.testclient.TestClient(app)++[email protected](autouse=True)+def setup_app_auth(mock_jwt_user):+ """Setup auth overrides for all tests in this module."""+ from autogpt_libs.auth.jwt_utils import get_jwt_payload++ app.dependency_overrides[get_jwt_payload] = mock_jwt_user["get_jwt_payload"]+ yield+ app.dependency_overrides.clear()+++# =============================================================================+# /log_raw_metric endpoint tests+# =============================================================================+++def test_log_raw_metric_success(+ mocker: pytest_mock.MockFixture,+ configured_snapshot: Snapshot,+ test_user_id: str,+) -> None:+ """Test successful raw metric logging."""+ mock_result = Mock(id="metric-123-uuid")+ mock_log_metric = mocker.patch(+ "backend.data.analytics.log_raw_metric",+ new_callable=AsyncMock,+ return_value=mock_result,+ )++ request_data = {+ "metric_name": "page_load_time",+ "metric_value": 2.5,+ "data_string": "/dashboard",+ }++ response = client.post("/log_raw_metric", json=request_data)++ assert response.status_code == 200, f"Unexpected response: {response.text}"+ assert response.json() == "metric-123-uuid"++ mock_log_metric.assert_called_once_with(+ user_id=test_user_id,+ metric_name="page_load_time",+ metric_value=2.5,+ data_string="/dashboard",+ )++ configured_snapshot.assert_match(+ json.dumps({"metric_id": response.json()}, indent=2, sort_keys=True),+ "analytics_log_metric_success",+ )+++ "metric_value,metric_name,data_string,test_id",+ [+ (100, "api_calls_count", "external_api", "integer_value"),+ (0, "error_count", "no_errors", "zero_value"),+ (-5.2, "temperature_delta", "cooling", "negative_value"),+ (1.23456789, "precision_test", "float_precision", "float_precision"),+ (999999999, "large_number", "max_value", "large_number"),+ (0.0000001, "tiny_number", "min_value", "tiny_number"),+ ],+)+def test_log_raw_metric_various_values(+ mocker: pytest_mock.MockFixture,+ configured_snapshot: Snapshot,+ metric_value: float,+ metric_name: str,+ data_string: str,+ test_id: str,+) -> None:+ """Test raw metric logging with various metric values."""+ mock_result = Mock(id=f"metric-{test_id}-uuid")+ mocker.patch(+ "backend.data.analytics.log_raw_metric",+ new_callable=AsyncMock,+ return_value=mock_result,+ )++ request_data = {+ "metric_name": metric_name,+ "metric_value": metric_value,+ "data_string": data_string,+ }++ response = client.post("/log_raw_metric", json=request_data)++ assert response.status_code == 200, f"Failed for {test_id}: {response.text}"++ configured_snapshot.assert_match(+ json.dumps(+ {"metric_id": response.json(), "test_case": test_id},+ indent=2,+ sort_keys=True,+ ),+ f"analytics_metric_{test_id}",+ )+++ "invalid_data,expected_error",+ [+ ({}, "Field required"),+ ({"metric_name": "test"}, "Field required"),+ (+ {"metric_name": "test", "metric_value": "not_a_number", "data_string": "x"},+ "Input should be a valid number",+ ),+ (+ {"metric_name": "", "metric_value": 1.0, "data_string": "test"},+ "String should have at least 1 character",+ ),+ (+ {"metric_name": "test", "metric_value": 1.0, "data_string": ""},+ "String should have at least 1 character",+ ),+ ],+ ids=[+ "empty_request",+ "missing_metric_value_and_data_string",+ "invalid_metric_value_type",+ "empty_metric_name",+ "empty_data_string",+ ],+)+def test_log_raw_metric_validation_errors(+ invalid_data: dict,+ expected_error: str,+) -> None:+ """Test validation errors for invalid metric requests."""+ response = client.post("/log_raw_metric", json=invalid_data)++ assert response.status_code == 422+ error_detail = response.json()+ assert "detail" in error_detail, f"Missing 'detail' in error: {error_detail}"++ error_text = json.dumps(error_detail)+ assert (+ expected_error in error_text+ ), f"Expected '{expected_error}' in error response: {error_text}"+++def test_log_raw_metric_service_error(+ mocker: pytest_mock.MockFixture,+ test_user_id: str,+) -> None:+ """Test error handling when analytics service fails."""+ mocker.patch(+ "backend.data.analytics.log_raw_metric",+ new_callable=AsyncMock,+ side_effect=Exception("Database connection failed"),+ )++ request_data = {+ "metric_name": "test_metric",+ "metric_value": 1.0,+ "data_string": "test",+ }++ response = client.post("/log_raw_metric", json=request_data)++ assert response.status_code == 500+ error_detail = response.json()["detail"]+ assert "Database connection failed" in error_detail["message"]+ assert "hint" in error_detail+++# =============================================================================+# /log_raw_analytics endpoint tests+# =============================================================================+++def test_log_raw_analytics_success(+ mocker: pytest_mock.MockFixture,+ configured_snapshot: Snapshot,+ test_user_id: str,+) -> None:+ """Test successful raw analytics logging."""+ mock_result = Mock(id="analytics-789-uuid")+ mock_log_analytics = mocker.patch(+ "backend.data.analytics.log_raw_analytics",+ new_callable=AsyncMock,+ return_value=mock_result,+ )++ request_data = {+ "type": "user_action",+ "data": {+ "action": "button_click",+ "button_id": "submit_form",+ "timestamp": "2023-01-01T00:00:00Z",+ "metadata": {"form_type": "registration", "fields_filled": 5},+ },+ "data_index": "button_click_submit_form",+ }++ response = client.post("/log_raw_analytics", json=request_data)++ assert response.status_code == 200, f"Unexpected response: {response.text}"+ assert response.json() == "analytics-789-uuid"++ mock_log_analytics.assert_called_once_with(+ test_user_id,+ "user_action",+ request_data["data"],+ "button_click_submit_form",+ )++ configured_snapshot.assert_match(+ json.dumps({"analytics_id": response.json()}, indent=2, sort_keys=True),+ "analytics_log_analytics_success",+ )+++def test_log_raw_analytics_complex_data(+ mocker: pytest_mock.MockFixture,+ configured_snapshot: Snapshot,+) -> None:+ """Test raw analytics logging with complex nested data structures."""+ mock_result = Mock(id="analytics-complex-uuid")+ mocker.patch(+ "backend.data.analytics.log_raw_analytics",+ new_callable=AsyncMock,+ return_value=mock_result,+ )++ request_data = {+ "type": "agent_execution",+ "data": {+ "agent_id": "agent_123",+ "execution_id": "exec_456",+ "status": "completed",+ "duration_ms": 3500,+ "nodes_executed": 15,+ "blocks_used": [+ {"block_id": "llm_block", "count": 3},+ {"block_id": "http_block", "count": 5},+ {"block_id": "code_block", "count": 2},+ ],+ "errors": [],+ "metadata": {+ "trigger": "manual",+ "user_tier": "premium",+ "environment": "production",+ },+ },+ "data_index": "agent_123_exec_456",+ }++ response = client.post("/log_raw_analytics", json=request_data)++ assert response.status_code == 200++ configured_snapshot.assert_match(+ json.dumps(+ {"analytics_id": response.json(), "logged_data": request_data["data"]},+ indent=2,+ sort_keys=True,+ ),+ "analytics_log_analytics_complex_data",+ )+++ "invalid_data,expected_error",+ [+ ({}, "Field required"),+ ({"type": "test"}, "Field required"),+ (+ {"type": "test", "data": "not_a_dict", "data_index": "test"},+ "Input should be a valid dictionary",+ ),+ ({"type": "test", "data": {"key": "value"}}, "Field required"),+ ],+ ids=[+ "empty_request",+ "missing_data_and_data_index",+ "invalid_data_type",+ "missing_data_index",+ ],+)+def test_log_raw_analytics_validation_errors(+ invalid_data: dict,+ expected_error: str,+) -> None:+ """Test validation errors for invalid analytics requests."""+ response = client.post("/log_raw_analytics", json=invalid_data)++ assert response.status_code == 422+ error_detail = response.json()+ assert "detail" in error_detail, f"Missing 'detail' in error: {error_detail}"++ error_text = json.dumps(error_detail)+ assert (+ expected_error in error_text+ ), f"Expected '{expected_error}' in error response: {error_text}"+++def test_log_raw_analytics_service_error(+ mocker: pytest_mock.MockFixture,+ test_user_id: str,+) -> None:+ """Test error handling when analytics service fails."""+ mocker.patch(+ "backend.data.analytics.log_raw_analytics",+ new_callable=AsyncMock,+ side_effect=Exception("Analytics DB unreachable"),+ )++ request_data = {+ "type": "test_event",+ "data": {"key": "value"},+ "data_index": "test_index",+ }++ response = client.post("/log_raw_analytics", json=request_data)++ assert response.status_code == 500+ error_detail = response.json()["detail"]+ assert "Analytics DB unreachable" in error_detail["message"]+ assert "hint" in error_detaildiff --git a/autogpt_platform/backend/backend/server/v2/store/__init__.py b/autogpt_platform/backend/backend/api/features/builder/__init__.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/store/__init__.pyrename to autogpt_platform/backend/backend/api/features/builder/__init__.pydiff --git a/autogpt_platform/backend/backend/server/v2/builder/db.py b/autogpt_platform/backend/backend/api/features/builder/db.pysimilarity index 98%rename from autogpt_platform/backend/backend/server/v2/builder/db.pyrename to autogpt_platform/backend/backend/api/features/builder/db.pyindex 9856d53c0e..7177fa4dc6 100644--- a/autogpt_platform/backend/backend/server/v2/builder/db.py+++ b/autogpt_platform/backend/backend/api/features/builder/db.py@@ -6,17 +6,20 @@ from typing import Sequenceimport prisma+import backend.api.features.library.db as library_db+import backend.api.features.library.model as library_model+import backend.api.features.store.db as store_db+import backend.api.features.store.model as store_modelimport backend.data.block-import backend.server.v2.library.db as library_db-import backend.server.v2.library.model as library_model-import backend.server.v2.store.db as store_db-import backend.server.v2.store.model as store_modelfrom backend.blocks import load_all_blocksfrom backend.blocks.llm import LlmModelfrom backend.data.block import AnyBlockSchema, BlockCategory, BlockInfo, BlockSchemafrom backend.data.db import query_raw_with_schemafrom backend.integrations.providers import ProviderName-from backend.server.v2.builder.model import (+from backend.util.cache import cached+from backend.util.models import Pagination++from .model import (BlockCategoryResponse,BlockResponse,BlockType,@@ -26,8 +29,6 @@ from backend.server.v2.builder.model import (ProviderResponse,SearchEntry,)-from backend.util.cache import cached-from backend.util.models import Paginationlogger = logging.getLogger(__name__)llm_models = [name.name.lower().replace("_", " ") for name in LlmModel]diff --git a/autogpt_platform/backend/backend/server/v2/builder/model.py b/autogpt_platform/backend/backend/api/features/builder/model.pysimilarity index 93%rename from autogpt_platform/backend/backend/server/v2/builder/model.pyrename to autogpt_platform/backend/backend/api/features/builder/model.pyindex 4a1de595d1..fcd19dba94 100644--- a/autogpt_platform/backend/backend/server/v2/builder/model.py+++ b/autogpt_platform/backend/backend/api/features/builder/model.py@@ -2,8 +2,8 @@ from typing import Literalfrom pydantic import BaseModel-import backend.server.v2.library.model as library_model-import backend.server.v2.store.model as store_model+import backend.api.features.library.model as library_model+import backend.api.features.store.model as store_modelfrom backend.data.block import BlockInfofrom backend.integrations.providers import ProviderNamefrom backend.util.models import Paginationdiff --git a/autogpt_platform/backend/backend/server/v2/builder/routes.py b/autogpt_platform/backend/backend/api/features/builder/routes.pysimilarity index 98%rename from autogpt_platform/backend/backend/server/v2/builder/routes.pyrename to autogpt_platform/backend/backend/api/features/builder/routes.pyindex b87bf8ca1a..7fe9cab189 100644--- a/autogpt_platform/backend/backend/server/v2/builder/routes.py+++ b/autogpt_platform/backend/backend/api/features/builder/routes.py@@ -4,11 +4,12 @@ from typing import Annotated, Sequenceimport fastapifrom autogpt_libs.auth.dependencies import get_user_id, requires_user-import backend.server.v2.builder.db as builder_db-import backend.server.v2.builder.model as builder_modelfrom backend.integrations.providers import ProviderNamefrom backend.util.models import Pagination+from . import db as builder_db+from . import model as builder_model+logger = logging.getLogger(__name__)router = fastapi.APIRouter(diff --git a/autogpt_platform/backend/backend/api/features/chat/__init__.py b/autogpt_platform/backend/backend/api/features/chat/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/autogpt_platform/backend/backend/server/v2/chat/config.py b/autogpt_platform/backend/backend/api/features/chat/config.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/chat/config.pyrename to autogpt_platform/backend/backend/api/features/chat/config.pydiff --git a/autogpt_platform/backend/backend/server/v2/chat/model.py b/autogpt_platform/backend/backend/api/features/chat/model.pysimilarity index 99%rename from autogpt_platform/backend/backend/server/v2/chat/model.pyrename to autogpt_platform/backend/backend/api/features/chat/model.pyindex 0f06ddab00..b8aea5a334 100644--- a/autogpt_platform/backend/backend/server/v2/chat/model.py+++ b/autogpt_platform/backend/backend/api/features/chat/model.py@@ -19,9 +19,10 @@ from openai.types.chat.chat_completion_message_tool_call_param import (from pydantic import BaseModelfrom backend.data.redis_client import get_redis_async-from backend.server.v2.chat.config import ChatConfigfrom backend.util.exceptions import RedisError+from .config import ChatConfig+logger = logging.getLogger(__name__)config = ChatConfig()diff --git a/autogpt_platform/backend/backend/server/v2/chat/model_test.py b/autogpt_platform/backend/backend/api/features/chat/model_test.pysimilarity index 97%rename from autogpt_platform/backend/backend/server/v2/chat/model_test.pyrename to autogpt_platform/backend/backend/api/features/chat/model_test.pyindex f9c79b331b..b7f4c8a493 100644--- a/autogpt_platform/backend/backend/server/v2/chat/model_test.py+++ b/autogpt_platform/backend/backend/api/features/chat/model_test.py@@ -1,6 +1,6 @@import pytest-from backend.server.v2.chat.model import (+from .model import (ChatMessage,ChatSession,Usage,diff --git a/autogpt_platform/backend/backend/server/v2/chat/prompts/chat_system.md b/autogpt_platform/backend/backend/api/features/chat/prompts/chat_system.mdsimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/chat/prompts/chat_system.mdrename to autogpt_platform/backend/backend/api/features/chat/prompts/chat_system.mddiff --git a/autogpt_platform/backend/backend/server/v2/chat/response_model.py b/autogpt_platform/backend/backend/api/features/chat/response_model.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/chat/response_model.pyrename to autogpt_platform/backend/backend/api/features/chat/response_model.pydiff --git a/autogpt_platform/backend/backend/server/v2/chat/routes.py b/autogpt_platform/backend/backend/api/features/chat/routes.pysimilarity index 98%rename from autogpt_platform/backend/backend/server/v2/chat/routes.pyrename to autogpt_platform/backend/backend/api/features/chat/routes.pyindex 86bcf861c0..667335d048 100644--- a/autogpt_platform/backend/backend/server/v2/chat/routes.py+++ b/autogpt_platform/backend/backend/api/features/chat/routes.py@@ -9,10 +9,11 @@ from fastapi import APIRouter, Depends, Query, Securityfrom fastapi.responses import StreamingResponsefrom pydantic import BaseModel-import backend.server.v2.chat.service as chat_service-from backend.server.v2.chat.config import ChatConfigfrom backend.util.exceptions import NotFoundError+from . import service as chat_service+from .config import ChatConfig+config = ChatConfig()diff --git a/autogpt_platform/backend/backend/server/v2/chat/service.py b/autogpt_platform/backend/backend/api/features/chat/service.pysimilarity index 98%rename from autogpt_platform/backend/backend/server/v2/chat/service.pyrename to autogpt_platform/backend/backend/api/features/chat/service.pyindex 4328deb016..2d96d4abcd 100644--- a/autogpt_platform/backend/backend/server/v2/chat/service.py+++ b/autogpt_platform/backend/backend/api/features/chat/service.py@@ -7,15 +7,17 @@ import orjsonfrom openai import AsyncOpenAIfrom openai.types.chat import ChatCompletionChunk, ChatCompletionToolParam-import backend.server.v2.chat.config-from backend.server.v2.chat.model import (+from backend.util.exceptions import NotFoundError++from .config import ChatConfig+from .model import (ChatMessage,ChatSession,Usage,get_chat_session,upsert_chat_session,)-from backend.server.v2.chat.response_model import (+from .response_model import (StreamBaseResponse,StreamEnd,StreamError,@@ -26,12 +28,11 @@ from backend.server.v2.chat.response_model import (StreamToolExecutionResult,StreamUsage,)-from backend.server.v2.chat.tools import execute_tool, tools-from backend.util.exceptions import NotFoundError+from .tools import execute_tool, toolslogger = logging.getLogger(__name__)-config = backend.server.v2.chat.config.ChatConfig()+config = ChatConfig()client = AsyncOpenAI(api_key=config.api_key, base_url=config.base_url)diff --git a/autogpt_platform/backend/backend/server/v2/chat/service_test.py b/autogpt_platform/backend/backend/api/features/chat/service_test.pysimilarity index 95%rename from autogpt_platform/backend/backend/server/v2/chat/service_test.pyrename to autogpt_platform/backend/backend/api/features/chat/service_test.pyindex df3d64976e..d1af22a71a 100644--- a/autogpt_platform/backend/backend/server/v2/chat/service_test.py+++ b/autogpt_platform/backend/backend/api/features/chat/service_test.py@@ -3,8 +3,8 @@ from os import getenvimport pytest-import backend.server.v2.chat.service as chat_service-from backend.server.v2.chat.response_model import (+from . import service as chat_service+from .response_model import (StreamEnd,StreamError,StreamTextChunk,diff --git a/autogpt_platform/backend/backend/server/v2/chat/tools/__init__.py b/autogpt_platform/backend/backend/api/features/chat/tools/__init__.pysimilarity index 87%rename from autogpt_platform/backend/backend/server/v2/chat/tools/__init__.pyrename to autogpt_platform/backend/backend/api/features/chat/tools/__init__.pyindex 50f0d9892b..5b9b8649a8 100644--- a/autogpt_platform/backend/backend/server/v2/chat/tools/__init__.py+++ b/autogpt_platform/backend/backend/api/features/chat/tools/__init__.py@@ -2,14 +2,14 @@ from typing import TYPE_CHECKING, Anyfrom openai.types.chat import ChatCompletionToolParam-from backend.server.v2.chat.model import ChatSession+from backend.api.features.chat.model import ChatSessionfrom .base import BaseToolfrom .find_agent import FindAgentToolfrom .run_agent import RunAgentToolif TYPE_CHECKING:- from backend.server.v2.chat.response_model import StreamToolExecutionResult+ from backend.api.features.chat.response_model import StreamToolExecutionResult# Initialize tool instancesfind_agent_tool = FindAgentTool()diff --git a/autogpt_platform/backend/backend/server/v2/chat/tools/_test_data.py b/autogpt_platform/backend/backend/api/features/chat/tools/_test_data.pysimilarity index 99%rename from autogpt_platform/backend/backend/server/v2/chat/tools/_test_data.pyrename to autogpt_platform/backend/backend/api/features/chat/tools/_test_data.pyindex 162894f5f1..f75b7bb0d0 100644--- a/autogpt_platform/backend/backend/server/v2/chat/tools/_test_data.py+++ b/autogpt_platform/backend/backend/api/features/chat/tools/_test_data.py@@ -5,6 +5,8 @@ from os import getenvimport pytestfrom pydantic import SecretStr+from backend.api.features.chat.model import ChatSession+from backend.api.features.store import db as store_dbfrom backend.blocks.firecrawl.scrape import FirecrawlScrapeBlockfrom backend.blocks.io import AgentInputBlock, AgentOutputBlockfrom backend.blocks.llm import AITextGeneratorBlock@@ -13,8 +15,6 @@ from backend.data.graph import Graph, Link, Node, create_graphfrom backend.data.model import APIKeyCredentialsfrom backend.data.user import get_or_create_userfrom backend.integrations.credentials_store import IntegrationCredentialsStore-from backend.server.v2.chat.model import ChatSession-from backend.server.v2.store import db as store_dbdef make_session(user_id: str | None = None):diff --git a/autogpt_platform/backend/backend/server/v2/chat/tools/base.py b/autogpt_platform/backend/backend/api/features/chat/tools/base.pysimilarity index 96%rename from autogpt_platform/backend/backend/server/v2/chat/tools/base.pyrename to autogpt_platform/backend/backend/api/features/chat/tools/base.pyindex f6c4c06284..b4c9d8d731 100644--- a/autogpt_platform/backend/backend/server/v2/chat/tools/base.py+++ b/autogpt_platform/backend/backend/api/features/chat/tools/base.py@@ -5,8 +5,8 @@ from typing import Anyfrom openai.types.chat import ChatCompletionToolParam-from backend.server.v2.chat.model import ChatSession-from backend.server.v2.chat.response_model import StreamToolExecutionResult+from backend.api.features.chat.model import ChatSession+from backend.api.features.chat.response_model import StreamToolExecutionResultfrom .models import ErrorResponse, NeedLoginResponse, ToolResponseBasediff --git a/autogpt_platform/backend/backend/server/v2/chat/tools/find_agent.py b/autogpt_platform/backend/backend/api/features/chat/tools/find_agent.pysimilarity index 95%rename from autogpt_platform/backend/backend/server/v2/chat/tools/find_agent.pyrename to autogpt_platform/backend/backend/api/features/chat/tools/find_agent.pyindex 111041a8f4..3ad071f412 100644--- a/autogpt_platform/backend/backend/server/v2/chat/tools/find_agent.py+++ b/autogpt_platform/backend/backend/api/features/chat/tools/find_agent.py@@ -3,17 +3,18 @@import loggingfrom typing import Any-from backend.server.v2.chat.model import ChatSession-from backend.server.v2.chat.tools.base import BaseTool-from backend.server.v2.chat.tools.models import (+from backend.api.features.chat.model import ChatSession+from backend.api.features.store import db as store_db+from backend.util.exceptions import DatabaseError, NotFoundError++from .base import BaseTool+from .models import (AgentCarouselResponse,AgentInfo,ErrorResponse,NoResultsResponse,ToolResponseBase,)-from backend.server.v2.store import db as store_db-from backend.util.exceptions import DatabaseError, NotFoundErrorlogger = logging.getLogger(__name__)diff --git a/autogpt_platform/backend/backend/server/v2/chat/tools/models.py b/autogpt_platform/backend/backend/api/features/chat/tools/models.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/chat/tools/models.pyrename to autogpt_platform/backend/backend/api/features/chat/tools/models.pydiff --git a/autogpt_platform/backend/backend/server/v2/chat/tools/run_agent.py b/autogpt_platform/backend/backend/api/features/chat/tools/run_agent.pysimilarity index 98%rename from autogpt_platform/backend/backend/server/v2/chat/tools/run_agent.pyrename to autogpt_platform/backend/backend/api/features/chat/tools/run_agent.pyindex 9ba2eab893..931e075021 100644--- a/autogpt_platform/backend/backend/server/v2/chat/tools/run_agent.py+++ b/autogpt_platform/backend/backend/api/features/chat/tools/run_agent.py@@ -5,14 +5,21 @@ from typing import Anyfrom pydantic import BaseModel, Field, field_validator+from backend.api.features.chat.config import ChatConfig+from backend.api.features.chat.model import ChatSessionfrom backend.data.graph import GraphModelfrom backend.data.model import CredentialsMetaInputfrom backend.data.user import get_user_by_idfrom backend.executor import utils as execution_utils-from backend.server.v2.chat.config import ChatConfig-from backend.server.v2.chat.model import ChatSession-from backend.server.v2.chat.tools.base import BaseTool-from backend.server.v2.chat.tools.models import (+from backend.util.clients import get_scheduler_client+from backend.util.exceptions import DatabaseError, NotFoundError+from backend.util.timezone_utils import (+ convert_utc_time_to_user_timezone,+ get_user_timezone_or_utc,+)++from .base import BaseTool+from .models import (AgentDetails,AgentDetailsResponse,ErrorResponse,@@ -23,19 +30,13 @@ from backend.server.v2.chat.tools.models import (ToolResponseBase,UserReadiness,)-from backend.server.v2.chat.tools.utils import (+from .utils import (check_user_has_required_credentials,extract_credentials_from_schema,fetch_graph_from_store_slug,get_or_create_library_agent,match_user_credentials_to_graph,)-from backend.util.clients import get_scheduler_client-from backend.util.exceptions import DatabaseError, NotFoundError-from backend.util.timezone_utils import (- convert_utc_time_to_user_timezone,- get_user_timezone_or_utc,-)logger = logging.getLogger(__name__)config = ChatConfig()diff --git a/autogpt_platform/backend/backend/server/v2/chat/tools/run_agent_test.py b/autogpt_platform/backend/backend/api/features/chat/tools/run_agent_test.pysimilarity index 99%rename from autogpt_platform/backend/backend/server/v2/chat/tools/run_agent_test.pyrename to autogpt_platform/backend/backend/api/features/chat/tools/run_agent_test.pyindex 3ffd4a883e..ebad1a0050 100644--- a/autogpt_platform/backend/backend/server/v2/chat/tools/run_agent_test.py+++ b/autogpt_platform/backend/backend/api/features/chat/tools/run_agent_test.py@@ -3,13 +3,13 @@ import uuidimport orjsonimport pytest-from backend.server.v2.chat.tools._test_data import (+from ._test_data import (make_session,setup_firecrawl_test_data,setup_llm_test_data,setup_test_data,)-from backend.server.v2.chat.tools.run_agent import RunAgentTool+from .run_agent import RunAgentTool# This is so the formatter doesn't remove the fixture importssetup_llm_test_data = setup_llm_test_datadiff --git a/autogpt_platform/backend/backend/server/v2/chat/tools/utils.py b/autogpt_platform/backend/backend/api/features/chat/tools/utils.pysimilarity index 98%rename from autogpt_platform/backend/backend/server/v2/chat/tools/utils.pyrename to autogpt_platform/backend/backend/api/features/chat/tools/utils.pyindex ef4bc6f272..19e092c312 100644--- a/autogpt_platform/backend/backend/server/v2/chat/tools/utils.py+++ b/autogpt_platform/backend/backend/api/features/chat/tools/utils.py@@ -3,13 +3,13 @@import loggingfrom typing import Any+from backend.api.features.library import db as library_db+from backend.api.features.library import model as library_model+from backend.api.features.store import db as store_dbfrom backend.data import graph as graph_dbfrom backend.data.graph import GraphModelfrom backend.data.model import CredentialsMetaInputfrom backend.integrations.creds_manager import IntegrationCredentialsManager-from backend.server.v2.library import db as library_db-from backend.server.v2.library import model as library_model-from backend.server.v2.store import db as store_dbfrom backend.util.exceptions import NotFoundErrorlogger = logging.getLogger(__name__)diff --git a/autogpt_platform/backend/backend/api/features/executions/__init__.py b/autogpt_platform/backend/backend/api/features/executions/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/autogpt_platform/backend/backend/api/features/executions/review/__init__.py b/autogpt_platform/backend/backend/api/features/executions/review/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/autogpt_platform/backend/backend/server/v2/executions/review/model.py b/autogpt_platform/backend/backend/api/features/executions/review/model.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/executions/review/model.pyrename to autogpt_platform/backend/backend/api/features/executions/review/model.pydiff --git a/autogpt_platform/backend/backend/server/v2/executions/review/review_routes_test.py b/autogpt_platform/backend/backend/api/features/executions/review/review_routes_test.pysimilarity index 87%rename from autogpt_platform/backend/backend/server/v2/executions/review/review_routes_test.pyrename to autogpt_platform/backend/backend/api/features/executions/review/review_routes_test.pyindex 2e62641ad3..9d1df5f999 100644--- a/autogpt_platform/backend/backend/server/v2/executions/review/review_routes_test.py+++ b/autogpt_platform/backend/backend/api/features/executions/review/review_routes_test.py@@ -7,9 +7,10 @@ import pytest_mockfrom prisma.enums import ReviewStatusfrom pytest_snapshot.plugin import Snapshot-from backend.server.rest_api import handle_internal_http_error-from backend.server.v2.executions.review.model import PendingHumanReviewModel-from backend.server.v2.executions.review.routes import router+from backend.api.rest_api import handle_internal_http_error++from .model import PendingHumanReviewModel+from .routes import router# Using a fixed timestamp for reproducible testsFIXED_NOW = datetime.datetime(2023, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc)@@ -60,7 +61,7 @@ def test_get_pending_reviews_empty() -> None:"""Test getting pending reviews when none exist"""mock_get_reviews = mocker.patch(- "backend.server.v2.executions.review.routes.get_pending_reviews_for_user"+ "backend.api.features.executions.review.routes.get_pending_reviews_for_user")mock_get_reviews.return_value = []@@ -79,7 +80,7 @@ def test_get_pending_reviews_with_data() -> None:"""Test getting pending reviews with data"""mock_get_reviews = mocker.patch(- "backend.server.v2.executions.review.routes.get_pending_reviews_for_user"+ "backend.api.features.executions.review.routes.get_pending_reviews_for_user")mock_get_reviews.return_value = [sample_pending_review]@@ -101,7 +102,7 @@ def test_get_pending_reviews_for_execution_success() -> None:"""Test getting pending reviews for specific execution"""mock_get_graph_execution = mocker.patch(- "backend.server.v2.executions.review.routes.get_graph_execution_meta"+ "backend.api.features.executions.review.routes.get_graph_execution_meta")mock_get_graph_execution.return_value = {"id": "test_graph_exec_456",@@ -109,7 +110,7 @@ def test_get_pending_reviews_for_execution_success(}mock_get_reviews = mocker.patch(- "backend.server.v2.executions.review.routes.get_pending_reviews_for_execution"+ "backend.api.features.executions.review.routes.get_pending_reviews_for_execution")mock_get_reviews.return_value = [sample_pending_review]@@ -127,7 +128,7 @@ def test_get_pending_reviews_for_execution_access_denied() -> None:"""Test access denied when user doesn't own the execution"""mock_get_graph_execution = mocker.patch(- "backend.server.v2.executions.review.routes.get_graph_execution_meta"+ "backend.api.features.executions.review.routes.get_graph_execution_meta")mock_get_graph_execution.return_value = None@@ -146,12 +147,12 @@ def test_process_review_action_approve_success(# Mock the route functionsmock_get_reviews_for_execution = mocker.patch(- "backend.server.v2.executions.review.routes.get_pending_reviews_for_execution"+ "backend.api.features.executions.review.routes.get_pending_reviews_for_execution")mock_get_reviews_for_execution.return_value = [sample_pending_review]mock_process_all_reviews = mocker.patch(- "backend.server.v2.executions.review.routes.process_all_reviews_for_execution"+ "backend.api.features.executions.review.routes.process_all_reviews_for_execution")# Create approved review for returnapproved_review = PendingHumanReviewModel(@@ -174,11 +175,11 @@ def test_process_review_action_approve_success(mock_process_all_reviews.return_value = {"test_node_123": approved_review}mock_has_pending = mocker.patch(- "backend.server.v2.executions.review.routes.has_pending_reviews_for_graph_exec"+ "backend.api.features.executions.review.routes.has_pending_reviews_for_graph_exec")mock_has_pending.return_value = False- mocker.patch("backend.server.v2.executions.review.routes.add_graph_execution")+ mocker.patch("backend.api.features.executions.review.routes.add_graph_execution")request_data = {"reviews": [@@ -210,12 +211,12 @@ def test_process_review_action_reject_success(# Mock the route functionsmock_get_reviews_for_execution = mocker.patch(- "backend.server.v2.executions.review.routes.get_pending_reviews_for_execution"+ "backend.api.features.executions.review.routes.get_pending_reviews_for_execution")mock_get_reviews_for_execution.return_value = [sample_pending_review]mock_process_all_reviews = mocker.patch(- "backend.server.v2.executions.review.routes.process_all_reviews_for_execution"+ "backend.api.features.executions.review.routes.process_all_reviews_for_execution")rejected_review = PendingHumanReviewModel(node_exec_id="test_node_123",@@ -237,7 +238,7 @@ def test_process_review_action_reject_success(mock_process_all_reviews.return_value = {"test_node_123": rejected_review}mock_has_pending = mocker.patch(- "backend.server.v2.executions.review.routes.has_pending_reviews_for_graph_exec"+ "backend.api.features.executions.review.routes.has_pending_reviews_for_graph_exec")mock_has_pending.return_value = False@@ -289,12 +290,12 @@ def test_process_review_action_mixed_success(# Mock the route functionsmock_get_reviews_for_execution = mocker.patch(- "backend.server.v2.executions.review.routes.get_pending_reviews_for_execution"+ "backend.api.features.executions.review.routes.get_pending_reviews_for_execution")mock_get_reviews_for_execution.return_value = [sample_pending_review, second_review]mock_process_all_reviews = mocker.patch(- "backend.server.v2.executions.review.routes.process_all_reviews_for_execution"+ "backend.api.features.executions.review.routes.process_all_reviews_for_execution")# Create approved version of first reviewapproved_review = PendingHumanReviewModel(@@ -338,7 +339,7 @@ def test_process_review_action_mixed_success(}mock_has_pending = mocker.patch(- "backend.server.v2.executions.review.routes.has_pending_reviews_for_graph_exec"+ "backend.api.features.executions.review.routes.has_pending_reviews_for_graph_exec")mock_has_pending.return_value = False@@ -392,13 +393,13 @@ def test_process_review_action_review_not_found("""Test error when review is not found"""# Mock the functions that extract graph execution ID from the requestmock_get_reviews_for_execution = mocker.patch(- "backend.server.v2.executions.review.routes.get_pending_reviews_for_execution"+ "backend.api.features.executions.review.routes.get_pending_reviews_for_execution")mock_get_reviews_for_execution.return_value = [] # No reviews found# Mock process_all_reviews to simulate not finding reviewsmock_process_all_reviews = mocker.patch(- "backend.server.v2.executions.review.routes.process_all_reviews_for_execution"+ "backend.api.features.executions.review.routes.process_all_reviews_for_execution")# This should raise a ValueError with "Reviews not found" message based on the data/human_review.py logicmock_process_all_reviews.side_effect = ValueError(@@ -429,13 +430,13 @@ def test_process_review_action_partial_failure("""Test handling of partial failures in review processing"""# Mock the route functionsmock_get_reviews_for_execution = mocker.patch(- "backend.server.v2.executions.review.routes.get_pending_reviews_for_execution"+ "backend.api.features.executions.review.routes.get_pending_reviews_for_execution")mock_get_reviews_for_execution.return_value = [sample_pending_review]# Mock partial failure in processingmock_process_all_reviews = mocker.patch(- "backend.server.v2.executions.review.routes.process_all_reviews_for_execution"+ "backend.api.features.executions.review.routes.process_all_reviews_for_execution")mock_process_all_reviews.side_effect = ValueError("Some reviews failed validation")@@ -463,13 +464,13 @@ def test_process_review_action_invalid_node_exec_id("""Test failure when trying to process review with invalid node execution ID"""# Mock the route functionsmock_get_reviews_for_execution = mocker.patch(- "backend.server.v2.executions.review.routes.get_pending_reviews_for_execution"+ "backend.api.features.executions.review.routes.get_pending_reviews_for_execution")mock_get_reviews_for_execution.return_value = [sample_pending_review]# Mock validation failure - this should return 400, not 500mock_process_all_reviews = mocker.patch(- "backend.server.v2.executions.review.routes.process_all_reviews_for_execution"+ "backend.api.features.executions.review.routes.process_all_reviews_for_execution")mock_process_all_reviews.side_effect = ValueError("Invalid node execution ID format"diff --git a/autogpt_platform/backend/backend/server/v2/executions/review/routes.py b/autogpt_platform/backend/backend/api/features/executions/review/routes.pysimilarity index 98%rename from autogpt_platform/backend/backend/server/v2/executions/review/routes.pyrename to autogpt_platform/backend/backend/api/features/executions/review/routes.pyindex 14fb435457..4aa4fac49b 100644--- a/autogpt_platform/backend/backend/server/v2/executions/review/routes.py+++ b/autogpt_platform/backend/backend/api/features/executions/review/routes.py@@ -13,11 +13,8 @@ from backend.data.human_review import (process_all_reviews_for_execution,)from backend.executor.utils import add_graph_execution-from backend.server.v2.executions.review.model import (- PendingHumanReviewModel,- ReviewRequest,- ReviewResponse,-)++from .model import PendingHumanReviewModel, ReviewRequest, ReviewResponselogger = logging.getLogger(__name__)diff --git a/autogpt_platform/backend/backend/api/features/integrations/__init__.py b/autogpt_platform/backend/backend/api/features/integrations/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/autogpt_platform/backend/backend/server/integrations/models.py b/autogpt_platform/backend/backend/api/features/integrations/models.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/integrations/models.pyrename to autogpt_platform/backend/backend/api/features/integrations/models.pydiff --git a/autogpt_platform/backend/backend/server/integrations/router.py b/autogpt_platform/backend/backend/api/features/integrations/router.pysimilarity index 99%rename from autogpt_platform/backend/backend/server/integrations/router.pyrename to autogpt_platform/backend/backend/api/features/integrations/router.pyindex b4227ad02a..f5dd8c092b 100644--- a/autogpt_platform/backend/backend/server/integrations/router.py+++ b/autogpt_platform/backend/backend/api/features/integrations/router.py@@ -17,6 +17,8 @@ from fastapi import (from pydantic import BaseModel, Field, SecretStrfrom starlette.status import HTTP_500_INTERNAL_SERVER_ERROR, HTTP_502_BAD_GATEWAY+from backend.api.features.library.db import set_preset_webhook, update_preset+from backend.api.features.library.model import LibraryAgentPresetfrom backend.data.graph import NodeModel, get_graph, set_node_webhookfrom backend.data.integrations import (WebhookEvent,@@ -45,13 +47,6 @@ from backend.integrations.creds_manager import IntegrationCredentialsManagerfrom backend.integrations.oauth import CREDENTIALS_BY_PROVIDER, HANDLERS_BY_NAMEfrom backend.integrations.providers import ProviderNamefrom backend.integrations.webhooks import get_webhook_manager-from backend.server.integrations.models import (- ProviderConstants,- ProviderNamesResponse,- get_all_provider_names,-)-from backend.server.v2.library.db import set_preset_webhook, update_preset-from backend.server.v2.library.model import LibraryAgentPresetfrom backend.util.exceptions import (GraphNotInLibraryError,MissingConfigError,@@ -60,6 +55,8 @@ from backend.util.exceptions import ()from backend.util.settings import Settings+from .models import ProviderConstants, ProviderNamesResponse, get_all_provider_names+if TYPE_CHECKING:from backend.integrations.oauth import BaseOAuthHandlerdiff --git a/autogpt_platform/backend/backend/api/features/library/__init__.py b/autogpt_platform/backend/backend/api/features/library/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/autogpt_platform/backend/backend/server/v2/library/db.py b/autogpt_platform/backend/backend/api/features/library/db.pysimilarity index 99%rename from autogpt_platform/backend/backend/server/v2/library/db.pyrename to autogpt_platform/backend/backend/api/features/library/db.pyindex 17a0efa7be..ad34326700 100644--- a/autogpt_platform/backend/backend/server/v2/library/db.py+++ b/autogpt_platform/backend/backend/api/features/library/db.py@@ -4,16 +4,14 @@ from typing import Literal, Optionalimport fastapiimport prisma.errors-import prisma.fieldsimport prisma.modelsimport prisma.types+import backend.api.features.store.exceptions as store_exceptions+import backend.api.features.store.image_gen as store_image_gen+import backend.api.features.store.media as store_mediaimport backend.data.graph as graph_dbimport backend.data.integrations as integrations_db-import backend.server.v2.library.model as library_model-import backend.server.v2.store.exceptions as store_exceptions-import backend.server.v2.store.image_gen as store_image_gen-import backend.server.v2.store.media as store_mediafrom backend.data.block import BlockInputfrom backend.data.db import transactionfrom backend.data.execution import get_graph_execution@@ -28,6 +26,8 @@ from backend.util.json import SafeJsonfrom backend.util.models import Paginationfrom backend.util.settings import Config+from . import model as library_model+logger = logging.getLogger(__name__)config = Config()integration_creds_manager = IntegrationCredentialsManager()diff --git a/autogpt_platform/backend/backend/server/v2/library/db_test.py b/autogpt_platform/backend/backend/api/features/library/db_test.pysimilarity index 94%rename from autogpt_platform/backend/backend/server/v2/library/db_test.pyrename to autogpt_platform/backend/backend/api/features/library/db_test.pyindex cb0095fb39..6023177070 100644--- a/autogpt_platform/backend/backend/server/v2/library/db_test.py+++ b/autogpt_platform/backend/backend/api/features/library/db_test.py@@ -1,16 +1,15 @@from datetime import datetimeimport prisma.enums-import prisma.errorsimport prisma.models-import prisma.typesimport pytest-import backend.server.v2.library.db as db-import backend.server.v2.store.exceptions+import backend.api.features.store.exceptionsfrom backend.data.db import connectfrom backend.data.includes import library_agent_include+from . import db+@pytest.mark.asyncioasync def test_get_library_agents(mocker):@@ -88,7 +87,7 @@ async def test_add_agent_to_library(mocker):await connect()# Mock the transaction context- mock_transaction = mocker.patch("backend.server.v2.library.db.transaction")+ mock_transaction = mocker.patch("backend.api.features.library.db.transaction")mock_transaction.return_value.__aenter__ = mocker.AsyncMock(return_value=None)mock_transaction.return_value.__aexit__ = mocker.AsyncMock(return_value=None)# Mock data@@ -151,7 +150,7 @@ async def test_add_agent_to_library(mocker):)# Mock graph_db.get_graph function that's called to check for HITL blocks- mock_graph_db = mocker.patch("backend.server.v2.library.db.graph_db")+ mock_graph_db = mocker.patch("backend.api.features.library.db.graph_db")mock_graph_model = mocker.Mock()mock_graph_model.nodes = ([]@@ -159,7 +158,9 @@ async def test_add_agent_to_library(mocker):mock_graph_db.get_graph = mocker.AsyncMock(return_value=mock_graph_model)# Mock the model conversion- mock_from_db = mocker.patch("backend.server.v2.library.model.LibraryAgent.from_db")+ mock_from_db = mocker.patch(+ "backend.api.features.library.model.LibraryAgent.from_db"+ )mock_from_db.return_value = mocker.Mock()# Call function@@ -217,7 +218,7 @@ async def test_add_agent_to_library_not_found(mocker):)# Call function and verify exception- with pytest.raises(backend.server.v2.store.exceptions.AgentNotFoundError):+ with pytest.raises(backend.api.features.store.exceptions.AgentNotFoundError):await db.add_store_agent_to_library("version123", "test-user")# Verify mock called correctlydiff --git a/autogpt_platform/backend/backend/server/v2/library/model.py b/autogpt_platform/backend/backend/api/features/library/model.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/library/model.pyrename to autogpt_platform/backend/backend/api/features/library/model.pydiff --git a/autogpt_platform/backend/backend/server/v2/library/model_test.py b/autogpt_platform/backend/backend/api/features/library/model_test.pysimilarity index 95%rename from autogpt_platform/backend/backend/server/v2/library/model_test.pyrename to autogpt_platform/backend/backend/api/features/library/model_test.pyindex d90ecf6f7a..a32b19322d 100644--- a/autogpt_platform/backend/backend/server/v2/library/model_test.py+++ b/autogpt_platform/backend/backend/api/features/library/model_test.py@@ -3,7 +3,7 @@ import datetimeimport prisma.modelsimport pytest-import backend.server.v2.library.model as library_model+from . import model as library_model@pytest.mark.asynciodiff --git a/autogpt_platform/backend/backend/server/v2/library/routes/__init__.py b/autogpt_platform/backend/backend/api/features/library/routes/__init__.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/library/routes/__init__.pyrename to autogpt_platform/backend/backend/api/features/library/routes/__init__.pydiff --git a/autogpt_platform/backend/backend/server/v2/library/routes/agents.py b/autogpt_platform/backend/backend/api/features/library/routes/agents.pysimilarity index 98%rename from autogpt_platform/backend/backend/server/v2/library/routes/agents.pyrename to autogpt_platform/backend/backend/api/features/library/routes/agents.pyindex 173b6ab2b4..5a043009fc 100644--- a/autogpt_platform/backend/backend/server/v2/library/routes/agents.py+++ b/autogpt_platform/backend/backend/api/features/library/routes/agents.py@@ -6,12 +6,13 @@ from fastapi import APIRouter, Body, HTTPException, Query, Security, statusfrom fastapi.responses import Responsefrom prisma.enums import OnboardingStep-import backend.server.v2.library.db as library_db-import backend.server.v2.library.model as library_model-import backend.server.v2.store.exceptions as store_exceptions+import backend.api.features.store.exceptions as store_exceptionsfrom backend.data.onboarding import complete_onboarding_stepfrom backend.util.exceptions import DatabaseError, NotFoundError+from .. import db as library_db+from .. import model as library_model+logger = logging.getLogger(__name__)router = APIRouter(diff --git a/autogpt_platform/backend/backend/server/v2/library/routes/presets.py b/autogpt_platform/backend/backend/api/features/library/routes/presets.pysimilarity index 99%rename from autogpt_platform/backend/backend/server/v2/library/routes/presets.pyrename to autogpt_platform/backend/backend/api/features/library/routes/presets.pyindex b1810395f0..cd4c04e0f2 100644--- a/autogpt_platform/backend/backend/server/v2/library/routes/presets.py+++ b/autogpt_platform/backend/backend/api/features/library/routes/presets.py@@ -4,8 +4,6 @@ from typing import Any, Optionalimport autogpt_libs.auth as autogpt_auth_libfrom fastapi import APIRouter, Body, HTTPException, Query, Security, status-import backend.server.v2.library.db as db-import backend.server.v2.library.model as modelsfrom backend.data.execution import GraphExecutionMetafrom backend.data.graph import get_graphfrom backend.data.integrations import get_webhook@@ -17,6 +15,9 @@ from backend.integrations.webhooks import get_webhook_managerfrom backend.integrations.webhooks.utils import setup_webhook_for_blockfrom backend.util.exceptions import NotFoundError+from .. import db+from .. import model as models+logger = logging.getLogger(__name__)credentials_manager = IntegrationCredentialsManager()diff --git a/autogpt_platform/backend/backend/server/v2/library/routes_test.py b/autogpt_platform/backend/backend/api/features/library/routes_test.pysimilarity index 93%rename from autogpt_platform/backend/backend/server/v2/library/routes_test.pyrename to autogpt_platform/backend/backend/api/features/library/routes_test.pyindex bd5d9827de..ad28b5b6bd 100644--- a/autogpt_platform/backend/backend/server/v2/library/routes_test.py+++ b/autogpt_platform/backend/backend/api/features/library/routes_test.py@@ -7,10 +7,11 @@ import pytestimport pytest_mockfrom pytest_snapshot.plugin import Snapshot-import backend.server.v2.library.model as library_model-from backend.server.v2.library.routes import router as library_routerfrom backend.util.models import Pagination+from . import model as library_model+from .routes import router as library_router+app = fastapi.FastAPI()app.include_router(library_router)@@ -86,7 +87,7 @@ async def test_get_library_agents_success(total_items=2, total_pages=1, current_page=1, page_size=50),)- mock_db_call = mocker.patch("backend.server.v2.library.db.list_library_agents")+ mock_db_call = mocker.patch("backend.api.features.library.db.list_library_agents")mock_db_call.return_value = mocked_valueresponse = client.get("/agents?search_term=test")@@ -112,7 +113,7 @@ async def test_get_library_agents_success(def test_get_library_agents_error(mocker: pytest_mock.MockFixture, test_user_id: str):- mock_db_call = mocker.patch("backend.server.v2.library.db.list_library_agents")+ mock_db_call = mocker.patch("backend.api.features.library.db.list_library_agents")mock_db_call.side_effect = Exception("Test error")response = client.get("/agents?search_term=test")@@ -161,7 +162,7 @@ async def test_get_favorite_library_agents_success(),)mock_db_call = mocker.patch(- "backend.server.v2.library.db.list_favorite_library_agents"+ "backend.api.features.library.db.list_favorite_library_agents")mock_db_call.return_value = mocked_value@@ -184,7 +185,7 @@ def test_get_favorite_library_agents_error(mocker: pytest_mock.MockFixture, test_user_id: str):mock_db_call = mocker.patch(- "backend.server.v2.library.db.list_favorite_library_agents"+ "backend.api.features.library.db.list_favorite_library_agents")mock_db_call.side_effect = Exception("Test error")@@ -223,11 +224,11 @@ def test_add_agent_to_library_success()mock_db_call = mocker.patch(- "backend.server.v2.library.db.add_store_agent_to_library"+ "backend.api.features.library.db.add_store_agent_to_library")mock_db_call.return_value = mock_library_agentmock_complete_onboarding = mocker.patch(- "backend.server.v2.library.routes.agents.complete_onboarding_step",+ "backend.api.features.library.routes.agents.complete_onboarding_step",new_callable=AsyncMock,)@@ -249,7 +250,7 @@ def test_add_agent_to_library_success(def test_add_agent_to_library_error(mocker: pytest_mock.MockFixture, test_user_id: str):mock_db_call = mocker.patch(- "backend.server.v2.library.db.add_store_agent_to_library"+ "backend.api.features.library.db.add_store_agent_to_library")mock_db_call.side_effect = Exception("Test error")diff --git a/autogpt_platform/backend/backend/server/routers/oauth.py b/autogpt_platform/backend/backend/api/features/oauth.pysimilarity index 99%rename from autogpt_platform/backend/backend/server/routers/oauth.pyrename to autogpt_platform/backend/backend/api/features/oauth.pyindex 55f591427a..023a433951 100644--- a/autogpt_platform/backend/backend/server/routers/oauth.py+++ b/autogpt_platform/backend/backend/api/features/oauth.py@@ -5,11 +5,11 @@ Implements OAuth 2.0 Authorization Code flow with PKCE support.Flow:1. User clicks "Login with AutoGPT" in 3rd party app-2. App redirects user to /oauth/authorize with client_id, redirect_uri, scope, state+2. App redirects user to /auth/authorize with client_id, redirect_uri, scope, state3. User sees consent screen (if not already logged in, redirects to login first)4. User approves → backend creates authorization code5. User redirected back to app with code-6. App exchanges code for access/refresh tokens at /oauth/token+6. App exchanges code for access/refresh tokens at /api/oauth/token7. App uses access token to call external API endpoints"""diff --git a/autogpt_platform/backend/backend/server/routers/oauth_test.py b/autogpt_platform/backend/backend/api/features/oauth_test.pysimilarity index 99%rename from autogpt_platform/backend/backend/server/routers/oauth_test.pyrename to autogpt_platform/backend/backend/api/features/oauth_test.pyindex 8ec6911152..5f6b85a88a 100644--- a/autogpt_platform/backend/backend/server/routers/oauth_test.py+++ b/autogpt_platform/backend/backend/api/features/oauth_test.py@@ -28,7 +28,7 @@ from prisma.models import OAuthAuthorizationCode as PrismaOAuthAuthorizationCodefrom prisma.models import OAuthRefreshToken as PrismaOAuthRefreshTokenfrom prisma.models import User as PrismaUser-from backend.server.rest_api import app+from backend.api.rest_api import appkeysmith = APIKeySmith()diff --git a/autogpt_platform/backend/backend/api/features/otto/__init__.py b/autogpt_platform/backend/backend/api/features/otto/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/autogpt_platform/backend/backend/server/v2/otto/models.py b/autogpt_platform/backend/backend/api/features/otto/models.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/otto/models.pyrename to autogpt_platform/backend/backend/api/features/otto/models.pydiff --git a/autogpt_platform/backend/backend/server/v2/otto/routes.py b/autogpt_platform/backend/backend/api/features/otto/routes.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/otto/routes.pyrename to autogpt_platform/backend/backend/api/features/otto/routes.pydiff --git a/autogpt_platform/backend/backend/server/v2/otto/routes_test.py b/autogpt_platform/backend/backend/api/features/otto/routes_test.pysimilarity index 97%rename from autogpt_platform/backend/backend/server/v2/otto/routes_test.pyrename to autogpt_platform/backend/backend/api/features/otto/routes_test.pyindex 2641babe2b..416bcdee76 100644--- a/autogpt_platform/backend/backend/server/v2/otto/routes_test.py+++ b/autogpt_platform/backend/backend/api/features/otto/routes_test.py@@ -6,9 +6,9 @@ import pytestimport pytest_mockfrom pytest_snapshot.plugin import Snapshot-import backend.server.v2.otto.models as otto_models-import backend.server.v2.otto.routes as otto_routes-from backend.server.v2.otto.service import OttoService+from . import models as otto_models+from . import routes as otto_routes+from .service import OttoServiceapp = fastapi.FastAPI()app.include_router(otto_routes.router)diff --git a/autogpt_platform/backend/backend/server/v2/otto/service.py b/autogpt_platform/backend/backend/api/features/otto/service.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/otto/service.pyrename to autogpt_platform/backend/backend/api/features/otto/service.pydiff --git a/autogpt_platform/backend/backend/api/features/postmark/__init__.py b/autogpt_platform/backend/backend/api/features/postmark/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/autogpt_platform/backend/backend/server/routers/postmark/models.py b/autogpt_platform/backend/backend/api/features/postmark/models.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/routers/postmark/models.pyrename to autogpt_platform/backend/backend/api/features/postmark/models.pydiff --git a/autogpt_platform/backend/backend/server/routers/postmark/postmark.py b/autogpt_platform/backend/backend/api/features/postmark/postmark.pysimilarity index 96%rename from autogpt_platform/backend/backend/server/routers/postmark/postmark.pyrename to autogpt_platform/backend/backend/api/features/postmark/postmark.pyindex 2190aa5fce..224e30fa9d 100644--- a/autogpt_platform/backend/backend/server/routers/postmark/postmark.py+++ b/autogpt_platform/backend/backend/api/features/postmark/postmark.py@@ -4,12 +4,15 @@ from typing import Annotatedfrom fastapi import APIRouter, Body, HTTPException, Query, Securityfrom fastapi.responses import JSONResponse+from backend.api.utils.api_key_auth import APIKeyAuthenticatorfrom backend.data.user import (get_user_by_email,set_user_email_verification,unsubscribe_user_by_token,)-from backend.server.routers.postmark.models import (+from backend.util.settings import Settings++from .models import (PostmarkBounceEnum,PostmarkBounceWebhook,PostmarkClickWebhook,@@ -19,8 +22,6 @@ from backend.server.routers.postmark.models import (PostmarkSubscriptionChangeWebhook,PostmarkWebhook,)-from backend.server.utils.api_key_auth import APIKeyAuthenticator-from backend.util.settings import Settingslogger = logging.getLogger(__name__)settings = Settings()diff --git a/autogpt_platform/backend/backend/server/v2/store/README.md b/autogpt_platform/backend/backend/api/features/store/README.mdsimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/store/README.mdrename to autogpt_platform/backend/backend/api/features/store/README.mddiff --git a/autogpt_platform/backend/backend/api/features/store/__init__.py b/autogpt_platform/backend/backend/api/features/store/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/autogpt_platform/backend/backend/server/v2/store/cache.py b/autogpt_platform/backend/backend/api/features/store/cache.pysimilarity index 85%rename from autogpt_platform/backend/backend/server/v2/store/cache.pyrename to autogpt_platform/backend/backend/api/features/store/cache.pyindex 574403342e..7832069d49 100644--- a/autogpt_platform/backend/backend/server/v2/store/cache.py+++ b/autogpt_platform/backend/backend/api/features/store/cache.py@@ -1,8 +1,9 @@from typing import Literal-import backend.server.v2.store.dbfrom backend.util.cache import cached+from . import db as store_db+############################################################# Caches #####################################################################@@ -29,7 +30,7 @@ async def _get_cached_store_agents(page_size: int,):"""Cached helper to get store agents."""- return await backend.server.v2.store.db.get_store_agents(+ return await store_db.get_store_agents(featured=featured,creators=[creator] if creator else None,sorted_by=sorted_by,@@ -44,7 +45,7 @@ async def _get_cached_store_agents(@cached(maxsize=200, ttl_seconds=300, shared_cache=True)async def _get_cached_agent_details(username: str, agent_name: str):"""Cached helper to get agent details."""- return await backend.server.v2.store.db.get_store_agent_details(+ return await store_db.get_store_agent_details(username=username, agent_name=agent_name)@@ -59,7 +60,7 @@ async def _get_cached_store_creators(page_size: int,):"""Cached helper to get store creators."""- return await backend.server.v2.store.db.get_store_creators(+ return await store_db.get_store_creators(featured=featured,search_query=search_query,sorted_by=sorted_by,@@ -72,6 +73,4 @@ async def _get_cached_store_creators(@cached(maxsize=100, ttl_seconds=300, shared_cache=True)async def _get_cached_creator_details(username: str):"""Cached helper to get creator details."""- return await backend.server.v2.store.db.get_store_creator_details(- username=username.lower()- )+ return await store_db.get_store_creator_details(username=username.lower())diff --git a/autogpt_platform/backend/backend/server/v2/store/db.py b/autogpt_platform/backend/backend/api/features/store/db.pysimilarity index 92%rename from autogpt_platform/backend/backend/server/v2/store/db.pyrename to autogpt_platform/backend/backend/api/features/store/db.pyindex 33554a9c2a..12f1783468 100644--- a/autogpt_platform/backend/backend/server/v2/store/db.py+++ b/autogpt_platform/backend/backend/api/features/store/db.py@@ -10,8 +10,6 @@ import prisma.errorsimport prisma.modelsimport prisma.types-import backend.server.v2.store.exceptions-import backend.server.v2.store.modelfrom backend.data.db import query_raw_with_schema, transactionfrom backend.data.graph import (GraphMeta,@@ -30,6 +28,9 @@ from backend.notifications.notifications import queue_notification_asyncfrom backend.util.exceptions import DatabaseErrorfrom backend.util.settings import Settings+from . import exceptions as store_exceptions+from . import model as store_model+logger = logging.getLogger(__name__)settings = Settings()@@ -47,7 +48,7 @@ async def get_store_agents(category: str | None = None,page: int = 1,page_size: int = 20,-) -> backend.server.v2.store.model.StoreAgentsResponse:+) -> store_model.StoreAgentsResponse:"""Get PUBLIC store agents from the StoreAgent view"""@@ -148,10 +149,10 @@ async def get_store_agents(total_pages = (total + page_size - 1) // page_size# Convert raw results to StoreAgent models- store_agents: list[backend.server.v2.store.model.StoreAgent] = []+ store_agents: list[store_model.StoreAgent] = []for agent in agents:try:- store_agent = backend.server.v2.store.model.StoreAgent(+ store_agent = store_model.StoreAgent(slug=agent["slug"],agent_name=agent["agent_name"],agent_image=(@@ -197,11 +198,11 @@ async def get_store_agents(total = await prisma.models.StoreAgent.prisma().count(where=where_clause)total_pages = (total + page_size - 1) // page_size- store_agents: list[backend.server.v2.store.model.StoreAgent] = []+ store_agents: list[store_model.StoreAgent] = []for agent in agents:try:# Create the StoreAgent object safely- store_agent = backend.server.v2.store.model.StoreAgent(+ store_agent = store_model.StoreAgent(slug=agent.slug,agent_name=agent.agent_name,agent_image=agent.agent_image[0] if agent.agent_image else "",@@ -223,9 +224,9 @@ async def get_store_agents(continuelogger.debug(f"Found {len(store_agents)} agents")- return backend.server.v2.store.model.StoreAgentsResponse(+ return store_model.StoreAgentsResponse(agents=store_agents,- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(current_page=page,total_items=total,total_pages=total_pages,@@ -257,7 +258,7 @@ async def log_search_term(search_query: str):async def get_store_agent_details(username: str, agent_name: str-) -> backend.server.v2.store.model.StoreAgentDetails:+) -> store_model.StoreAgentDetails:"""Get PUBLIC store agent details from the StoreAgent view"""logger.debug(f"Getting store agent details for {username}/{agent_name}")@@ -268,7 +269,7 @@ async def get_store_agent_details(if not agent:logger.warning(f"Agent not found: {username}/{agent_name}")- raise backend.server.v2.store.exceptions.AgentNotFoundError(+ raise store_exceptions.AgentNotFoundError(f"Agent {username}/{agent_name} not found")@@ -322,7 +323,7 @@ async def get_store_agent_details(recommended_schedule_cron = Nonelogger.debug(f"Found agent details for {username}/{agent_name}")- return backend.server.v2.store.model.StoreAgentDetails(+ return store_model.StoreAgentDetails(store_listing_version_id=agent.storeListingVersionId,slug=agent.slug,agent_name=agent.agent_name,@@ -342,7 +343,7 @@ async def get_store_agent_details(has_approved_version=has_approved_version,recommended_schedule_cron=recommended_schedule_cron,)- except backend.server.v2.store.exceptions.AgentNotFoundError:+ except store_exceptions.AgentNotFoundError:raiseexcept Exception as e:logger.error(f"Error getting store agent details: {e}")@@ -378,7 +379,7 @@ async def get_available_graph(store_listing_version_id: str) -> GraphMeta:async def get_store_agent_by_version_id(store_listing_version_id: str,-) -> backend.server.v2.store.model.StoreAgentDetails:+) -> store_model.StoreAgentDetails:logger.debug(f"Getting store agent details for {store_listing_version_id}")try:@@ -388,12 +389,12 @@ async def get_store_agent_by_version_id(if not agent:logger.warning(f"Agent not found: {store_listing_version_id}")- raise backend.server.v2.store.exceptions.AgentNotFoundError(+ raise store_exceptions.AgentNotFoundError(f"Agent {store_listing_version_id} not found")logger.debug(f"Found agent details for {store_listing_version_id}")- return backend.server.v2.store.model.StoreAgentDetails(+ return store_model.StoreAgentDetails(store_listing_version_id=agent.storeListingVersionId,slug=agent.slug,agent_name=agent.agent_name,@@ -410,7 +411,7 @@ async def get_store_agent_by_version_id(versions=agent.versions,last_updated=agent.updated_at,)- except backend.server.v2.store.exceptions.AgentNotFoundError:+ except store_exceptions.AgentNotFoundError:raiseexcept Exception as e:logger.error(f"Error getting store agent details: {e}")@@ -423,7 +424,7 @@ async def get_store_creators(sorted_by: Literal["agent_rating", "agent_runs", "num_agents"] | None = None,page: int = 1,page_size: int = 20,-) -> backend.server.v2.store.model.CreatorsResponse:+) -> store_model.CreatorsResponse:"""Get PUBLIC store creators from the Creator view"""logger.debug(f"Getting store creators. featured={featured}, search={search_query}, sorted_by={sorted_by}, page={page}"@@ -498,7 +499,7 @@ async def get_store_creators(# Convert to response modelcreator_models = [- backend.server.v2.store.model.Creator(+ store_model.Creator(username=creator.username,name=creator.name,description=creator.description,@@ -512,9 +513,9 @@ async def get_store_creators(]logger.debug(f"Found {len(creator_models)} creators")- return backend.server.v2.store.model.CreatorsResponse(+ return store_model.CreatorsResponse(creators=creator_models,- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(current_page=page,total_items=total,total_pages=total_pages,@@ -528,7 +529,7 @@ async def get_store_creators(async def get_store_creator_details(username: str,-) -> backend.server.v2.store.model.CreatorDetails:+) -> store_model.CreatorDetails:logger.debug(f"Getting store creator details for {username}")try:@@ -539,12 +540,10 @@ async def get_store_creator_details(if not creator:logger.warning(f"Creator not found: {username}")- raise backend.server.v2.store.exceptions.CreatorNotFoundError(- f"Creator {username} not found"- )+ raise store_exceptions.CreatorNotFoundError(f"Creator {username} not found")logger.debug(f"Found creator details for {username}")- return backend.server.v2.store.model.CreatorDetails(+ return store_model.CreatorDetails(name=creator.name,username=creator.username,description=creator.description,@@ -554,7 +553,7 @@ async def get_store_creator_details(agent_runs=creator.agent_runs,top_categories=creator.top_categories,)- except backend.server.v2.store.exceptions.CreatorNotFoundError:+ except store_exceptions.CreatorNotFoundError:raiseexcept Exception as e:logger.error(f"Error getting store creator details: {e}")@@ -563,7 +562,7 @@ async def get_store_creator_details(async def get_store_submissions(user_id: str, page: int = 1, page_size: int = 20-) -> backend.server.v2.store.model.StoreSubmissionsResponse:+) -> store_model.StoreSubmissionsResponse:"""Get store submissions for the authenticated user -- not an admin"""logger.debug(f"Getting store submissions for user {user_id}, page={page}")@@ -588,7 +587,7 @@ async def get_store_submissions(# Convert to response modelssubmission_models = []for sub in submissions:- submission_model = backend.server.v2.store.model.StoreSubmission(+ submission_model = store_model.StoreSubmission(agent_id=sub.agent_id,agent_version=sub.agent_version,name=sub.name,@@ -613,9 +612,9 @@ async def get_store_submissions(submission_models.append(submission_model)logger.debug(f"Found {len(submission_models)} submissions")- return backend.server.v2.store.model.StoreSubmissionsResponse(+ return store_model.StoreSubmissionsResponse(submissions=submission_models,- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(current_page=page,total_items=total,total_pages=total_pages,@@ -626,9 +625,9 @@ async def get_store_submissions(except Exception as e:logger.error(f"Error fetching store submissions: {e}")# Return empty response rather than exposing internal errors- return backend.server.v2.store.model.StoreSubmissionsResponse(+ return store_model.StoreSubmissionsResponse(submissions=[],- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(current_page=page,total_items=0,total_pages=0,@@ -661,7 +660,7 @@ async def delete_store_submission(if not submission:logger.warning(f"Submission not found for user {user_id}: {submission_id}")- raise backend.server.v2.store.exceptions.SubmissionNotFoundError(+ raise store_exceptions.SubmissionNotFoundError(f"Submission not found for this user. User ID: {user_id}, Submission ID: {submission_id}")@@ -693,7 +692,7 @@ async def create_store_submission(categories: list[str] = [],changes_summary: str | None = "Initial Submission",recommended_schedule_cron: str | None = None,-) -> backend.server.v2.store.model.StoreSubmission:+) -> store_model.StoreSubmission:"""Create the first (and only) store listing and thus submission as a normal user@@ -734,7 +733,7 @@ async def create_store_submission(logger.warning(f"Agent not found for user {user_id}: {agent_id} v{agent_version}")- raise backend.server.v2.store.exceptions.AgentNotFoundError(+ raise store_exceptions.AgentNotFoundError(f"Agent not found for this user. User ID: {user_id}, Agent ID: {agent_id}, Version: {agent_version}")@@ -807,7 +806,7 @@ async def create_store_submission(logger.debug(f"Created store listing for agent {agent_id}")# Return submission details- return backend.server.v2.store.model.StoreSubmission(+ return store_model.StoreSubmission(agent_id=agent_id,agent_version=agent_version,name=name,@@ -830,7 +829,7 @@ async def create_store_submission(logger.debug(f"Slug '{slug}' is already in use by another agent (agent_id: {agent_id}) for user {user_id}")- raise backend.server.v2.store.exceptions.SlugAlreadyInUseError(+ raise store_exceptions.SlugAlreadyInUseError(f"The URL slug '{slug}' is already in use by another one of your agents. Please choose a different slug.") from excelse:@@ -839,8 +838,8 @@ async def create_store_submission(f"Unique constraint violated (not slug): {error_str}") from excexcept (- backend.server.v2.store.exceptions.AgentNotFoundError,- backend.server.v2.store.exceptions.ListingExistsError,+ store_exceptions.AgentNotFoundError,+ store_exceptions.ListingExistsError,):raiseexcept prisma.errors.PrismaError as e:@@ -861,7 +860,7 @@ async def edit_store_submission(changes_summary: str | None = "Update submission",recommended_schedule_cron: str | None = None,instructions: str | None = None,-) -> backend.server.v2.store.model.StoreSubmission:+) -> store_model.StoreSubmission:"""Edit an existing store listing submission.@@ -903,7 +902,7 @@ async def edit_store_submission()if not current_version:- raise backend.server.v2.store.exceptions.SubmissionNotFoundError(+ raise store_exceptions.SubmissionNotFoundError(f"Store listing version not found: {store_listing_version_id}")@@ -912,7 +911,7 @@ async def edit_store_submission(not current_version.StoreListingor current_version.StoreListing.owningUserId != user_id):- raise backend.server.v2.store.exceptions.UnauthorizedError(+ raise store_exceptions.UnauthorizedError(f"User {user_id} does not own submission {store_listing_version_id}")@@ -921,7 +920,7 @@ async def edit_store_submission(# Check if we can edit this submissionif current_version.submissionStatus == prisma.enums.SubmissionStatus.REJECTED:- raise backend.server.v2.store.exceptions.InvalidOperationError(+ raise store_exceptions.InvalidOperationError("Cannot edit a rejected submission")@@ -970,7 +969,7 @@ async def edit_store_submission(if not updated_version:raise DatabaseError("Failed to update store listing version")- return backend.server.v2.store.model.StoreSubmission(+ return store_model.StoreSubmission(agent_id=current_version.agentGraphId,agent_version=current_version.agentGraphVersion,name=name,@@ -991,16 +990,16 @@ async def edit_store_submission()else:- raise backend.server.v2.store.exceptions.InvalidOperationError(+ raise store_exceptions.InvalidOperationError(f"Cannot edit submission with status: {current_version.submissionStatus}")except (- backend.server.v2.store.exceptions.SubmissionNotFoundError,- backend.server.v2.store.exceptions.UnauthorizedError,- backend.server.v2.store.exceptions.AgentNotFoundError,- backend.server.v2.store.exceptions.ListingExistsError,- backend.server.v2.store.exceptions.InvalidOperationError,+ store_exceptions.SubmissionNotFoundError,+ store_exceptions.UnauthorizedError,+ store_exceptions.AgentNotFoundError,+ store_exceptions.ListingExistsError,+ store_exceptions.InvalidOperationError,):raiseexcept prisma.errors.PrismaError as e:@@ -1023,7 +1022,7 @@ async def create_store_version(categories: list[str] = [],changes_summary: str | None = "Initial submission",recommended_schedule_cron: str | None = None,-) -> backend.server.v2.store.model.StoreSubmission:+) -> store_model.StoreSubmission:"""Create a new version for an existing store listing@@ -1056,7 +1055,7 @@ async def create_store_version()if not listing:- raise backend.server.v2.store.exceptions.ListingNotFoundError(+ raise store_exceptions.ListingNotFoundError(f"Store listing not found. User ID: {user_id}, Listing ID: {store_listing_id}")@@ -1068,7 +1067,7 @@ async def create_store_version()if not agent:- raise backend.server.v2.store.exceptions.AgentNotFoundError(+ raise store_exceptions.AgentNotFoundError(f"Agent not found for this user. User ID: {user_id}, Agent ID: {agent_id}, Version: {agent_version}")@@ -1103,7 +1102,7 @@ async def create_store_version(f"Created new version for listing {store_listing_id} of agent {agent_id}")# Return submission details- return backend.server.v2.store.model.StoreSubmission(+ return store_model.StoreSubmission(agent_id=agent_id,agent_version=agent_version,name=name,@@ -1130,7 +1129,7 @@ async def create_store_review(store_listing_version_id: str,score: int,comments: str | None = None,-) -> backend.server.v2.store.model.StoreReview:+) -> store_model.StoreReview:"""Create a review for a store listing as a user to detail their experience"""try:data = prisma.types.StoreListingReviewUpsertInput(@@ -1155,7 +1154,7 @@ async def create_store_review(data=data,)- return backend.server.v2.store.model.StoreReview(+ return store_model.StoreReview(score=review.score,comments=review.comments,)@@ -1167,7 +1166,7 @@ async def create_store_review(async def get_user_profile(user_id: str,-) -> backend.server.v2.store.model.ProfileDetails | None:+) -> store_model.ProfileDetails | None:logger.debug(f"Getting user profile for {user_id}")try:@@ -1177,7 +1176,7 @@ async def get_user_profile(if not profile:return None- return backend.server.v2.store.model.ProfileDetails(+ return store_model.ProfileDetails(name=profile.name,username=profile.username,description=profile.description,@@ -1190,8 +1189,8 @@ async def get_user_profile(async def update_profile(- user_id: str, profile: backend.server.v2.store.model.Profile-) -> backend.server.v2.store.model.CreatorDetails:+ user_id: str, profile: store_model.Profile+) -> store_model.CreatorDetails:"""Update the store profile for a user or create a new one if it doesn't exist.Args:@@ -1214,7 +1213,7 @@ async def update_profile(where={"userId": user_id})if not existing_profile:- raise backend.server.v2.store.exceptions.ProfileNotFoundError(+ raise store_exceptions.ProfileNotFoundError(f"Profile not found for user {user_id}. This should not be possible.")@@ -1250,7 +1249,7 @@ async def update_profile(logger.error(f"Failed to update profile for user {user_id}")raise DatabaseError("Failed to update profile")- return backend.server.v2.store.model.CreatorDetails(+ return store_model.CreatorDetails(name=updated_profile.name,username=updated_profile.username,description=updated_profile.description,@@ -1270,7 +1269,7 @@ async def get_my_agents(user_id: str,page: int = 1,page_size: int = 20,-) -> backend.server.v2.store.model.MyAgentsResponse:+) -> store_model.MyAgentsResponse:"""Get the agents for the authenticated user"""logger.debug(f"Getting my agents for user {user_id}, page={page}")@@ -1307,7 +1306,7 @@ async def get_my_agents(total_pages = (total + page_size - 1) // page_sizemy_agents = [- backend.server.v2.store.model.MyAgent(+ store_model.MyAgent(agent_id=graph.id,agent_version=graph.version,agent_name=graph.name or "",@@ -1320,9 +1319,9 @@ async def get_my_agents(if (graph := library_agent.AgentGraph)]- return backend.server.v2.store.model.MyAgentsResponse(+ return store_model.MyAgentsResponse(agents=my_agents,- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(current_page=page,total_items=total,total_pages=total_pages,@@ -1469,7 +1468,7 @@ async def review_store_submission(external_comments: str,internal_comments: str,reviewer_id: str,-) -> backend.server.v2.store.model.StoreSubmission:+) -> store_model.StoreSubmission:"""Review a store listing submission as an admin."""try:store_listing_version = (@@ -1682,7 +1681,7 @@ async def review_store_submission(pass# Convert to Pydantic model for consistency- return backend.server.v2.store.model.StoreSubmission(+ return store_model.StoreSubmission(agent_id=submission.agentGraphId,agent_version=submission.agentGraphVersion,name=submission.name,@@ -1717,7 +1716,7 @@ async def get_admin_listings_with_versions(search_query: str | None = None,page: int = 1,page_size: int = 20,-) -> backend.server.v2.store.model.StoreListingsWithVersionsResponse:+) -> store_model.StoreListingsWithVersionsResponse:"""Get store listings for admins with all their versions.@@ -1816,10 +1815,10 @@ async def get_admin_listings_with_versions(# Convert to response modelslistings_with_versions = []for listing in listings:- versions: list[backend.server.v2.store.model.StoreSubmission] = []+ versions: list[store_model.StoreSubmission] = []# If we have versions, turn them into StoreSubmission modelsfor version in listing.Versions or []:- version_model = backend.server.v2.store.model.StoreSubmission(+ version_model = store_model.StoreSubmission(agent_id=version.agentGraphId,agent_version=version.agentGraphVersion,name=version.name,@@ -1847,26 +1846,24 @@ async def get_admin_listings_with_versions(creator_email = listing.OwningUser.email if listing.OwningUser else None- listing_with_versions = (- backend.server.v2.store.model.StoreListingWithVersions(- listing_id=listing.id,- slug=listing.slug,- agent_id=listing.agentGraphId,- agent_version=listing.agentGraphVersion,- active_version_id=listing.activeVersionId,- has_approved_version=listing.hasApprovedVersion,- creator_email=creator_email,- latest_version=latest_version,- versions=versions,- )+ listing_with_versions = store_model.StoreListingWithVersions(+ listing_id=listing.id,+ slug=listing.slug,+ agent_id=listing.agentGraphId,+ agent_version=listing.agentGraphVersion,+ active_version_id=listing.activeVersionId,+ has_approved_version=listing.hasApprovedVersion,+ creator_email=creator_email,+ latest_version=latest_version,+ versions=versions,)listings_with_versions.append(listing_with_versions)logger.debug(f"Found {len(listings_with_versions)} listings for admin")- return backend.server.v2.store.model.StoreListingsWithVersionsResponse(+ return store_model.StoreListingsWithVersionsResponse(listings=listings_with_versions,- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(current_page=page,total_items=total,total_pages=total_pages,@@ -1876,9 +1873,9 @@ async def get_admin_listings_with_versions(except Exception as e:logger.error(f"Error fetching admin store listings: {e}")# Return empty response rather than exposing internal errors- return backend.server.v2.store.model.StoreListingsWithVersionsResponse(+ return store_model.StoreListingsWithVersionsResponse(listings=[],- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(current_page=page,total_items=0,total_pages=0,diff --git a/autogpt_platform/backend/backend/server/v2/store/db_test.py b/autogpt_platform/backend/backend/api/features/store/db_test.pysimilarity index 99%rename from autogpt_platform/backend/backend/server/v2/store/db_test.pyrename to autogpt_platform/backend/backend/api/features/store/db_test.pyindex bf7cf39d6a..641f392d86 100644--- a/autogpt_platform/backend/backend/server/v2/store/db_test.py+++ b/autogpt_platform/backend/backend/api/features/store/db_test.py@@ -6,8 +6,8 @@ import prisma.modelsimport pytestfrom prisma import Prisma-import backend.server.v2.store.db as db-from backend.server.v2.store.model import Profile+from . import db+from .model import Profile@pytest.fixture(autouse=True)diff --git a/autogpt_platform/backend/backend/server/v2/store/exceptions.py b/autogpt_platform/backend/backend/api/features/store/exceptions.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/store/exceptions.pyrename to autogpt_platform/backend/backend/api/features/store/exceptions.pydiff --git a/autogpt_platform/backend/backend/server/v2/store/image_gen.py b/autogpt_platform/backend/backend/api/features/store/image_gen.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/store/image_gen.pyrename to autogpt_platform/backend/backend/api/features/store/image_gen.pydiff --git a/autogpt_platform/backend/backend/server/v2/store/media.py b/autogpt_platform/backend/backend/api/features/store/media.pysimilarity index 81%rename from autogpt_platform/backend/backend/server/v2/store/media.pyrename to autogpt_platform/backend/backend/api/features/store/media.pyindex 88542dd2c8..cfdc71567a 100644--- a/autogpt_platform/backend/backend/server/v2/store/media.py+++ b/autogpt_platform/backend/backend/api/features/store/media.py@@ -5,11 +5,12 @@ import uuidimport fastapifrom gcloud.aio import storage as async_storage-import backend.server.v2.store.exceptionsfrom backend.util.exceptions import MissingConfigErrorfrom backend.util.settings import Settingsfrom backend.util.virus_scanner import scan_content_safe+from . import exceptions as store_exceptions+logger = logging.getLogger(__name__)ALLOWED_IMAGE_TYPES = {"image/jpeg", "image/png", "image/gif", "image/webp"}@@ -68,61 +69,55 @@ async def upload_media(await file.seek(0) # Reset file pointerexcept Exception as e:logger.error(f"Error reading file content: {str(e)}")- raise backend.server.v2.store.exceptions.FileReadError(- "Failed to read file content"- ) from e+ raise store_exceptions.FileReadError("Failed to read file content") from e# Validate file signature/magic bytesif file.content_type in ALLOWED_IMAGE_TYPES:# Check image file signaturesif content.startswith(b"\xff\xd8\xff"): # JPEGif file.content_type != "image/jpeg":- raise backend.server.v2.store.exceptions.InvalidFileTypeError(+ raise store_exceptions.InvalidFileTypeError("File signature does not match content type")elif content.startswith(b"\x89PNG\r\n\x1a\n"): # PNGif file.content_type != "image/png":- raise backend.server.v2.store.exceptions.InvalidFileTypeError(+ raise store_exceptions.InvalidFileTypeError("File signature does not match content type")elif content.startswith(b"GIF87a") or content.startswith(b"GIF89a"): # GIFif file.content_type != "image/gif":- raise backend.server.v2.store.exceptions.InvalidFileTypeError(+ raise store_exceptions.InvalidFileTypeError("File signature does not match content type")elif content.startswith(b"RIFF") and content[8:12] == b"WEBP": # WebPif file.content_type != "image/webp":- raise backend.server.v2.store.exceptions.InvalidFileTypeError(+ raise store_exceptions.InvalidFileTypeError("File signature does not match content type")else:- raise backend.server.v2.store.exceptions.InvalidFileTypeError(- "Invalid image file signature"- )+ raise store_exceptions.InvalidFileTypeError("Invalid image file signature")elif file.content_type in ALLOWED_VIDEO_TYPES:# Check video file signaturesif content.startswith(b"\x00\x00\x00") and (content[4:8] == b"ftyp"): # MP4if file.content_type != "video/mp4":- raise backend.server.v2.store.exceptions.InvalidFileTypeError(+ raise store_exceptions.InvalidFileTypeError("File signature does not match content type")elif content.startswith(b"\x1a\x45\xdf\xa3"): # WebMif file.content_type != "video/webm":- raise backend.server.v2.store.exceptions.InvalidFileTypeError(+ raise store_exceptions.InvalidFileTypeError("File signature does not match content type")else:- raise backend.server.v2.store.exceptions.InvalidFileTypeError(- "Invalid video file signature"- )+ raise store_exceptions.InvalidFileTypeError("Invalid video file signature")settings = Settings()# Check required settings first before doing any file processingif not settings.config.media_gcs_bucket_name:logger.error("Missing GCS bucket name setting")- raise backend.server.v2.store.exceptions.StorageConfigError(+ raise store_exceptions.StorageConfigError("Missing storage bucket configuration")@@ -137,7 +132,7 @@ async def upload_media(and content_type not in ALLOWED_VIDEO_TYPES):logger.warning(f"Invalid file type attempted: {content_type}")- raise backend.server.v2.store.exceptions.InvalidFileTypeError(+ raise store_exceptions.InvalidFileTypeError(f"File type not supported. Must be jpeg, png, gif, webp, mp4 or webm. Content type: {content_type}")@@ -150,16 +145,14 @@ async def upload_media(file_size += len(chunk)if file_size > MAX_FILE_SIZE:logger.warning(f"File size too large: {file_size} bytes")- raise backend.server.v2.store.exceptions.FileSizeTooLargeError(+ raise store_exceptions.FileSizeTooLargeError("File too large. Maximum size is 50MB")- except backend.server.v2.store.exceptions.FileSizeTooLargeError:+ except store_exceptions.FileSizeTooLargeError:raiseexcept Exception as e:logger.error(f"Error reading file chunks: {str(e)}")- raise backend.server.v2.store.exceptions.FileReadError(- "Failed to read uploaded file"- ) from e+ raise store_exceptions.FileReadError("Failed to read uploaded file") from e# Reset file pointerawait file.seek(0)@@ -198,14 +191,14 @@ async def upload_media(except Exception as e:logger.error(f"GCS storage error: {str(e)}")- raise backend.server.v2.store.exceptions.StorageUploadError(+ raise store_exceptions.StorageUploadError("Failed to upload file to storage") from e- except backend.server.v2.store.exceptions.MediaUploadError:+ except store_exceptions.MediaUploadError:raiseexcept Exception as e:logger.exception("Unexpected error in upload_media")- raise backend.server.v2.store.exceptions.MediaUploadError(+ raise store_exceptions.MediaUploadError("Unexpected error during media upload") from ediff --git a/autogpt_platform/backend/backend/server/v2/store/media_test.py b/autogpt_platform/backend/backend/api/features/store/media_test.pysimilarity index 75%rename from autogpt_platform/backend/backend/server/v2/store/media_test.pyrename to autogpt_platform/backend/backend/api/features/store/media_test.pyindex 3722d2fdc3..7f3899c8a5 100644--- a/autogpt_platform/backend/backend/server/v2/store/media_test.py+++ b/autogpt_platform/backend/backend/api/features/store/media_test.py@@ -6,17 +6,18 @@ import fastapiimport pytestimport starlette.datastructures-import backend.server.v2.store.exceptions-import backend.server.v2.store.mediafrom backend.util.settings import Settings+from . import exceptions as store_exceptions+from . import media as store_media+@pytest.fixturedef mock_settings(monkeypatch):settings = Settings()settings.config.media_gcs_bucket_name = "test-bucket"settings.config.google_application_credentials = "test-credentials"- monkeypatch.setattr("backend.server.v2.store.media.Settings", lambda: settings)+ monkeypatch.setattr("backend.api.features.store.media.Settings", lambda: settings)return settings@@ -32,12 +33,13 @@ def mock_storage_client(mocker):# Mock the constructor to return our mock clientmocker.patch(- "backend.server.v2.store.media.async_storage.Storage", return_value=mock_client+ "backend.api.features.store.media.async_storage.Storage",+ return_value=mock_client,)# Mock virus scanner to avoid actual scanningmocker.patch(- "backend.server.v2.store.media.scan_content_safe", new_callable=AsyncMock+ "backend.api.features.store.media.scan_content_safe", new_callable=AsyncMock)return mock_client@@ -53,7 +55,7 @@ async def test_upload_media_success(mock_settings, mock_storage_client):headers=starlette.datastructures.Headers({"content-type": "image/jpeg"}),)- result = await backend.server.v2.store.media.upload_media("test-user", test_file)+ result = await store_media.upload_media("test-user", test_file)assert result.startswith("https://storage.googleapis.com/test-bucket/users/test-user/images/"@@ -69,8 +71,8 @@ async def test_upload_media_invalid_type(mock_settings, mock_storage_client):headers=starlette.datastructures.Headers({"content-type": "text/plain"}),)- with pytest.raises(backend.server.v2.store.exceptions.InvalidFileTypeError):- await backend.server.v2.store.media.upload_media("test-user", test_file)+ with pytest.raises(store_exceptions.InvalidFileTypeError):+ await store_media.upload_media("test-user", test_file)mock_storage_client.upload.assert_not_called()@@ -79,7 +81,7 @@ async def test_upload_media_missing_credentials(monkeypatch):settings = Settings()settings.config.media_gcs_bucket_name = ""settings.config.google_application_credentials = ""- monkeypatch.setattr("backend.server.v2.store.media.Settings", lambda: settings)+ monkeypatch.setattr("backend.api.features.store.media.Settings", lambda: settings)test_file = fastapi.UploadFile(filename="laptop.jpeg",@@ -87,8 +89,8 @@ async def test_upload_media_missing_credentials(monkeypatch):headers=starlette.datastructures.Headers({"content-type": "image/jpeg"}),)- with pytest.raises(backend.server.v2.store.exceptions.StorageConfigError):- await backend.server.v2.store.media.upload_media("test-user", test_file)+ with pytest.raises(store_exceptions.StorageConfigError):+ await store_media.upload_media("test-user", test_file)async def test_upload_media_video_type(mock_settings, mock_storage_client):@@ -98,7 +100,7 @@ async def test_upload_media_video_type(mock_settings, mock_storage_client):headers=starlette.datastructures.Headers({"content-type": "video/mp4"}),)- result = await backend.server.v2.store.media.upload_media("test-user", test_file)+ result = await store_media.upload_media("test-user", test_file)assert result.startswith("https://storage.googleapis.com/test-bucket/users/test-user/videos/"@@ -117,8 +119,8 @@ async def test_upload_media_file_too_large(mock_settings, mock_storage_client):headers=starlette.datastructures.Headers({"content-type": "image/jpeg"}),)- with pytest.raises(backend.server.v2.store.exceptions.FileSizeTooLargeError):- await backend.server.v2.store.media.upload_media("test-user", test_file)+ with pytest.raises(store_exceptions.FileSizeTooLargeError):+ await store_media.upload_media("test-user", test_file)async def test_upload_media_file_read_error(mock_settings, mock_storage_client):@@ -129,8 +131,8 @@ async def test_upload_media_file_read_error(mock_settings, mock_storage_client):)test_file.read = unittest.mock.AsyncMock(side_effect=Exception("Read error"))- with pytest.raises(backend.server.v2.store.exceptions.FileReadError):- await backend.server.v2.store.media.upload_media("test-user", test_file)+ with pytest.raises(store_exceptions.FileReadError):+ await store_media.upload_media("test-user", test_file)async def test_upload_media_png_success(mock_settings, mock_storage_client):@@ -140,7 +142,7 @@ async def test_upload_media_png_success(mock_settings, mock_storage_client):headers=starlette.datastructures.Headers({"content-type": "image/png"}),)- result = await backend.server.v2.store.media.upload_media("test-user", test_file)+ result = await store_media.upload_media("test-user", test_file)assert result.startswith("https://storage.googleapis.com/test-bucket/users/test-user/images/")@@ -154,7 +156,7 @@ async def test_upload_media_gif_success(mock_settings, mock_storage_client):headers=starlette.datastructures.Headers({"content-type": "image/gif"}),)- result = await backend.server.v2.store.media.upload_media("test-user", test_file)+ result = await store_media.upload_media("test-user", test_file)assert result.startswith("https://storage.googleapis.com/test-bucket/users/test-user/images/")@@ -168,7 +170,7 @@ async def test_upload_media_webp_success(mock_settings, mock_storage_client):headers=starlette.datastructures.Headers({"content-type": "image/webp"}),)- result = await backend.server.v2.store.media.upload_media("test-user", test_file)+ result = await store_media.upload_media("test-user", test_file)assert result.startswith("https://storage.googleapis.com/test-bucket/users/test-user/images/")@@ -182,7 +184,7 @@ async def test_upload_media_webm_success(mock_settings, mock_storage_client):headers=starlette.datastructures.Headers({"content-type": "video/webm"}),)- result = await backend.server.v2.store.media.upload_media("test-user", test_file)+ result = await store_media.upload_media("test-user", test_file)assert result.startswith("https://storage.googleapis.com/test-bucket/users/test-user/videos/")@@ -196,8 +198,8 @@ async def test_upload_media_mismatched_signature(mock_settings, mock_storage_cliheaders=starlette.datastructures.Headers({"content-type": "image/jpeg"}),)- with pytest.raises(backend.server.v2.store.exceptions.InvalidFileTypeError):- await backend.server.v2.store.media.upload_media("test-user", test_file)+ with pytest.raises(store_exceptions.InvalidFileTypeError):+ await store_media.upload_media("test-user", test_file)async def test_upload_media_invalid_signature(mock_settings, mock_storage_client):@@ -207,5 +209,5 @@ async def test_upload_media_invalid_signature(mock_settings, mock_storage_clientheaders=starlette.datastructures.Headers({"content-type": "image/jpeg"}),)- with pytest.raises(backend.server.v2.store.exceptions.InvalidFileTypeError):- await backend.server.v2.store.media.upload_media("test-user", test_file)+ with pytest.raises(store_exceptions.InvalidFileTypeError):+ await store_media.upload_media("test-user", test_file)diff --git a/autogpt_platform/backend/backend/server/v2/store/model.py b/autogpt_platform/backend/backend/api/features/store/model.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/store/model.pyrename to autogpt_platform/backend/backend/api/features/store/model.pydiff --git a/autogpt_platform/backend/backend/server/v2/store/model_test.py b/autogpt_platform/backend/backend/api/features/store/model_test.pysimilarity index 83%rename from autogpt_platform/backend/backend/server/v2/store/model_test.pyrename to autogpt_platform/backend/backend/api/features/store/model_test.pyindex c387dfdecb..3633e6549e 100644--- a/autogpt_platform/backend/backend/server/v2/store/model_test.py+++ b/autogpt_platform/backend/backend/api/features/store/model_test.py@@ -2,11 +2,11 @@ import datetimeimport prisma.enums-import backend.server.v2.store.model+from . import model as store_modeldef test_pagination():- pagination = backend.server.v2.store.model.Pagination(+ pagination = store_model.Pagination(total_items=100, total_pages=5, current_page=2, page_size=20)assert pagination.total_items == 100@@ -16,7 +16,7 @@ def test_pagination():def test_store_agent():- agent = backend.server.v2.store.model.StoreAgent(+ agent = store_model.StoreAgent(slug="test-agent",agent_name="Test Agent",agent_image="test.jpg",@@ -34,9 +34,9 @@ def test_store_agent():def test_store_agents_response():- response = backend.server.v2.store.model.StoreAgentsResponse(+ response = store_model.StoreAgentsResponse(agents=[- backend.server.v2.store.model.StoreAgent(+ store_model.StoreAgent(slug="test-agent",agent_name="Test Agent",agent_image="test.jpg",@@ -48,7 +48,7 @@ def test_store_agents_response():rating=4.5,)],- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(total_items=1, total_pages=1, current_page=1, page_size=20),)@@ -57,7 +57,7 @@ def test_store_agents_response():def test_store_agent_details():- details = backend.server.v2.store.model.StoreAgentDetails(+ details = store_model.StoreAgentDetails(store_listing_version_id="version123",slug="test-agent",agent_name="Test Agent",@@ -81,7 +81,7 @@ def test_store_agent_details():def test_creator():- creator = backend.server.v2.store.model.Creator(+ creator = store_model.Creator(agent_rating=4.8,agent_runs=1000,name="Test Creator",@@ -96,9 +96,9 @@ def test_creator():def test_creators_response():- response = backend.server.v2.store.model.CreatorsResponse(+ response = store_model.CreatorsResponse(creators=[- backend.server.v2.store.model.Creator(+ store_model.Creator(agent_rating=4.8,agent_runs=1000,name="Test Creator",@@ -109,7 +109,7 @@ def test_creators_response():is_featured=False,)],- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(total_items=1, total_pages=1, current_page=1, page_size=20),)@@ -118,7 +118,7 @@ def test_creators_response():def test_creator_details():- details = backend.server.v2.store.model.CreatorDetails(+ details = store_model.CreatorDetails(name="Test Creator",username="creator1",description="Test description",@@ -135,7 +135,7 @@ def test_creator_details():def test_store_submission():- submission = backend.server.v2.store.model.StoreSubmission(+ submission = store_model.StoreSubmission(agent_id="agent123",agent_version=1,sub_heading="Test subheading",@@ -154,9 +154,9 @@ def test_store_submission():def test_store_submissions_response():- response = backend.server.v2.store.model.StoreSubmissionsResponse(+ response = store_model.StoreSubmissionsResponse(submissions=[- backend.server.v2.store.model.StoreSubmission(+ store_model.StoreSubmission(agent_id="agent123",agent_version=1,sub_heading="Test subheading",@@ -170,7 +170,7 @@ def test_store_submissions_response():rating=4.5,)],- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(total_items=1, total_pages=1, current_page=1, page_size=20),)@@ -179,7 +179,7 @@ def test_store_submissions_response():def test_store_submission_request():- request = backend.server.v2.store.model.StoreSubmissionRequest(+ request = store_model.StoreSubmissionRequest(agent_id="agent123",agent_version=1,slug="test-agent",diff --git a/autogpt_platform/backend/backend/server/v2/store/routes.py b/autogpt_platform/backend/backend/api/features/store/routes.pysimilarity index 87%rename from autogpt_platform/backend/backend/server/v2/store/routes.pyrename to autogpt_platform/backend/backend/api/features/store/routes.pyindex b0c1df6e22..6a9bb05291 100644--- a/autogpt_platform/backend/backend/server/v2/store/routes.py+++ b/autogpt_platform/backend/backend/api/features/store/routes.py@@ -9,14 +9,14 @@ import fastapiimport fastapi.responsesimport backend.data.graph-import backend.server.v2.store.cache as store_cache-import backend.server.v2.store.db-import backend.server.v2.store.exceptions-import backend.server.v2.store.image_gen-import backend.server.v2.store.media-import backend.server.v2.store.modelimport backend.util.json+from . import cache as store_cache+from . import db as store_db+from . import image_gen as store_image_gen+from . import media as store_media+from . import model as store_model+logger = logging.getLogger(__name__)router = fastapi.APIRouter()@@ -32,7 +32,7 @@ router = fastapi.APIRouter()summary="Get user profile",tags=["store", "private"],dependencies=[fastapi.Security(autogpt_libs.auth.requires_user)],- response_model=backend.server.v2.store.model.ProfileDetails,+ response_model=store_model.ProfileDetails,)async def get_profile(user_id: str = fastapi.Security(autogpt_libs.auth.get_user_id),@@ -41,7 +41,7 @@ async def get_profile(Get the profile details for the authenticated user.Cached for 1 hour per user."""- profile = await backend.server.v2.store.db.get_user_profile(user_id)+ profile = await store_db.get_user_profile(user_id)if profile is None:return fastapi.responses.JSONResponse(status_code=404,@@ -55,10 +55,10 @@ async def get_profile(summary="Update user profile",tags=["store", "private"],dependencies=[fastapi.Security(autogpt_libs.auth.requires_user)],- response_model=backend.server.v2.store.model.CreatorDetails,+ response_model=store_model.CreatorDetails,)async def update_or_create_profile(- profile: backend.server.v2.store.model.Profile,+ profile: store_model.Profile,user_id: str = fastapi.Security(autogpt_libs.auth.get_user_id),):"""@@ -74,9 +74,7 @@ async def update_or_create_profile(Raises:HTTPException: If there is an error updating the profile"""- updated_profile = await backend.server.v2.store.db.update_profile(- user_id=user_id, profile=profile- )+ updated_profile = await store_db.update_profile(user_id=user_id, profile=profile)return updated_profile@@ -89,7 +87,7 @@ async def update_or_create_profile("/agents",summary="List store agents",tags=["store", "public"],- response_model=backend.server.v2.store.model.StoreAgentsResponse,+ response_model=store_model.StoreAgentsResponse,)async def get_agents(featured: bool = False,@@ -152,7 +150,7 @@ async def get_agents("/agents/{username}/{agent_name}",summary="Get specific agent",tags=["store", "public"],- response_model=backend.server.v2.store.model.StoreAgentDetails,+ response_model=store_model.StoreAgentDetails,)async def get_agent(username: str, agent_name: str):"""@@ -179,9 +177,7 @@ async def get_graph_meta_by_store_listing_version_id(store_listing_version_id: s"""Get Agent Graph from Store Listing Version ID."""- graph = await backend.server.v2.store.db.get_available_graph(- store_listing_version_id- )+ graph = await store_db.get_available_graph(store_listing_version_id)return graph@@ -190,15 +186,13 @@ async def get_graph_meta_by_store_listing_version_id(store_listing_version_id: ssummary="Get agent by version",tags=["store"],dependencies=[fastapi.Security(autogpt_libs.auth.requires_user)],- response_model=backend.server.v2.store.model.StoreAgentDetails,+ response_model=store_model.StoreAgentDetails,)async def get_store_agent(store_listing_version_id: str):"""Get Store Agent Details from Store Listing Version ID."""- agent = await backend.server.v2.store.db.get_store_agent_by_version_id(- store_listing_version_id- )+ agent = await store_db.get_store_agent_by_version_id(store_listing_version_id)return agent@@ -208,12 +202,12 @@ async def get_store_agent(store_listing_version_id: str):summary="Create agent review",tags=["store"],dependencies=[fastapi.Security(autogpt_libs.auth.requires_user)],- response_model=backend.server.v2.store.model.StoreReview,+ response_model=store_model.StoreReview,)async def create_review(username: str,agent_name: str,- review: backend.server.v2.store.model.StoreReviewCreate,+ review: store_model.StoreReviewCreate,user_id: str = fastapi.Security(autogpt_libs.auth.get_user_id),):"""@@ -231,7 +225,7 @@ async def create_review(username = urllib.parse.unquote(username).lower()agent_name = urllib.parse.unquote(agent_name).lower()# Create the review- created_review = await backend.server.v2.store.db.create_store_review(+ created_review = await store_db.create_store_review(user_id=user_id,store_listing_version_id=review.store_listing_version_id,score=review.score,@@ -250,7 +244,7 @@ async def create_review("/creators",summary="List store creators",tags=["store", "public"],- response_model=backend.server.v2.store.model.CreatorsResponse,+ response_model=store_model.CreatorsResponse,)async def get_creators(featured: bool = False,@@ -295,7 +289,7 @@ async def get_creators("/creator/{username}",summary="Get creator details",tags=["store", "public"],- response_model=backend.server.v2.store.model.CreatorDetails,+ response_model=store_model.CreatorDetails,)async def get_creator(username: str,@@ -319,7 +313,7 @@ async def get_creator(summary="Get my agents",tags=["store", "private"],dependencies=[fastapi.Security(autogpt_libs.auth.requires_user)],- response_model=backend.server.v2.store.model.MyAgentsResponse,+ response_model=store_model.MyAgentsResponse,)async def get_my_agents(user_id: str = fastapi.Security(autogpt_libs.auth.get_user_id),@@ -329,9 +323,7 @@ async def get_my_agents("""Get user's own agents."""- agents = await backend.server.v2.store.db.get_my_agents(- user_id, page=page, page_size=page_size- )+ agents = await store_db.get_my_agents(user_id, page=page, page_size=page_size)return agents@@ -356,7 +348,7 @@ async def delete_submission(Returns:bool: True if the submission was successfully deleted, False otherwise"""- result = await backend.server.v2.store.db.delete_store_submission(+ result = await store_db.delete_store_submission(user_id=user_id,submission_id=submission_id,)@@ -369,7 +361,7 @@ async def delete_submission(summary="List my submissions",tags=["store", "private"],dependencies=[fastapi.Security(autogpt_libs.auth.requires_user)],- response_model=backend.server.v2.store.model.StoreSubmissionsResponse,+ response_model=store_model.StoreSubmissionsResponse,)async def get_submissions(user_id: str = fastapi.Security(autogpt_libs.auth.get_user_id),@@ -399,7 +391,7 @@ async def get_submissions(raise fastapi.HTTPException(status_code=422, detail="Page size must be greater than 0")- listings = await backend.server.v2.store.db.get_store_submissions(+ listings = await store_db.get_store_submissions(user_id=user_id,page=page,page_size=page_size,@@ -412,10 +404,10 @@ async def get_submissions(summary="Create store submission",tags=["store", "private"],dependencies=[fastapi.Security(autogpt_libs.auth.requires_user)],- response_model=backend.server.v2.store.model.StoreSubmission,+ response_model=store_model.StoreSubmission,)async def create_submission(- submission_request: backend.server.v2.store.model.StoreSubmissionRequest,+ submission_request: store_model.StoreSubmissionRequest,user_id: str = fastapi.Security(autogpt_libs.auth.get_user_id),):"""@@ -431,7 +423,7 @@ async def create_submission(Raises:HTTPException: If there is an error creating the submission"""- result = await backend.server.v2.store.db.create_store_submission(+ result = await store_db.create_store_submission(user_id=user_id,agent_id=submission_request.agent_id,agent_version=submission_request.agent_version,@@ -456,11 +448,11 @@ async def create_submission(summary="Edit store submission",tags=["store", "private"],dependencies=[fastapi.Security(autogpt_libs.auth.requires_user)],- response_model=backend.server.v2.store.model.StoreSubmission,+ response_model=store_model.StoreSubmission,)async def edit_submission(store_listing_version_id: str,- submission_request: backend.server.v2.store.model.StoreSubmissionEditRequest,+ submission_request: store_model.StoreSubmissionEditRequest,user_id: str = fastapi.Security(autogpt_libs.auth.get_user_id),):"""@@ -477,7 +469,7 @@ async def edit_submission(Raises:HTTPException: If there is an error editing the submission"""- result = await backend.server.v2.store.db.edit_store_submission(+ result = await store_db.edit_store_submission(user_id=user_id,store_listing_version_id=store_listing_version_id,name=submission_request.name,@@ -518,9 +510,7 @@ async def upload_submission_media(Raises:HTTPException: If there is an error uploading the media"""- media_url = await backend.server.v2.store.media.upload_media(- user_id=user_id, file=file- )+ media_url = await store_media.upload_media(user_id=user_id, file=file)return media_url@@ -555,14 +545,12 @@ async def generate_image(# Use .jpeg here since we are generating JPEG imagesfilename = f"agent_{agent_id}.jpeg"- existing_url = await backend.server.v2.store.media.check_media_exists(- user_id, filename- )+ existing_url = await store_media.check_media_exists(user_id, filename)if existing_url:logger.info(f"Using existing image for agent {agent_id}")return fastapi.responses.JSONResponse(content={"image_url": existing_url})# Generate agent image as JPEG- image = await backend.server.v2.store.image_gen.generate_agent_image(agent=agent)+ image = await store_image_gen.generate_agent_image(agent=agent)# Create UploadFile with the correct filename and content_typeimage_file = fastapi.UploadFile(@@ -570,7 +558,7 @@ async def generate_image(filename=filename,)- image_url = await backend.server.v2.store.media.upload_media(+ image_url = await store_media.upload_media(user_id=user_id, file=image_file, use_file_name=True)@@ -599,7 +587,7 @@ async def download_agent_file(Raises:HTTPException: If the agent is not found or an unexpected error occurs."""- graph_data = await backend.server.v2.store.db.get_agent(store_listing_version_id)+ graph_data = await store_db.get_agent(store_listing_version_id)file_name = f"agent_{graph_data.id}_v{graph_data.version or 'latest'}.json"# Sending graph as a stream (similar to marketplace v1)diff --git a/autogpt_platform/backend/backend/server/v2/store/routes_test.py b/autogpt_platform/backend/backend/api/features/store/routes_test.pysimilarity index 76%rename from autogpt_platform/backend/backend/server/v2/store/routes_test.pyrename to autogpt_platform/backend/backend/api/features/store/routes_test.pyindex 03322ee988..b9c040c149 100644--- a/autogpt_platform/backend/backend/server/v2/store/routes_test.py+++ b/autogpt_platform/backend/backend/api/features/store/routes_test.py@@ -8,15 +8,15 @@ import pytestimport pytest_mockfrom pytest_snapshot.plugin import Snapshot-import backend.server.v2.store.model-import backend.server.v2.store.routes+from . import model as store_model+from . import routes as store_routes# Using a fixed timestamp for reproducible tests# 2023 date is intentionally used to ensure tests work regardless of current yearFIXED_NOW = datetime.datetime(2023, 1, 1, 0, 0, 0)app = fastapi.FastAPI()-app.include_router(backend.server.v2.store.routes.router)+app.include_router(store_routes.router)client = fastapi.testclient.TestClient(app)@@ -35,23 +35,21 @@ def test_get_agents_defaults(mocker: pytest_mock.MockFixture,snapshot: Snapshot,) -> None:- mocked_value = backend.server.v2.store.model.StoreAgentsResponse(+ mocked_value = store_model.StoreAgentsResponse(agents=[],- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(current_page=0,total_items=0,total_pages=0,page_size=10,),)- mock_db_call = mocker.patch("backend.server.v2.store.db.get_store_agents")+ mock_db_call = mocker.patch("backend.api.features.store.db.get_store_agents")mock_db_call.return_value = mocked_valueresponse = client.get("/agents")assert response.status_code == 200- data = backend.server.v2.store.model.StoreAgentsResponse.model_validate(- response.json()- )+ data = store_model.StoreAgentsResponse.model_validate(response.json())assert data.pagination.total_pages == 0assert data.agents == []@@ -72,9 +70,9 @@ def test_get_agents_featured(mocker: pytest_mock.MockFixture,snapshot: Snapshot,) -> None:- mocked_value = backend.server.v2.store.model.StoreAgentsResponse(+ mocked_value = store_model.StoreAgentsResponse(agents=[- backend.server.v2.store.model.StoreAgent(+ store_model.StoreAgent(slug="featured-agent",agent_name="Featured Agent",agent_image="featured.jpg",@@ -86,20 +84,18 @@ def test_get_agents_featured(rating=4.5,)],- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(current_page=1,total_items=1,total_pages=1,page_size=20,),)- mock_db_call = mocker.patch("backend.server.v2.store.db.get_store_agents")+ mock_db_call = mocker.patch("backend.api.features.store.db.get_store_agents")mock_db_call.return_value = mocked_valueresponse = client.get("/agents?featured=true")assert response.status_code == 200- data = backend.server.v2.store.model.StoreAgentsResponse.model_validate(- response.json()- )+ data = store_model.StoreAgentsResponse.model_validate(response.json())assert len(data.agents) == 1assert data.agents[0].slug == "featured-agent"snapshot.snapshot_dir = "snapshots"@@ -119,9 +115,9 @@ def test_get_agents_by_creator(mocker: pytest_mock.MockFixture,snapshot: Snapshot,) -> None:- mocked_value = backend.server.v2.store.model.StoreAgentsResponse(+ mocked_value = store_model.StoreAgentsResponse(agents=[- backend.server.v2.store.model.StoreAgent(+ store_model.StoreAgent(slug="creator-agent",agent_name="Creator Agent",agent_image="agent.jpg",@@ -133,20 +129,18 @@ def test_get_agents_by_creator(rating=4.0,)],- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(current_page=1,total_items=1,total_pages=1,page_size=20,),)- mock_db_call = mocker.patch("backend.server.v2.store.db.get_store_agents")+ mock_db_call = mocker.patch("backend.api.features.store.db.get_store_agents")mock_db_call.return_value = mocked_valueresponse = client.get("/agents?creator=specific-creator")assert response.status_code == 200- data = backend.server.v2.store.model.StoreAgentsResponse.model_validate(- response.json()- )+ data = store_model.StoreAgentsResponse.model_validate(response.json())assert len(data.agents) == 1assert data.agents[0].creator == "specific-creator"snapshot.snapshot_dir = "snapshots"@@ -166,9 +160,9 @@ def test_get_agents_sorted(mocker: pytest_mock.MockFixture,snapshot: Snapshot,) -> None:- mocked_value = backend.server.v2.store.model.StoreAgentsResponse(+ mocked_value = store_model.StoreAgentsResponse(agents=[- backend.server.v2.store.model.StoreAgent(+ store_model.StoreAgent(slug="top-agent",agent_name="Top Agent",agent_image="top.jpg",@@ -180,20 +174,18 @@ def test_get_agents_sorted(rating=5.0,)],- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(current_page=1,total_items=1,total_pages=1,page_size=20,),)- mock_db_call = mocker.patch("backend.server.v2.store.db.get_store_agents")+ mock_db_call = mocker.patch("backend.api.features.store.db.get_store_agents")mock_db_call.return_value = mocked_valueresponse = client.get("/agents?sorted_by=runs")assert response.status_code == 200- data = backend.server.v2.store.model.StoreAgentsResponse.model_validate(- response.json()- )+ data = store_model.StoreAgentsResponse.model_validate(response.json())assert len(data.agents) == 1assert data.agents[0].runs == 1000snapshot.snapshot_dir = "snapshots"@@ -213,9 +205,9 @@ def test_get_agents_search(mocker: pytest_mock.MockFixture,snapshot: Snapshot,) -> None:- mocked_value = backend.server.v2.store.model.StoreAgentsResponse(+ mocked_value = store_model.StoreAgentsResponse(agents=[- backend.server.v2.store.model.StoreAgent(+ store_model.StoreAgent(slug="search-agent",agent_name="Search Agent",agent_image="search.jpg",@@ -227,20 +219,18 @@ def test_get_agents_search(rating=4.2,)],- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(current_page=1,total_items=1,total_pages=1,page_size=20,),)- mock_db_call = mocker.patch("backend.server.v2.store.db.get_store_agents")+ mock_db_call = mocker.patch("backend.api.features.store.db.get_store_agents")mock_db_call.return_value = mocked_valueresponse = client.get("/agents?search_query=specific")assert response.status_code == 200- data = backend.server.v2.store.model.StoreAgentsResponse.model_validate(- response.json()- )+ data = store_model.StoreAgentsResponse.model_validate(response.json())assert len(data.agents) == 1assert "specific" in data.agents[0].description.lower()snapshot.snapshot_dir = "snapshots"@@ -260,9 +250,9 @@ def test_get_agents_category(mocker: pytest_mock.MockFixture,snapshot: Snapshot,) -> None:- mocked_value = backend.server.v2.store.model.StoreAgentsResponse(+ mocked_value = store_model.StoreAgentsResponse(agents=[- backend.server.v2.store.model.StoreAgent(+ store_model.StoreAgent(slug="category-agent",agent_name="Category Agent",agent_image="category.jpg",@@ -274,20 +264,18 @@ def test_get_agents_category(rating=4.1,)],- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(current_page=1,total_items=1,total_pages=1,page_size=20,),)- mock_db_call = mocker.patch("backend.server.v2.store.db.get_store_agents")+ mock_db_call = mocker.patch("backend.api.features.store.db.get_store_agents")mock_db_call.return_value = mocked_valueresponse = client.get("/agents?category=test-category")assert response.status_code == 200- data = backend.server.v2.store.model.StoreAgentsResponse.model_validate(- response.json()- )+ data = store_model.StoreAgentsResponse.model_validate(response.json())assert len(data.agents) == 1snapshot.snapshot_dir = "snapshots"snapshot.assert_match(json.dumps(response.json(), indent=2), "agts_category")@@ -306,9 +294,9 @@ def test_get_agents_pagination(mocker: pytest_mock.MockFixture,snapshot: Snapshot,) -> None:- mocked_value = backend.server.v2.store.model.StoreAgentsResponse(+ mocked_value = store_model.StoreAgentsResponse(agents=[- backend.server.v2.store.model.StoreAgent(+ store_model.StoreAgent(slug=f"agent-{i}",agent_name=f"Agent {i}",agent_image=f"agent{i}.jpg",@@ -321,20 +309,18 @@ def test_get_agents_pagination()for i in range(5)],- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(current_page=2,total_items=15,total_pages=3,page_size=5,),)- mock_db_call = mocker.patch("backend.server.v2.store.db.get_store_agents")+ mock_db_call = mocker.patch("backend.api.features.store.db.get_store_agents")mock_db_call.return_value = mocked_valueresponse = client.get("/agents?page=2&page_size=5")assert response.status_code == 200- data = backend.server.v2.store.model.StoreAgentsResponse.model_validate(- response.json()- )+ data = store_model.StoreAgentsResponse.model_validate(response.json())assert len(data.agents) == 5assert data.pagination.current_page == 2assert data.pagination.page_size == 5@@ -365,7 +351,7 @@ def test_get_agents_malformed_request(mocker: pytest_mock.MockFixture):assert response.status_code == 422# Verify no DB calls were made- mock_db_call = mocker.patch("backend.server.v2.store.db.get_store_agents")+ mock_db_call = mocker.patch("backend.api.features.store.db.get_store_agents")mock_db_call.assert_not_called()@@ -373,7 +359,7 @@ def test_get_agent_details(mocker: pytest_mock.MockFixture,snapshot: Snapshot,) -> None:- mocked_value = backend.server.v2.store.model.StoreAgentDetails(+ mocked_value = store_model.StoreAgentDetails(store_listing_version_id="test-version-id",slug="test-agent",agent_name="Test Agent",@@ -390,15 +376,13 @@ def test_get_agent_details(versions=["1.0.0", "1.1.0"],last_updated=FIXED_NOW,)- mock_db_call = mocker.patch("backend.server.v2.store.db.get_store_agent_details")+ mock_db_call = mocker.patch("backend.api.features.store.db.get_store_agent_details")mock_db_call.return_value = mocked_valueresponse = client.get("/agents/creator1/test-agent")assert response.status_code == 200- data = backend.server.v2.store.model.StoreAgentDetails.model_validate(- response.json()- )+ data = store_model.StoreAgentDetails.model_validate(response.json())assert data.agent_name == "Test Agent"assert data.creator == "creator1"snapshot.snapshot_dir = "snapshots"@@ -410,24 +394,22 @@ def test_get_creators_defaults(mocker: pytest_mock.MockFixture,snapshot: Snapshot,) -> None:- mocked_value = backend.server.v2.store.model.CreatorsResponse(+ mocked_value = store_model.CreatorsResponse(creators=[],- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(current_page=0,total_items=0,total_pages=0,page_size=10,),)- mock_db_call = mocker.patch("backend.server.v2.store.db.get_store_creators")+ mock_db_call = mocker.patch("backend.api.features.store.db.get_store_creators")mock_db_call.return_value = mocked_valueresponse = client.get("/creators")assert response.status_code == 200- data = backend.server.v2.store.model.CreatorsResponse.model_validate(- response.json()- )+ data = store_model.CreatorsResponse.model_validate(response.json())assert data.pagination.total_pages == 0assert data.creators == []snapshot.snapshot_dir = "snapshots"@@ -441,9 +423,9 @@ def test_get_creators_pagination(mocker: pytest_mock.MockFixture,snapshot: Snapshot,) -> None:- mocked_value = backend.server.v2.store.model.CreatorsResponse(+ mocked_value = store_model.CreatorsResponse(creators=[- backend.server.v2.store.model.Creator(+ store_model.Creator(name=f"Creator {i}",username=f"creator{i}",description=f"Creator {i} description",@@ -455,22 +437,20 @@ def test_get_creators_pagination()for i in range(5)],- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(current_page=2,total_items=15,total_pages=3,page_size=5,),)- mock_db_call = mocker.patch("backend.server.v2.store.db.get_store_creators")+ mock_db_call = mocker.patch("backend.api.features.store.db.get_store_creators")mock_db_call.return_value = mocked_valueresponse = client.get("/creators?page=2&page_size=5")assert response.status_code == 200- data = backend.server.v2.store.model.CreatorsResponse.model_validate(- response.json()- )+ data = store_model.CreatorsResponse.model_validate(response.json())assert len(data.creators) == 5assert data.pagination.current_page == 2assert data.pagination.page_size == 5@@ -495,7 +475,7 @@ def test_get_creators_malformed_request(mocker: pytest_mock.MockFixture):assert response.status_code == 422# Verify no DB calls were made- mock_db_call = mocker.patch("backend.server.v2.store.db.get_store_creators")+ mock_db_call = mocker.patch("backend.api.features.store.db.get_store_creators")mock_db_call.assert_not_called()@@ -503,7 +483,7 @@ def test_get_creator_details(mocker: pytest_mock.MockFixture,snapshot: Snapshot,) -> None:- mocked_value = backend.server.v2.store.model.CreatorDetails(+ mocked_value = store_model.CreatorDetails(name="Test User",username="creator1",description="Test creator description",@@ -513,13 +493,15 @@ def test_get_creator_details(agent_runs=1000,top_categories=["category1", "category2"],)- mock_db_call = mocker.patch("backend.server.v2.store.db.get_store_creator_details")+ mock_db_call = mocker.patch(+ "backend.api.features.store.db.get_store_creator_details"+ )mock_db_call.return_value = mocked_valueresponse = client.get("/creator/creator1")assert response.status_code == 200- data = backend.server.v2.store.model.CreatorDetails.model_validate(response.json())+ data = store_model.CreatorDetails.model_validate(response.json())assert data.username == "creator1"assert data.name == "Test User"snapshot.snapshot_dir = "snapshots"@@ -532,9 +514,9 @@ def test_get_submissions_success(snapshot: Snapshot,test_user_id: str,) -> None:- mocked_value = backend.server.v2.store.model.StoreSubmissionsResponse(+ mocked_value = store_model.StoreSubmissionsResponse(submissions=[- backend.server.v2.store.model.StoreSubmission(+ store_model.StoreSubmission(name="Test Agent",description="Test agent description",image_urls=["test.jpg"],@@ -550,22 +532,20 @@ def test_get_submissions_success(categories=["test-category"],)],- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(current_page=1,total_items=1,total_pages=1,page_size=20,),)- mock_db_call = mocker.patch("backend.server.v2.store.db.get_store_submissions")+ mock_db_call = mocker.patch("backend.api.features.store.db.get_store_submissions")mock_db_call.return_value = mocked_valueresponse = client.get("/submissions")assert response.status_code == 200- data = backend.server.v2.store.model.StoreSubmissionsResponse.model_validate(- response.json()- )+ data = store_model.StoreSubmissionsResponse.model_validate(response.json())assert len(data.submissions) == 1assert data.submissions[0].name == "Test Agent"assert data.pagination.current_page == 1@@ -579,24 +559,22 @@ def test_get_submissions_pagination(snapshot: Snapshot,test_user_id: str,) -> None:- mocked_value = backend.server.v2.store.model.StoreSubmissionsResponse(+ mocked_value = store_model.StoreSubmissionsResponse(submissions=[],- pagination=backend.server.v2.store.model.Pagination(+ pagination=store_model.Pagination(current_page=2,total_items=10,total_pages=2,page_size=5,),)- mock_db_call = mocker.patch("backend.server.v2.store.db.get_store_submissions")+ mock_db_call = mocker.patch("backend.api.features.store.db.get_store_submissions")mock_db_call.return_value = mocked_valueresponse = client.get("/submissions?page=2&page_size=5")assert response.status_code == 200- data = backend.server.v2.store.model.StoreSubmissionsResponse.model_validate(- response.json()- )+ data = store_model.StoreSubmissionsResponse.model_validate(response.json())assert data.pagination.current_page == 2assert data.pagination.page_size == 5snapshot.snapshot_dir = "snapshots"@@ -618,5 +596,5 @@ def test_get_submissions_malformed_request(mocker: pytest_mock.MockFixture):assert response.status_code == 422# Verify no DB calls were made- mock_db_call = mocker.patch("backend.server.v2.store.db.get_store_submissions")+ mock_db_call = mocker.patch("backend.api.features.store.db.get_store_submissions")mock_db_call.assert_not_called()diff --git a/autogpt_platform/backend/backend/server/v2/store/test_cache_delete.py b/autogpt_platform/backend/backend/api/features/store/test_cache_delete.pysimilarity index 96%rename from autogpt_platform/backend/backend/server/v2/store/test_cache_delete.pyrename to autogpt_platform/backend/backend/api/features/store/test_cache_delete.pyindex 4111de0ee8..dd9be1f4ab 100644--- a/autogpt_platform/backend/backend/server/v2/store/test_cache_delete.py+++ b/autogpt_platform/backend/backend/api/features/store/test_cache_delete.py@@ -8,10 +8,11 @@ from unittest.mock import AsyncMock, patchimport pytest-from backend.server.v2.store import cache as store_cache-from backend.server.v2.store.model import StoreAgent, StoreAgentsResponsefrom backend.util.models import Pagination+from . import cache as store_cache+from .model import StoreAgent, StoreAgentsResponse+class TestCacheDeletion:"""Test cache deletion functionality for store routes."""@@ -43,7 +44,7 @@ class TestCacheDeletion:)with patch(- "backend.server.v2.store.db.get_store_agents",+ "backend.api.features.store.db.get_store_agents",new_callable=AsyncMock,return_value=mock_response,) as mock_db:@@ -152,7 +153,7 @@ class TestCacheDeletion:)with patch(- "backend.server.v2.store.db.get_store_agents",+ "backend.api.features.store.db.get_store_agents",new_callable=AsyncMock,return_value=mock_response,):@@ -203,7 +204,7 @@ class TestCacheDeletion:)with patch(- "backend.server.v2.store.db.get_store_agents",+ "backend.api.features.store.db.get_store_agents",new_callable=AsyncMock,return_value=mock_response,) as mock_db:diff --git a/autogpt_platform/backend/backend/server/routers/v1.py b/autogpt_platform/backend/backend/api/features/v1.pysimilarity index 98%rename from autogpt_platform/backend/backend/server/routers/v1.pyrename to autogpt_platform/backend/backend/api/features/v1.pyindex e5e74690f8..9b05b4755f 100644--- a/autogpt_platform/backend/backend/server/routers/v1.py+++ b/autogpt_platform/backend/backend/api/features/v1.py@@ -28,9 +28,18 @@ from pydantic import BaseModelfrom starlette.status import HTTP_204_NO_CONTENT, HTTP_404_NOT_FOUNDfrom typing_extensions import Optional, TypedDict-import backend.server.integrations.router-import backend.server.routers.analytics-import backend.server.v2.library.db as library_db+from backend.api.model import (+ CreateAPIKeyRequest,+ CreateAPIKeyResponse,+ CreateGraph,+ GraphExecutionSource,+ RequestTopUp,+ SetGraphActiveVersion,+ TimezoneResponse,+ UpdatePermissionsRequest,+ UpdateTimezoneRequest,+ UploadFileResponse,+)from backend.data import execution as execution_dbfrom backend.data import graph as graph_dbfrom backend.data.auth import api_key as api_key_db@@ -79,19 +88,6 @@ from backend.monitoring.instrumentation import (record_graph_execution,record_graph_operation,)-from backend.server.model import (- CreateAPIKeyRequest,- CreateAPIKeyResponse,- CreateGraph,- GraphExecutionSource,- RequestTopUp,- SetGraphActiveVersion,- TimezoneResponse,- UpdatePermissionsRequest,- UpdateTimezoneRequest,- UploadFileResponse,-)-from backend.server.v2.store.model import StoreAgentDetailsfrom backend.util.cache import cachedfrom backend.util.clients import get_scheduler_clientfrom backend.util.cloud_storage import get_cloud_storage_handler@@ -105,6 +101,10 @@ from backend.util.timezone_utils import ()from backend.util.virus_scanner import scan_content_safe+from .library import db as library_db+from .library import model as library_model+from .store.model import StoreAgentDetails+def _create_file_size_error(size_bytes: int, max_size_mb: int) -> HTTPException:"""Create standardized file size error response."""@@ -118,76 +118,9 @@ settings = Settings()logger = logging.getLogger(__name__)-async def hide_activity_summaries_if_disabled(- executions: list[execution_db.GraphExecutionMeta], user_id: str-) -> list[execution_db.GraphExecutionMeta]:- """Hide activity summaries and scores if AI_ACTIVITY_STATUS feature is disabled."""- if await is_feature_enabled(Flag.AI_ACTIVITY_STATUS, user_id):- return executions # Return as-is if feature is enabled-- # Filter out activity features if disabled- filtered_executions = []- for execution in executions:- if execution.stats:- filtered_stats = execution.stats.without_activity_features()- execution = execution.model_copy(update={"stats": filtered_stats})- filtered_executions.append(execution)- return filtered_executions---async def hide_activity_summary_if_disabled(- execution: execution_db.GraphExecution | execution_db.GraphExecutionWithNodes,- user_id: str,-) -> execution_db.GraphExecution | execution_db.GraphExecutionWithNodes:- """Hide activity summary and score for a single execution if AI_ACTIVITY_STATUS feature is disabled."""- if await is_feature_enabled(Flag.AI_ACTIVITY_STATUS, user_id):- return execution # Return as-is if feature is enabled-- # Filter out activity features if disabled- if execution.stats:- filtered_stats = execution.stats.without_activity_features()- return execution.model_copy(update={"stats": filtered_stats})- return execution---async def _update_library_agent_version_and_settings(- user_id: str, agent_graph: graph_db.GraphModel-) -> library_db.library_model.LibraryAgent:- # Keep the library agent up to date with the new active version- library = await library_db.update_agent_version_in_library(- user_id, agent_graph.id, agent_graph.version- )- # If the graph has HITL node, initialize the setting if it's not already set.- if (- agent_graph.has_human_in_the_loop- and library.settings.human_in_the_loop_safe_mode is None- ):- await library_db.update_library_agent_settings(- user_id=user_id,- agent_id=library.id,- settings=library.settings.model_copy(- update={"human_in_the_loop_safe_mode": True}- ),- )- return library--# Define the API routesv1_router = APIRouter()-v1_router.include_router(- backend.server.integrations.router.router,- prefix="/integrations",- tags=["integrations"],-)--v1_router.include_router(- backend.server.routers.analytics.router,- prefix="/analytics",- tags=["analytics"],- dependencies=[Security(requires_user)],-)-############################################################################# Auth #############################@@ -953,6 +886,28 @@ async def set_graph_active_version(await on_graph_deactivate(current_active_graph, user_id=user_id)+async def _update_library_agent_version_and_settings(+ user_id: str, agent_graph: graph_db.GraphModel+) -> library_model.LibraryAgent:+ # Keep the library agent up to date with the new active version+ library = await library_db.update_agent_version_in_library(+ user_id, agent_graph.id, agent_graph.version+ )+ # If the graph has HITL node, initialize the setting if it's not already set.+ if (+ agent_graph.has_human_in_the_loop+ and library.settings.human_in_the_loop_safe_mode is None+ ):+ await library_db.update_library_agent_settings(+ user_id=user_id,+ agent_id=library.id,+ settings=library.settings.model_copy(+ update={"human_in_the_loop_safe_mode": True}+ ),+ )+ return library++@v1_router.patch(path="/graphs/{graph_id}/settings",summary="Update graph settings",@@ -1155,6 +1110,23 @@ async def list_graph_executions()+async def hide_activity_summaries_if_disabled(+ executions: list[execution_db.GraphExecutionMeta], user_id: str+) -> list[execution_db.GraphExecutionMeta]:+ """Hide activity summaries and scores if AI_ACTIVITY_STATUS feature is disabled."""+ if await is_feature_enabled(Flag.AI_ACTIVITY_STATUS, user_id):+ return executions # Return as-is if feature is enabled++ # Filter out activity features if disabled+ filtered_executions = []+ for execution in executions:+ if execution.stats:+ filtered_stats = execution.stats.without_activity_features()+ execution = execution.model_copy(update={"stats": filtered_stats})+ filtered_executions.append(execution)+ return filtered_executions++@v1_router.get(path="/graphs/{graph_id}/executions/{graph_exec_id}",summary="Get execution details",@@ -1197,6 +1169,21 @@ async def get_graph_execution(return result+async def hide_activity_summary_if_disabled(+ execution: execution_db.GraphExecution | execution_db.GraphExecutionWithNodes,+ user_id: str,+) -> execution_db.GraphExecution | execution_db.GraphExecutionWithNodes:+ """Hide activity summary and score for a single execution if AI_ACTIVITY_STATUS feature is disabled."""+ if await is_feature_enabled(Flag.AI_ACTIVITY_STATUS, user_id):+ return execution # Return as-is if feature is enabled++ # Filter out activity features if disabled+ if execution.stats:+ filtered_stats = execution.stats.without_activity_features()+ return execution.model_copy(update={"stats": filtered_stats})+ return execution++@v1_router.delete(path="/executions/{graph_exec_id}",summary="Delete graph execution",@@ -1257,7 +1244,7 @@ async def enable_execution_sharing()# Return the share URL- frontend_url = Settings().config.frontend_base_url or "http://localhost:3000"+ frontend_url = settings.config.frontend_base_url or "http://localhost:3000"share_url = f"{frontend_url}/share/{share_token}"return ShareResponse(share_url=share_url, share_token=share_token)diff --git a/autogpt_platform/backend/backend/server/routers/v1_test.py b/autogpt_platform/backend/backend/api/features/v1_test.pysimilarity index 91%rename from autogpt_platform/backend/backend/server/routers/v1_test.pyrename to autogpt_platform/backend/backend/api/features/v1_test.pyindex 69e1b5f2ae..a186d38810 100644--- a/autogpt_platform/backend/backend/server/routers/v1_test.py+++ b/autogpt_platform/backend/backend/api/features/v1_test.py@@ -11,13 +11,13 @@ import starlette.datastructuresfrom fastapi import HTTPException, UploadFilefrom pytest_snapshot.plugin import Snapshot-import backend.server.routers.v1 as v1_routesfrom backend.data.credit import AutoTopUpConfigfrom backend.data.graph import GraphModel-from backend.server.routers.v1 import upload_file++from .v1 import upload_file, v1_routerapp = fastapi.FastAPI()-app.include_router(v1_routes.v1_router)+app.include_router(v1_router)client = fastapi.testclient.TestClient(app)@@ -50,7 +50,7 @@ def test_get_or_create_user_route(}mocker.patch(- "backend.server.routers.v1.get_or_create_user",+ "backend.api.features.v1.get_or_create_user",return_value=mock_user,)@@ -71,7 +71,7 @@ def test_update_user_email_route() -> None:"""Test update user email endpoint"""mocker.patch(- "backend.server.routers.v1.update_user_email",+ "backend.api.features.v1.update_user_email",return_value=None,)@@ -107,7 +107,7 @@ def test_get_graph_blocks(# Mock get_blocksmocker.patch(- "backend.server.routers.v1.get_blocks",+ "backend.api.features.v1.get_blocks",return_value={"test-block": lambda: mock_block},)@@ -146,7 +146,7 @@ def test_execute_graph_block(mock_block.execute = mock_executemocker.patch(- "backend.server.routers.v1.get_block",+ "backend.api.features.v1.get_block",return_value=mock_block,)@@ -155,7 +155,7 @@ def test_execute_graph_block(mock_user.timezone = "UTC"mocker.patch(- "backend.server.routers.v1.get_user_by_id",+ "backend.api.features.v1.get_user_by_id",return_value=mock_user,)@@ -181,7 +181,7 @@ def test_execute_graph_block_not_found() -> None:"""Test execute block with non-existent block"""mocker.patch(- "backend.server.routers.v1.get_block",+ "backend.api.features.v1.get_block",return_value=None,)@@ -200,7 +200,7 @@ def test_get_user_credits(mock_credit_model = Mock()mock_credit_model.get_credits = AsyncMock(return_value=1000)mocker.patch(- "backend.server.routers.v1.get_user_credit_model",+ "backend.api.features.v1.get_user_credit_model",return_value=mock_credit_model,)@@ -227,7 +227,7 @@ def test_request_top_up(return_value="https://checkout.example.com/session123")mocker.patch(- "backend.server.routers.v1.get_user_credit_model",+ "backend.api.features.v1.get_user_credit_model",return_value=mock_credit_model,)@@ -254,7 +254,7 @@ def test_get_auto_top_up(mock_config = AutoTopUpConfig(threshold=100, amount=500)mocker.patch(- "backend.server.routers.v1.get_auto_top_up",+ "backend.api.features.v1.get_auto_top_up",return_value=mock_config,)@@ -279,7 +279,7 @@ def test_configure_auto_top_up("""Test configure auto top-up endpoint - this test would have caught the enum casting bug"""# Mock the set_auto_top_up function to avoid database operationsmocker.patch(- "backend.server.routers.v1.set_auto_top_up",+ "backend.api.features.v1.set_auto_top_up",return_value=None,)@@ -289,7 +289,7 @@ def test_configure_auto_top_up(mock_credit_model.top_up_credits.return_value = Nonemocker.patch(- "backend.server.routers.v1.get_user_credit_model",+ "backend.api.features.v1.get_user_credit_model",return_value=mock_credit_model,)@@ -311,7 +311,7 @@ def test_configure_auto_top_up_validation_errors() -> None:"""Test configure auto top-up endpoint validation"""# Mock set_auto_top_up to avoid database operations for successful case- mocker.patch("backend.server.routers.v1.set_auto_top_up")+ mocker.patch("backend.api.features.v1.set_auto_top_up")# Mock credit model to avoid Stripe API calls for the successful casemock_credit_model = mocker.AsyncMock()@@ -319,7 +319,7 @@ def test_configure_auto_top_up_validation_errors(mock_credit_model.top_up_credits.return_value = Nonemocker.patch(- "backend.server.routers.v1.get_user_credit_model",+ "backend.api.features.v1.get_user_credit_model",return_value=mock_credit_model,)@@ -393,7 +393,7 @@ def test_get_graph()mocker.patch(- "backend.server.routers.v1.graph_db.get_graph",+ "backend.api.features.v1.graph_db.get_graph",return_value=mock_graph,)@@ -415,7 +415,7 @@ def test_get_graph_not_found() -> None:"""Test get graph with non-existent ID"""mocker.patch(- "backend.server.routers.v1.graph_db.get_graph",+ "backend.api.features.v1.graph_db.get_graph",return_value=None,)@@ -443,15 +443,15 @@ def test_delete_graph()mocker.patch(- "backend.server.routers.v1.graph_db.get_graph",+ "backend.api.features.v1.graph_db.get_graph",return_value=mock_graph,)mocker.patch(- "backend.server.routers.v1.on_graph_deactivate",+ "backend.api.features.v1.on_graph_deactivate",return_value=None,)mocker.patch(- "backend.server.routers.v1.graph_db.delete_graph",+ "backend.api.features.v1.graph_db.delete_graph",return_value=3, # Number of versions deleted)@@ -498,8 +498,8 @@ async def test_upload_file_success(test_user_id: str):)# Mock dependencies- with patch("backend.server.routers.v1.scan_content_safe") as mock_scan, patch(- "backend.server.routers.v1.get_cloud_storage_handler"+ with patch("backend.api.features.v1.scan_content_safe") as mock_scan, patch(+ "backend.api.features.v1.get_cloud_storage_handler") as mock_handler_getter:mock_scan.return_value = None@@ -550,8 +550,8 @@ async def test_upload_file_no_filename(test_user_id: str):),)- with patch("backend.server.routers.v1.scan_content_safe") as mock_scan, patch(- "backend.server.routers.v1.get_cloud_storage_handler"+ with patch("backend.api.features.v1.scan_content_safe") as mock_scan, patch(+ "backend.api.features.v1.get_cloud_storage_handler") as mock_handler_getter:mock_scan.return_value = None@@ -610,7 +610,7 @@ async def test_upload_file_virus_scan_failure(test_user_id: str):headers=starlette.datastructures.Headers({"content-type": "text/plain"}),)- with patch("backend.server.routers.v1.scan_content_safe") as mock_scan:+ with patch("backend.api.features.v1.scan_content_safe") as mock_scan:# Mock virus scan to raise exceptionmock_scan.side_effect = RuntimeError("Virus detected!")@@ -631,8 +631,8 @@ async def test_upload_file_cloud_storage_failure(test_user_id: str):headers=starlette.datastructures.Headers({"content-type": "text/plain"}),)- with patch("backend.server.routers.v1.scan_content_safe") as mock_scan, patch(- "backend.server.routers.v1.get_cloud_storage_handler"+ with patch("backend.api.features.v1.scan_content_safe") as mock_scan, patch(+ "backend.api.features.v1.get_cloud_storage_handler") as mock_handler_getter:mock_scan.return_value = None@@ -678,8 +678,8 @@ async def test_upload_file_gcs_not_configured_fallback(test_user_id: str):headers=starlette.datastructures.Headers({"content-type": "text/plain"}),)- with patch("backend.server.routers.v1.scan_content_safe") as mock_scan, patch(- "backend.server.routers.v1.get_cloud_storage_handler"+ with patch("backend.api.features.v1.scan_content_safe") as mock_scan, patch(+ "backend.api.features.v1.get_cloud_storage_handler") as mock_handler_getter:mock_scan.return_value = Nonediff --git a/autogpt_platform/backend/backend/server/middleware/security.py b/autogpt_platform/backend/backend/api/middleware/security.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/middleware/security.pyrename to autogpt_platform/backend/backend/api/middleware/security.pydiff --git a/autogpt_platform/backend/backend/server/middleware/security_test.py b/autogpt_platform/backend/backend/api/middleware/security_test.pysimilarity index 98%rename from autogpt_platform/backend/backend/server/middleware/security_test.pyrename to autogpt_platform/backend/backend/api/middleware/security_test.pyindex 462e5b27ed..57137afc9a 100644--- a/autogpt_platform/backend/backend/server/middleware/security_test.py+++ b/autogpt_platform/backend/backend/api/middleware/security_test.py@@ -3,7 +3,7 @@ from fastapi import FastAPIfrom fastapi.testclient import TestClientfrom starlette.applications import Starlette-from backend.server.middleware.security import SecurityHeadersMiddleware+from backend.api.middleware.security import SecurityHeadersMiddleware@pytest.fixturediff --git a/autogpt_platform/backend/backend/server/model.py b/autogpt_platform/backend/backend/api/model.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/model.pyrename to autogpt_platform/backend/backend/api/model.pydiff --git a/autogpt_platform/backend/backend/server/rest_api.py b/autogpt_platform/backend/backend/api/rest_api.pysimilarity index 78%rename from autogpt_platform/backend/backend/server/rest_api.pyrename to autogpt_platform/backend/backend/api/rest_api.pyindex 5db2b18c27..147f62e781 100644--- a/autogpt_platform/backend/backend/server/rest_api.py+++ b/autogpt_platform/backend/backend/api/rest_api.py@@ -16,36 +16,33 @@ from fastapi.middleware.gzip import GZipMiddlewarefrom fastapi.routing import APIRoutefrom prisma.errors import PrismaError+import backend.api.features.admin.credit_admin_routes+import backend.api.features.admin.execution_analytics_routes+import backend.api.features.admin.store_admin_routes+import backend.api.features.builder+import backend.api.features.builder.routes+import backend.api.features.chat.routes as chat_routes+import backend.api.features.executions.review.routes+import backend.api.features.library.db+import backend.api.features.library.model+import backend.api.features.library.routes+import backend.api.features.oauth+import backend.api.features.otto.routes+import backend.api.features.postmark.postmark+import backend.api.features.store.model+import backend.api.features.store.routes+import backend.api.features.v1import backend.data.blockimport backend.data.dbimport backend.data.graphimport backend.data.userimport backend.integrations.webhooks.utils-import backend.server.routers.oauth-import backend.server.routers.postmark.postmark-import backend.server.routers.v1-import backend.server.v2.admin.credit_admin_routes-import backend.server.v2.admin.execution_analytics_routes-import backend.server.v2.admin.store_admin_routes-import backend.server.v2.builder-import backend.server.v2.builder.routes-import backend.server.v2.chat.routes as chat_routes-import backend.server.v2.executions.review.routes-import backend.server.v2.library.db-import backend.server.v2.library.model-import backend.server.v2.library.routes-import backend.server.v2.otto.routes-import backend.server.v2.store.model-import backend.server.v2.store.routesimport backend.util.serviceimport backend.util.settingsfrom backend.blocks.llm import LlmModelfrom backend.data.model import Credentialsfrom backend.integrations.providers import ProviderNamefrom backend.monitoring.instrumentation import instrument_fastapi-from backend.server.external.api import external_app-from backend.server.middleware.security import SecurityHeadersMiddleware-from backend.server.utils.cors import build_cors_paramsfrom backend.util import jsonfrom backend.util.cloud_storage import shutdown_cloud_storage_handlerfrom backend.util.exceptions import (@@ -56,6 +53,13 @@ from backend.util.exceptions import (from backend.util.feature_flag import initialize_launchdarkly, shutdown_launchdarklyfrom backend.util.service import UnhealthyServiceError+from .external.fastapi_app import external_api+from .features.analytics import router as analytics_router+from .features.integrations.router import router as integrations_router+from .middleware.security import SecurityHeadersMiddleware+from .utils.cors import build_cors_params+from .utils.openapi import sort_openapi+settings = backend.util.settings.Settings()logger = logging.getLogger(__name__)@@ -176,6 +180,9 @@ app.add_middleware(GZipMiddleware, minimum_size=50_000) # 50KB threshold# Add 401 responses to authenticated endpoints in OpenAPI specadd_auth_responses_to_openapi(app)+# Sort OpenAPI schema to eliminate diff on refactors+sort_openapi(app)+# Add Prometheus instrumentationinstrument_fastapi(app,@@ -254,42 +261,52 @@ app.add_exception_handler(MissingConfigError, handle_internal_http_error(503))app.add_exception_handler(ValueError, handle_internal_http_error(400))app.add_exception_handler(Exception, handle_internal_http_error(500))-app.include_router(backend.server.routers.v1.v1_router, tags=["v1"], prefix="/api")+app.include_router(backend.api.features.v1.v1_router, tags=["v1"], prefix="/api")+app.include_router(+ integrations_router,+ prefix="/api/integrations",+ tags=["v1", "integrations"],+)app.include_router(- backend.server.v2.store.routes.router, tags=["v2"], prefix="/api/store"+ analytics_router,+ prefix="/api/analytics",+ tags=["analytics"],)app.include_router(- backend.server.v2.builder.routes.router, tags=["v2"], prefix="/api/builder"+ backend.api.features.store.routes.router, tags=["v2"], prefix="/api/store")app.include_router(- backend.server.v2.admin.store_admin_routes.router,+ backend.api.features.builder.routes.router, tags=["v2"], prefix="/api/builder"+)+app.include_router(+ backend.api.features.admin.store_admin_routes.router,tags=["v2", "admin"],prefix="/api/store",)app.include_router(- backend.server.v2.admin.credit_admin_routes.router,+ backend.api.features.admin.credit_admin_routes.router,tags=["v2", "admin"],prefix="/api/credits",)app.include_router(- backend.server.v2.admin.execution_analytics_routes.router,+ backend.api.features.admin.execution_analytics_routes.router,tags=["v2", "admin"],prefix="/api/executions",)app.include_router(- backend.server.v2.executions.review.routes.router,+ backend.api.features.executions.review.routes.router,tags=["v2", "executions", "review"],prefix="/api/review",)app.include_router(- backend.server.v2.library.routes.router, tags=["v2"], prefix="/api/library"+ backend.api.features.library.routes.router, tags=["v2"], prefix="/api/library")app.include_router(- backend.server.v2.otto.routes.router, tags=["v2", "otto"], prefix="/api/otto"+ backend.api.features.otto.routes.router, tags=["v2", "otto"], prefix="/api/otto")app.include_router(- backend.server.routers.postmark.postmark.router,+ backend.api.features.postmark.postmark.router,tags=["v1", "email"],prefix="/api/email",)@@ -299,12 +316,12 @@ app.include_router(prefix="/api/chat",)app.include_router(- backend.server.routers.oauth.router,+ backend.api.features.oauth.router,tags=["oauth"],prefix="/api/oauth",)-app.mount("/external-api", external_app)+app.mount("/external-api", external_api)@app.get(path="/health", tags=["health"], dependencies=[])@@ -357,7 +374,7 @@ class AgentServer(backend.util.service.AppProcess):graph_version: Optional[int] = None,node_input: Optional[dict[str, Any]] = None,):- return await backend.server.routers.v1.execute_graph(+ return await backend.api.features.v1.execute_graph(user_id=user_id,graph_id=graph_id,graph_version=graph_version,@@ -372,16 +389,16 @@ class AgentServer(backend.util.service.AppProcess):user_id: str,for_export: bool = False,):- return await backend.server.routers.v1.get_graph(+ return await backend.api.features.v1.get_graph(graph_id, user_id, graph_version, for_export)@staticmethodasync def test_create_graph(- create_graph: backend.server.routers.v1.CreateGraph,+ create_graph: backend.api.features.v1.CreateGraph,user_id: str,):- return await backend.server.routers.v1.create_new_graph(create_graph, user_id)+ return await backend.api.features.v1.create_new_graph(create_graph, user_id)@staticmethodasync def test_get_graph_run_status(graph_exec_id: str, user_id: str):@@ -397,45 +414,45 @@ class AgentServer(backend.util.service.AppProcess):@staticmethodasync def test_delete_graph(graph_id: str, user_id: str):"""Used for clean-up after a test run"""- await backend.server.v2.library.db.delete_library_agent_by_graph_id(+ await backend.api.features.library.db.delete_library_agent_by_graph_id(graph_id=graph_id, user_id=user_id)- return await backend.server.routers.v1.delete_graph(graph_id, user_id)+ return await backend.api.features.v1.delete_graph(graph_id, user_id)@staticmethodasync def test_get_presets(user_id: str, page: int = 1, page_size: int = 10):- return await backend.server.v2.library.routes.presets.list_presets(+ return await backend.api.features.library.routes.presets.list_presets(user_id=user_id, page=page, page_size=page_size)@staticmethodasync def test_get_preset(preset_id: str, user_id: str):- return await backend.server.v2.library.routes.presets.get_preset(+ return await backend.api.features.library.routes.presets.get_preset(preset_id=preset_id, user_id=user_id)@staticmethodasync def test_create_preset(- preset: backend.server.v2.library.model.LibraryAgentPresetCreatable,+ preset: backend.api.features.library.model.LibraryAgentPresetCreatable,user_id: str,):- return await backend.server.v2.library.routes.presets.create_preset(+ return await backend.api.features.library.routes.presets.create_preset(preset=preset, user_id=user_id)@staticmethodasync def test_update_preset(preset_id: str,- preset: backend.server.v2.library.model.LibraryAgentPresetUpdatable,+ preset: backend.api.features.library.model.LibraryAgentPresetUpdatable,user_id: str,):- return await backend.server.v2.library.routes.presets.update_preset(+ return await backend.api.features.library.routes.presets.update_preset(preset_id=preset_id, preset=preset, user_id=user_id)@staticmethodasync def test_delete_preset(preset_id: str, user_id: str):- return await backend.server.v2.library.routes.presets.delete_preset(+ return await backend.api.features.library.routes.presets.delete_preset(preset_id=preset_id, user_id=user_id)@@ -445,7 +462,7 @@ class AgentServer(backend.util.service.AppProcess):user_id: str,inputs: Optional[dict[str, Any]] = None,):- return await backend.server.v2.library.routes.presets.execute_preset(+ return await backend.api.features.library.routes.presets.execute_preset(preset_id=preset_id,user_id=user_id,inputs=inputs or {},@@ -454,18 +471,20 @@ class AgentServer(backend.util.service.AppProcess):@staticmethodasync def test_create_store_listing(- request: backend.server.v2.store.model.StoreSubmissionRequest, user_id: str+ request: backend.api.features.store.model.StoreSubmissionRequest, user_id: str):- return await backend.server.v2.store.routes.create_submission(request, user_id)+ return await backend.api.features.store.routes.create_submission(+ request, user_id+ )### ADMIN ###@staticmethodasync def test_review_store_listing(- request: backend.server.v2.store.model.ReviewSubmissionRequest,+ request: backend.api.features.store.model.ReviewSubmissionRequest,user_id: str,):- return await backend.server.v2.admin.store_admin_routes.review_submission(+ return await backend.api.features.admin.store_admin_routes.review_submission(request.store_listing_version_id, request, user_id)@@ -475,10 +494,7 @@ class AgentServer(backend.util.service.AppProcess):provider: ProviderName,credentials: Credentials,) -> Credentials:- from backend.server.integrations.router import (- create_credentials,- get_credential,- )+ from .features.integrations.router import create_credentials, get_credentialtry:return await create_credentials(diff --git a/autogpt_platform/backend/backend/server/test_helpers.py b/autogpt_platform/backend/backend/api/test_helpers.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/test_helpers.pyrename to autogpt_platform/backend/backend/api/test_helpers.pydiff --git a/autogpt_platform/backend/backend/server/utils/api_key_auth.py b/autogpt_platform/backend/backend/api/utils/api_key_auth.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/utils/api_key_auth.pyrename to autogpt_platform/backend/backend/api/utils/api_key_auth.pydiff --git a/autogpt_platform/backend/backend/server/utils/api_key_auth_test.py b/autogpt_platform/backend/backend/api/utils/api_key_auth_test.pysimilarity index 99%rename from autogpt_platform/backend/backend/server/utils/api_key_auth_test.pyrename to autogpt_platform/backend/backend/api/utils/api_key_auth_test.pyindex df6af6633c..39c3150561 100644--- a/autogpt_platform/backend/backend/server/utils/api_key_auth_test.py+++ b/autogpt_platform/backend/backend/api/utils/api_key_auth_test.py@@ -8,7 +8,7 @@ import pytestfrom fastapi import HTTPException, Requestfrom starlette.status import HTTP_401_UNAUTHORIZED, HTTP_403_FORBIDDEN-from backend.server.utils.api_key_auth import APIKeyAuthenticator+from backend.api.utils.api_key_auth import APIKeyAuthenticatorfrom backend.util.exceptions import MissingConfigErrordiff --git a/autogpt_platform/backend/backend/server/utils/cors.py b/autogpt_platform/backend/backend/api/utils/cors.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/utils/cors.pyrename to autogpt_platform/backend/backend/api/utils/cors.pydiff --git a/autogpt_platform/backend/backend/server/utils/cors_test.py b/autogpt_platform/backend/backend/api/utils/cors_test.pysimilarity index 97%rename from autogpt_platform/backend/backend/server/utils/cors_test.pyrename to autogpt_platform/backend/backend/api/utils/cors_test.pyindex 94b3f17cfc..011974383b 100644--- a/autogpt_platform/backend/backend/server/utils/cors_test.py+++ b/autogpt_platform/backend/backend/api/utils/cors_test.py@@ -1,6 +1,6 @@import pytest-from backend.server.utils.cors import build_cors_params+from backend.api.utils.cors import build_cors_paramsfrom backend.util.settings import AppEnvironmentdiff --git a/autogpt_platform/backend/backend/api/utils/openapi.py b/autogpt_platform/backend/backend/api/utils/openapi.pynew file mode 100644index 0000000000..757b220fd0--- /dev/null+++ b/autogpt_platform/backend/backend/api/utils/openapi.py@@ -0,0 +1,41 @@+from fastapi import FastAPI+++def sort_openapi(app: FastAPI) -> None:+ """+ Patch a FastAPI instance's `openapi()` method to sort the endpoints,+ schemas, and responses.+ """+ wrapped_openapi = app.openapi++ def custom_openapi():+ if app.openapi_schema:+ return app.openapi_schema++ openapi_schema = wrapped_openapi()++ # Sort endpoints+ openapi_schema["paths"] = dict(sorted(openapi_schema["paths"].items()))++ # Sort endpoints -> methods+ for p in openapi_schema["paths"].keys():+ openapi_schema["paths"][p] = dict(+ sorted(openapi_schema["paths"][p].items())+ )++ # Sort endpoints -> methods -> responses+ for m in openapi_schema["paths"][p].keys():+ openapi_schema["paths"][p][m]["responses"] = dict(+ sorted(openapi_schema["paths"][p][m]["responses"].items())+ )++ # Sort schemas and responses as well+ for k in openapi_schema["components"].keys():+ openapi_schema["components"][k] = dict(+ sorted(openapi_schema["components"][k].items())+ )++ app.openapi_schema = openapi_schema+ return openapi_schema++ app.openapi = custom_openapidiff --git a/autogpt_platform/backend/backend/server/ws_api.py b/autogpt_platform/backend/backend/api/ws_api.pysimilarity index 98%rename from autogpt_platform/backend/backend/server/ws_api.pyrename to autogpt_platform/backend/backend/api/ws_api.pyindex 344fd7e1a6..b71fdb3526 100644--- a/autogpt_platform/backend/backend/server/ws_api.py+++ b/autogpt_platform/backend/backend/api/ws_api.py@@ -9,6 +9,14 @@ from autogpt_libs.auth.jwt_utils import parse_jwt_tokenfrom fastapi import Depends, FastAPI, WebSocket, WebSocketDisconnectfrom starlette.middleware.cors import CORSMiddleware+from backend.api.conn_manager import ConnectionManager+from backend.api.model import (+ WSMessage,+ WSMethod,+ WSSubscribeGraphExecutionRequest,+ WSSubscribeGraphExecutionsRequest,+)+from backend.api.utils.cors import build_cors_paramsfrom backend.data.execution import AsyncRedisExecutionEventBusfrom backend.data.notification_bus import AsyncRedisNotificationEventBusfrom backend.data.user import DEFAULT_USER_ID@@ -16,14 +24,6 @@ from backend.monitoring.instrumentation import (instrument_fastapi,update_websocket_connections,)-from backend.server.conn_manager import ConnectionManager-from backend.server.model import (- WSMessage,- WSMethod,- WSSubscribeGraphExecutionRequest,- WSSubscribeGraphExecutionsRequest,-)-from backend.server.utils.cors import build_cors_paramsfrom backend.util.retry import continuous_retryfrom backend.util.service import AppProcessfrom backend.util.settings import AppEnvironment, Config, Settingsdiff --git a/autogpt_platform/backend/backend/server/ws_api_test.py b/autogpt_platform/backend/backend/api/ws_api_test.pysimilarity index 92%rename from autogpt_platform/backend/backend/server/ws_api_test.pyrename to autogpt_platform/backend/backend/api/ws_api_test.pyindex 0bc9902145..edab1bbded 100644--- a/autogpt_platform/backend/backend/server/ws_api_test.py+++ b/autogpt_platform/backend/backend/api/ws_api_test.py@@ -6,17 +6,17 @@ import pytestfrom fastapi import WebSocket, WebSocketDisconnectfrom pytest_snapshot.plugin import Snapshot-from backend.data.user import DEFAULT_USER_ID-from backend.server.conn_manager import ConnectionManager-from backend.server.test_helpers import override_config-from backend.server.ws_api import AppEnvironment, WebsocketServer, WSMessage, WSMethod-from backend.server.ws_api import app as websocket_app-from backend.server.ws_api import (+from backend.api.conn_manager import ConnectionManager+from backend.api.test_helpers import override_config+from backend.api.ws_api import AppEnvironment, WebsocketServer, WSMessage, WSMethod+from backend.api.ws_api import app as websocket_app+from backend.api.ws_api import (handle_subscribe,handle_unsubscribe,settings,websocket_router,)+from backend.data.user import DEFAULT_USER_ID@pytest.fixture@@ -36,12 +36,12 @@ def test_websocket_server_uses_cors_helper(mocker) -> None:"allow_origins": ["https://app.example.com"],"allow_origin_regex": None,}- mocker.patch("backend.server.ws_api.uvicorn.run")+ mocker.patch("backend.api.ws_api.uvicorn.run")cors_middleware = mocker.patch(- "backend.server.ws_api.CORSMiddleware", return_value=object()+ "backend.api.ws_api.CORSMiddleware", return_value=object())build_cors = mocker.patch(- "backend.server.ws_api.build_cors_params", return_value=cors_params+ "backend.api.ws_api.build_cors_params", return_value=cors_params)with override_config(@@ -63,7 +63,7 @@ def test_websocket_server_uses_cors_helper(mocker) -> None:def test_websocket_server_blocks_localhost_in_production(mocker) -> None:- mocker.patch("backend.server.ws_api.uvicorn.run")+ mocker.patch("backend.api.ws_api.uvicorn.run")with override_config(settings, "backend_cors_allow_origins", ["http://localhost:3000"]@@ -78,7 +78,7 @@ async def test_websocket_router_subscribe() -> None:# Mock the authenticate_websocket function to ensure it returns a valid user_idmocker.patch(- "backend.server.ws_api.authenticate_websocket", return_value=DEFAULT_USER_ID+ "backend.api.ws_api.authenticate_websocket", return_value=DEFAULT_USER_ID)mock_websocket.receive_text.side_effect = [@@ -128,7 +128,7 @@ async def test_websocket_router_unsubscribe() -> None:# Mock the authenticate_websocket function to ensure it returns a valid user_idmocker.patch(- "backend.server.ws_api.authenticate_websocket", return_value=DEFAULT_USER_ID+ "backend.api.ws_api.authenticate_websocket", return_value=DEFAULT_USER_ID)mock_websocket.receive_text.side_effect = [@@ -175,7 +175,7 @@ async def test_websocket_router_invalid_method() -> None:# Mock the authenticate_websocket function to ensure it returns a valid user_idmocker.patch(- "backend.server.ws_api.authenticate_websocket", return_value=DEFAULT_USER_ID+ "backend.api.ws_api.authenticate_websocket", return_value=DEFAULT_USER_ID)mock_websocket.receive_text.side_effect = [diff --git a/autogpt_platform/backend/backend/app.py b/autogpt_platform/backend/backend/app.pyindex 596962ae0b..0afed130ed 100644--- a/autogpt_platform/backend/backend/app.py+++ b/autogpt_platform/backend/backend/app.py@@ -36,10 +36,10 @@ def main(**kwargs):Run all the processes required for the AutoGPT-server (REST and WebSocket APIs)."""+ from backend.api.rest_api import AgentServer+ from backend.api.ws_api import WebsocketServerfrom backend.executor import DatabaseManager, ExecutionManager, Schedulerfrom backend.notifications import NotificationManager- from backend.server.rest_api import AgentServer- from backend.server.ws_api import WebsocketServerrun_processes(DatabaseManager().set_log_level("warning"),diff --git a/autogpt_platform/backend/backend/blocks/test/test_smart_decision_maker.py b/autogpt_platform/backend/backend/blocks/test/test_smart_decision_maker.pyindex 29f572d0d6..deff4278f9 100644--- a/autogpt_platform/backend/backend/blocks/test/test_smart_decision_maker.py+++ b/autogpt_platform/backend/backend/blocks/test/test_smart_decision_maker.py@@ -5,10 +5,10 @@ from unittest.mock import AsyncMock, MagicMock, patchimport pytest+from backend.api.model import CreateGraph+from backend.api.rest_api import AgentServerfrom backend.data.execution import ExecutionContextfrom backend.data.model import ProviderName, User-from backend.server.model import CreateGraph-from backend.server.rest_api import AgentServerfrom backend.usecases.sample import create_test_graph, create_test_userfrom backend.util.test import SpinTestServer, wait_executiondiff --git a/autogpt_platform/backend/backend/cli.py b/autogpt_platform/backend/backend/cli.pyindex 0fc1bc53c1..d6eaca1dd0 100755--- a/autogpt_platform/backend/backend/cli.py+++ b/autogpt_platform/backend/backend/cli.py@@ -244,11 +244,7 @@ def websocket(server_address: str, graph_exec_id: str):import websockets.asyncio.client- from backend.server.ws_api import (- WSMessage,- WSMethod,- WSSubscribeGraphExecutionRequest,- )+ from backend.api.ws_api import WSMessage, WSMethod, WSSubscribeGraphExecutionRequestasync def send_message(server_address: str):uri = f"ws://{server_address}"diff --git a/autogpt_platform/backend/backend/cli/generate_openapi_json.py b/autogpt_platform/backend/backend/cli/generate_openapi_json.pyindex 313e603c44..de74c0b5d2 100644--- a/autogpt_platform/backend/backend/cli/generate_openapi_json.py+++ b/autogpt_platform/backend/backend/cli/generate_openapi_json.py@@ -2,7 +2,7 @@"""Script to generate OpenAPI JSON specification for the FastAPI app.-This script imports the FastAPI app from backend.server.rest_api and outputs+This script imports the FastAPI app from backend.api.rest_api and outputsthe OpenAPI specification as JSON to stdout or a specified file.Usage:@@ -46,7 +46,7 @@ def main(output: Path, pretty: bool):def get_openapi_schema():"""Get the OpenAPI schema from the FastAPI app"""- from backend.server.rest_api import app+ from backend.api.rest_api import appreturn app.openapi()diff --git a/autogpt_platform/backend/backend/data/__init__.py b/autogpt_platform/backend/backend/data/__init__.pyindex 31ab09a5df..c98667e362 100644--- a/autogpt_platform/backend/backend/data/__init__.py+++ b/autogpt_platform/backend/backend/data/__init__.py@@ -1,4 +1,4 @@-from backend.server.v2.library.model import LibraryAgentPreset+from backend.api.features.library.model import LibraryAgentPresetfrom .graph import NodeModelfrom .integrations import Webhook # noqa: F401diff --git a/autogpt_platform/backend/backend/data/credit.py b/autogpt_platform/backend/backend/data/credit.pyindex a8942d3b2e..95f0b158e1 100644--- a/autogpt_platform/backend/backend/data/credit.py+++ b/autogpt_platform/backend/backend/data/credit.py@@ -16,6 +16,7 @@ from prisma.models import CreditRefundRequest, CreditTransaction, User, UserBalafrom prisma.types import CreditRefundRequestCreateInput, CreditTransactionWhereInputfrom pydantic import BaseModel+from backend.api.features.admin.model import UserHistoryResponsefrom backend.data.block_cost_config import BLOCK_COSTSfrom backend.data.db import query_raw_with_schemafrom backend.data.includes import MAX_CREDIT_REFUND_REQUESTS_FETCH@@ -29,7 +30,6 @@ from backend.data.model import (from backend.data.notifications import NotificationEventModel, RefundRequestDatafrom backend.data.user import get_user_by_id, get_user_email_by_idfrom backend.notifications.notifications import queue_notification_async-from backend.server.v2.admin.model import UserHistoryResponsefrom backend.util.exceptions import InsufficientBalanceErrorfrom backend.util.feature_flag import Flag, is_feature_enabledfrom backend.util.json import SafeJson, dumpsdiff --git a/autogpt_platform/backend/backend/data/db.py b/autogpt_platform/backend/backend/data/db.pyindex b64ce4ef5c..31a27e9163 100644--- a/autogpt_platform/backend/backend/data/db.py+++ b/autogpt_platform/backend/backend/data/db.py@@ -111,7 +111,7 @@ def get_database_schema() -> str:async def query_raw_with_schema(query_template: str, *args) -> list[dict]:"""Execute raw SQL query with proper schema handling."""schema = get_database_schema()- schema_prefix = f"{schema}." if schema != "public" else ""+ schema_prefix = f'"{schema}".' if schema != "public" else ""formatted_query = query_template.format(schema_prefix=schema_prefix)import prisma as prisma_modulediff --git a/autogpt_platform/backend/backend/data/graph_test.py b/autogpt_platform/backend/backend/data/graph_test.pyindex e570392658..044d75e0ca 100644--- a/autogpt_platform/backend/backend/data/graph_test.py+++ b/autogpt_platform/backend/backend/data/graph_test.py@@ -6,14 +6,14 @@ import fastapi.exceptionsimport pytestfrom pytest_snapshot.plugin import Snapshot-import backend.server.v2.store.model as store+import backend.api.features.store.model as store+from backend.api.model import CreateGraphfrom backend.blocks.basic import StoreValueBlockfrom backend.blocks.io import AgentInputBlock, AgentOutputBlockfrom backend.data.block import BlockSchema, BlockSchemaInputfrom backend.data.graph import Graph, Link, Nodefrom backend.data.model import SchemaFieldfrom backend.data.user import DEFAULT_USER_ID-from backend.server.model import CreateGraphfrom backend.usecases.sample import create_test_userfrom backend.util.test import SpinTestServerdiff --git a/autogpt_platform/backend/backend/data/human_review.py b/autogpt_platform/backend/backend/data/human_review.pyindex 11b87ec1dd..de7a30759e 100644--- a/autogpt_platform/backend/backend/data/human_review.py+++ b/autogpt_platform/backend/backend/data/human_review.py@@ -13,7 +13,7 @@ from prisma.models import PendingHumanReviewfrom prisma.types import PendingHumanReviewUpdateInputfrom pydantic import BaseModel-from backend.server.v2.executions.review.model import (+from backend.api.features.executions.review.model import (PendingHumanReviewModel,SafeJsonData,)diff --git a/autogpt_platform/backend/backend/data/integrations.py b/autogpt_platform/backend/backend/data/integrations.pyindex 0f328e81b7..5f44f928bd 100644--- a/autogpt_platform/backend/backend/data/integrations.py+++ b/autogpt_platform/backend/backend/data/integrations.py@@ -23,7 +23,7 @@ from backend.util.exceptions import NotFoundErrorfrom backend.util.json import SafeJsonif TYPE_CHECKING:- from backend.server.v2.library.model import LibraryAgentPreset+ from backend.api.features.library.model import LibraryAgentPresetfrom .db import BaseDbModelfrom .graph import NodeModel@@ -79,7 +79,7 @@ class WebhookWithRelations(Webhook):# integrations.py → library/model.py → integrations.py (for Webhook)# Runtime import is used in WebhookWithRelations.from_db() method instead# Import at runtime to avoid circular dependency- from backend.server.v2.library.model import LibraryAgentPreset+ from backend.api.features.library.model import LibraryAgentPresetreturn WebhookWithRelations(**Webhook.from_db(webhook).model_dump(),@@ -285,8 +285,8 @@ async def unlink_webhook_from_graph(user_id: The ID of the user (for authorization)"""# Avoid circular imports+ from backend.api.features.library.db import set_preset_webhookfrom backend.data.graph import set_node_webhook- from backend.server.v2.library.db import set_preset_webhook# Find all nodes in this graph that use this webhooknodes = await AgentNode.prisma().find_many(diff --git a/autogpt_platform/backend/backend/data/notification_bus.py b/autogpt_platform/backend/backend/data/notification_bus.pyindex 6eb90dca12..fbd484d379 100644--- a/autogpt_platform/backend/backend/data/notification_bus.py+++ b/autogpt_platform/backend/backend/data/notification_bus.py@@ -4,8 +4,8 @@ from typing import AsyncGeneratorfrom pydantic import BaseModel, field_serializer+from backend.api.model import NotificationPayloadfrom backend.data.event_bus import AsyncRedisEventBus-from backend.server.model import NotificationPayloadfrom backend.util.settings import Settingsdiff --git a/autogpt_platform/backend/backend/data/onboarding.py b/autogpt_platform/backend/backend/data/onboarding.pyindex 1415c7694e..d9977e9535 100644--- a/autogpt_platform/backend/backend/data/onboarding.py+++ b/autogpt_platform/backend/backend/data/onboarding.py@@ -9,6 +9,8 @@ from prisma.enums import OnboardingStepfrom prisma.models import UserOnboardingfrom prisma.types import UserOnboardingCreateInput, UserOnboardingUpdateInput+from backend.api.features.store.model import StoreAgentDetails+from backend.api.model import OnboardingNotificationPayloadfrom backend.data import execution as execution_dbfrom backend.data.credit import get_user_credit_modelfrom backend.data.notification_bus import (@@ -16,8 +18,6 @@ from backend.data.notification_bus import (NotificationEvent,)from backend.data.user import get_user_by_id-from backend.server.model import OnboardingNotificationPayload-from backend.server.v2.store.model import StoreAgentDetailsfrom backend.util.cache import cachedfrom backend.util.json import SafeJsonfrom backend.util.timezone_utils import get_user_timezone_or_utcdiff --git a/autogpt_platform/backend/backend/server/v2/AutoMod/__init__.py b/autogpt_platform/backend/backend/executor/automod/__init__.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/AutoMod/__init__.pyrename to autogpt_platform/backend/backend/executor/automod/__init__.pydiff --git a/autogpt_platform/backend/backend/server/v2/AutoMod/manager.py b/autogpt_platform/backend/backend/executor/automod/manager.pysimilarity index 99%rename from autogpt_platform/backend/backend/server/v2/AutoMod/manager.pyrename to autogpt_platform/backend/backend/executor/automod/manager.pyindex 181fcec248..81001196dd 100644--- a/autogpt_platform/backend/backend/server/v2/AutoMod/manager.py+++ b/autogpt_platform/backend/backend/executor/automod/manager.py@@ -9,16 +9,13 @@ if TYPE_CHECKING:from pydantic import ValidationErrorfrom backend.data.execution import ExecutionStatus-from backend.server.v2.AutoMod.models import (- AutoModRequest,- AutoModResponse,- ModerationConfig,-)from backend.util.exceptions import ModerationErrorfrom backend.util.feature_flag import Flag, is_feature_enabledfrom backend.util.request import Requestsfrom backend.util.settings import Settings+from .models import AutoModRequest, AutoModResponse, ModerationConfig+logger = logging.getLogger(__name__)diff --git a/autogpt_platform/backend/backend/server/v2/AutoMod/models.py b/autogpt_platform/backend/backend/executor/automod/models.pysimilarity index 100%rename from autogpt_platform/backend/backend/server/v2/AutoMod/models.pyrename to autogpt_platform/backend/backend/executor/automod/models.pydiff --git a/autogpt_platform/backend/backend/executor/database.py b/autogpt_platform/backend/backend/executor/database.pyindex 9c2b3970c6..af68bf526d 100644--- a/autogpt_platform/backend/backend/executor/database.py+++ b/autogpt_platform/backend/backend/executor/database.py@@ -2,6 +2,11 @@ import loggingfrom contextlib import asynccontextmanagerfrom typing import TYPE_CHECKING, Callable, Concatenate, ParamSpec, TypeVar, cast+from backend.api.features.library.db import (+ add_store_agent_to_library,+ list_library_agents,+)+from backend.api.features.store.db import get_store_agent_details, get_store_agentsfrom backend.data import dbfrom backend.data.analytics import (get_accuracy_trends_and_alerts,@@ -61,8 +66,6 @@ from backend.data.user import (get_user_notification_preference,update_user_integrations,)-from backend.server.v2.library.db import add_store_agent_to_library, list_library_agents-from backend.server.v2.store.db import get_store_agent_details, get_store_agentsfrom backend.util.service import (AppService,AppServiceClient,diff --git a/autogpt_platform/backend/backend/executor/manager.py b/autogpt_platform/backend/backend/executor/manager.pyindex 234f8127c8..161e68b0d6 100644--- a/autogpt_platform/backend/backend/executor/manager.py+++ b/autogpt_platform/backend/backend/executor/manager.py@@ -48,27 +48,8 @@ from backend.data.notifications import (ZeroBalanceData,)from backend.data.rabbitmq import SyncRabbitMQ-from backend.executor.activity_status_generator import (- generate_activity_status_for_execution,-)-from backend.executor.utils import (- GRACEFUL_SHUTDOWN_TIMEOUT_SECONDS,- GRAPH_EXECUTION_CANCEL_QUEUE_NAME,- GRAPH_EXECUTION_EXCHANGE,- GRAPH_EXECUTION_QUEUE_NAME,- GRAPH_EXECUTION_ROUTING_KEY,- CancelExecutionEvent,- ExecutionOutputEntry,- LogMetadata,- NodeExecutionProgress,- block_usage_cost,- create_execution_queue_config,- execution_usage_cost,- validate_exec,-)from backend.integrations.creds_manager import IntegrationCredentialsManagerfrom backend.notifications.notifications import queue_notification-from backend.server.v2.AutoMod.manager import automod_managerfrom backend.util import jsonfrom backend.util.clients import (get_async_execution_event_bus,@@ -95,7 +76,24 @@ from backend.util.retry import ()from backend.util.settings import Settings+from .activity_status_generator import generate_activity_status_for_execution+from .automod.manager import automod_managerfrom .cluster_lock import ClusterLock+from .utils import (+ GRACEFUL_SHUTDOWN_TIMEOUT_SECONDS,+ GRAPH_EXECUTION_CANCEL_QUEUE_NAME,+ GRAPH_EXECUTION_EXCHANGE,+ GRAPH_EXECUTION_QUEUE_NAME,+ GRAPH_EXECUTION_ROUTING_KEY,+ CancelExecutionEvent,+ ExecutionOutputEntry,+ LogMetadata,+ NodeExecutionProgress,+ block_usage_cost,+ create_execution_queue_config,+ execution_usage_cost,+ validate_exec,+)if TYPE_CHECKING:from backend.executor import DatabaseManagerAsyncClient, DatabaseManagerClientdiff --git a/autogpt_platform/backend/backend/executor/manager_test.py b/autogpt_platform/backend/backend/executor/manager_test.pyindex cd543fef4e..bdfdb5d724 100644--- a/autogpt_platform/backend/backend/executor/manager_test.py+++ b/autogpt_platform/backend/backend/executor/manager_test.py@@ -3,16 +3,16 @@ import loggingimport fastapi.responsesimport pytest-import backend.server.v2.library.model-import backend.server.v2.store.model+import backend.api.features.library.model+import backend.api.features.store.model+from backend.api.model import CreateGraph+from backend.api.rest_api import AgentServerfrom backend.blocks.basic import StoreValueBlockfrom backend.blocks.data_manipulation import FindInDictionaryBlockfrom backend.blocks.io import AgentInputBlockfrom backend.blocks.maths import CalculatorBlock, Operationfrom backend.data import execution, graphfrom backend.data.model import User-from backend.server.model import CreateGraph-from backend.server.rest_api import AgentServerfrom backend.usecases.sample import create_test_graph, create_test_userfrom backend.util.test import SpinTestServer, wait_execution@@ -356,7 +356,7 @@ async def test_execute_preset(server: SpinTestServer):test_graph = await create_graph(server, test_graph, test_user)# Create preset with initial values- preset = backend.server.v2.library.model.LibraryAgentPresetCreatable(+ preset = backend.api.features.library.model.LibraryAgentPresetCreatable(name="Test Preset With Clash",description="Test preset with clashing input values",graph_id=test_graph.id,@@ -444,7 +444,7 @@ async def test_execute_preset_with_clash(server: SpinTestServer):test_graph = await create_graph(server, test_graph, test_user)# Create preset with initial values- preset = backend.server.v2.library.model.LibraryAgentPresetCreatable(+ preset = backend.api.features.library.model.LibraryAgentPresetCreatable(name="Test Preset With Clash",description="Test preset with clashing input values",graph_id=test_graph.id,@@ -485,7 +485,7 @@ async def test_store_listing_graph(server: SpinTestServer):test_user = await create_test_user()test_graph = await create_graph(server, create_test_graph(), test_user)- store_submission_request = backend.server.v2.store.model.StoreSubmissionRequest(+ store_submission_request = backend.api.features.store.model.StoreSubmissionRequest(agent_id=test_graph.id,agent_version=test_graph.version,slug=test_graph.id,@@ -514,7 +514,7 @@ async def test_store_listing_graph(server: SpinTestServer):admin_user = await create_test_user(alt_user=True)await server.agent_server.test_review_store_listing(- backend.server.v2.store.model.ReviewSubmissionRequest(+ backend.api.features.store.model.ReviewSubmissionRequest(store_listing_version_id=slv_id,is_approved=True,comments="Test comments",@@ -523,7 +523,7 @@ async def test_store_listing_graph(server: SpinTestServer):)# Add the approved store listing to the admin user's library so they can execute it- from backend.server.v2.library.db import add_store_agent_to_library+ from backend.api.features.library.db import add_store_agent_to_libraryawait add_store_agent_to_library(store_listing_version_id=slv_id, user_id=admin_user.iddiff --git a/autogpt_platform/backend/backend/executor/scheduler_test.py b/autogpt_platform/backend/backend/executor/scheduler_test.pyindex c4fa35d46c..21acbaf0e1 100644--- a/autogpt_platform/backend/backend/executor/scheduler_test.py+++ b/autogpt_platform/backend/backend/executor/scheduler_test.py@@ -1,7 +1,7 @@import pytest+from backend.api.model import CreateGraphfrom backend.data import db-from backend.server.model import CreateGraphfrom backend.usecases.sample import create_test_graph, create_test_userfrom backend.util.clients import get_scheduler_clientfrom backend.util.test import SpinTestServerdiff --git a/autogpt_platform/backend/backend/integrations/webhooks/utils.py b/autogpt_platform/backend/backend/integrations/webhooks/utils.pyindex fafd641c93..79316c4c0e 100644--- a/autogpt_platform/backend/backend/integrations/webhooks/utils.py+++ b/autogpt_platform/backend/backend/integrations/webhooks/utils.py@@ -149,10 +149,10 @@ async def setup_webhook_for_block(async def migrate_legacy_triggered_graphs():from prisma.models import AgentGraph+ from backend.api.features.library.db import create_preset+ from backend.api.features.library.model import LibraryAgentPresetCreatablefrom backend.data.graph import AGENT_GRAPH_INCLUDE, GraphModel, set_node_webhookfrom backend.data.model import is_credentials_field_name- from backend.server.v2.library.db import create_preset- from backend.server.v2.library.model import LibraryAgentPresetCreatabletriggered_graphs = [GraphModel.from_db(_graph)diff --git a/autogpt_platform/backend/backend/rest.py b/autogpt_platform/backend/backend/rest.pyindex b601144c6f..96a807c125 100644--- a/autogpt_platform/backend/backend/rest.py+++ b/autogpt_platform/backend/backend/rest.py@@ -1,5 +1,5 @@+from backend.api.rest_api import AgentServerfrom backend.app import run_processes-from backend.server.rest_api import AgentServerdef main():diff --git a/autogpt_platform/backend/backend/server/external/api.py b/autogpt_platform/backend/backend/server/external/api.pydeleted file mode 100644index 3bafa63108..0000000000--- a/autogpt_platform/backend/backend/server/external/api.py+++ /dev/null@@ -1,29 +0,0 @@-from fastapi import FastAPI--from backend.monitoring.instrumentation import instrument_fastapi-from backend.server.middleware.security import SecurityHeadersMiddleware--from .routes.integrations import integrations_router-from .routes.tools import tools_router-from .routes.v1 import v1_router--external_app = FastAPI(- title="AutoGPT External API",- description="External API for AutoGPT integrations",- docs_url="/docs",- version="1.0",-)--external_app.add_middleware(SecurityHeadersMiddleware)-external_app.include_router(v1_router, prefix="/v1")-external_app.include_router(tools_router, prefix="/v1")-external_app.include_router(integrations_router, prefix="/v1")--# Add Prometheus instrumentation-instrument_fastapi(- external_app,- service_name="external-api",- expose_endpoint=True,- endpoint="/metrics",- include_in_schema=True,-)diff --git a/autogpt_platform/backend/backend/server/routers/analytics_improved_test.py b/autogpt_platform/backend/backend/server/routers/analytics_improved_test.pydeleted file mode 100644index 7040faa0b5..0000000000--- a/autogpt_platform/backend/backend/server/routers/analytics_improved_test.py+++ /dev/null@@ -1,150 +0,0 @@-"""Example of analytics tests with improved error handling and assertions."""--import json-from unittest.mock import AsyncMock, Mock--import fastapi-import fastapi.testclient-import pytest-import pytest_mock-from pytest_snapshot.plugin import Snapshot--import backend.server.routers.analytics as analytics_routes-from backend.server.test_helpers import (- assert_error_response_structure,- assert_mock_called_with_partial,- assert_response_status,- safe_parse_json,-)--app = fastapi.FastAPI()-app.include_router(analytics_routes.router)--client = fastapi.testclient.TestClient(app)--[email protected](autouse=True)-def setup_app_auth(mock_jwt_user):- """Setup auth overrides for all tests in this module"""- from autogpt_libs.auth.jwt_utils import get_jwt_payload-- app.dependency_overrides[get_jwt_payload] = mock_jwt_user["get_jwt_payload"]- yield- app.dependency_overrides.clear()---def test_log_raw_metric_success_improved(- mocker: pytest_mock.MockFixture,- configured_snapshot: Snapshot,- test_user_id: str,-) -> None:- """Test successful raw metric logging with improved assertions."""- # Mock the analytics function- mock_result = Mock(id="metric-123-uuid")-- mock_log_metric = mocker.patch(- "backend.data.analytics.log_raw_metric",- new_callable=AsyncMock,- return_value=mock_result,- )-- request_data = {- "metric_name": "page_load_time",- "metric_value": 2.5,- "data_string": "/dashboard",- }-- response = client.post("/log_raw_metric", json=request_data)-- # Improved assertions with better error messages- assert_response_status(response, 200, "Metric logging should succeed")- response_data = safe_parse_json(response, "Metric response parsing")-- assert response_data == "metric-123-uuid", f"Unexpected response: {response_data}"-- # Verify the function was called with correct parameters- assert_mock_called_with_partial(- mock_log_metric,- user_id=test_user_id,- metric_name="page_load_time",- metric_value=2.5,- data_string="/dashboard",- )-- # Snapshot test the response- configured_snapshot.assert_match(- json.dumps({"metric_id": response_data}, indent=2, sort_keys=True),- "analytics_log_metric_success_improved",- )---def test_log_raw_metric_invalid_request_improved() -> None:- """Test invalid metric request with improved error assertions."""- # Test missing required fields- response = client.post("/log_raw_metric", json={})-- error_data = assert_error_response_structure(- response, expected_status=422, expected_error_fields=["loc", "msg", "type"]- )-- # Verify specific error details- detail = error_data["detail"]- assert isinstance(detail, list), "Error detail should be a list"- assert len(detail) > 0, "Should have at least one error"-- # Check that required fields are mentioned in errors- error_fields = [error["loc"][-1] for error in detail if "loc" in error]- assert "metric_name" in error_fields, "Should report missing metric_name"- assert "metric_value" in error_fields, "Should report missing metric_value"- assert "data_string" in error_fields, "Should report missing data_string"---def test_log_raw_metric_type_validation_improved(- mocker: pytest_mock.MockFixture,-) -> None:- """Test metric type validation with improved assertions."""- # Mock the analytics function to avoid event loop issues- mocker.patch(- "backend.data.analytics.log_raw_metric",- new_callable=AsyncMock,- return_value=Mock(id="test-id"),- )-- invalid_requests = [- {- "data": {- "metric_name": "test",- "metric_value": "not_a_number", # Invalid type- "data_string": "test",- },- "expected_error": "Input should be a valid number",- },- {- "data": {- "metric_name": "", # Empty string- "metric_value": 1.0,- "data_string": "test",- },- "expected_error": "String should have at least 1 character",- },- {- "data": {- "metric_name": "test",- "metric_value": 123, # Valid number- "data_string": "", # Empty data_string- },- "expected_error": "String should have at least 1 character",- },- ]-- for test_case in invalid_requests:- response = client.post("/log_raw_metric", json=test_case["data"])-- error_data = assert_error_response_structure(response, expected_status=422)-- # Check that expected error is in the response- error_text = json.dumps(error_data)- assert (- test_case["expected_error"] in error_text- or test_case["expected_error"].lower() in error_text.lower()- ), f"Expected error '{test_case['expected_error']}' not found in: {error_text}"diff --git a/autogpt_platform/backend/backend/server/routers/analytics_parametrized_test.py b/autogpt_platform/backend/backend/server/routers/analytics_parametrized_test.pydeleted file mode 100644index 9dbf03b727..0000000000--- a/autogpt_platform/backend/backend/server/routers/analytics_parametrized_test.py+++ /dev/null@@ -1,115 +0,0 @@-"""Example of parametrized tests for analytics endpoints."""--import json-from unittest.mock import AsyncMock, Mock--import fastapi-import fastapi.testclient-import pytest-import pytest_mock-from pytest_snapshot.plugin import Snapshot--import backend.server.routers.analytics as analytics_routes--app = fastapi.FastAPI()-app.include_router(analytics_routes.router)--client = fastapi.testclient.TestClient(app)--[email protected](autouse=True)-def setup_app_auth(mock_jwt_user):- """Setup auth overrides for all tests in this module"""- from autogpt_libs.auth.jwt_utils import get_jwt_payload-- app.dependency_overrides[get_jwt_payload] = mock_jwt_user["get_jwt_payload"]- yield- app.dependency_overrides.clear()--- "metric_value,metric_name,data_string,test_id",- [- (100, "api_calls_count", "external_api", "integer_value"),- (0, "error_count", "no_errors", "zero_value"),- (-5.2, "temperature_delta", "cooling", "negative_value"),- (1.23456789, "precision_test", "float_precision", "float_precision"),- (999999999, "large_number", "max_value", "large_number"),- (0.0000001, "tiny_number", "min_value", "tiny_number"),- ],-)-def test_log_raw_metric_values_parametrized(- mocker: pytest_mock.MockFixture,- configured_snapshot: Snapshot,- metric_value: float,- metric_name: str,- data_string: str,- test_id: str,-) -> None:- """Test raw metric logging with various metric values using parametrize."""- # Mock the analytics function- mock_result = Mock(id=f"metric-{test_id}-uuid")-- mocker.patch(- "backend.data.analytics.log_raw_metric",- new_callable=AsyncMock,- return_value=mock_result,- )-- request_data = {- "metric_name": metric_name,- "metric_value": metric_value,- "data_string": data_string,- }-- response = client.post("/log_raw_metric", json=request_data)-- # Better error handling- assert response.status_code == 200, f"Failed for {test_id}: {response.text}"- response_data = response.json()-- # Snapshot test the response- configured_snapshot.assert_match(- json.dumps(- {"metric_id": response_data, "test_case": test_id}, indent=2, sort_keys=True- ),- f"analytics_metric_{test_id}",- )--- "invalid_data,expected_error",- [- ({}, "Field required"), # Missing all fields- ({"metric_name": "test"}, "Field required"), # Missing metric_value- (- {"metric_name": "test", "metric_value": "not_a_number"},- "Input should be a valid number",- ), # Invalid type- (- {"metric_name": "", "metric_value": 1.0, "data_string": "test"},- "String should have at least 1 character",- ), # Empty name- ],-)-def test_log_raw_metric_invalid_requests_parametrized(- mocker: pytest_mock.MockFixture,- invalid_data: dict,- expected_error: str,-) -> None:- """Test invalid metric requests with parametrize."""- # Mock the analytics function to avoid event loop issues- mocker.patch(- "backend.data.analytics.log_raw_metric",- new_callable=AsyncMock,- return_value=Mock(id="test-id"),- )-- response = client.post("/log_raw_metric", json=invalid_data)-- assert response.status_code == 422- error_detail = response.json()- assert "detail" in error_detail- # Verify error message contains expected error- error_text = json.dumps(error_detail)- assert expected_error in error_text or expected_error.lower() in error_text.lower()diff --git a/autogpt_platform/backend/backend/server/routers/analytics_test.py b/autogpt_platform/backend/backend/server/routers/analytics_test.pydeleted file mode 100644index 16ee6708dc..0000000000--- a/autogpt_platform/backend/backend/server/routers/analytics_test.py+++ /dev/null@@ -1,284 +0,0 @@-import json-from unittest.mock import AsyncMock, Mock--import fastapi-import fastapi.testclient-import pytest-import pytest_mock-from pytest_snapshot.plugin import Snapshot--import backend.server.routers.analytics as analytics_routes--app = fastapi.FastAPI()-app.include_router(analytics_routes.router)--client = fastapi.testclient.TestClient(app)--[email protected](autouse=True)-def setup_app_auth(mock_jwt_user):- """Setup auth overrides for all tests in this module"""- from autogpt_libs.auth.jwt_utils import get_jwt_payload-- app.dependency_overrides[get_jwt_payload] = mock_jwt_user["get_jwt_payload"]- yield- app.dependency_overrides.clear()---def test_log_raw_metric_success(- mocker: pytest_mock.MockFixture,- configured_snapshot: Snapshot,- test_user_id: str,-) -> None:- """Test successful raw metric logging"""-- # Mock the analytics function- mock_result = Mock(id="metric-123-uuid")-- mock_log_metric = mocker.patch(- "backend.data.analytics.log_raw_metric",- new_callable=AsyncMock,- return_value=mock_result,- )-- request_data = {- "metric_name": "page_load_time",- "metric_value": 2.5,- "data_string": "/dashboard",- }-- response = client.post("/log_raw_metric", json=request_data)-- assert response.status_code == 200- response_data = response.json()- assert response_data == "metric-123-uuid"-- # Verify the function was called with correct parameters- mock_log_metric.assert_called_once_with(- user_id=test_user_id,- metric_name="page_load_time",- metric_value=2.5,- data_string="/dashboard",- )-- # Snapshot test the response- configured_snapshot.assert_match(- json.dumps({"metric_id": response.json()}, indent=2, sort_keys=True),- "analytics_log_metric_success",- )---def test_log_raw_metric_various_values(- mocker: pytest_mock.MockFixture,- configured_snapshot: Snapshot,-) -> None:- """Test raw metric logging with various metric values"""-- # Mock the analytics function- mock_result = Mock(id="metric-456-uuid")-- mocker.patch(- "backend.data.analytics.log_raw_metric",- new_callable=AsyncMock,- return_value=mock_result,- )-- # Test with integer value- request_data = {- "metric_name": "api_calls_count",- "metric_value": 100,- "data_string": "external_api",- }-- response = client.post("/log_raw_metric", json=request_data)- assert response.status_code == 200-- # Test with zero value- request_data = {- "metric_name": "error_count",- "metric_value": 0,- "data_string": "no_errors",- }-- response = client.post("/log_raw_metric", json=request_data)- assert response.status_code == 200-- # Test with negative value- request_data = {- "metric_name": "temperature_delta",- "metric_value": -5.2,- "data_string": "cooling",- }-- response = client.post("/log_raw_metric", json=request_data)- assert response.status_code == 200-- # Snapshot the last response- configured_snapshot.assert_match(- json.dumps({"metric_id": response.json()}, indent=2, sort_keys=True),- "analytics_log_metric_various_values",- )---def test_log_raw_analytics_success(- mocker: pytest_mock.MockFixture,- configured_snapshot: Snapshot,- test_user_id: str,-) -> None:- """Test successful raw analytics logging"""-- # Mock the analytics function- mock_result = Mock(id="analytics-789-uuid")-- mock_log_analytics = mocker.patch(- "backend.data.analytics.log_raw_analytics",- new_callable=AsyncMock,- return_value=mock_result,- )-- request_data = {- "type": "user_action",- "data": {- "action": "button_click",- "button_id": "submit_form",- "timestamp": "2023-01-01T00:00:00Z",- "metadata": {- "form_type": "registration",- "fields_filled": 5,- },- },- "data_index": "button_click_submit_form",- }-- response = client.post("/log_raw_analytics", json=request_data)-- assert response.status_code == 200- response_data = response.json()- assert response_data == "analytics-789-uuid"-- # Verify the function was called with correct parameters- mock_log_analytics.assert_called_once_with(- test_user_id,- "user_action",- request_data["data"],- "button_click_submit_form",- )-- # Snapshot test the response- configured_snapshot.assert_match(- json.dumps({"analytics_id": response_data}, indent=2, sort_keys=True),- "analytics_log_analytics_success",- )---def test_log_raw_analytics_complex_data(- mocker: pytest_mock.MockFixture,- configured_snapshot: Snapshot,-) -> None:- """Test raw analytics logging with complex nested data"""-- # Mock the analytics function- mock_result = Mock(id="analytics-complex-uuid")-- mocker.patch(- "backend.data.analytics.log_raw_analytics",- new_callable=AsyncMock,- return_value=mock_result,- )-- request_data = {- "type": "agent_execution",- "data": {- "agent_id": "agent_123",- "execution_id": "exec_456",- "status": "completed",- "duration_ms": 3500,- "nodes_executed": 15,- "blocks_used": [- {"block_id": "llm_block", "count": 3},- {"block_id": "http_block", "count": 5},- {"block_id": "code_block", "count": 2},- ],- "errors": [],- "metadata": {- "trigger": "manual",- "user_tier": "premium",- "environment": "production",- },- },- "data_index": "agent_123_exec_456",- }-- response = client.post("/log_raw_analytics", json=request_data)-- assert response.status_code == 200- response_data = response.json()-- # Snapshot test the complex data structure- configured_snapshot.assert_match(- json.dumps(- {- "analytics_id": response_data,- "logged_data": request_data["data"],- },- indent=2,- sort_keys=True,- ),- "analytics_log_analytics_complex_data",- )---def test_log_raw_metric_invalid_request() -> None:- """Test raw metric logging with invalid request data"""- # Missing required fields- response = client.post("/log_raw_metric", json={})- assert response.status_code == 422-- # Invalid metric_value type- response = client.post(- "/log_raw_metric",- json={- "metric_name": "test",- "metric_value": "not_a_number",- "data_string": "test",- },- )- assert response.status_code == 422-- # Missing data_string- response = client.post(- "/log_raw_metric",- json={- "metric_name": "test",- "metric_value": 1.0,- },- )- assert response.status_code == 422---def test_log_raw_analytics_invalid_request() -> None:- """Test raw analytics logging with invalid request data"""- # Missing required fields- response = client.post("/log_raw_analytics", json={})- assert response.status_code == 422-- # Invalid data type (should be dict)- response = client.post(- "/log_raw_analytics",- json={- "type": "test",- "data": "not_a_dict",- "data_index": "test",- },- )- assert response.status_code == 422-- # Missing data_index- response = client.post(- "/log_raw_analytics",- json={- "type": "test",- "data": {"key": "value"},- },- )- assert response.status_code == 422diff --git a/autogpt_platform/backend/backend/util/test.py b/autogpt_platform/backend/backend/util/test.pyindex 95ea9554ed..1e8244ff8e 100644--- a/autogpt_platform/backend/backend/util/test.py+++ b/autogpt_platform/backend/backend/util/test.py@@ -6,6 +6,7 @@ from typing import Sequence, castfrom autogpt_libs.auth import get_user_id+from backend.api.rest_api import AgentServerfrom backend.data import dbfrom backend.data.block import Block, BlockSchema, initialize_blocksfrom backend.data.execution import (@@ -18,7 +19,6 @@ from backend.data.model import _BaseCredentialsfrom backend.data.user import create_default_userfrom backend.executor import DatabaseManager, ExecutionManager, Schedulerfrom backend.notifications.notifications import NotificationManager-from backend.server.rest_api import AgentServerlog = logging.getLogger(__name__)diff --git a/autogpt_platform/backend/backend/util/virus_scanner.py b/autogpt_platform/backend/backend/util/virus_scanner.pyindex 1ea31cac95..aa43e5f5d9 100644--- a/autogpt_platform/backend/backend/util/virus_scanner.py+++ b/autogpt_platform/backend/backend/util/virus_scanner.py@@ -196,7 +196,7 @@ async def scan_content_safe(content: bytes, *, filename: str = "unknown") -> NonVirusDetectedError: If virus is foundVirusScanError: If scanning fails"""- from backend.server.v2.store.exceptions import VirusDetectedError, VirusScanError+ from backend.api.features.store.exceptions import VirusDetectedError, VirusScanErrortry:result = await get_virus_scanner().scan_file(content, filename=filename)diff --git a/autogpt_platform/backend/backend/util/virus_scanner_test.py b/autogpt_platform/backend/backend/util/virus_scanner_test.pyindex 81b5ad3342..77010c7320 100644--- a/autogpt_platform/backend/backend/util/virus_scanner_test.py+++ b/autogpt_platform/backend/backend/util/virus_scanner_test.py@@ -3,7 +3,7 @@ from unittest.mock import AsyncMock, Mock, patchimport pytest-from backend.server.v2.store.exceptions import VirusDetectedError, VirusScanError+from backend.api.features.store.exceptions import VirusDetectedError, VirusScanErrorfrom backend.util.virus_scanner import (VirusScannerService,VirusScannerSettings,diff --git a/autogpt_platform/backend/backend/ws.py b/autogpt_platform/backend/backend/ws.pyindex 3b15a60eb0..77e2e82a90 100644--- a/autogpt_platform/backend/backend/ws.py+++ b/autogpt_platform/backend/backend/ws.py@@ -1,5 +1,5 @@+from backend.api.ws_api import WebsocketServerfrom backend.app import run_processes-from backend.server.ws_api import WebsocketServerdef main():diff --git a/autogpt_platform/backend/test/e2e_test_data.py b/autogpt_platform/backend/test/e2e_test_data.pyindex 943c506f5c..d7576cdad3 100644--- a/autogpt_platform/backend/test/e2e_test_data.py+++ b/autogpt_platform/backend/test/e2e_test_data.py@@ -23,16 +23,18 @@ from typing import Any, Dict, Listfrom faker import Faker+# Import API functions from the backend+from backend.api.features.library.db import create_library_agent, create_preset+from backend.api.features.library.model import LibraryAgentPresetCreatable+from backend.api.features.store.db import (+ create_store_submission,+ review_store_submission,+)from backend.data.auth.api_key import create_api_keyfrom backend.data.credit import get_user_credit_modelfrom backend.data.db import prismafrom backend.data.graph import Graph, Link, Node, create_graphfrom backend.data.user import get_or_create_user--# Import API functions from the backend-from backend.server.v2.library.db import create_library_agent, create_preset-from backend.server.v2.library.model import LibraryAgentPresetCreatable-from backend.server.v2.store.db import create_store_submission, review_store_submissionfrom backend.util.clients import get_supabasefaker = Faker()diff --git a/autogpt_platform/frontend/src/app/(platform)/auth/authorize/page.tsx b/autogpt_platform/frontend/src/app/(platform)/auth/authorize/page.tsxindex 8093b75965..7472ef212e 100644--- a/autogpt_platform/frontend/src/app/(platform)/auth/authorize/page.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/auth/authorize/page.tsx@@ -16,7 +16,7 @@ import type { APIKeyPermission } from "@/app/api/__generated__/models/aPIKeyPerm// Human-readable scope descriptionsconst SCOPE_DESCRIPTIONS: { [key in APIKeyPermission]: string } = {- IDENTITY: "Read user ID, name, e-mail, and timezone",+ IDENTITY: "View your user ID, e-mail, and timezone",EXECUTE_GRAPH: "Run your agents",READ_GRAPH: "View your agents and their configurations",EXECUTE_BLOCK: "Execute individual blocks",diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.jsonindex 3556e2f5c7..61a3600892 100644--- a/autogpt_platform/frontend/src/app/api/openapi.json+++ b/autogpt_platform/frontend/src/app/api/openapi.json@@ -2,46 +2,33 @@"openapi": "3.1.0","info": {"title": "AutoGPT Agent Server",+ "summary": "AutoGPT Agent Server","description": "This server is used to execute agents that are created by the AutoGPT system.","version": "0.1"},"paths": {- "/api/integrations/{provider}/login": {- "get": {- "tags": ["v1", "integrations"],- "summary": "Initiate OAuth flow",- "operationId": "getV1Initiate oauth flow",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "provider",- "in": "path",- "required": true,- "schema": {- "type": "string",- "title": "The provider to initiate an OAuth flow for",- "description": "Provider name for integrations. Can be any string value, including custom provider names."+ "/api/analytics/log_raw_analytics": {+ "post": {+ "tags": ["analytics"],+ "summary": "Log Raw Analytics",+ "operationId": "postAnalyticsLogRawAnalytics",+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/Body_postAnalyticsLogRawAnalytics"+ }}},- {- "name": "scopes",- "in": "query",- "required": false,- "schema": {- "type": "string",- "title": "Comma-separated list of authorization scopes",- "default": ""- }- }- ],+ "required": true+ },"responses": {"200": {"description": "Successful Response",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/LoginResponse" }- }- }+ "content": { "application/json": { "schema": {} } }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"},"422": {"description": "Validation Error",@@ -50,51 +37,31 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- }+ },+ "security": [{ "HTTPBearerJWT": [] }]}},- "/api/integrations/{provider}/callback": {+ "/api/analytics/log_raw_metric": {"post": {- "tags": ["v1", "integrations"],- "summary": "Exchange OAuth code for tokens",- "operationId": "postV1Exchange oauth code for tokens",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "provider",- "in": "path",- "required": true,- "schema": {- "type": "string",- "title": "The target provider for this OAuth exchange",- "description": "Provider name for integrations. Can be any string value, including custom provider names."- }- }- ],+ "tags": ["analytics"],+ "summary": "Log Raw Metric",+ "operationId": "postAnalyticsLogRawMetric","requestBody": {- "required": true,"content": {"application/json": {- "schema": {- "$ref": "#/components/schemas/Body_postV1Exchange_oauth_code_for_tokens"- }+ "schema": { "$ref": "#/components/schemas/LogRawMetricRequest" }}- }+ },+ "required": true},"responses": {"200": {"description": "Successful Response",- "content": {- "application/json": {- "schema": {- "$ref": "#/components/schemas/CredentialsMetaResponse"- }- }- }+ "content": { "application/json": { "schema": {} } }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"},"422": {"description": "Validation Error",@@ -103,56 +70,88 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- }+ },+ "security": [{ "HTTPBearerJWT": [] }]}},- "/api/integrations/credentials": {+ "/api/api-keys": {"get": {- "tags": ["v1", "integrations"],- "summary": "List Credentials",- "operationId": "getV1List credentials",+ "tags": ["v1", "api-keys"],+ "summary": "List user API keys",+ "description": "List all API keys for the user",+ "operationId": "getV1List user api keys","responses": {"200": {"description": "Successful Response","content": {"application/json": {"schema": {- "items": {- "$ref": "#/components/schemas/CredentialsMetaResponse"- },+ "items": { "$ref": "#/components/schemas/APIKeyInfo" },"type": "array",- "title": "Response Getv1List Credentials"+ "title": "Response Getv1List User Api Keys"+ }+ }+ }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ }+ },+ "security": [{ "HTTPBearerJWT": [] }]+ },+ "post": {+ "tags": ["v1", "api-keys"],+ "summary": "Create new API key",+ "description": "Create a new API key",+ "operationId": "postV1Create new api key",+ "requestBody": {+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/CreateAPIKeyRequest" }+ }+ },+ "required": true+ },+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/CreateAPIKeyResponse"}}}},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }}},"security": [{ "HTTPBearerJWT": [] }]}},- "/api/integrations/{provider}/credentials": {- "get": {- "tags": ["v1", "integrations"],- "summary": "List Credentials By Provider",- "operationId": "getV1ListCredentialsByProvider",+ "/api/api-keys/{key_id}": {+ "delete": {+ "tags": ["v1", "api-keys"],+ "summary": "Revoke API key",+ "description": "Revoke an API key",+ "operationId": "deleteV1Revoke api key","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "provider",+ "name": "key_id","in": "path","required": true,- "schema": {- "type": "string",- "title": "The provider to list credentials for",- "description": "Provider name for integrations. Can be any string value, including custom provider names."- }+ "schema": { "type": "string", "title": "Key Id" }}],"responses": {@@ -160,16 +159,13 @@"description": "Successful Response","content": {"application/json": {- "schema": {- "type": "array",- "items": {- "$ref": "#/components/schemas/CredentialsMetaResponse"- },- "title": "Response Getv1Listcredentialsbyprovider"- }+ "schema": { "$ref": "#/components/schemas/APIKeyInfo" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -177,82 +173,35 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}},- "post": {- "tags": ["v1", "integrations"],- "summary": "Create Credentials",- "operationId": "postV1Create credentials",+ "get": {+ "tags": ["v1", "api-keys"],+ "summary": "Get specific API key",+ "description": "Get a specific API key",+ "operationId": "getV1Get specific api key","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "provider",+ "name": "key_id","in": "path","required": true,- "schema": {- "type": "string",- "title": "The provider to create credentials for",- "description": "Provider name for integrations. Can be any string value, including custom provider names."- }+ "schema": { "type": "string", "title": "Key Id" }}],- "requestBody": {- "required": true,- "content": {- "application/json": {- "schema": {- "oneOf": [- { "$ref": "#/components/schemas/OAuth2Credentials" },- { "$ref": "#/components/schemas/APIKeyCredentials" },- { "$ref": "#/components/schemas/UserPasswordCredentials" },- { "$ref": "#/components/schemas/HostScopedCredentials-Input" }- ],- "discriminator": {- "propertyName": "type",- "mapping": {- "oauth2": "#/components/schemas/OAuth2Credentials",- "api_key": "#/components/schemas/APIKeyCredentials",- "user_password": "#/components/schemas/UserPasswordCredentials",- "host_scoped": "#/components/schemas/HostScopedCredentials-Input"- }- },- "title": "Credentials"- }- }- }- },"responses": {- "201": {+ "200": {"description": "Successful Response","content": {"application/json": {- "schema": {- "oneOf": [- { "$ref": "#/components/schemas/OAuth2Credentials" },- { "$ref": "#/components/schemas/APIKeyCredentials" },- { "$ref": "#/components/schemas/UserPasswordCredentials" },- {- "$ref": "#/components/schemas/HostScopedCredentials-Output"- }- ],- "discriminator": {- "propertyName": "type",- "mapping": {- "oauth2": "#/components/schemas/OAuth2Credentials",- "api_key": "#/components/schemas/APIKeyCredentials",- "user_password": "#/components/schemas/UserPasswordCredentials",- "host_scoped": "#/components/schemas/HostScopedCredentials-Output"- }- },- "title": "Response Postv1Create Credentials"- }+ "schema": { "$ref": "#/components/schemas/APIKeyInfo" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -260,68 +209,47 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/integrations/{provider}/credentials/{cred_id}": {- "get": {- "tags": ["v1", "integrations"],- "summary": "Get Specific Credential By ID",- "operationId": "getV1Get specific credential by id",+ "/api/api-keys/{key_id}/permissions": {+ "put": {+ "tags": ["v1", "api-keys"],+ "summary": "Update key permissions",+ "description": "Update API key permissions",+ "operationId": "putV1Update key permissions","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "provider",- "in": "path",- "required": true,- "schema": {- "type": "string",- "title": "The provider to retrieve credentials for",- "description": "Provider name for integrations. Can be any string value, including custom provider names."- }- },- {- "name": "cred_id",+ "name": "key_id","in": "path","required": true,- "schema": {- "type": "string",- "title": "The ID of the credentials to retrieve"- }+ "schema": { "type": "string", "title": "Key Id" }}],+ "requestBody": {+ "required": true,+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/UpdatePermissionsRequest"+ }+ }+ }+ },"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": {- "oneOf": [- { "$ref": "#/components/schemas/OAuth2Credentials" },- { "$ref": "#/components/schemas/APIKeyCredentials" },- { "$ref": "#/components/schemas/UserPasswordCredentials" },- {- "$ref": "#/components/schemas/HostScopedCredentials-Output"- }- ],- "discriminator": {- "propertyName": "type",- "mapping": {- "oauth2": "#/components/schemas/OAuth2Credentials",- "api_key": "#/components/schemas/APIKeyCredentials",- "user_password": "#/components/schemas/UserPasswordCredentials",- "host_scoped": "#/components/schemas/HostScopedCredentials-Output"- }- },- "title": "Response Getv1Get Specific Credential By Id"- }+ "schema": { "$ref": "#/components/schemas/APIKeyInfo" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -329,46 +257,23 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}- },- "delete": {- "tags": ["v1", "integrations"],- "summary": "Delete Credentials",- "operationId": "deleteV1DeleteCredentials",+ }+ },+ "/api/api-keys/{key_id}/suspend": {+ "post": {+ "tags": ["v1", "api-keys"],+ "summary": "Suspend API key",+ "description": "Suspend an API key",+ "operationId": "postV1Suspend api key","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "provider",- "in": "path",- "required": true,- "schema": {- "type": "string",- "title": "The provider to delete credentials for",- "description": "Provider name for integrations. Can be any string value, including custom provider names."- }- },- {- "name": "cred_id",+ "name": "key_id","in": "path","required": true,- "schema": {- "type": "string",- "title": "The ID of the credentials to delete"- }- },- {- "name": "force",- "in": "query",- "required": false,- "schema": {- "type": "boolean",- "title": "Whether to proceed if any linked webhooks are still in use",- "default": false- }+ "schema": { "type": "string", "title": "Key Id" }}],"responses": {@@ -376,20 +281,13 @@"description": "Successful Response","content": {"application/json": {- "schema": {- "anyOf": [- {- "$ref": "#/components/schemas/CredentialsDeletionResponse"- },- {- "$ref": "#/components/schemas/CredentialsDeletionNeedsConfirmationResponse"- }- ],- "title": "Response Deletev1Deletecredentials"- }+ "schema": { "$ref": "#/components/schemas/APIKeyInfo" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -397,40 +295,55 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}+ }+ }+ }+ },+ "/api/auth/user": {+ "post": {+ "tags": ["v1", "auth"],+ "summary": "Get or create user",+ "operationId": "postV1Get or create user",+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": { "application/json": { "schema": {} } }},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- }+ },+ "security": [{ "HTTPBearerJWT": [] }]}},- "/api/integrations/{provider}/webhooks/{webhook_id}/ingress": {+ "/api/auth/user/email": {"post": {- "tags": ["v1", "integrations"],- "summary": "Webhook Ingress Generic",- "operationId": "postV1WebhookIngressGeneric",- "parameters": [- {- "name": "provider",- "in": "path",- "required": true,- "schema": {- "type": "string",- "title": "Provider where the webhook was registered",- "description": "Provider name for integrations. Can be any string value, including custom provider names."+ "tags": ["v1", "auth"],+ "summary": "Update user email",+ "operationId": "postV1Update user email",+ "requestBody": {+ "content": {+ "application/json": {+ "schema": { "type": "string", "title": "Email" }}},- {- "name": "webhook_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Our ID for the webhook" }- }- ],+ "required": true+ },"responses": {"200": {"description": "Successful Response",- "content": { "application/json": { "schema": {} } }+ "content": {+ "application/json": {+ "schema": {+ "additionalProperties": { "type": "string" },+ "type": "object",+ "title": "Response Postv1Update User Email"+ }+ }+ }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"},"422": {"description": "Validation Error",@@ -440,276 +353,78 @@}}}- }+ },+ "security": [{ "HTTPBearerJWT": [] }]}},- "/api/integrations/webhooks/{webhook_id}/ping": {- "post": {- "tags": ["v1", "integrations"],- "summary": "Webhook Ping",- "operationId": "postV1WebhookPing",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "webhook_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Our ID for the webhook" }- }- ],+ "/api/auth/user/preferences": {+ "get": {+ "tags": ["v1", "auth"],+ "summary": "Get notification preferences",+ "operationId": "getV1Get notification preferences","responses": {"200": {"description": "Successful Response",- "content": { "application/json": { "schema": {} } }- },- "422": {- "description": "Validation Error","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ "schema": {+ "$ref": "#/components/schemas/NotificationPreference"+ }}}},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- }- }- },- "/api/integrations/ayrshare/sso_url": {- "get": {- "tags": ["v1", "integrations"],- "summary": "Get Ayrshare Sso Url",- "description": "Generate an SSO URL for Ayrshare social media integration.\n\nReturns:\n dict: Contains the SSO URL for Ayrshare integration",- "operationId": "getV1GetAyrshareSsoUrl",+ },+ "security": [{ "HTTPBearerJWT": [] }]+ },+ "post": {+ "tags": ["v1", "auth"],+ "summary": "Update notification preferences",+ "operationId": "postV1Update notification preferences",+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/NotificationPreferenceDTO"+ }+ }+ },+ "required": true+ },"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/AyrshareSSOResponse" }+ "schema": {+ "$ref": "#/components/schemas/NotificationPreference"+ }}}},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }}},"security": [{ "HTTPBearerJWT": [] }]}},- "/api/integrations/providers": {+ "/api/auth/user/timezone": {"get": {- "tags": ["v1", "integrations"],- "summary": "List Providers",- "description": "Get a list of all available provider names.\n\nReturns both statically defined providers (from ProviderName enum)\nand dynamically registered providers (from SDK decorators).\n\nNote: The complete list of provider names is also available as a constant\nin the generated TypeScript client via PROVIDER_NAMES.",- "operationId": "getV1ListProviders",- "responses": {- "200": {- "description": "Successful Response",- "content": {- "application/json": {- "schema": {- "items": { "type": "string" },- "type": "array",- "title": "Response Getv1Listproviders"- }- }- }- }- }- }- },- "/api/integrations/providers/names": {- "get": {- "tags": ["v1", "integrations"],- "summary": "Get Provider Names",- "description": "Get all provider names in a structured format.\n\nThis endpoint is specifically designed to expose the provider names\nin the OpenAPI schema so that code generators like Orval can create\nappropriate TypeScript constants.",- "operationId": "getV1GetProviderNames",- "responses": {- "200": {- "description": "Successful Response",- "content": {- "application/json": {- "schema": {- "$ref": "#/components/schemas/ProviderNamesResponse"- }- }- }- }- }- }- },- "/api/integrations/providers/constants": {- "get": {- "tags": ["v1", "integrations"],- "summary": "Get Provider Constants",- "description": "Get provider names as constants.\n\nThis endpoint returns a model with provider names as constants,\nspecifically designed for OpenAPI code generation tools to create\nTypeScript constants.",- "operationId": "getV1GetProviderConstants",- "responses": {- "200": {- "description": "Successful Response",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/ProviderConstants" }- }- }- }- }- }- },- "/api/integrations/providers/enum-example": {- "get": {- "tags": ["v1", "integrations"],- "summary": "Get Provider Enum Example",- "description": "Example endpoint that uses the CompleteProviderNames enum.\n\nThis endpoint exists to ensure that the CompleteProviderNames enum is included\nin the OpenAPI schema, which will cause Orval to generate it as a\nTypeScript enum/constant.",- "operationId": "getV1GetProviderEnumExample",- "responses": {- "200": {- "description": "Successful Response",- "content": {- "application/json": {- "schema": {- "$ref": "#/components/schemas/ProviderEnumResponse"- }- }- }- }- }- }- },- "/api/analytics/log_raw_metric": {- "post": {- "tags": ["v1", "analytics"],- "summary": "Log Raw Metric",- "operationId": "postV1LogRawMetric",- "requestBody": {- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/LogRawMetricRequest" }- }- },- "required": true- },- "responses": {- "200": {- "description": "Successful Response",- "content": { "application/json": { "schema": {} } }- },- "422": {- "description": "Validation Error",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/HTTPValidationError" }- }- }- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }- },- "security": [{ "HTTPBearerJWT": [] }]- }- },- "/api/analytics/log_raw_analytics": {- "post": {- "tags": ["v1", "analytics"],- "summary": "Log Raw Analytics",- "operationId": "postV1LogRawAnalytics",- "requestBody": {- "content": {- "application/json": {- "schema": {- "$ref": "#/components/schemas/Body_postV1LogRawAnalytics"- }- }- },- "required": true- },- "responses": {- "200": {- "description": "Successful Response",- "content": { "application/json": { "schema": {} } }- },- "422": {- "description": "Validation Error",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/HTTPValidationError" }- }- }- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }- },- "security": [{ "HTTPBearerJWT": [] }]- }- },- "/api/auth/user": {- "post": {- "tags": ["v1", "auth"],- "summary": "Get or create user",- "operationId": "postV1Get or create user",- "responses": {- "200": {- "description": "Successful Response",- "content": { "application/json": { "schema": {} } }- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }- },- "security": [{ "HTTPBearerJWT": [] }]- }- },- "/api/auth/user/email": {- "post": {- "tags": ["v1", "auth"],- "summary": "Update user email",- "operationId": "postV1Update user email",- "requestBody": {- "content": {- "application/json": {- "schema": { "type": "string", "title": "Email" }- }- },- "required": true- },- "responses": {- "200": {- "description": "Successful Response",- "content": {- "application/json": {- "schema": {- "additionalProperties": { "type": "string" },- "type": "object",- "title": "Response Postv1Update User Email"- }- }- }- },- "422": {- "description": "Validation Error",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/HTTPValidationError" }- }- }- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }- },- "security": [{ "HTTPBearerJWT": [] }]- }- },- "/api/auth/user/timezone": {- "get": {- "tags": ["v1", "auth"],- "summary": "Get user timezone",- "description": "Get user timezone setting.",- "operationId": "getV1Get user timezone",+ "tags": ["v1", "auth"],+ "summary": "Get user timezone",+ "description": "Get user timezone setting.",+ "operationId": "getV1Get user timezone","responses": {"200": {"description": "Successful Response",@@ -747,6 +462,9 @@}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -754,26 +472,25 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}},"security": [{ "HTTPBearerJWT": [] }]}},- "/api/auth/user/preferences": {+ "/api/blocks": {"get": {- "tags": ["v1", "auth"],- "summary": "Get notification preferences",- "operationId": "getV1Get notification preferences",+ "tags": ["v1", "blocks"],+ "summary": "List available blocks",+ "operationId": "getV1List available blocks","responses": {"200": {"description": "Successful Response","content": {"application/json": {"schema": {- "$ref": "#/components/schemas/NotificationPreference"+ "items": { "additionalProperties": true, "type": "object" },+ "type": "array",+ "title": "Response Getv1List Available Blocks"}}}@@ -783,20 +500,33 @@}},"security": [{ "HTTPBearerJWT": [] }]- },+ }+ },+ "/api/blocks/{block_id}/execute": {"post": {- "tags": ["v1", "auth"],- "summary": "Update notification preferences",- "operationId": "postV1Update notification preferences",+ "tags": ["v1", "blocks"],+ "summary": "Execute graph block",+ "operationId": "postV1Execute graph block",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "block_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Block Id" }+ }+ ],"requestBody": {+ "required": true,"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/NotificationPreferenceDTO"+ "type": "object",+ "additionalProperties": true,+ "title": "Data"}}- },- "required": true+ }},"responses": {"200": {@@ -804,11 +534,16 @@"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/NotificationPreference"+ "type": "object",+ "additionalProperties": { "type": "array", "items": {} },+ "title": "Response Postv1Execute Graph Block"}}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -816,55 +551,82 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- },- "security": [{ "HTTPBearerJWT": [] }]+ }}},- "/api/onboarding": {+ "/api/builder/blocks": {"get": {- "tags": ["v1", "onboarding"],- "summary": "Onboarding state",- "operationId": "getV1Onboarding state",- "responses": {- "200": {- "description": "Successful Response",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/UserOnboarding" }- }+ "tags": ["v2"],+ "summary": "Get Builder blocks",+ "description": "Get blocks based on either category, type, or provider.",+ "operationId": "getV2Get builder blocks",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "category",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [{ "type": "string" }, { "type": "null" }],+ "title": "Category"}},- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }- },- "security": [{ "HTTPBearerJWT": [] }]- },- "patch": {- "tags": ["v1", "onboarding"],- "summary": "Update onboarding state",- "operationId": "patchV1Update onboarding state",- "requestBody": {- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/UserOnboardingUpdate" }+ {+ "name": "type",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [+ {+ "enum": ["all", "input", "action", "output"],+ "type": "string"+ },+ { "type": "null" }+ ],+ "title": "Type"}},- "required": true- },+ {+ "name": "provider",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [+ {+ "type": "string",+ "description": "Provider name for integrations. Can be any string value, including custom provider names."+ },+ { "type": "null" }+ ],+ "title": "Provider"+ }+ },+ {+ "name": "page",+ "in": "query",+ "required": false,+ "schema": { "type": "integer", "default": 1, "title": "Page" }+ },+ {+ "name": "page_size",+ "in": "query",+ "required": false,+ "schema": { "type": "integer", "default": 50, "title": "Page Size" }+ }+ ],"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/UserOnboarding" }+ "schema": { "$ref": "#/components/schemas/BlockResponse" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -872,46 +634,44 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- },- "security": [{ "HTTPBearerJWT": [] }]+ }}},- "/api/onboarding/step": {- "post": {- "tags": ["v1", "onboarding"],- "summary": "Complete onboarding step",- "operationId": "postV1Complete onboarding step",+ "/api/builder/blocks/batch": {+ "get": {+ "tags": ["v2"],+ "summary": "Get specific blocks",+ "description": "Get specific blocks by their IDs.",+ "operationId": "getV2Get specific blocks","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "step",+ "name": "block_ids","in": "query","required": true,"schema": {- "enum": [- "WELCOME",- "USAGE_REASON",- "INTEGRATIONS",- "AGENT_CHOICE",- "AGENT_NEW_RUN",- "AGENT_INPUT",- "CONGRATS",- "MARKETPLACE_VISIT",- "BUILDER_OPEN"- ],- "type": "string",- "title": "Step"+ "type": "array",+ "items": { "type": "string" },+ "title": "Block Ids"}}],"responses": {"200": {"description": "Successful Response",- "content": { "application/json": { "schema": {} } }+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": { "$ref": "#/components/schemas/BlockInfo" },+ "title": "Response Getv2Get Specific Blocks"+ }+ }+ }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"},"422": {"description": "Validation Error",@@ -920,73 +680,70 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/onboarding/agents": {+ "/api/builder/categories": {"get": {- "tags": ["v1", "onboarding"],- "summary": "Recommended onboarding agents",- "operationId": "getV1Recommended onboarding agents",+ "tags": ["v2"],+ "summary": "Get Builder block categories",+ "description": "Get all block categories with a specified number of blocks per category.",+ "operationId": "getV2Get builder block categories",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "blocks_per_category",+ "in": "query",+ "required": false,+ "schema": {+ "type": "integer",+ "default": 3,+ "title": "Blocks Per Category"+ }+ }+ ],"responses": {"200": {"description": "Successful Response","content": {"application/json": {"schema": {- "items": { "$ref": "#/components/schemas/StoreAgentDetails" },"type": "array",- "title": "Response Getv1Recommended Onboarding Agents"+ "items": {+ "$ref": "#/components/schemas/BlockCategoryResponse"+ },+ "title": "Response Getv2Get Builder Block Categories"}}}},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }- },- "security": [{ "HTTPBearerJWT": [] }]- }- },- "/api/onboarding/enabled": {- "get": {- "tags": ["v1", "onboarding", "public"],- "summary": "Is onboarding enabled",- "operationId": "getV1Is onboarding enabled",- "responses": {- "200": {- "description": "Successful Response",+ },+ "422": {+ "description": "Validation Error","content": {"application/json": {- "schema": {- "type": "boolean",- "title": "Response Getv1Is Onboarding Enabled"- }+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- },- "security": [{ "HTTPBearerJWT": [] }]+ }}},- "/api/onboarding/reset": {- "post": {- "tags": ["v1", "onboarding"],- "summary": "Reset onboarding progress",- "operationId": "postV1Reset onboarding progress",+ "/api/builder/counts": {+ "get": {+ "tags": ["v2"],+ "summary": "Get Builder item counts",+ "description": "Get item counts for the menu categories in the Blocks Menu.",+ "operationId": "getV2Get builder item counts","responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/UserOnboarding" }+ "schema": { "$ref": "#/components/schemas/CountResponse" }}}},@@ -997,132 +754,136 @@"security": [{ "HTTPBearerJWT": [] }]}},- "/api/blocks": {+ "/api/builder/providers": {"get": {- "tags": ["v1", "blocks"],- "summary": "List available blocks",- "operationId": "getV1List available blocks",+ "tags": ["v2"],+ "summary": "Get Builder integration providers",+ "description": "Get all integration providers with their block counts.",+ "operationId": "getV2Get builder integration providers",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "page",+ "in": "query",+ "required": false,+ "schema": { "type": "integer", "default": 1, "title": "Page" }+ },+ {+ "name": "page_size",+ "in": "query",+ "required": false,+ "schema": { "type": "integer", "default": 50, "title": "Page Size" }+ }+ ],"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": {- "items": { "additionalProperties": true, "type": "object" },- "type": "array",- "title": "Response Getv1List Available Blocks"- }+ "schema": { "$ref": "#/components/schemas/ProviderResponse" }}}},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }}- },- "security": [{ "HTTPBearerJWT": [] }]+ }}},- "/api/blocks/{block_id}/execute": {- "post": {- "tags": ["v1", "blocks"],- "summary": "Execute graph block",- "operationId": "postV1Execute graph block",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "block_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Block Id" }- }- ],- "requestBody": {- "required": true,- "content": {- "application/json": {- "schema": {- "type": "object",- "additionalProperties": true,- "title": "Data"- }- }- }- },- "responses": {- "200": {- "description": "Successful Response",- "content": {- "application/json": {- "schema": {- "type": "object",- "additionalProperties": { "type": "array", "items": {} },- "title": "Response Postv1Execute Graph Block"- }- }+ "/api/builder/search": {+ "get": {+ "tags": ["v2", "store", "private"],+ "summary": "Builder search",+ "description": "Search for blocks (including integrations), marketplace agents, and user library agents.",+ "operationId": "getV2Builder search",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "search_query",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [{ "type": "string" }, { "type": "null" }],+ "title": "Search Query"}},- "422": {- "description": "Validation Error",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/HTTPValidationError" }- }+ {+ "name": "filter",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [+ {+ "type": "array",+ "items": {+ "enum": [+ "blocks",+ "integrations",+ "marketplace_agents",+ "my_agents"+ ],+ "type": "string"+ }+ },+ { "type": "null" }+ ],+ "title": "Filter"}},- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }- }- }- },- "/api/files/upload": {- "post": {- "tags": ["v1", "files"],- "summary": "Upload file to cloud storage",- "description": "Upload a file to cloud storage and return a storage key that can be used\nwith FileStoreBlock and AgentFileInputBlock.\n\nArgs:\n file: The file to upload\n user_id: The user ID\n provider: Cloud storage provider (\"gcs\", \"s3\", \"azure\")\n expiration_hours: Hours until file expires (1-48)\n\nReturns:\n Dict containing the cloud storage path and signed URL",- "operationId": "postV1Upload file to cloud storage",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [{- "name": "provider",+ "name": "search_id","in": "query","required": false,"schema": {- "type": "string",- "default": "gcs",- "title": "Provider"+ "anyOf": [{ "type": "string" }, { "type": "null" }],+ "title": "Search Id"}},{- "name": "expiration_hours",+ "name": "by_creator","in": "query","required": false,"schema": {- "type": "integer",- "default": 24,- "title": "Expiration Hours"+ "anyOf": [+ { "type": "array", "items": { "type": "string" } },+ { "type": "null" }+ ],+ "title": "By Creator"}+ },+ {+ "name": "page",+ "in": "query",+ "required": false,+ "schema": { "type": "integer", "default": 1, "title": "Page" }+ },+ {+ "name": "page_size",+ "in": "query",+ "required": false,+ "schema": { "type": "integer", "default": 50, "title": "Page Size" }}],- "requestBody": {- "required": true,- "content": {- "multipart/form-data": {- "schema": {- "$ref": "#/components/schemas/Body_postV1Upload_file_to_cloud_storage"- }- }- }- },"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/UploadFileResponse" }+ "schema": { "$ref": "#/components/schemas/SearchResponse" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -1130,28 +891,22 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/credits": {+ "/api/builder/suggestions": {"get": {- "tags": ["v1", "credits"],- "summary": "Get user credits",- "operationId": "getV1Get user credits",+ "tags": ["v2"],+ "summary": "Get Builder suggestions",+ "description": "Get all suggestions for the Blocks Menu.",+ "operationId": "getV2Get builder suggestions","responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": {- "additionalProperties": { "type": "integer" },- "type": "object",- "title": "Response Getv1Get User Credits"- }+ "schema": { "$ref": "#/components/schemas/SuggestionsResponse" }}}},@@ -1160,46 +915,46 @@}},"security": [{ "HTTPBearerJWT": [] }]- },- "post": {- "tags": ["v1", "credits"],- "summary": "Request credit top up",- "operationId": "postV1Request credit top up",- "requestBody": {- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/RequestTopUp" }- }- },- "required": true- },+ }+ },+ "/api/chat/health": {+ "get": {+ "tags": ["v2", "chat", "chat"],+ "summary": "Health Check",+ "description": "Health check endpoint for the chat service.\n\nPerforms a full cycle test of session creation, assignment, and retrieval. Should always return healthy\nif the service and data layer are operational.\n\nReturns:\n dict: A status dictionary indicating health, service name, and API version.",+ "operationId": "getV2HealthCheck","responses": {"200": {"description": "Successful Response",- "content": { "application/json": { "schema": {} } }- },- "422": {- "description": "Validation Error","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ "schema": {+ "additionalProperties": true,+ "type": "object",+ "title": "Response Getv2Healthcheck"+ }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- },- "security": [{ "HTTPBearerJWT": [] }]- },- "patch": {- "tags": ["v1", "credits"],- "summary": "Fulfill checkout session",- "operationId": "patchV1Fulfill checkout session",+ }+ }+ },+ "/api/chat/sessions": {+ "post": {+ "tags": ["v2", "chat", "chat"],+ "summary": "Create Session",+ "description": "Create a new chat session.\n\nInitiates a new chat session for either an authenticated or anonymous user.\n\nArgs:\n user_id: The optional authenticated user ID parsed from the JWT. If missing, creates an anonymous session.\n\nReturns:\n CreateSessionResponse: Details of the created session.",+ "operationId": "postV2CreateSession","responses": {"200": {"description": "Successful Response",- "content": { "application/json": { "schema": {} } }+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/CreateSessionResponse"+ }+ }+ }},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"@@ -1208,44 +963,35 @@"security": [{ "HTTPBearerJWT": [] }]}},- "/api/credits/{transaction_key}/refund": {- "post": {- "tags": ["v1", "credits"],- "summary": "Refund credit transaction",- "operationId": "postV1Refund credit transaction",+ "/api/chat/sessions/{session_id}": {+ "get": {+ "tags": ["v2", "chat", "chat"],+ "summary": "Get Session",+ "description": "Retrieve the details of a specific chat session.\n\nLooks up a chat session by ID for the given user (if authenticated) and returns all session data including messages.\n\nArgs:\n session_id: The unique identifier for the desired chat session.\n user_id: The optional authenticated user ID, or None for anonymous access.\n\nReturns:\n SessionDetailResponse: Details for the requested session; raises NotFoundError if not found.",+ "operationId": "getV2GetSession","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "transaction_key",+ "name": "session_id","in": "path","required": true,- "schema": { "type": "string", "title": "Transaction Key" }+ "schema": { "type": "string", "title": "Session Id" }}],- "requestBody": {- "required": true,- "content": {- "application/json": {- "schema": {- "type": "object",- "additionalProperties": { "type": "string" },- "title": "Metadata"- }- }- }- },"responses": {"200": {"description": "Successful Response","content": {"application/json": {"schema": {- "type": "integer",- "title": "Response Postv1Refund Credit Transaction"+ "$ref": "#/components/schemas/SessionDetailResponse"}}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -1253,57 +999,41 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/credits/auto-top-up": {- "get": {- "tags": ["v1", "credits"],- "summary": "Get auto top up",- "operationId": "getV1Get auto top up",- "responses": {- "200": {- "description": "Successful Response",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/AutoTopUpConfig" }- }- }- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ "/api/chat/sessions/{session_id}/assign-user": {+ "patch": {+ "tags": ["v2", "chat", "chat"],+ "summary": "Session Assign User",+ "description": "Assign an authenticated user to a chat session.\n\nUsed (typically post-login) to claim an existing anonymous session as the current authenticated user.\n\nArgs:\n session_id: The identifier for the (previously anonymous) session.\n user_id: The authenticated user's ID to associate with the session.\n\nReturns:\n dict: Status of the assignment.",+ "operationId": "patchV2SessionAssignUser",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "session_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Session Id" }}- },- "security": [{ "HTTPBearerJWT": [] }]- },- "post": {- "tags": ["v1", "credits"],- "summary": "Configure auto top up",- "operationId": "postV1Configure auto top up",- "requestBody": {- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/AutoTopUpConfig" }- }- },- "required": true- },+ ],"responses": {"200": {"description": "Successful Response","content": {"application/json": {"schema": {- "type": "string",- "title": "Response Postv1Configure Auto Top Up"+ "type": "object",+ "additionalProperties": true,+ "title": "Response Patchv2Sessionassignuser"}}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -1311,99 +1041,53 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }- },- "security": [{ "HTTPBearerJWT": [] }]- }- },- "/api/credits/stripe_webhook": {- "post": {- "tags": ["v1", "credits"],- "summary": "Handle Stripe webhooks",- "operationId": "postV1Handle stripe webhooks",- "responses": {- "200": {- "description": "Successful Response",- "content": { "application/json": { "schema": {} } }}}}},- "/api/credits/manage": {- "get": {- "tags": ["v1", "credits"],- "summary": "Manage payment methods",- "operationId": "getV1Manage payment methods",- "responses": {- "200": {- "description": "Successful Response",- "content": {- "application/json": {- "schema": {- "additionalProperties": { "type": "string" },- "type": "object",- "title": "Response Getv1Manage Payment Methods"- }- }- }- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }- },- "security": [{ "HTTPBearerJWT": [] }]- }- },- "/api/credits/transactions": {+ "/api/chat/sessions/{session_id}/stream": {"get": {- "tags": ["v1", "credits"],- "summary": "Get credit history",- "operationId": "getV1Get credit history",+ "tags": ["v2", "chat", "chat"],+ "summary": "Stream Chat",+ "description": "Stream chat responses for a session.\n\nStreams the AI/completion responses in real time over Server-Sent Events (SSE), including:\n - Text fragments as they are generated\n - Tool call UI elements (if invoked)\n - Tool execution results\n\nArgs:\n session_id: The chat session identifier to associate with the streamed messages.\n message: The user's new message to process.\n user_id: Optional authenticated user ID.\n is_user_message: Whether the message is a user message.\nReturns:\n StreamingResponse: SSE-formatted response chunks.",+ "operationId": "getV2StreamChat","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "transaction_time",- "in": "query",- "required": false,- "schema": {- "anyOf": [- { "type": "string", "format": "date-time" },- { "type": "null" }- ],- "title": "Transaction Time"- }+ "name": "session_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Session Id" }},{- "name": "transaction_type",+ "name": "message","in": "query",- "required": false,+ "required": true,"schema": {- "anyOf": [{ "type": "string" }, { "type": "null" }],- "title": "Transaction Type"+ "type": "string",+ "minLength": 1,+ "maxLength": 10000,+ "title": "Message"}},{- "name": "transaction_count_limit",+ "name": "is_user_message","in": "query","required": false,"schema": {- "type": "integer",- "default": 100,- "title": "Transaction Count Limit"+ "type": "boolean",+ "default": true,+ "title": "Is User Message"}}],"responses": {"200": {"description": "Successful Response",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/TransactionHistory" }- }- }+ "content": { "application/json": { "schema": {} } }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"},"422": {"description": "Validation Error",@@ -1412,27 +1096,24 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/credits/refunds": {+ "/api/credits": {"get": {"tags": ["v1", "credits"],- "summary": "Get refund requests",- "operationId": "getV1Get refund requests",+ "summary": "Get user credits",+ "operationId": "getV1Get user credits","responses": {"200": {"description": "Successful Response","content": {"application/json": {"schema": {- "items": { "$ref": "#/components/schemas/RefundRequest" },- "type": "array",- "title": "Response Getv1Get Refund Requests"+ "additionalProperties": { "type": "integer" },+ "type": "object",+ "title": "Response Getv1Get User Credits"}}}@@ -1442,25 +1123,15 @@}},"security": [{ "HTTPBearerJWT": [] }]- }- },- "/api/graphs": {- "get": {- "tags": ["v1", "graphs"],- "summary": "List user graphs",- "operationId": "getV1List user graphs",+ },+ "patch": {+ "tags": ["v1", "credits"],+ "summary": "Fulfill checkout session",+ "operationId": "patchV1Fulfill checkout session","responses": {"200": {"description": "Successful Response",- "content": {- "application/json": {- "schema": {- "items": { "$ref": "#/components/schemas/GraphMeta" },- "type": "array",- "title": "Response Getv1List User Graphs"- }- }- }+ "content": { "application/json": { "schema": {} } }},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"@@ -1469,13 +1140,13 @@"security": [{ "HTTPBearerJWT": [] }]},"post": {- "tags": ["v1", "graphs"],- "summary": "Create new graph",- "operationId": "postV1Create new graph",+ "tags": ["v1", "credits"],+ "summary": "Request credit top up",+ "operationId": "postV1Request credit top up","requestBody": {"content": {"application/json": {- "schema": { "$ref": "#/components/schemas/CreateGraph" }+ "schema": { "$ref": "#/components/schemas/RequestTopUp" }}},"required": true@@ -1483,11 +1154,10 @@"responses": {"200": {"description": "Successful Response",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/GraphModel" }- }- }+ "content": { "application/json": { "schema": {} } }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"},"422": {"description": "Validation Error",@@ -1496,56 +1166,40 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}},"security": [{ "HTTPBearerJWT": [] }]}},- "/api/graphs/{graph_id}/versions/{version}": {- "get": {- "tags": ["v1", "graphs"],- "summary": "Get graph version",- "operationId": "getV1Get graph version",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "graph_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Graph Id" }- },- {- "name": "version",- "in": "path",- "required": true,- "schema": {- "anyOf": [{ "type": "integer" }, { "type": "null" }],- "title": "Version"+ "/api/credits/admin/add_credits": {+ "post": {+ "tags": ["v2", "admin", "credits", "admin"],+ "summary": "Add Credits to User",+ "operationId": "postV2Add credits to user",+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/Body_postV2Add_credits_to_user"+ }}},- {- "name": "for_export",- "in": "query",- "required": false,- "schema": {- "type": "boolean",- "default": false,- "title": "For Export"- }- }- ],+ "required": true+ },"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/GraphModel" }+ "schema": {+ "$ref": "#/components/schemas/AddUserCreditsResponse"+ }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -1553,43 +1207,49 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- }+ },+ "security": [{ "HTTPBearerJWT": [] }]}},- "/api/graphs/{graph_id}": {+ "/api/credits/admin/users_history": {"get": {- "tags": ["v1", "graphs"],- "summary": "Get specific graph",- "operationId": "getV1Get specific graph",+ "tags": ["v2", "admin", "credits", "admin"],+ "summary": "Get All Users History",+ "operationId": "getV2Get all users history","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "graph_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Graph Id" }- },- {- "name": "version",+ "name": "search","in": "query","required": false,"schema": {- "anyOf": [{ "type": "integer" }, { "type": "null" }],- "title": "Version"+ "anyOf": [{ "type": "string" }, { "type": "null" }],+ "title": "Search"}},{- "name": "for_export",+ "name": "page",+ "in": "query",+ "required": false,+ "schema": { "type": "integer", "default": 1, "title": "Page" }+ },+ {+ "name": "page_size",+ "in": "query",+ "required": false,+ "schema": { "type": "integer", "default": 20, "title": "Page Size" }+ },+ {+ "name": "transaction_filter","in": "query","required": false,"schema": {- "type": "boolean",- "default": false,- "title": "For Export"+ "anyOf": [+ { "$ref": "#/components/schemas/CreditTransactionType" },+ { "type": "null" }+ ],+ "title": "Transaction Filter"}}],@@ -1598,10 +1258,13 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/GraphModel" }+ "schema": { "$ref": "#/components/schemas/UserHistoryResponse" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -1609,77 +1272,57 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}- },- "delete": {- "tags": ["v1", "graphs"],- "summary": "Delete graph permanently",- "operationId": "deleteV1Delete graph permanently",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "graph_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Graph Id" }- }- ],+ }+ },+ "/api/credits/auto-top-up": {+ "get": {+ "tags": ["v1", "credits"],+ "summary": "Get auto top up",+ "operationId": "getV1Get auto top up","responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/DeleteGraphResponse" }- }- }- },- "422": {- "description": "Validation Error",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ "schema": { "$ref": "#/components/schemas/AutoTopUpConfig" }}}},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- }+ },+ "security": [{ "HTTPBearerJWT": [] }]},- "put": {- "tags": ["v1", "graphs"],- "summary": "Update graph version",- "operationId": "putV1Update graph version",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "graph_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Graph Id" }- }- ],+ "post": {+ "tags": ["v1", "credits"],+ "summary": "Configure auto top up",+ "operationId": "postV1Configure auto top up","requestBody": {- "required": true,"content": {"application/json": {- "schema": { "$ref": "#/components/schemas/Graph" }+ "schema": { "$ref": "#/components/schemas/AutoTopUpConfig" }}- }+ },+ "required": true},"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/GraphModel" }+ "schema": {+ "type": "string",+ "title": "Response Postv1Configure Auto Top Up"+ }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -1687,80 +1330,124 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- }+ },+ "security": [{ "HTTPBearerJWT": [] }]}},- "/api/graphs/{graph_id}/versions": {+ "/api/credits/manage": {"get": {- "tags": ["v1", "graphs"],- "summary": "Get all graph versions",- "operationId": "getV1Get all graph versions",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "graph_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Graph Id" }- }- ],+ "tags": ["v1", "credits"],+ "summary": "Manage payment methods",+ "operationId": "getV1Manage payment methods","responses": {"200": {"description": "Successful Response","content": {"application/json": {"schema": {- "type": "array",- "items": { "$ref": "#/components/schemas/GraphModel" },- "title": "Response Getv1Get All Graph Versions"+ "additionalProperties": { "type": "string" },+ "type": "object",+ "title": "Response Getv1Manage Payment Methods"}}}},- "422": {- "description": "Validation Error",+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ }+ },+ "security": [{ "HTTPBearerJWT": [] }]+ }+ },+ "/api/credits/refunds": {+ "get": {+ "tags": ["v1", "credits"],+ "summary": "Get refund requests",+ "operationId": "getV1Get refund requests",+ "responses": {+ "200": {+ "description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ "schema": {+ "items": { "$ref": "#/components/schemas/RefundRequest" },+ "type": "array",+ "title": "Response Getv1Get Refund Requests"+ }}}},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"}+ },+ "security": [{ "HTTPBearerJWT": [] }]+ }+ },+ "/api/credits/stripe_webhook": {+ "post": {+ "tags": ["v1", "credits"],+ "summary": "Handle Stripe webhooks",+ "operationId": "postV1Handle stripe webhooks",+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": { "application/json": { "schema": {} } }+ }}}},- "/api/graphs/{graph_id}/versions/active": {- "put": {- "tags": ["v1", "graphs"],- "summary": "Set active graph version",- "operationId": "putV1Set active graph version",+ "/api/credits/transactions": {+ "get": {+ "tags": ["v1", "credits"],+ "summary": "Get credit history",+ "operationId": "getV1Get credit history","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "graph_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Graph Id" }- }- ],- "requestBody": {- "required": true,- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/SetGraphActiveVersion" }+ "name": "transaction_time",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [+ { "type": "string", "format": "date-time" },+ { "type": "null" }+ ],+ "title": "Transaction Time"+ }+ },+ {+ "name": "transaction_type",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [{ "type": "string" }, { "type": "null" }],+ "title": "Transaction Type"+ }+ },+ {+ "name": "transaction_count_limit",+ "in": "query",+ "required": false,+ "schema": {+ "type": "integer",+ "default": 100,+ "title": "Transaction Count Limit"}}- },+ ],"responses": {"200": {"description": "Successful Response",- "content": { "application/json": { "schema": {} } }+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/TransactionHistory" }+ }+ }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"},"422": {"description": "Validation Error",@@ -1769,33 +1456,33 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/graphs/{graph_id}/settings": {- "patch": {- "tags": ["v1", "graphs"],- "summary": "Update graph settings",- "description": "Update graph settings for the user's library agent.",- "operationId": "patchV1Update graph settings",+ "/api/credits/{transaction_key}/refund": {+ "post": {+ "tags": ["v1", "credits"],+ "summary": "Refund credit transaction",+ "operationId": "postV1Refund credit transaction","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "graph_id",+ "name": "transaction_key","in": "path","required": true,- "schema": { "type": "string", "title": "Graph Id" }+ "schema": { "type": "string", "title": "Transaction Key" }}],"requestBody": {"required": true,"content": {"application/json": {- "schema": { "$ref": "#/components/schemas/GraphSettings" }+ "schema": {+ "type": "object",+ "additionalProperties": { "type": "string" },+ "title": "Metadata"+ }}}},@@ -1804,10 +1491,16 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/GraphSettings" }- }- }- },+ "schema": {+ "type": "integer",+ "title": "Response Postv1Refund Credit Transaction"+ }+ }+ }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -1815,62 +1508,52 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/graphs/{graph_id}/execute/{graph_version}": {+ "/api/email/": {"post": {- "tags": ["v1", "graphs"],- "summary": "Execute graph agent",- "operationId": "postV1Execute graph agent",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "graph_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Graph Id" }- },- {- "name": "graph_version",- "in": "path",- "required": true,- "schema": {- "anyOf": [{ "type": "integer" }, { "type": "null" }],- "title": "Graph Version"- }- },- {- "name": "preset_id",- "in": "query",- "required": false,- "schema": {- "anyOf": [{ "type": "string" }, { "type": "null" }],- "title": "Preset Id"- }- }- ],+ "tags": ["v1", "email"],+ "summary": "Handle Postmark Email Webhooks",+ "operationId": "postV1Handle postmark email webhooks","requestBody": {"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/Body_postV1Execute_graph_agent"+ "oneOf": [+ { "$ref": "#/components/schemas/PostmarkDeliveryWebhook" },+ { "$ref": "#/components/schemas/PostmarkBounceWebhook" },+ {+ "$ref": "#/components/schemas/PostmarkSpamComplaintWebhook"+ },+ { "$ref": "#/components/schemas/PostmarkOpenWebhook" },+ { "$ref": "#/components/schemas/PostmarkClickWebhook" },+ {+ "$ref": "#/components/schemas/PostmarkSubscriptionChangeWebhook"+ }+ ],+ "title": "Webhook",+ "discriminator": {+ "propertyName": "RecordType",+ "mapping": {+ "Delivery": "#/components/schemas/PostmarkDeliveryWebhook",+ "Bounce": "#/components/schemas/PostmarkBounceWebhook",+ "SpamComplaint": "#/components/schemas/PostmarkSpamComplaintWebhook",+ "Open": "#/components/schemas/PostmarkOpenWebhook",+ "Click": "#/components/schemas/PostmarkClickWebhook",+ "SubscriptionChange": "#/components/schemas/PostmarkSubscriptionChangeWebhook"+ }+ }}}- }+ },+ "required": true},"responses": {"200": {"description": "Successful Response",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/GraphExecutionMeta" }- }- }+ "content": { "application/json": { "schema": {} } }},"422": {"description": "Validation Error",@@ -1879,47 +1562,28 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- }+ },+ "security": [{ "APIKeyAuthenticator-X-Postmark-Webhook-Token": [] }]}},- "/api/graphs/{graph_id}/executions/{graph_exec_id}/stop": {+ "/api/email/unsubscribe": {"post": {- "tags": ["v1", "graphs"],- "summary": "Stop graph execution",- "operationId": "postV1Stop graph execution",- "security": [{ "HTTPBearerJWT": [] }],+ "tags": ["v1", "email"],+ "summary": "One Click Email Unsubscribe",+ "operationId": "postV1One click email unsubscribe","parameters": [{- "name": "graph_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Graph Id" }- },- {- "name": "graph_exec_id",- "in": "path",+ "name": "token",+ "in": "query","required": true,- "schema": { "type": "string", "title": "Graph Exec Id" }+ "schema": { "type": "string", "title": "Token" }}],"responses": {"200": {"description": "Successful Response",- "content": {- "application/json": {- "schema": {- "anyOf": [- { "$ref": "#/components/schemas/GraphExecutionMeta" },- { "type": "null" }- ],- "title": "Response Postv1Stop Graph Execution"- }- }- }+ "content": { "application/json": { "schema": {} } }},"422": {"description": "Validation Error",@@ -1928,9 +1592,6 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}@@ -1962,45 +1623,54 @@"security": [{ "HTTPBearerJWT": [] }]}},- "/api/graphs/{graph_id}/executions": {+ "/api/executions/admin/execution_accuracy_trends": {"get": {- "tags": ["v1", "graphs"],- "summary": "List graph executions",- "operationId": "getV1List graph executions",+ "tags": ["v2", "admin", "admin", "execution_analytics"],+ "summary": "Get Execution Accuracy Trends and Alerts",+ "description": "Get execution accuracy trends with moving averages and alert detection.\nSimple single-query approach.",+ "operationId": "getV2Get execution accuracy trends and alerts","security": [{ "HTTPBearerJWT": [] }],"parameters": [{"name": "graph_id",- "in": "path",+ "in": "query","required": true,"schema": { "type": "string", "title": "Graph Id" }},{- "name": "page",+ "name": "user_id","in": "query","required": false,"schema": {- "type": "integer",- "minimum": 1,- "description": "Page number (1-indexed)",- "default": 1,- "title": "Page"- },- "description": "Page number (1-indexed)"+ "anyOf": [{ "type": "string" }, { "type": "null" }],+ "title": "User Id"+ }},{- "name": "page_size",+ "name": "days_back",+ "in": "query",+ "required": false,+ "schema": { "type": "integer", "default": 30, "title": "Days Back" }+ },+ {+ "name": "drop_threshold","in": "query","required": false,"schema": {- "type": "integer",- "maximum": 100,- "minimum": 1,- "description": "Number of executions per page",- "default": 25,- "title": "Page Size"- },- "description": "Number of executions per page"+ "type": "number",+ "default": 10.0,+ "title": "Drop Threshold"+ }+ },+ {+ "name": "include_historical",+ "in": "query",+ "required": false,+ "schema": {+ "type": "boolean",+ "default": false,+ "title": "Include Historical"+ }}],"responses": {@@ -2009,11 +1679,14 @@"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/GraphExecutionsPaginated"+ "$ref": "#/components/schemas/AccuracyTrendsResponse"}}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -2021,48 +1694,40 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/graphs/{graph_id}/executions/{graph_exec_id}": {- "get": {- "tags": ["v1", "graphs"],- "summary": "Get execution details",- "operationId": "getV1Get execution details",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "graph_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Graph Id" }+ "/api/executions/admin/execution_analytics": {+ "post": {+ "tags": ["v2", "admin", "admin", "execution_analytics"],+ "summary": "Generate Execution Analytics",+ "description": "Generate activity summaries and correctness scores for graph executions.\n\nThis endpoint:\n1. Fetches all completed executions matching the criteria\n2. Identifies executions missing activity_status or correctness_score\n3. Generates missing data using AI in batches\n4. Updates the database with new stats\n5. Returns a detailed report of the analytics operation",+ "operationId": "postV2Generate execution analytics",+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ExecutionAnalyticsRequest"+ }+ }},- {- "name": "graph_exec_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Graph Exec Id" }- }- ],+ "required": true+ },"responses": {"200": {"description": "Successful Response","content": {"application/json": {"schema": {- "anyOf": [- { "$ref": "#/components/schemas/GraphExecution" },- { "$ref": "#/components/schemas/GraphExecutionWithNodes" }- ],- "title": "Response Getv1Get Execution Details"+ "$ref": "#/components/schemas/ExecutionAnalyticsResponse"}}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -2070,11 +1735,33 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}+ }+ },+ "security": [{ "HTTPBearerJWT": [] }]+ }+ },+ "/api/executions/admin/execution_analytics/config": {+ "get": {+ "tags": ["v2", "admin", "admin", "execution_analytics"],+ "summary": "Get Execution Analytics Configuration",+ "description": "Get the configuration for execution analytics including:\n- Available AI models with metadata\n- Default system and user prompts\n- Recommended model selection",+ "operationId": "getV2Get execution analytics configuration",+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ExecutionAnalyticsConfig"+ }+ }+ }},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- }+ },+ "security": [{ "HTTPBearerJWT": [] }]}},"/api/executions/{graph_exec_id}": {@@ -2093,6 +1780,9 @@],"responses": {"204": { "description": "Successful Response" },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -2100,40 +1790,45 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/graphs/{graph_id}/executions/{graph_exec_id}/share": {+ "/api/files/upload": {"post": {- "tags": ["v1"],- "summary": "Enable Execution Sharing",- "description": "Enable sharing for a graph execution.",- "operationId": "postV1EnableExecutionSharing",+ "tags": ["v1", "files"],+ "summary": "Upload file to cloud storage",+ "description": "Upload a file to cloud storage and return a storage key that can be used\nwith FileStoreBlock and AgentFileInputBlock.\n\nArgs:\n file: The file to upload\n user_id: The user ID\n provider: Cloud storage provider (\"gcs\", \"s3\", \"azure\")\n expiration_hours: Hours until file expires (1-48)\n\nReturns:\n Dict containing the cloud storage path and signed URL",+ "operationId": "postV1Upload file to cloud storage","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "graph_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Graph Id" }+ "name": "provider",+ "in": "query",+ "required": false,+ "schema": {+ "type": "string",+ "default": "gcs",+ "title": "Provider"+ }},{- "name": "graph_exec_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Graph Exec Id" }+ "name": "expiration_hours",+ "in": "query",+ "required": false,+ "schema": {+ "type": "integer",+ "default": 24,+ "title": "Expiration Hours"+ }}],"requestBody": {+ "required": true,"content": {- "application/json": {+ "multipart/form-data": {"schema": {- "$ref": "#/components/schemas/ShareRequest",- "default": {}+ "$ref": "#/components/schemas/Body_postV1Upload_file_to_cloud_storage"}}}@@ -2143,10 +1838,13 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/ShareResponse" }+ "schema": { "$ref": "#/components/schemas/UploadFileResponse" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -2154,17 +1852,75 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}+ }+ }+ }+ },+ "/api/graphs": {+ "get": {+ "tags": ["v1", "graphs"],+ "summary": "List user graphs",+ "operationId": "getV1List user graphs",+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": {+ "items": { "$ref": "#/components/schemas/GraphMeta" },+ "type": "array",+ "title": "Response Getv1List User Graphs"+ }+ }+ }},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- }+ },+ "security": [{ "HTTPBearerJWT": [] }]},+ "post": {+ "tags": ["v1", "graphs"],+ "summary": "Create new graph",+ "operationId": "postV1Create new graph",+ "requestBody": {+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/CreateGraph" }+ }+ },+ "required": true+ },+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/GraphModel" }+ }+ }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }+ }+ },+ "security": [{ "HTTPBearerJWT": [] }]+ }+ },+ "/api/graphs/{graph_id}": {"delete": {- "tags": ["v1"],- "summary": "Disable Execution Sharing",- "description": "Disable sharing for a graph execution.",- "operationId": "deleteV1DisableExecutionSharing",+ "tags": ["v1", "graphs"],+ "summary": "Delete graph permanently",+ "operationId": "deleteV1Delete graph permanently","security": [{ "HTTPBearerJWT": [] }],"parameters": [{@@ -2172,45 +1928,59 @@"in": "path","required": true,"schema": { "type": "string", "title": "Graph Id" }- },- {- "name": "graph_exec_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Graph Exec Id" }}],"responses": {- "204": { "description": "Successful Response" },- "422": {- "description": "Validation Error",+ "200": {+ "description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ "schema": { "$ref": "#/components/schemas/DeleteGraphResponse" }}}},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }}}- }- },- "/api/public/shared/{share_token}": {+ },"get": {- "tags": ["v1"],- "summary": "Get Shared Execution",- "description": "Get a shared graph execution by share token (no auth required).",- "operationId": "getV1GetSharedExecution",+ "tags": ["v1", "graphs"],+ "summary": "Get specific graph",+ "operationId": "getV1Get specific graph",+ "security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "share_token",+ "name": "graph_id","in": "path","required": true,+ "schema": { "type": "string", "title": "Graph Id" }+ },+ {+ "name": "version",+ "in": "query",+ "required": false,"schema": {- "type": "string",- "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",- "title": "Share Token"+ "anyOf": [{ "type": "integer" }, { "type": "null" }],+ "title": "Version"+ }+ },+ {+ "name": "for_export",+ "in": "query",+ "required": false,+ "schema": {+ "type": "boolean",+ "default": false,+ "title": "For Export"}}],@@ -2219,12 +1989,13 @@"description": "Successful Response","content": {"application/json": {- "schema": {- "$ref": "#/components/schemas/SharedExecutionResponse"- }+ "schema": { "$ref": "#/components/schemas/GraphModel" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -2234,34 +2005,25 @@}}}- }- },- "/api/graphs/{graph_id}/schedules": {- "post": {- "tags": ["v1", "schedules"],- "summary": "Create execution schedule",- "operationId": "postV1Create execution schedule",+ },+ "put": {+ "tags": ["v1", "graphs"],+ "summary": "Update graph version",+ "operationId": "putV1Update graph version","security": [{ "HTTPBearerJWT": [] }],"parameters": [{"name": "graph_id","in": "path","required": true,- "schema": {- "type": "string",- "description": "ID of the graph to schedule",- "title": "Graph Id"- },- "description": "ID of the graph to schedule"+ "schema": { "type": "string", "title": "Graph Id" }}],"requestBody": {"required": true,"content": {"application/json": {- "schema": {- "$ref": "#/components/schemas/ScheduleCreationRequest"- }+ "schema": { "$ref": "#/components/schemas/Graph" }}}},@@ -2270,12 +2032,13 @@"description": "Successful Response","content": {"application/json": {- "schema": {- "$ref": "#/components/schemas/GraphExecutionJobInfo"- }+ "schema": { "$ref": "#/components/schemas/GraphModel" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -2283,16 +2046,15 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}- },- "get": {- "tags": ["v1", "schedules"],- "summary": "List execution schedules for a graph",- "operationId": "getV1List execution schedules for a graph",+ }+ },+ "/api/graphs/{graph_id}/execute/{graph_version}": {+ "post": {+ "tags": ["v1", "graphs"],+ "summary": "Execute graph agent",+ "operationId": "postV1Execute graph agent","security": [{ "HTTPBearerJWT": [] }],"parameters": [{@@ -2300,23 +2062,47 @@"in": "path","required": true,"schema": { "type": "string", "title": "Graph Id" }+ },+ {+ "name": "graph_version",+ "in": "path",+ "required": true,+ "schema": {+ "anyOf": [{ "type": "integer" }, { "type": "null" }],+ "title": "Graph Version"+ }+ },+ {+ "name": "preset_id",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [{ "type": "string" }, { "type": "null" }],+ "title": "Preset Id"+ }}],+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/Body_postV1Execute_graph_agent"+ }+ }+ }+ },"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": {- "type": "array",- "items": {- "$ref": "#/components/schemas/GraphExecutionJobInfo"- },- "title": "Response Getv1List Execution Schedules For A Graph"- }+ "schema": { "$ref": "#/components/schemas/GraphExecutionMeta" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -2324,57 +2110,49 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/schedules": {+ "/api/graphs/{graph_id}/executions": {"get": {- "tags": ["v1", "schedules"],- "summary": "List execution schedules for a user",- "operationId": "getV1List execution schedules for a user",- "responses": {- "200": {- "description": "Successful Response",- "content": {- "application/json": {- "schema": {- "items": {- "$ref": "#/components/schemas/GraphExecutionJobInfo"- },- "type": "array",- "title": "Response Getv1List Execution Schedules For A User"- }- }- }- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }- },- "security": [{ "HTTPBearerJWT": [] }]- }- },- "/api/schedules/{schedule_id}": {- "delete": {- "tags": ["v1", "schedules"],- "summary": "Delete execution schedule",- "operationId": "deleteV1Delete execution schedule",+ "tags": ["v1", "graphs"],+ "summary": "List graph executions",+ "operationId": "getV1List graph executions","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "schedule_id",+ "name": "graph_id","in": "path","required": true,+ "schema": { "type": "string", "title": "Graph Id" }+ },+ {+ "name": "page",+ "in": "query",+ "required": false,"schema": {- "type": "string",- "description": "ID of the schedule to delete",- "title": "Schedule Id"+ "type": "integer",+ "minimum": 1,+ "description": "Page number (1-indexed)",+ "default": 1,+ "title": "Page"},- "description": "ID of the schedule to delete"+ "description": "Page number (1-indexed)"+ },+ {+ "name": "page_size",+ "in": "query",+ "required": false,+ "schema": {+ "type": "integer",+ "maximum": 100,+ "minimum": 1,+ "description": "Number of executions per page",+ "default": 25,+ "title": "Page Size"+ },+ "description": "Number of executions per page"}],"responses": {@@ -2383,13 +2161,14 @@"content": {"application/json": {"schema": {- "type": "object",- "additionalProperties": true,- "title": "Response Deletev1Delete Execution Schedule"+ "$ref": "#/components/schemas/GraphExecutionsPaginated"}}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -2397,61 +2176,47 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/api-keys": {+ "/api/graphs/{graph_id}/executions/{graph_exec_id}": {"get": {- "tags": ["v1", "api-keys"],- "summary": "List user API keys",- "description": "List all API keys for the user",- "operationId": "getV1List user api keys",+ "tags": ["v1", "graphs"],+ "summary": "Get execution details",+ "operationId": "getV1Get execution details",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "graph_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Graph Id" }+ },+ {+ "name": "graph_exec_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Graph Exec Id" }+ }+ ],"responses": {"200": {"description": "Successful Response","content": {"application/json": {"schema": {- "items": { "$ref": "#/components/schemas/APIKeyInfo" },- "type": "array",- "title": "Response Getv1List User Api Keys"+ "anyOf": [+ { "$ref": "#/components/schemas/GraphExecution" },+ { "$ref": "#/components/schemas/GraphExecutionWithNodes" }+ ],+ "title": "Response Getv1Get Execution Details"}}}},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }- },- "security": [{ "HTTPBearerJWT": [] }]- },- "post": {- "tags": ["v1", "api-keys"],- "summary": "Create new API key",- "description": "Create a new API key",- "operationId": "postV1Create new api key",- "requestBody": {- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/CreateAPIKeyRequest" }- }- },- "required": true- },- "responses": {- "200": {- "description": "Successful Response",- "content": {- "application/json": {- "schema": {- "$ref": "#/components/schemas/CreateAPIKeyResponse"- }- }- }},"422": {"description": "Validation Error",@@ -2460,37 +2225,35 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- },- "security": [{ "HTTPBearerJWT": [] }]+ }}},- "/api/api-keys/{key_id}": {- "get": {- "tags": ["v1", "api-keys"],- "summary": "Get specific API key",- "description": "Get a specific API key",- "operationId": "getV1Get specific api key",+ "/api/graphs/{graph_id}/executions/{graph_exec_id}/share": {+ "delete": {+ "tags": ["v1"],+ "summary": "Disable Execution Sharing",+ "description": "Disable sharing for a graph execution.",+ "operationId": "deleteV1DisableExecutionSharing","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "key_id",+ "name": "graph_id","in": "path","required": true,- "schema": { "type": "string", "title": "Key Id" }+ "schema": { "type": "string", "title": "Graph Id" }+ },+ {+ "name": "graph_exec_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Graph Exec Id" }}],"responses": {- "200": {- "description": "Successful Response",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/APIKeyInfo" }- }- }+ "204": { "description": "Successful Response" },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"},"422": {"description": "Validation Error",@@ -2499,35 +2262,51 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}},- "delete": {- "tags": ["v1", "api-keys"],- "summary": "Revoke API key",- "description": "Revoke an API key",- "operationId": "deleteV1Revoke api key",+ "post": {+ "tags": ["v1"],+ "summary": "Enable Execution Sharing",+ "description": "Enable sharing for a graph execution.",+ "operationId": "postV1EnableExecutionSharing","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "key_id",+ "name": "graph_id","in": "path","required": true,- "schema": { "type": "string", "title": "Key Id" }+ "schema": { "type": "string", "title": "Graph Id" }+ },+ {+ "name": "graph_exec_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Graph Exec Id" }}],+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ShareRequest",+ "default": {}+ }+ }+ }+ },"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/APIKeyInfo" }+ "schema": { "$ref": "#/components/schemas/ShareResponse" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -2535,26 +2314,28 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/api-keys/{key_id}/suspend": {+ "/api/graphs/{graph_id}/executions/{graph_exec_id}/stop": {"post": {- "tags": ["v1", "api-keys"],- "summary": "Suspend API key",- "description": "Suspend an API key",- "operationId": "postV1Suspend api key",+ "tags": ["v1", "graphs"],+ "summary": "Stop graph execution",+ "operationId": "postV1Stop graph execution","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "key_id",+ "name": "graph_id","in": "path","required": true,- "schema": { "type": "string", "title": "Key Id" }+ "schema": { "type": "string", "title": "Graph Id" }+ },+ {+ "name": "graph_exec_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Graph Exec Id" }}],"responses": {@@ -2562,10 +2343,19 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/APIKeyInfo" }+ "schema": {+ "anyOf": [+ { "$ref": "#/components/schemas/GraphExecutionMeta" },+ { "type": "null" }+ ],+ "title": "Response Postv1Stop Graph Execution"+ }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -2573,47 +2363,42 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/api-keys/{key_id}/permissions": {- "put": {- "tags": ["v1", "api-keys"],- "summary": "Update key permissions",- "description": "Update API key permissions",- "operationId": "putV1Update key permissions",+ "/api/graphs/{graph_id}/schedules": {+ "get": {+ "tags": ["v1", "schedules"],+ "summary": "List execution schedules for a graph",+ "operationId": "getV1List execution schedules for a graph","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "key_id",+ "name": "graph_id","in": "path","required": true,- "schema": { "type": "string", "title": "Key Id" }+ "schema": { "type": "string", "title": "Graph Id" }}],- "requestBody": {- "required": true,- "content": {- "application/json": {- "schema": {- "$ref": "#/components/schemas/UpdatePermissionsRequest"- }- }- }- },"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/APIKeyInfo" }+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/GraphExecutionJobInfo"+ },+ "title": "Response Getv1List Execution Schedules For A Graph"+ }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -2621,56 +2406,51 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}- }- },- "/api/store/profile": {- "get": {- "tags": ["v2", "store", "private"],- "summary": "Get user profile",- "description": "Get the profile details for the authenticated user.\nCached for 1 hour per user.",- "operationId": "getV2Get user profile",- "responses": {- "200": {- "description": "Successful Response",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/ProfileDetails" }- }- }- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }- },- "security": [{ "HTTPBearerJWT": [] }]},"post": {- "tags": ["v2", "store", "private"],- "summary": "Update user profile",- "description": "Update the store profile for the authenticated user.\n\nArgs:\n profile (Profile): The updated profile details\n user_id (str): ID of the authenticated user\n\nReturns:\n CreatorDetails: The updated profile\n\nRaises:\n HTTPException: If there is an error updating the profile",- "operationId": "postV2Update user profile",+ "tags": ["v1", "schedules"],+ "summary": "Create execution schedule",+ "operationId": "postV1Create execution schedule",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "graph_id",+ "in": "path",+ "required": true,+ "schema": {+ "type": "string",+ "description": "ID of the graph to schedule",+ "title": "Graph Id"+ },+ "description": "ID of the graph to schedule"+ }+ ],"requestBody": {+ "required": true,"content": {"application/json": {- "schema": { "$ref": "#/components/schemas/Profile" }+ "schema": {+ "$ref": "#/components/schemas/ScheduleCreationRequest"+ }}- },- "required": true+ }},"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/CreatorDetails" }+ "schema": {+ "$ref": "#/components/schemas/GraphExecutionJobInfo"+ }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -2678,95 +2458,45 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- },- "security": [{ "HTTPBearerJWT": [] }]+ }}},- "/api/store/agents": {- "get": {- "tags": ["v2", "store", "public"],- "summary": "List store agents",- "description": "Get a paginated list of agents from the store with optional filtering and sorting.\n\nArgs:\n featured (bool, optional): Filter to only show featured agents. Defaults to False.\n creator (str | None, optional): Filter agents by creator username. Defaults to None.\n sorted_by (str | None, optional): Sort agents by \"runs\" or \"rating\". Defaults to None.\n search_query (str | None, optional): Search agents by name, subheading and description. Defaults to None.\n category (str | None, optional): Filter agents by category. Defaults to None.\n page (int, optional): Page number for pagination. Defaults to 1.\n page_size (int, optional): Number of agents per page. Defaults to 20.\n\nReturns:\n StoreAgentsResponse: Paginated list of agents matching the filters\n\nRaises:\n HTTPException: If page or page_size are less than 1\n\nUsed for:\n- Home Page Featured Agents\n- Home Page Top Agents\n- Search Results\n- Agent Details - Other Agents By Creator\n- Agent Details - Similar Agents\n- Creator Details - Agents By Creator",- "operationId": "getV2List store agents",+ "/api/graphs/{graph_id}/settings": {+ "patch": {+ "tags": ["v1", "graphs"],+ "summary": "Update graph settings",+ "description": "Update graph settings for the user's library agent.",+ "operationId": "patchV1Update graph settings",+ "security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "featured",- "in": "query",- "required": false,- "schema": {- "type": "boolean",- "default": false,- "title": "Featured"- }- },- {- "name": "creator",- "in": "query",- "required": false,- "schema": {- "anyOf": [{ "type": "string" }, { "type": "null" }],- "title": "Creator"- }- },- {- "name": "sorted_by",- "in": "query",- "required": false,- "schema": {- "anyOf": [- {- "enum": ["rating", "runs", "name", "updated_at"],- "type": "string"- },- { "type": "null" }- ],- "title": "Sorted By"- }- },- {- "name": "search_query",- "in": "query",- "required": false,- "schema": {- "anyOf": [{ "type": "string" }, { "type": "null" }],- "title": "Search Query"- }- },- {- "name": "category",- "in": "query",- "required": false,- "schema": {- "anyOf": [{ "type": "string" }, { "type": "null" }],- "title": "Category"- }- },- {- "name": "page",- "in": "query",- "required": false,- "schema": { "type": "integer", "default": 1, "title": "Page" }- },- {- "name": "page_size",- "in": "query",- "required": false,- "schema": { "type": "integer", "default": 20, "title": "Page Size" }+ "name": "graph_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Graph Id" }}],+ "requestBody": {+ "required": true,+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/GraphSettings" }+ }+ }+ },"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/StoreAgentsResponse" }+ "schema": { "$ref": "#/components/schemas/GraphSettings" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -2778,24 +2508,18 @@}}},- "/api/store/agents/{username}/{agent_name}": {+ "/api/graphs/{graph_id}/versions": {"get": {- "tags": ["v2", "store", "public"],- "summary": "Get specific agent",- "description": "This is only used on the AgentDetails Page.\n\nIt returns the store listing agents details.",- "operationId": "getV2Get specific agent",+ "tags": ["v1", "graphs"],+ "summary": "Get all graph versions",+ "operationId": "getV1Get all graph versions",+ "security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "username",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Username" }- },- {- "name": "agent_name",+ "name": "graph_id","in": "path","required": true,- "schema": { "type": "string", "title": "Agent Name" }+ "schema": { "type": "string", "title": "Graph Id" }}],"responses": {@@ -2803,10 +2527,17 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/StoreAgentDetails" }+ "schema": {+ "type": "array",+ "items": { "$ref": "#/components/schemas/GraphModel" },+ "title": "Response Getv1Get All Graph Versions"+ }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -2818,26 +2549,36 @@}}},- "/api/store/graph/{store_listing_version_id}": {- "get": {- "tags": ["v2", "store"],- "summary": "Get agent graph",- "description": "Get Agent Graph from Store Listing Version ID.",- "operationId": "getV2Get agent graph",+ "/api/graphs/{graph_id}/versions/active": {+ "put": {+ "tags": ["v1", "graphs"],+ "summary": "Set active graph version",+ "operationId": "putV1Set active graph version","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "store_listing_version_id",+ "name": "graph_id","in": "path","required": true,- "schema": { "type": "string", "title": "Store Listing Version Id" }+ "schema": { "type": "string", "title": "Graph Id" }}],+ "requestBody": {+ "required": true,+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/SetGraphActiveVersion" }+ }+ }+ },"responses": {"200": {"description": "Successful Response","content": { "application/json": { "schema": {} } }},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -2845,26 +2586,41 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/store/agents/{store_listing_version_id}": {+ "/api/graphs/{graph_id}/versions/{version}": {"get": {- "tags": ["v2", "store"],- "summary": "Get agent by version",- "description": "Get Store Agent Details from Store Listing Version ID.",- "operationId": "getV2Get agent by version",+ "tags": ["v1", "graphs"],+ "summary": "Get graph version",+ "operationId": "getV1Get graph version","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "store_listing_version_id",+ "name": "graph_id","in": "path","required": true,- "schema": { "type": "string", "title": "Store Listing Version Id" }+ "schema": { "type": "string", "title": "Graph Id" }+ },+ {+ "name": "version",+ "in": "path",+ "required": true,+ "schema": {+ "anyOf": [{ "type": "integer" }, { "type": "null" }],+ "title": "Version"+ }+ },+ {+ "name": "for_export",+ "in": "query",+ "required": false,+ "schema": {+ "type": "boolean",+ "default": false,+ "title": "For Export"+ }}],"responses": {@@ -2872,10 +2628,13 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/StoreAgentDetails" }+ "schema": { "$ref": "#/components/schemas/GraphModel" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -2883,39 +2642,197 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}+ }+ }+ }+ },+ "/api/integrations/ayrshare/sso_url": {+ "get": {+ "tags": ["v1", "integrations"],+ "summary": "Get Ayrshare Sso Url",+ "description": "Generate an SSO URL for Ayrshare social media integration.\n\nReturns:\n dict: Contains the SSO URL for Ayrshare integration",+ "operationId": "getV1GetAyrshareSsoUrl",+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/AyrshareSSOResponse" }+ }+ }},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"}+ },+ "security": [{ "HTTPBearerJWT": [] }]+ }+ },+ "/api/integrations/credentials": {+ "get": {+ "tags": ["v1", "integrations"],+ "summary": "List Credentials",+ "operationId": "getV1List credentials",+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": {+ "items": {+ "$ref": "#/components/schemas/CredentialsMetaResponse"+ },+ "type": "array",+ "title": "Response Getv1List Credentials"+ }+ }+ }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ }+ },+ "security": [{ "HTTPBearerJWT": [] }]+ }+ },+ "/api/integrations/providers": {+ "get": {+ "tags": ["v1", "integrations"],+ "summary": "List Providers",+ "description": "Get a list of all available provider names.\n\nReturns both statically defined providers (from ProviderName enum)\nand dynamically registered providers (from SDK decorators).\n\nNote: The complete list of provider names is also available as a constant\nin the generated TypeScript client via PROVIDER_NAMES.",+ "operationId": "getV1ListProviders",+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": {+ "items": { "type": "string" },+ "type": "array",+ "title": "Response Getv1Listproviders"+ }+ }+ }+ }}}},- "/api/store/agents/{username}/{agent_name}/review": {+ "/api/integrations/providers/constants": {+ "get": {+ "tags": ["v1", "integrations"],+ "summary": "Get Provider Constants",+ "description": "Get provider names as constants.\n\nThis endpoint returns a model with provider names as constants,\nspecifically designed for OpenAPI code generation tools to create\nTypeScript constants.",+ "operationId": "getV1GetProviderConstants",+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/ProviderConstants" }+ }+ }+ }+ }+ }+ },+ "/api/integrations/providers/enum-example": {+ "get": {+ "tags": ["v1", "integrations"],+ "summary": "Get Provider Enum Example",+ "description": "Example endpoint that uses the CompleteProviderNames enum.\n\nThis endpoint exists to ensure that the CompleteProviderNames enum is included\nin the OpenAPI schema, which will cause Orval to generate it as a\nTypeScript enum/constant.",+ "operationId": "getV1GetProviderEnumExample",+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ProviderEnumResponse"+ }+ }+ }+ }+ }+ }+ },+ "/api/integrations/providers/names": {+ "get": {+ "tags": ["v1", "integrations"],+ "summary": "Get Provider Names",+ "description": "Get all provider names in a structured format.\n\nThis endpoint is specifically designed to expose the provider names\nin the OpenAPI schema so that code generators like Orval can create\nappropriate TypeScript constants.",+ "operationId": "getV1GetProviderNames",+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ProviderNamesResponse"+ }+ }+ }+ }+ }+ }+ },+ "/api/integrations/webhooks/{webhook_id}/ping": {"post": {- "tags": ["v2", "store"],- "summary": "Create agent review",- "description": "Create a review for a store agent.\n\nArgs:\n username: Creator's username\n agent_name: Name/slug of the agent\n review: Review details including score and optional comments\n user_id: ID of authenticated user creating the review\n\nReturns:\n The created review",- "operationId": "postV2Create agent review",+ "tags": ["v1", "integrations"],+ "summary": "Webhook Ping",+ "operationId": "postV1WebhookPing","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "username",+ "name": "webhook_id","in": "path","required": true,- "schema": { "type": "string", "title": "Username" }+ "schema": { "type": "string", "title": "Our ID for the webhook" }+ }+ ],+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": { "application/json": { "schema": {} } }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"},+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }+ }+ }+ }+ },+ "/api/integrations/{provider}/callback": {+ "post": {+ "tags": ["v1", "integrations"],+ "summary": "Exchange OAuth code for tokens",+ "operationId": "postV1Exchange oauth code for tokens",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [{- "name": "agent_name",+ "name": "provider","in": "path","required": true,- "schema": { "type": "string", "title": "Agent Name" }+ "schema": {+ "type": "string",+ "title": "The target provider for this OAuth exchange",+ "description": "Provider name for integrations. Can be any string value, including custom provider names."+ }}],"requestBody": {"required": true,"content": {"application/json": {- "schema": { "$ref": "#/components/schemas/StoreReviewCreate" }+ "schema": {+ "$ref": "#/components/schemas/Body_postV1Exchange_oauth_code_for_tokens"+ }}}},@@ -2924,10 +2841,15 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/StoreReview" }+ "schema": {+ "$ref": "#/components/schemas/CredentialsMetaResponse"+ }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -2935,65 +2857,175 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/store/creators": {+ "/api/integrations/{provider}/credentials": {"get": {- "tags": ["v2", "store", "public"],- "summary": "List store creators",- "description": "This is needed for:\n- Home Page Featured Creators\n- Search Results Page\n\n---\n\nTo support this functionality we need:\n- featured: bool - to limit the list to just featured agents\n- search_query: str - vector search based on the creators profile description.\n- sorted_by: [agent_rating, agent_runs] -",- "operationId": "getV2List store creators",+ "tags": ["v1", "integrations"],+ "summary": "List Credentials By Provider",+ "operationId": "getV1ListCredentialsByProvider",+ "security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "featured",- "in": "query",- "required": false,+ "name": "provider",+ "in": "path",+ "required": true,"schema": {- "type": "boolean",- "default": false,- "title": "Featured"+ "type": "string",+ "title": "The provider to list credentials for",+ "description": "Provider name for integrations. Can be any string value, including custom provider names."+ }+ }+ ],+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/CredentialsMetaResponse"+ },+ "title": "Response Getv1Listcredentialsbyprovider"+ }+ }}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }+ }+ }+ },+ "post": {+ "tags": ["v1", "integrations"],+ "summary": "Create Credentials",+ "operationId": "postV1Create credentials",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [{- "name": "search_query",- "in": "query",- "required": false,+ "name": "provider",+ "in": "path",+ "required": true,"schema": {- "anyOf": [{ "type": "string" }, { "type": "null" }],- "title": "Search Query"+ "type": "string",+ "title": "The provider to create credentials for",+ "description": "Provider name for integrations. Can be any string value, including custom provider names."+ }+ }+ ],+ "requestBody": {+ "required": true,+ "content": {+ "application/json": {+ "schema": {+ "oneOf": [+ { "$ref": "#/components/schemas/OAuth2Credentials" },+ { "$ref": "#/components/schemas/APIKeyCredentials" },+ { "$ref": "#/components/schemas/UserPasswordCredentials" },+ { "$ref": "#/components/schemas/HostScopedCredentials-Input" }+ ],+ "discriminator": {+ "propertyName": "type",+ "mapping": {+ "oauth2": "#/components/schemas/OAuth2Credentials",+ "api_key": "#/components/schemas/APIKeyCredentials",+ "user_password": "#/components/schemas/UserPasswordCredentials",+ "host_scoped": "#/components/schemas/HostScopedCredentials-Input"+ }+ },+ "title": "Credentials"+ }+ }+ }+ },+ "responses": {+ "201": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": {+ "oneOf": [+ { "$ref": "#/components/schemas/OAuth2Credentials" },+ { "$ref": "#/components/schemas/APIKeyCredentials" },+ { "$ref": "#/components/schemas/UserPasswordCredentials" },+ {+ "$ref": "#/components/schemas/HostScopedCredentials-Output"+ }+ ],+ "discriminator": {+ "propertyName": "type",+ "mapping": {+ "oauth2": "#/components/schemas/OAuth2Credentials",+ "api_key": "#/components/schemas/APIKeyCredentials",+ "user_password": "#/components/schemas/UserPasswordCredentials",+ "host_scoped": "#/components/schemas/HostScopedCredentials-Output"+ }+ },+ "title": "Response Postv1Create Credentials"+ }+ }}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }+ }+ }+ }+ },+ "/api/integrations/{provider}/credentials/{cred_id}": {+ "delete": {+ "tags": ["v1", "integrations"],+ "summary": "Delete Credentials",+ "operationId": "deleteV1DeleteCredentials",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [{- "name": "sorted_by",- "in": "query",- "required": false,+ "name": "provider",+ "in": "path",+ "required": true,"schema": {- "anyOf": [- {- "enum": ["agent_rating", "agent_runs", "num_agents"],- "type": "string"- },- { "type": "null" }- ],- "title": "Sorted By"+ "type": "string",+ "title": "The provider to delete credentials for",+ "description": "Provider name for integrations. Can be any string value, including custom provider names."}},{- "name": "page",- "in": "query",- "required": false,- "schema": { "type": "integer", "default": 1, "title": "Page" }+ "name": "cred_id",+ "in": "path",+ "required": true,+ "schema": {+ "type": "string",+ "title": "The ID of the credentials to delete"+ }},{- "name": "page_size",+ "name": "force","in": "query","required": false,- "schema": { "type": "integer", "default": 20, "title": "Page Size" }+ "schema": {+ "type": "boolean",+ "title": "Whether to proceed if any linked webhooks are still in use",+ "default": false+ }}],"responses": {@@ -3001,10 +3033,23 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/CreatorsResponse" }+ "schema": {+ "anyOf": [+ {+ "$ref": "#/components/schemas/CredentialsDeletionResponse"+ },+ {+ "$ref": "#/components/schemas/CredentialsDeletionNeedsConfirmationResponse"+ }+ ],+ "title": "Response Deletev1Deletecredentials"+ }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -3014,20 +3059,31 @@}}}- }- },- "/api/store/creator/{username}": {+ },"get": {- "tags": ["v2", "store", "public"],- "summary": "Get creator details",- "description": "Get the details of a creator.\n- Creator Details Page",- "operationId": "getV2Get creator details",+ "tags": ["v1", "integrations"],+ "summary": "Get Specific Credential By ID",+ "operationId": "getV1Get specific credential by id",+ "security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "username",+ "name": "provider","in": "path","required": true,- "schema": { "type": "string", "title": "Username" }+ "schema": {+ "type": "string",+ "title": "The provider to retrieve credentials for",+ "description": "Provider name for integrations. Can be any string value, including custom provider names."+ }+ },+ {+ "name": "cred_id",+ "in": "path",+ "required": true,+ "schema": {+ "type": "string",+ "title": "The ID of the credentials to retrieve"+ }}],"responses": {@@ -3035,10 +3091,32 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/CreatorDetails" }+ "schema": {+ "oneOf": [+ { "$ref": "#/components/schemas/OAuth2Credentials" },+ { "$ref": "#/components/schemas/APIKeyCredentials" },+ { "$ref": "#/components/schemas/UserPasswordCredentials" },+ {+ "$ref": "#/components/schemas/HostScopedCredentials-Output"+ }+ ],+ "discriminator": {+ "propertyName": "type",+ "mapping": {+ "oauth2": "#/components/schemas/OAuth2Credentials",+ "api_key": "#/components/schemas/APIKeyCredentials",+ "user_password": "#/components/schemas/UserPasswordCredentials",+ "host_scoped": "#/components/schemas/HostScopedCredentials-Output"+ }+ },+ "title": "Response Getv1Get Specific Credential By Id"+ }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -3050,34 +3128,31 @@}}},- "/api/store/myagents": {+ "/api/integrations/{provider}/login": {"get": {- "tags": ["v2", "store", "private"],- "summary": "Get my agents",- "description": "Get user's own agents.",- "operationId": "getV2Get my agents",+ "tags": ["v1", "integrations"],+ "summary": "Initiate OAuth flow",+ "operationId": "getV1Initiate oauth flow","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "page",- "in": "query",- "required": false,+ "name": "provider",+ "in": "path",+ "required": true,"schema": {- "type": "integer",- "minimum": 1,- "default": 1,- "title": "Page"+ "type": "string",+ "title": "The provider to initiate an OAuth flow for",+ "description": "Provider name for integrations. Can be any string value, including custom provider names."}},{- "name": "page_size",+ "name": "scopes","in": "query","required": false,"schema": {- "type": "integer",- "minimum": 1,- "default": 20,- "title": "Page Size"+ "type": "string",+ "title": "Comma-separated list of authorization scopes",+ "default": ""}}],@@ -3086,10 +3161,13 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/MyAgentsResponse" }+ "schema": { "$ref": "#/components/schemas/LoginResponse" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -3097,39 +3175,37 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/store/submissions/{submission_id}": {- "delete": {- "tags": ["v2", "store", "private"],- "summary": "Delete store submission",- "description": "Delete a store listing submission.\n\nArgs:\n user_id (str): ID of the authenticated user\n submission_id (str): ID of the submission to be deleted\n\nReturns:\n bool: True if the submission was successfully deleted, False otherwise",- "operationId": "deleteV2Delete store submission",- "security": [{ "HTTPBearerJWT": [] }],+ "/api/integrations/{provider}/webhooks/{webhook_id}/ingress": {+ "post": {+ "tags": ["v1", "integrations"],+ "summary": "Webhook Ingress Generic",+ "operationId": "postV1WebhookIngressGeneric","parameters": [{- "name": "submission_id",+ "name": "provider","in": "path","required": true,- "schema": { "type": "string", "title": "Submission Id" }+ "schema": {+ "type": "string",+ "title": "Provider where the webhook was registered",+ "description": "Provider name for integrations. Can be any string value, including custom provider names."+ }+ },+ {+ "name": "webhook_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Our ID for the webhook" }}],"responses": {"200": {"description": "Successful Response",- "content": {- "application/json": {- "schema": {- "type": "boolean",- "title": "Response Deletev2Delete Store Submission"- }- }- }+ "content": { "application/json": { "schema": {} } }},"422": {"description": "Validation Error",@@ -3138,82 +3214,80 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/store/submissions": {+ "/api/library/agents": {"get": {- "tags": ["v2", "store", "private"],- "summary": "List my submissions",- "description": "Get a paginated list of store submissions for the authenticated user.\n\nArgs:\n user_id (str): ID of the authenticated user\n page (int, optional): Page number for pagination. Defaults to 1.\n page_size (int, optional): Number of submissions per page. Defaults to 20.\n\nReturns:\n StoreListingsResponse: Paginated list of store submissions\n\nRaises:\n HTTPException: If page or page_size are less than 1",- "operationId": "getV2List my submissions",+ "tags": ["v2", "library", "private"],+ "summary": "List Library Agents",+ "description": "Get all agents in the user's library (both created and saved).\n\nArgs:\n user_id: ID of the authenticated user.\n search_term: Optional search term to filter agents by name/description.\n filter_by: List of filters to apply (favorites, created by user).\n sort_by: List of sorting criteria (created date, updated date).\n page: Page number to retrieve.\n page_size: Number of agents per page.\n\nReturns:\n A LibraryAgentResponse containing agents and pagination metadata.\n\nRaises:\n HTTPException: If a server/database error occurs.",+ "operationId": "getV2List library agents","security": [{ "HTTPBearerJWT": [] }],"parameters": [+ {+ "name": "search_term",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [{ "type": "string" }, { "type": "null" }],+ "description": "Search term to filter agents",+ "title": "Search Term"+ },+ "description": "Search term to filter agents"+ },+ {+ "name": "sort_by",+ "in": "query",+ "required": false,+ "schema": {+ "$ref": "#/components/schemas/LibraryAgentSort",+ "description": "Criteria to sort results by",+ "default": "updatedAt"+ },+ "description": "Criteria to sort results by"+ },{"name": "page","in": "query","required": false,- "schema": { "type": "integer", "default": 1, "title": "Page" }+ "schema": {+ "type": "integer",+ "minimum": 1,+ "description": "Page number to retrieve (must be >= 1)",+ "default": 1,+ "title": "Page"+ },+ "description": "Page number to retrieve (must be >= 1)"},{"name": "page_size","in": "query","required": false,- "schema": { "type": "integer", "default": 20, "title": "Page Size" }+ "schema": {+ "type": "integer",+ "minimum": 1,+ "description": "Number of agents per page (must be >= 1)",+ "default": 15,+ "title": "Page Size"+ },+ "description": "Number of agents per page (must be >= 1)"}],"responses": {"200": {- "description": "Successful Response",+ "description": "List of library agents","content": {"application/json": {"schema": {- "$ref": "#/components/schemas/StoreSubmissionsResponse"+ "$ref": "#/components/schemas/LibraryAgentResponse"}}}},- "422": {- "description": "Validation Error",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/HTTPValidationError" }- }- }- },"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }- }- },- "post": {- "tags": ["v2", "store", "private"],- "summary": "Create store submission",- "description": "Create a new store listing submission.\n\nArgs:\n submission_request (StoreSubmissionRequest): The submission details\n user_id (str): ID of the authenticated user submitting the listing\n\nReturns:\n StoreSubmission: The created store submission\n\nRaises:\n HTTPException: If there is an error creating the submission",- "operationId": "postV2Create store submission",- "security": [{ "HTTPBearerJWT": [] }],- "requestBody": {- "required": true,- "content": {- "application/json": {- "schema": {- "$ref": "#/components/schemas/StoreSubmissionRequest"- }- }- }- },- "responses": {- "200": {- "description": "Successful Response",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/StoreSubmission" }- }- }},"422": {"description": "Validation Error",@@ -3223,116 +3297,41 @@}}},- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ "500": {+ "description": "Server error",+ "content": { "application/json": {} }}}- }- },- "/api/store/submissions/{store_listing_version_id}": {- "put": {- "tags": ["v2", "store", "private"],- "summary": "Edit store submission",- "description": "Edit an existing store listing submission.\n\nArgs:\n store_listing_version_id (str): ID of the store listing version to edit\n submission_request (StoreSubmissionRequest): The updated submission details\n user_id (str): ID of the authenticated user editing the listing\n\nReturns:\n StoreSubmission: The updated store submission\n\nRaises:\n HTTPException: If there is an error editing the submission",- "operationId": "putV2Edit store submission",+ },+ "post": {+ "tags": ["v2", "library", "private"],+ "summary": "Add Marketplace Agent",+ "description": "Add an agent from the marketplace to the user's library.\n\nArgs:\n store_listing_version_id: ID of the store listing version to add.\n user_id: ID of the authenticated user.\n\nReturns:\n library_model.LibraryAgent: Agent added to the library\n\nRaises:\n HTTPException(404): If the listing version is not found.\n HTTPException(500): If a server/database error occurs.",+ "operationId": "postV2Add marketplace agent","security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "store_listing_version_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Store Listing Version Id" }- }- ],"requestBody": {"required": true,"content": {- "application/json": {- "schema": {- "$ref": "#/components/schemas/StoreSubmissionEditRequest"- }- }- }- },- "responses": {- "200": {- "description": "Successful Response",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/StoreSubmission" }- }- }- },- "422": {- "description": "Validation Error",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/HTTPValidationError" }- }- }- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }- }- }- },- "/api/store/submissions/media": {- "post": {- "tags": ["v2", "store", "private"],- "summary": "Upload submission media",- "description": "Upload media (images/videos) for a store listing submission.\n\nArgs:\n file (UploadFile): The media file to upload\n user_id (str): ID of the authenticated user uploading the media\n\nReturns:\n str: URL of the uploaded media file\n\nRaises:\n HTTPException: If there is an error uploading the media",- "operationId": "postV2Upload submission media",- "requestBody": {- "content": {- "multipart/form-data": {+ "application/json": {"schema": {- "$ref": "#/components/schemas/Body_postV2Upload_submission_media"+ "$ref": "#/components/schemas/Body_postV2Add_marketplace_agent"}}- },- "required": true+ }},"responses": {- "200": {- "description": "Successful Response",- "content": { "application/json": { "schema": {} } }- },- "422": {- "description": "Validation Error",+ "201": {+ "description": "Agent added successfully","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ "schema": { "$ref": "#/components/schemas/LibraryAgent" }}}},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }- },- "security": [{ "HTTPBearerJWT": [] }]- }- },- "/api/store/submissions/generate_image": {- "post": {- "tags": ["v2", "store", "private"],- "summary": "Generate submission image",- "description": "Generate an image for a store listing submission.\n\nArgs:\n agent_id (str): ID of the agent to generate an image for\n user_id (str): ID of the authenticated user\n\nReturns:\n JSONResponse: JSON containing the URL of the generated image",- "operationId": "postV2Generate submission image",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "agent_id",- "in": "query",- "required": true,- "schema": { "type": "string", "title": "Agent Id" }- }- ],- "responses": {- "200": {- "description": "Successful Response",- "content": { "application/json": { "schema": {} } }},+ "404": { "description": "Store listing version not found" },"422": {"description": "Validation Error","content": {@@ -3341,35 +3340,44 @@}}},- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }+ "500": { "description": "Server error" }}}},- "/api/store/download/agents/{store_listing_version_id}": {+ "/api/library/agents/by-graph/{graph_id}": {"get": {- "tags": ["v2", "store", "public"],- "summary": "Download agent file",- "description": "Download the agent file by streaming its content.\n\nArgs:\n store_listing_version_id (str): The ID of the agent to download\n\nReturns:\n StreamingResponse: A streaming response containing the agent's graph data.\n\nRaises:\n HTTPException: If the agent is not found or an unexpected error occurs.",- "operationId": "getV2Download agent file",+ "tags": ["v2", "library", "private"],+ "summary": "Get Library Agent By Graph Id",+ "operationId": "getV2GetLibraryAgentByGraphId",+ "security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "store_listing_version_id",+ "name": "graph_id","in": "path","required": true,+ "schema": { "type": "string", "title": "Graph Id" }+ },+ {+ "name": "version",+ "in": "query",+ "required": false,"schema": {- "type": "string",- "description": "The ID of the agent to download",- "title": "Store Listing Version Id"- },- "description": "The ID of the agent to download"+ "anyOf": [{ "type": "integer" }, { "type": "null" }],+ "title": "Version"+ }}],"responses": {"200": {"description": "Successful Response",- "content": { "application/json": { "schema": {} } }+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/LibraryAgent" }+ }+ }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"},"422": {"description": "Validation Error",@@ -3382,76 +3390,104 @@}}},- "/api/store/metrics/cache": {+ "/api/library/agents/favorites": {"get": {- "tags": ["v2", "store", "metrics"],- "summary": "Get cache metrics in Prometheus format",- "description": "Get cache metrics in Prometheus text format.\n\nReturns Prometheus-compatible metrics for monitoring cache performance.\nMetrics include size, maxsize, TTL, and hit rate for each cache.\n\nReturns:\n str: Prometheus-formatted metrics text",- "operationId": "getV2Get cache metrics in prometheus format",- "responses": {- "200": {- "description": "Successful Response",- "content": { "text/plain": { "schema": { "type": "string" } } }+ "tags": ["v2", "library", "private"],+ "summary": "List Favorite Library Agents",+ "description": "Get all favorite agents in the user's library.\n\nArgs:\n user_id: ID of the authenticated user.\n page: Page number to retrieve.\n page_size: Number of agents per page.\n\nReturns:\n A LibraryAgentResponse containing favorite agents and pagination metadata.\n\nRaises:\n HTTPException: If a server/database error occurs.",+ "operationId": "getV2List favorite library agents",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "page",+ "in": "query",+ "required": false,+ "schema": {+ "type": "integer",+ "minimum": 1,+ "description": "Page number to retrieve (must be >= 1)",+ "default": 1,+ "title": "Page"+ },+ "description": "Page number to retrieve (must be >= 1)"+ },+ {+ "name": "page_size",+ "in": "query",+ "required": false,+ "schema": {+ "type": "integer",+ "minimum": 1,+ "description": "Number of agents per page (must be >= 1)",+ "default": 15,+ "title": "Page Size"+ },+ "description": "Number of agents per page (must be >= 1)"}- }- }- },- "/api/builder/suggestions": {- "get": {- "tags": ["v2"],- "summary": "Get Builder suggestions",- "description": "Get all suggestions for the Blocks Menu.",- "operationId": "getV2Get builder suggestions",+ ],"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/SuggestionsResponse" }+ "schema": {+ "$ref": "#/components/schemas/LibraryAgentResponse"+ }}}},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }+ },+ "500": {+ "description": "Server error",+ "content": { "application/json": {} }}- },- "security": [{ "HTTPBearerJWT": [] }]+ }}},- "/api/builder/categories": {+ "/api/library/agents/marketplace/{store_listing_version_id}": {"get": {- "tags": ["v2"],- "summary": "Get Builder block categories",- "description": "Get all block categories with a specified number of blocks per category.",- "operationId": "getV2Get builder block categories",+ "tags": ["v2", "library", "private", "store", "library"],+ "summary": "Get Agent By Store ID",+ "description": "Get Library Agent from Store Listing Version ID.",+ "operationId": "getV2Get agent by store id","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "blocks_per_category",- "in": "query",- "required": false,- "schema": {- "type": "integer",- "default": 3,- "title": "Blocks Per Category"- }+ "name": "store_listing_version_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Store Listing Version Id" }}],"responses": {"200": {- "description": "Successful Response",+ "description": "Library agent found","content": {"application/json": {"schema": {- "type": "array",- "items": {- "$ref": "#/components/schemas/BlockCategoryResponse"- },- "title": "Response Getv2Get Builder Block Categories"+ "anyOf": [+ { "$ref": "#/components/schemas/LibraryAgent" },+ { "type": "null" }+ ],+ "title": "Response Getv2Get Agent By Store Id"}}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "404": { "description": "Agent not found" },"422": {"description": "Validation Error","content": {@@ -3459,71 +3495,57 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/builder/blocks": {- "get": {- "tags": ["v2"],- "summary": "Get Builder blocks",- "description": "Get blocks based on either category, type, or provider.",- "operationId": "getV2Get builder blocks",+ "/api/library/agents/{library_agent_id}": {+ "delete": {+ "tags": ["v2", "library", "private"],+ "summary": "Delete Library Agent",+ "description": "Soft-delete the specified library agent.\n\nArgs:\n library_agent_id: ID of the library agent to delete.\n user_id: ID of the authenticated user.\n\nReturns:\n 204 No Content if successful.\n\nRaises:\n HTTPException(404): If the agent does not exist.\n HTTPException(500): If a server/database error occurs.",+ "operationId": "deleteV2Delete library agent","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "category",- "in": "query",- "required": false,- "schema": {- "anyOf": [{ "type": "string" }, { "type": "null" }],- "title": "Category"- }+ "name": "library_agent_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Library Agent Id" }+ }+ ],+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": { "application/json": { "schema": {} } }},- {- "name": "type",- "in": "query",- "required": false,- "schema": {- "anyOf": [- {- "enum": ["all", "input", "action", "output"],- "type": "string"- },- { "type": "null" }- ],- "title": "Type"- }+ "204": { "description": "Agent deleted successfully" },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"},- {- "name": "provider",- "in": "query",- "required": false,- "schema": {- "anyOf": [- {- "type": "string",- "description": "Provider name for integrations. Can be any string value, including custom provider names."- },- { "type": "null" }- ],- "title": "Provider"+ "404": { "description": "Agent not found" },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }}},+ "500": { "description": "Server error" }+ }+ },+ "get": {+ "tags": ["v2", "library", "private"],+ "summary": "Get Library Agent",+ "operationId": "getV2Get library agent",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [{- "name": "page",- "in": "query",- "required": false,- "schema": { "type": "integer", "default": 1, "title": "Page" }- },- {- "name": "page_size",- "in": "query",- "required": false,- "schema": { "type": "integer", "default": 50, "title": "Page Size" }+ "name": "library_agent_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Library Agent Id" }}],"responses": {@@ -3531,10 +3553,13 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/BlockResponse" }+ "schema": { "$ref": "#/components/schemas/LibraryAgent" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -3542,45 +3567,45 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}- }- },- "/api/builder/blocks/batch": {- "get": {- "tags": ["v2"],- "summary": "Get specific blocks",- "description": "Get specific blocks by their IDs.",- "operationId": "getV2Get specific blocks",+ },+ "patch": {+ "tags": ["v2", "library", "private"],+ "summary": "Update Library Agent",+ "description": "Update the library agent with the given fields.\n\nArgs:\n library_agent_id: ID of the library agent to update.\n payload: Fields to update (auto_update_version, is_favorite, etc.).\n user_id: ID of the authenticated user.\n\nRaises:\n HTTPException(500): If a server/database error occurs.",+ "operationId": "patchV2Update library agent","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "block_ids",- "in": "query",+ "name": "library_agent_id",+ "in": "path","required": true,- "schema": {- "type": "array",- "items": { "type": "string" },- "title": "Block Ids"- }+ "schema": { "type": "string", "title": "Library Agent Id" }}],+ "requestBody": {+ "required": true,+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/LibraryAgentUpdateRequest"+ }+ }+ }+ },"responses": {"200": {- "description": "Successful Response",+ "description": "Agent updated successfully","content": {"application/json": {- "schema": {- "type": "array",- "items": { "$ref": "#/components/schemas/BlockInfo" },- "title": "Response Getv2Get Specific Blocks"- }+ "schema": { "$ref": "#/components/schemas/LibraryAgent" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -3589,31 +3614,22 @@}}},- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }+ "500": { "description": "Server error" }}}},- "/api/builder/providers": {- "get": {- "tags": ["v2"],- "summary": "Get Builder integration providers",- "description": "Get all integration providers with their block counts.",- "operationId": "getV2Get builder integration providers",+ "/api/library/agents/{library_agent_id}/fork": {+ "post": {+ "tags": ["v2", "library", "private"],+ "summary": "Fork Library Agent",+ "operationId": "postV2Fork library agent","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "page",- "in": "query",- "required": false,- "schema": { "type": "integer", "default": 1, "title": "Page" }- },- {- "name": "page_size",- "in": "query",- "required": false,- "schema": { "type": "integer", "default": 50, "title": "Page Size" }+ "name": "library_agent_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Library Agent Id" }}],"responses": {@@ -3621,10 +3637,13 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/ProviderResponse" }+ "schema": { "$ref": "#/components/schemas/LibraryAgent" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -3632,85 +3651,50 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/builder/search": {+ "/api/library/presets": {"get": {- "tags": ["v2", "store", "private"],- "summary": "Builder search",- "description": "Search for blocks (including integrations), marketplace agents, and user library agents.",- "operationId": "getV2Builder search",+ "tags": ["v2", "presets"],+ "summary": "List presets",+ "description": "Retrieve a paginated list of presets for the current user.",+ "operationId": "getV2List presets","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "search_query",+ "name": "page","in": "query","required": false,"schema": {- "anyOf": [{ "type": "string" }, { "type": "null" }],- "title": "Search Query"+ "type": "integer",+ "minimum": 1,+ "default": 1,+ "title": "Page"}},{- "name": "filter",+ "name": "page_size","in": "query","required": false,"schema": {- "anyOf": [- {- "type": "array",- "items": {- "enum": [- "blocks",- "integrations",- "marketplace_agents",- "my_agents"- ],- "type": "string"- }- },- { "type": "null" }- ],- "title": "Filter"+ "type": "integer",+ "minimum": 1,+ "default": 10,+ "title": "Page Size"}},{- "name": "search_id",+ "name": "graph_id","in": "query",- "required": false,+ "required": true,"schema": {"anyOf": [{ "type": "string" }, { "type": "null" }],- "title": "Search Id"- }- },- {- "name": "by_creator",- "in": "query",- "required": false,- "schema": {- "anyOf": [- { "type": "array", "items": { "type": "string" } },- { "type": "null" }- ],- "title": "By Creator"- }- },- {- "name": "page",- "in": "query",- "required": false,- "schema": { "type": "integer", "default": 1, "title": "Page" }- },- {- "name": "page_size",- "in": "query",- "required": false,- "schema": { "type": "integer", "default": 50, "title": "Page Size" }+ "description": "Allows to filter presets by a specific agent graph",+ "title": "Graph Id"+ },+ "description": "Allows to filter presets by a specific agent graph"}],"responses": {@@ -3718,10 +3702,15 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/SearchResponse" }+ "schema": {+ "$ref": "#/components/schemas/LibraryAgentPresetResponse"+ }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -3729,75 +3718,138 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}+ }+ }+ },+ "post": {+ "tags": ["v2", "presets"],+ "summary": "Create a new preset",+ "description": "Create a new preset for the current user.",+ "operationId": "postV2Create a new preset",+ "security": [{ "HTTPBearerJWT": [] }],+ "requestBody": {+ "required": true,+ "content": {+ "application/json": {+ "schema": {+ "anyOf": [+ {+ "$ref": "#/components/schemas/LibraryAgentPresetCreatable"+ },+ {+ "$ref": "#/components/schemas/LibraryAgentPresetCreatableFromGraphExecution"+ }+ ],+ "title": "Preset"+ }+ }+ }+ },+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/LibraryAgentPreset" }+ }+ }},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }}}}},- "/api/builder/counts": {- "get": {- "tags": ["v2"],- "summary": "Get Builder item counts",- "description": "Get item counts for the menu categories in the Blocks Menu.",- "operationId": "getV2Get builder item counts",+ "/api/library/presets/setup-trigger": {+ "post": {+ "tags": ["v2", "presets"],+ "summary": "Setup Trigger",+ "description": "Sets up a webhook-triggered `LibraryAgentPreset` for a `LibraryAgent`.\nReturns the correspondingly created `LibraryAgentPreset` with `webhook_id` set.",+ "operationId": "postV2SetupTrigger",+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/TriggeredPresetSetupRequest"+ }+ }+ },+ "required": true+ },"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/CountResponse" }+ "schema": { "$ref": "#/components/schemas/LibraryAgentPreset" }}}},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }}},"security": [{ "HTTPBearerJWT": [] }]}},- "/api/store/admin/listings": {- "get": {- "tags": ["v2", "admin", "store", "admin"],- "summary": "Get Admin Listings History",- "description": "Get store listings with their version history for admins.\n\nThis provides a consolidated view of listings with their versions,\nallowing for an expandable UI in the admin dashboard.\n\nArgs:\n status: Filter by submission status (PENDING, APPROVED, REJECTED)\n search: Search by name, description, or user email\n page: Page number for pagination\n page_size: Number of items per page\n\nReturns:\n StoreListingsWithVersionsResponse with listings and their versions",- "operationId": "getV2Get admin listings history",+ "/api/library/presets/{preset_id}": {+ "delete": {+ "tags": ["v2", "presets"],+ "summary": "Delete a preset",+ "description": "Delete an existing preset by its ID.",+ "operationId": "deleteV2Delete a preset","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "status",- "in": "query",- "required": false,- "schema": {- "anyOf": [- { "$ref": "#/components/schemas/SubmissionStatus" },- { "type": "null" }- ],- "title": "Status"- }+ "name": "preset_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Preset Id" }+ }+ ],+ "responses": {+ "204": { "description": "Successful Response" },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"},- {- "name": "search",- "in": "query",- "required": false,- "schema": {- "anyOf": [{ "type": "string" }, { "type": "null" }],- "title": "Search"+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }}- },- {- "name": "page",- "in": "query",- "required": false,- "schema": { "type": "integer", "default": 1, "title": "Page" }- },+ }+ }+ },+ "get": {+ "tags": ["v2", "presets"],+ "summary": "Get a specific preset",+ "description": "Retrieve details for a specific preset by its ID.",+ "operationId": "getV2Get a specific preset",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [{- "name": "page_size",- "in": "query",- "required": false,- "schema": { "type": "integer", "default": 20, "title": "Page Size" }+ "name": "preset_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Preset Id" }}],"responses": {@@ -3805,12 +3857,13 @@"description": "Successful Response","content": {"application/json": {- "schema": {- "$ref": "#/components/schemas/StoreListingsWithVersionsResponse"- }+ "schema": { "$ref": "#/components/schemas/LibraryAgentPreset" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -3818,26 +3871,21 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}- }- },- "/api/store/admin/submissions/{store_listing_version_id}/review": {- "post": {- "tags": ["v2", "admin", "store", "admin"],- "summary": "Review Store Submission",- "description": "Review a store listing submission.\n\nArgs:\n store_listing_version_id: ID of the submission to review\n request: Review details including approval status and comments\n user_id: Authenticated admin user performing the review\n\nReturns:\n StoreSubmission with updated review information",- "operationId": "postV2Review store submission",+ },+ "patch": {+ "tags": ["v2", "presets"],+ "summary": "Update an existing preset",+ "description": "Update an existing preset by its ID.",+ "operationId": "patchV2Update an existing preset","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "store_listing_version_id",+ "name": "preset_id","in": "path","required": true,- "schema": { "type": "string", "title": "Store Listing Version Id" }+ "schema": { "type": "string", "title": "Preset Id" }}],"requestBody": {@@ -3845,7 +3893,7 @@"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/ReviewSubmissionRequest"+ "$ref": "#/components/schemas/LibraryAgentPresetUpdatable"}}}@@ -3855,10 +3903,13 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/StoreSubmission" }+ "schema": { "$ref": "#/components/schemas/LibraryAgentPreset" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -3866,37 +3917,45 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/store/admin/submissions/download/{store_listing_version_id}": {- "get": {- "tags": ["v2", "admin", "store", "admin", "store", "admin"],- "summary": "Admin Download Agent File",- "description": "Download the agent file by streaming its content.\n\nArgs:\n store_listing_version_id (str): The ID of the agent to download\n\nReturns:\n StreamingResponse: A streaming response containing the agent's graph data.\n\nRaises:\n HTTPException: If the agent is not found or an unexpected error occurs.",- "operationId": "getV2Admin download agent file",+ "/api/library/presets/{preset_id}/execute": {+ "post": {+ "tags": ["v2", "presets", "presets"],+ "summary": "Execute a preset",+ "description": "Execute a preset with the given graph and node input for the current user.",+ "operationId": "postV2Execute a preset","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "store_listing_version_id",+ "name": "preset_id","in": "path","required": true,- "schema": {- "type": "string",- "description": "The ID of the agent to download",- "title": "Store Listing Version Id"- },- "description": "The ID of the agent to download"+ "schema": { "type": "string", "title": "Preset Id" }}],+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/Body_postV2Execute_a_preset"+ }+ }+ }+ },"responses": {"200": {"description": "Successful Response",- "content": { "application/json": { "schema": {} } }+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/GraphExecutionMeta" }+ }+ }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"},"422": {"description": "Validation Error",@@ -3905,39 +3964,40 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/credits/admin/add_credits": {- "post": {- "tags": ["v2", "admin", "credits", "admin"],- "summary": "Add Credits to User",- "operationId": "postV2Add credits to user",- "requestBody": {- "content": {- "application/json": {- "schema": {- "$ref": "#/components/schemas/Body_postV2Add_credits_to_user"- }- }- },- "required": true- },+ "/api/oauth/app/{client_id}": {+ "get": {+ "tags": ["oauth"],+ "summary": "Get Oauth App Info",+ "description": "Get public information about an OAuth application.\n\nThis endpoint is used by the consent screen to display application details\nto the user before they authorize access.\n\nReturns:\n- name: Application name\n- description: Application description (if provided)\n- scopes: List of scopes the application is allowed to request",+ "operationId": "getOauthGetOauthAppInfo",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "client_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Client Id" }+ }+ ],"responses": {"200": {"description": "Successful Response","content": {"application/json": {"schema": {- "$ref": "#/components/schemas/AddUserCreditsResponse"+ "$ref": "#/components/schemas/OAuthApplicationPublicInfo"}}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "404": { "description": "Application not found or disabled" },"422": {"description": "Validation Error","content": {@@ -3945,64 +4005,75 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- },- "security": [{ "HTTPBearerJWT": [] }]+ }}},- "/api/credits/admin/users_history": {+ "/api/oauth/apps/mine": {"get": {- "tags": ["v2", "admin", "credits", "admin"],- "summary": "Get All Users History",- "operationId": "getV2Get all users history",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "search",- "in": "query",- "required": false,- "schema": {- "anyOf": [{ "type": "string" }, { "type": "null" }],- "title": "Search"- }- },- {- "name": "page",- "in": "query",- "required": false,- "schema": { "type": "integer", "default": 1, "title": "Page" }- },- {- "name": "page_size",- "in": "query",- "required": false,- "schema": { "type": "integer", "default": 20, "title": "Page Size" }- },- {- "name": "transaction_filter",- "in": "query",- "required": false,- "schema": {- "anyOf": [- { "$ref": "#/components/schemas/CreditTransactionType" },- { "type": "null" }- ],- "title": "Transaction Filter"+ "tags": ["oauth"],+ "summary": "List My Oauth Apps",+ "description": "List all OAuth applications owned by the current user.\n\nReturns a list of OAuth applications with their details including:\n- id, name, description, logo_url\n- client_id (public identifier)\n- redirect_uris, grant_types, scopes\n- is_active status\n- created_at, updated_at timestamps\n\nNote: client_secret is never returned for security reasons.",+ "operationId": "getOauthListMyOauthApps",+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": {+ "items": {+ "$ref": "#/components/schemas/OAuthApplicationInfo"+ },+ "type": "array",+ "title": "Response Getoauthlistmyoauthapps"+ }+ }}+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ }+ },+ "security": [{ "HTTPBearerJWT": [] }]+ }+ },+ "/api/oauth/apps/{app_id}/logo": {+ "patch": {+ "tags": ["oauth"],+ "summary": "Update App Logo",+ "description": "Update the logo URL for an OAuth application.\n\nOnly the application owner can update the logo.\nThe logo should be uploaded first using the media upload endpoint,\nthen this endpoint is called with the resulting URL.\n\nLogo requirements:\n- Must be square (1:1 aspect ratio)\n- Minimum 512x512 pixels\n- Maximum 2048x2048 pixels\n\nReturns the updated application info.",+ "operationId": "patchOauthUpdateAppLogo",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "app_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "App Id" }}],+ "requestBody": {+ "required": true,+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/UpdateAppLogoRequest" }+ }+ }+ },"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/UserHistoryResponse" }+ "schema": {+ "$ref": "#/components/schemas/OAuthApplicationInfo"+ }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -4010,52 +4081,84 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/executions/admin/execution_analytics/config": {- "get": {- "tags": ["v2", "admin", "admin", "execution_analytics"],- "summary": "Get Execution Analytics Configuration",- "description": "Get the configuration for execution analytics including:\n- Available AI models with metadata\n- Default system and user prompts\n- Recommended model selection",- "operationId": "getV2Get execution analytics configuration",+ "/api/oauth/apps/{app_id}/logo/upload": {+ "post": {+ "tags": ["oauth"],+ "summary": "Upload App Logo",+ "description": "Upload a logo image for an OAuth application.\n\nRequirements:\n- Image must be square (1:1 aspect ratio)\n- Minimum 512x512 pixels\n- Maximum 2048x2048 pixels\n- Allowed formats: JPEG, PNG, WebP\n- Maximum file size: 3MB\n\nThe image is uploaded to cloud storage and the app's logoUrl is updated.\nReturns the updated application info.",+ "operationId": "postOauthUploadAppLogo",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "app_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "App Id" }+ }+ ],+ "requestBody": {+ "required": true,+ "content": {+ "multipart/form-data": {+ "schema": {+ "$ref": "#/components/schemas/Body_postOauthUploadAppLogo"+ }+ }+ }+ },"responses": {"200": {"description": "Successful Response","content": {"application/json": {"schema": {- "$ref": "#/components/schemas/ExecutionAnalyticsConfig"+ "$ref": "#/components/schemas/OAuthApplicationInfo"}}}},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }}- },- "security": [{ "HTTPBearerJWT": [] }]+ }}},- "/api/executions/admin/execution_analytics": {- "post": {- "tags": ["v2", "admin", "admin", "execution_analytics"],- "summary": "Generate Execution Analytics",- "description": "Generate activity summaries and correctness scores for graph executions.\n\nThis endpoint:\n1. Fetches all completed executions matching the criteria\n2. Identifies executions missing activity_status or correctness_score\n3. Generates missing data using AI in batches\n4. Updates the database with new stats\n5. Returns a detailed report of the analytics operation",- "operationId": "postV2Generate execution analytics",+ "/api/oauth/apps/{app_id}/status": {+ "patch": {+ "tags": ["oauth"],+ "summary": "Update App Status",+ "description": "Enable or disable an OAuth application.\n\nOnly the application owner can update the status.\nWhen disabled, the application cannot be used for new authorizations\nand existing access tokens will fail validation.\n\nReturns the updated application info.",+ "operationId": "patchOauthUpdateAppStatus",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "app_id",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "App Id" }+ }+ ],"requestBody": {+ "required": true,"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/ExecutionAnalyticsRequest"+ "$ref": "#/components/schemas/Body_patchOauthUpdateAppStatus"}}- },- "required": true+ }},"responses": {"200": {@@ -4063,11 +4166,14 @@"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/ExecutionAnalyticsResponse"+ "$ref": "#/components/schemas/OAuthApplicationInfo"}}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -4075,75 +4181,36 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- },- "security": [{ "HTTPBearerJWT": [] }]+ }}},- "/api/executions/admin/execution_accuracy_trends": {- "get": {- "tags": ["v2", "admin", "admin", "execution_analytics"],- "summary": "Get Execution Accuracy Trends and Alerts",- "description": "Get execution accuracy trends with moving averages and alert detection.\nSimple single-query approach.",- "operationId": "getV2Get execution accuracy trends and alerts",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "graph_id",- "in": "query",- "required": true,- "schema": { "type": "string", "title": "Graph Id" }- },- {- "name": "user_id",- "in": "query",- "required": false,- "schema": {- "anyOf": [{ "type": "string" }, { "type": "null" }],- "title": "User Id"- }- },- {- "name": "days_back",- "in": "query",- "required": false,- "schema": { "type": "integer", "default": 30, "title": "Days Back" }- },- {- "name": "drop_threshold",- "in": "query",- "required": false,- "schema": {- "type": "number",- "default": 10.0,- "title": "Drop Threshold"+ "/api/oauth/authorize": {+ "post": {+ "tags": ["oauth"],+ "summary": "Authorize",+ "description": "OAuth 2.0 Authorization Endpoint\n\nUser must be logged in (authenticated with Supabase JWT).\nThis endpoint creates an authorization code and returns a redirect URL.\n\nPKCE (Proof Key for Code Exchange) is REQUIRED for all authorization requests.\n\nThe frontend consent screen should call this endpoint after the user approves,\nthen redirect the user to the returned `redirect_url`.\n\nRequest Body:\n- client_id: The OAuth application's client ID\n- redirect_uri: Where to redirect after authorization (must match registered URI)\n- scopes: List of permissions (e.g., \"EXECUTE_GRAPH READ_GRAPH\")\n- state: Anti-CSRF token provided by client (will be returned in redirect)\n- response_type: Must be \"code\" (for authorization code flow)\n- code_challenge: PKCE code challenge (required)\n- code_challenge_method: \"S256\" (recommended) or \"plain\"\n\nReturns:\n- redirect_url: The URL to redirect the user to (includes authorization code)\n\nError cases return a redirect_url with error parameters, or raise HTTPException\nfor critical errors (like invalid redirect_uri).",+ "operationId": "postOauthAuthorize",+ "requestBody": {+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/AuthorizeRequest" }}},- {- "name": "include_historical",- "in": "query",- "required": false,- "schema": {- "type": "boolean",- "default": false,- "title": "Include Historical"- }- }- ],+ "required": true+ },"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": {- "$ref": "#/components/schemas/AccuracyTrendsResponse"- }+ "schema": { "$ref": "#/components/schemas/AuthorizeResponse" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -4151,68 +4218,38 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- }+ },+ "security": [{ "HTTPBearerJWT": [] }]}},- "/api/review/pending": {- "get": {- "tags": ["v2", "executions", "review", "v2", "executions", "review"],- "summary": "Get Pending Reviews",- "description": "Get all pending reviews for the current user.\n\nRetrieves all reviews with status \"WAITING\" that belong to the authenticated user.\nResults are ordered by creation time (newest first).\n\nArgs:\n user_id: Authenticated user ID from security dependency\n\nReturns:\n List of pending review objects with status converted to typed literals\n\nRaises:\n HTTPException: If authentication fails or database error occurs\n\nNote:\n Reviews with invalid status values are logged as warnings but excluded\n from results rather than failing the entire request.",- "operationId": "getV2Get pending reviews",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "page",- "in": "query",- "required": false,- "schema": {- "type": "integer",- "minimum": 1,- "description": "Page number (1-indexed)",- "default": 1,- "title": "Page"- },- "description": "Page number (1-indexed)"+ "/api/oauth/introspect": {+ "post": {+ "tags": ["oauth"],+ "summary": "Introspect",+ "description": "OAuth 2.0 Token Introspection Endpoint (RFC 7662)\n\nAllows clients to check if a token is valid and get its metadata.\n\nReturns:\n- active: Whether the token is currently active\n- scopes: List of authorized scopes (if active)\n- client_id: The client the token was issued to (if active)\n- user_id: The user the token represents (if active)\n- exp: Expiration timestamp (if active)\n- token_type: \"access_token\" or \"refresh_token\" (if active)",+ "operationId": "postOauthIntrospect",+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/Body_postOauthIntrospect"+ }+ }},- {- "name": "page_size",- "in": "query",- "required": false,- "schema": {- "type": "integer",- "maximum": 100,- "minimum": 1,- "description": "Number of reviews per page",- "default": 25,- "title": "Page Size"- },- "description": "Number of reviews per page"- }- ],+ "required": true+ },"responses": {"200": {- "description": "List of pending reviews",- "content": {- "application/json": {- "schema": {- "type": "array",- "items": {- "$ref": "#/components/schemas/PendingHumanReviewModel"- },- "title": "Response Getv2Get Pending Reviews"+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/TokenIntrospectionResult"}}}},- "500": {- "description": "Server error",- "content": { "application/json": {} }- },"422": {"description": "Validation Error","content": {@@ -4220,48 +4257,28 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/review/execution/{graph_exec_id}": {- "get": {- "tags": ["v2", "executions", "review", "v2", "executions", "review"],- "summary": "Get Pending Reviews for Execution",- "description": "Get all pending reviews for a specific graph execution.\n\nRetrieves all reviews with status \"WAITING\" for the specified graph execution\nthat belong to the authenticated user. Results are ordered by creation time\n(oldest first) to preserve review order within the execution.\n\nArgs:\n graph_exec_id: ID of the graph execution to get reviews for\n user_id: Authenticated user ID from security dependency\n\nReturns:\n List of pending review objects for the specified execution\n\nRaises:\n HTTPException:\n - 403: If user doesn't own the graph execution\n - 500: If authentication fails or database error occurs\n\nNote:\n Only returns reviews owned by the authenticated user for security.\n Reviews with invalid status are excluded with warning logs.",- "operationId": "getV2Get pending reviews for execution",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "graph_exec_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Graph Exec Id" }- }- ],- "responses": {- "200": {- "description": "List of pending reviews for the execution",- "content": {- "application/json": {- "schema": {- "type": "array",- "items": {- "$ref": "#/components/schemas/PendingHumanReviewModel"- },- "title": "Response Getv2Get Pending Reviews For Execution"- }- }+ "/api/oauth/revoke": {+ "post": {+ "tags": ["oauth"],+ "summary": "Revoke",+ "description": "OAuth 2.0 Token Revocation Endpoint (RFC 7009)\n\nAllows clients to revoke an access or refresh token.\n\nNote: Revoking a refresh token does NOT revoke associated access tokens.\nRevoking an access token does NOT revoke the associated refresh token.",+ "operationId": "postOauthRevoke",+ "requestBody": {+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/Body_postOauthRevoke" }}},- "400": { "description": "Invalid graph execution ID" },- "403": { "description": "Access denied to graph execution" },- "500": {- "description": "Server error",- "content": { "application/json": {} }+ "required": true+ },+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": { "application/json": { "schema": {} } }},"422": {"description": "Validation Error",@@ -4270,23 +4287,26 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/review/action": {+ "/api/oauth/token": {"post": {- "tags": ["v2", "executions", "review", "v2", "executions", "review"],- "summary": "Process Review Action",- "description": "Process reviews with approve or reject actions.",- "operationId": "postV2ProcessReviewAction",+ "tags": ["oauth"],+ "summary": "Token",+ "description": "OAuth 2.0 Token Endpoint\n\nExchanges authorization code or refresh token for access token.\n\nGrant Types:\n1. authorization_code: Exchange authorization code for tokens\n - Required: grant_type, code, redirect_uri, client_id, client_secret\n - Optional: code_verifier (required if PKCE was used)\n\n2. refresh_token: Exchange refresh token for new access token\n - Required: grant_type, refresh_token, client_id, client_secret\n\nReturns:\n- access_token: Bearer token for API access (1 hour TTL)\n- token_type: \"Bearer\"\n- expires_in: Seconds until access token expires\n- refresh_token: Token for refreshing access (30 days TTL)\n- scopes: List of scopes",+ "operationId": "postOauthToken","requestBody": {"content": {"application/json": {- "schema": { "$ref": "#/components/schemas/ReviewRequest" }+ "schema": {+ "anyOf": [+ { "$ref": "#/components/schemas/TokenRequestByCode" },+ { "$ref": "#/components/schemas/TokenRequestByRefreshToken" }+ ],+ "title": "Request"+ }}},"required": true@@ -4296,7 +4316,7 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/ReviewResponse" }+ "schema": { "$ref": "#/components/schemas/TokenResponse" }}}},@@ -4307,67 +4327,54 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- },- "security": [{ "HTTPBearerJWT": [] }]+ }}},- "/api/library/presets": {+ "/api/onboarding": {"get": {- "tags": ["v2", "presets"],- "summary": "List presets",- "description": "Retrieve a paginated list of presets for the current user.",- "operationId": "getV2List presets",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "page",- "in": "query",- "required": false,- "schema": {- "type": "integer",- "minimum": 1,- "default": 1,- "title": "Page"+ "tags": ["v1", "onboarding"],+ "summary": "Onboarding state",+ "operationId": "getV1Onboarding state",+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/UserOnboarding" }+ }}},- {- "name": "page_size",- "in": "query",- "required": false,- "schema": {- "type": "integer",- "minimum": 1,- "default": 10,- "title": "Page Size"+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ }+ },+ "security": [{ "HTTPBearerJWT": [] }]+ },+ "patch": {+ "tags": ["v1", "onboarding"],+ "summary": "Update onboarding state",+ "operationId": "patchV1Update onboarding state",+ "requestBody": {+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/UserOnboardingUpdate" }}},- {- "name": "graph_id",- "in": "query",- "required": true,- "schema": {- "anyOf": [{ "type": "string" }, { "type": "null" }],- "description": "Allows to filter presets by a specific agent graph",- "title": "Graph Id"- },- "description": "Allows to filter presets by a specific agent graph"- }- ],+ "required": true+ },"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": {- "$ref": "#/components/schemas/LibraryAgentPresetResponse"- }+ "schema": { "$ref": "#/components/schemas/UserOnboarding" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -4375,82 +4382,116 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- }- },- "post": {- "tags": ["v2", "presets"],- "summary": "Create a new preset",- "description": "Create a new preset for the current user.",- "operationId": "postV2Create a new preset",- "security": [{ "HTTPBearerJWT": [] }],- "requestBody": {- "required": true,- "content": {- "application/json": {- "schema": {- "anyOf": [- {- "$ref": "#/components/schemas/LibraryAgentPresetCreatable"- },- {- "$ref": "#/components/schemas/LibraryAgentPresetCreatableFromGraphExecution"- }- ],- "title": "Preset"+ },+ "security": [{ "HTTPBearerJWT": [] }]+ }+ },+ "/api/onboarding/agents": {+ "get": {+ "tags": ["v1", "onboarding"],+ "summary": "Recommended onboarding agents",+ "operationId": "getV1Recommended onboarding agents",+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": {+ "items": { "$ref": "#/components/schemas/StoreAgentDetails" },+ "type": "array",+ "title": "Response Getv1Recommended Onboarding Agents"+ }}}+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}},+ "security": [{ "HTTPBearerJWT": [] }]+ }+ },+ "/api/onboarding/enabled": {+ "get": {+ "tags": ["v1", "onboarding", "public"],+ "summary": "Is onboarding enabled",+ "operationId": "getV1Is onboarding enabled","responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/LibraryAgentPreset" }+ "schema": {+ "type": "boolean",+ "title": "Response Getv1Is Onboarding Enabled"+ }}}},- "422": {- "description": "Validation Error",+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ }+ },+ "security": [{ "HTTPBearerJWT": [] }]+ }+ },+ "/api/onboarding/reset": {+ "post": {+ "tags": ["v1", "onboarding"],+ "summary": "Reset onboarding progress",+ "operationId": "postV1Reset onboarding progress",+ "responses": {+ "200": {+ "description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ "schema": { "$ref": "#/components/schemas/UserOnboarding" }}}},"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- }+ },+ "security": [{ "HTTPBearerJWT": [] }]}},- "/api/library/presets/{preset_id}": {- "get": {- "tags": ["v2", "presets"],- "summary": "Get a specific preset",- "description": "Retrieve details for a specific preset by its ID.",- "operationId": "getV2Get a specific preset",+ "/api/onboarding/step": {+ "post": {+ "tags": ["v1", "onboarding"],+ "summary": "Complete onboarding step",+ "operationId": "postV1Complete onboarding step","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "preset_id",- "in": "path",+ "name": "step",+ "in": "query","required": true,- "schema": { "type": "string", "title": "Preset Id" }+ "schema": {+ "enum": [+ "WELCOME",+ "USAGE_REASON",+ "INTEGRATIONS",+ "AGENT_CHOICE",+ "AGENT_NEW_RUN",+ "AGENT_INPUT",+ "CONGRATS",+ "MARKETPLACE_VISIT",+ "BUILDER_OPEN"+ ],+ "type": "string",+ "title": "Step"+ }}],"responses": {"200": {"description": "Successful Response",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/LibraryAgentPreset" }- }- }+ "content": { "application/json": { "schema": {} } }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"},"422": {"description": "Validation Error",@@ -4459,45 +4500,36 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}- },- "patch": {- "tags": ["v2", "presets"],- "summary": "Update an existing preset",- "description": "Update an existing preset by its ID.",- "operationId": "patchV2Update an existing preset",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "preset_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Preset Id" }- }- ],+ }+ },+ "/api/otto/ask": {+ "post": {+ "tags": ["v2", "otto"],+ "summary": "Proxy Otto Chat Request",+ "description": "Proxy requests to Otto API while adding necessary security headers and logging.\nRequires an authenticated user.",+ "operationId": "postV2Proxy otto chat request","requestBody": {- "required": true,"content": {"application/json": {- "schema": {- "$ref": "#/components/schemas/LibraryAgentPresetUpdatable"- }+ "schema": { "$ref": "#/components/schemas/ChatRequest" }}- }+ },+ "required": true},"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/LibraryAgentPreset" }+ "schema": { "$ref": "#/components/schemas/ApiResponse" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -4505,28 +4537,40 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- }- },- "delete": {- "tags": ["v2", "presets"],- "summary": "Delete a preset",- "description": "Delete an existing preset by its ID.",- "operationId": "deleteV2Delete a preset",- "security": [{ "HTTPBearerJWT": [] }],+ },+ "security": [{ "HTTPBearerJWT": [] }]+ }+ },+ "/api/public/shared/{share_token}": {+ "get": {+ "tags": ["v1"],+ "summary": "Get Shared Execution",+ "description": "Get a shared graph execution by share token (no auth required).",+ "operationId": "getV1GetSharedExecution","parameters": [{- "name": "preset_id",+ "name": "share_token","in": "path","required": true,- "schema": { "type": "string", "title": "Preset Id" }+ "schema": {+ "type": "string",+ "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",+ "title": "Share Token"+ }}],"responses": {- "204": { "description": "Successful Response" },+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SharedExecutionResponse"+ }+ }+ }+ },"422": {"description": "Validation Error","content": {@@ -4534,25 +4578,20 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/library/presets/setup-trigger": {+ "/api/review/action": {"post": {- "tags": ["v2", "presets"],- "summary": "Setup Trigger",- "description": "Sets up a webhook-triggered `LibraryAgentPreset` for a `LibraryAgent`.\nReturns the correspondingly created `LibraryAgentPreset` with `webhook_id` set.",- "operationId": "postV2SetupTrigger",+ "tags": ["v2", "executions", "review", "v2", "executions", "review"],+ "summary": "Process Review Action",+ "description": "Process reviews with approve or reject actions.",+ "operationId": "postV2ProcessReviewAction","requestBody": {"content": {"application/json": {- "schema": {- "$ref": "#/components/schemas/TriggeredPresetSetupRequest"- }+ "schema": { "$ref": "#/components/schemas/ReviewRequest" }}},"required": true@@ -4562,10 +4601,13 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/LibraryAgentPreset" }+ "schema": { "$ref": "#/components/schemas/ReviewResponse" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -4573,47 +4615,46 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}},"security": [{ "HTTPBearerJWT": [] }]}},- "/api/library/presets/{preset_id}/execute": {- "post": {- "tags": ["v2", "presets", "presets"],- "summary": "Execute a preset",- "description": "Execute a preset with the given graph and node input for the current user.",- "operationId": "postV2Execute a preset",+ "/api/review/execution/{graph_exec_id}": {+ "get": {+ "tags": ["v2", "executions", "review", "v2", "executions", "review"],+ "summary": "Get Pending Reviews for Execution",+ "description": "Get all pending reviews for a specific graph execution.\n\nRetrieves all reviews with status \"WAITING\" for the specified graph execution\nthat belong to the authenticated user. Results are ordered by creation time\n(oldest first) to preserve review order within the execution.\n\nArgs:\n graph_exec_id: ID of the graph execution to get reviews for\n user_id: Authenticated user ID from security dependency\n\nReturns:\n List of pending review objects for the specified execution\n\nRaises:\n HTTPException:\n - 403: If user doesn't own the graph execution\n - 500: If authentication fails or database error occurs\n\nNote:\n Only returns reviews owned by the authenticated user for security.\n Reviews with invalid status are excluded with warning logs.",+ "operationId": "getV2Get pending reviews for execution","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "preset_id",+ "name": "graph_exec_id","in": "path","required": true,- "schema": { "type": "string", "title": "Preset Id" }+ "schema": { "type": "string", "title": "Graph Exec Id" }}],- "requestBody": {- "content": {- "application/json": {- "schema": {- "$ref": "#/components/schemas/Body_postV2Execute_a_preset"- }- }- }- },"responses": {"200": {- "description": "Successful Response",+ "description": "List of pending reviews for the execution","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/GraphExecutionMeta" }+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/PendingHumanReviewModel"+ },+ "title": "Response Getv2Get Pending Reviews For Execution"+ }}}},+ "400": { "description": "Invalid graph execution ID" },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "403": { "description": "Access denied to graph execution" },"422": {"description": "Validation Error","content": {@@ -4622,42 +4663,21 @@}}},- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ "500": {+ "description": "Server error",+ "content": { "application/json": {} }}}}},- "/api/library/agents": {+ "/api/review/pending": {"get": {- "tags": ["v2", "library", "private"],- "summary": "List Library Agents",- "description": "Get all agents in the user's library (both created and saved).\n\nArgs:\n user_id: ID of the authenticated user.\n search_term: Optional search term to filter agents by name/description.\n filter_by: List of filters to apply (favorites, created by user).\n sort_by: List of sorting criteria (created date, updated date).\n page: Page number to retrieve.\n page_size: Number of agents per page.\n\nReturns:\n A LibraryAgentResponse containing agents and pagination metadata.\n\nRaises:\n HTTPException: If a server/database error occurs.",- "operationId": "getV2List library agents",+ "tags": ["v2", "executions", "review", "v2", "executions", "review"],+ "summary": "Get Pending Reviews",+ "description": "Get all pending reviews for the current user.\n\nRetrieves all reviews with status \"WAITING\" that belong to the authenticated user.\nResults are ordered by creation time (newest first).\n\nArgs:\n user_id: Authenticated user ID from security dependency\n\nReturns:\n List of pending review objects with status converted to typed literals\n\nRaises:\n HTTPException: If authentication fails or database error occurs\n\nNote:\n Reviews with invalid status values are logged as warnings but excluded\n from results rather than failing the entire request.",+ "operationId": "getV2Get pending reviews","security": [{ "HTTPBearerJWT": [] }],"parameters": [- {- "name": "search_term",- "in": "query",- "required": false,- "schema": {- "anyOf": [{ "type": "string" }, { "type": "null" }],- "description": "Search term to filter agents",- "title": "Search Term"- },- "description": "Search term to filter agents"- },- {- "name": "sort_by",- "in": "query",- "required": false,- "schema": {- "$ref": "#/components/schemas/LibraryAgentSort",- "description": "Criteria to sort results by",- "default": "updatedAt"- },- "description": "Criteria to sort results by"- },{"name": "page","in": "query",@@ -4665,11 +4685,11 @@"schema": {"type": "integer","minimum": 1,- "description": "Page number to retrieve (must be >= 1)",+ "description": "Page number (1-indexed)","default": 1,"title": "Page"},- "description": "Page number to retrieve (must be >= 1)"+ "description": "Page number (1-indexed)"},{"name": "page_size",@@ -4677,69 +4697,110 @@"required": false,"schema": {"type": "integer",+ "maximum": 100,"minimum": 1,- "description": "Number of agents per page (must be >= 1)",- "default": 15,+ "description": "Number of reviews per page",+ "default": 25,"title": "Page Size"},- "description": "Number of agents per page (must be >= 1)"+ "description": "Number of reviews per page"}],"responses": {"200": {- "description": "List of library agents",+ "description": "List of pending reviews",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/PendingHumanReviewModel"+ },+ "title": "Response Getv2Get Pending Reviews"+ }+ }+ }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },+ "422": {+ "description": "Validation Error",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/HTTPValidationError" }+ }+ }+ },+ "500": {+ "description": "Server error",+ "content": { "application/json": {} }+ }+ }+ }+ },+ "/api/schedules": {+ "get": {+ "tags": ["v1", "schedules"],+ "summary": "List execution schedules for a user",+ "operationId": "getV1List execution schedules for a user",+ "responses": {+ "200": {+ "description": "Successful Response","content": {"application/json": {"schema": {- "$ref": "#/components/schemas/LibraryAgentResponse"+ "items": {+ "$ref": "#/components/schemas/GraphExecutionJobInfo"+ },+ "type": "array",+ "title": "Response Getv1List Execution Schedules For A User"}}}},- "500": {- "description": "Server error",- "content": { "application/json": {} }- },- "422": {- "description": "Validation Error",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/HTTPValidationError" }- }- }- },"401": {"$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- }- },- "post": {- "tags": ["v2", "library", "private"],- "summary": "Add Marketplace Agent",- "description": "Add an agent from the marketplace to the user's library.\n\nArgs:\n store_listing_version_id: ID of the store listing version to add.\n user_id: ID of the authenticated user.\n\nReturns:\n library_model.LibraryAgent: Agent added to the library\n\nRaises:\n HTTPException(404): If the listing version is not found.\n HTTPException(500): If a server/database error occurs.",- "operationId": "postV2Add marketplace agent",+ },+ "security": [{ "HTTPBearerJWT": [] }]+ }+ },+ "/api/schedules/{schedule_id}": {+ "delete": {+ "tags": ["v1", "schedules"],+ "summary": "Delete execution schedule",+ "operationId": "deleteV1Delete execution schedule","security": [{ "HTTPBearerJWT": [] }],- "requestBody": {- "required": true,- "content": {- "application/json": {- "schema": {- "$ref": "#/components/schemas/Body_postV2Add_marketplace_agent"- }- }+ "parameters": [+ {+ "name": "schedule_id",+ "in": "path",+ "required": true,+ "schema": {+ "type": "string",+ "description": "ID of the schedule to delete",+ "title": "Schedule Id"+ },+ "description": "ID of the schedule to delete"}- },+ ],"responses": {- "201": {- "description": "Agent added successfully",+ "200": {+ "description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/LibraryAgent" }+ "schema": {+ "type": "object",+ "additionalProperties": true,+ "title": "Response Deletev1Delete Execution Schedule"+ }}}},- "404": { "description": "Store listing version not found" },- "500": { "description": "Server error" },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -4747,46 +4808,50 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/library/agents/favorites": {+ "/api/store/admin/listings": {"get": {- "tags": ["v2", "library", "private"],- "summary": "List Favorite Library Agents",- "description": "Get all favorite agents in the user's library.\n\nArgs:\n user_id: ID of the authenticated user.\n page: Page number to retrieve.\n page_size: Number of agents per page.\n\nReturns:\n A LibraryAgentResponse containing favorite agents and pagination metadata.\n\nRaises:\n HTTPException: If a server/database error occurs.",- "operationId": "getV2List favorite library agents",+ "tags": ["v2", "admin", "store", "admin"],+ "summary": "Get Admin Listings History",+ "description": "Get store listings with their version history for admins.\n\nThis provides a consolidated view of listings with their versions,\nallowing for an expandable UI in the admin dashboard.\n\nArgs:\n status: Filter by submission status (PENDING, APPROVED, REJECTED)\n search: Search by name, description, or user email\n page: Page number for pagination\n page_size: Number of items per page\n\nReturns:\n StoreListingsWithVersionsResponse with listings and their versions",+ "operationId": "getV2Get admin listings history","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "page",+ "name": "status","in": "query","required": false,"schema": {- "type": "integer",- "minimum": 1,- "description": "Page number to retrieve (must be >= 1)",- "default": 1,- "title": "Page"- },- "description": "Page number to retrieve (must be >= 1)"+ "anyOf": [+ { "$ref": "#/components/schemas/SubmissionStatus" },+ { "type": "null" }+ ],+ "title": "Status"+ }},{- "name": "page_size",+ "name": "search","in": "query","required": false,"schema": {- "type": "integer",- "minimum": 1,- "description": "Number of agents per page (must be >= 1)",- "default": 15,- "title": "Page Size"- },- "description": "Number of agents per page (must be >= 1)"+ "anyOf": [{ "type": "string" }, { "type": "null" }],+ "title": "Search"+ }+ },+ {+ "name": "page",+ "in": "query",+ "required": false,+ "schema": { "type": "integer", "default": 1, "title": "Page" }+ },+ {+ "name": "page_size",+ "in": "query",+ "required": false,+ "schema": { "type": "integer", "default": 20, "title": "Page Size" }}],"responses": {@@ -4795,14 +4860,13 @@"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/LibraryAgentResponse"+ "$ref": "#/components/schemas/StoreListingsWithVersionsResponse"}}}},- "500": {- "description": "Server error",- "content": { "application/json": {} }+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"},"422": {"description": "Validation Error",@@ -4811,35 +4875,37 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/library/agents/{library_agent_id}": {+ "/api/store/admin/submissions/download/{store_listing_version_id}": {"get": {- "tags": ["v2", "library", "private"],- "summary": "Get Library Agent",- "operationId": "getV2Get library agent",+ "tags": ["v2", "admin", "store", "admin", "store", "admin"],+ "summary": "Admin Download Agent File",+ "description": "Download the agent file by streaming its content.\n\nArgs:\n store_listing_version_id (str): The ID of the agent to download\n\nReturns:\n StreamingResponse: A streaming response containing the agent's graph data.\n\nRaises:\n HTTPException: If the agent is not found or an unexpected error occurs.",+ "operationId": "getV2Admin download agent file","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "library_agent_id",+ "name": "store_listing_version_id","in": "path","required": true,- "schema": { "type": "string", "title": "Library Agent Id" }+ "schema": {+ "type": "string",+ "description": "The ID of the agent to download",+ "title": "Store Listing Version Id"+ },+ "description": "The ID of the agent to download"}],"responses": {"200": {"description": "Successful Response",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/LibraryAgent" }- }- }+ "content": { "application/json": { "schema": {} } }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"},"422": {"description": "Validation Error",@@ -4848,24 +4914,23 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}- },- "patch": {- "tags": ["v2", "library", "private"],- "summary": "Update Library Agent",- "description": "Update the library agent with the given fields.\n\nArgs:\n library_agent_id: ID of the library agent to update.\n payload: Fields to update (auto_update_version, is_favorite, etc.).\n user_id: ID of the authenticated user.\n\nRaises:\n HTTPException(500): If a server/database error occurs.",- "operationId": "patchV2Update library agent",+ }+ },+ "/api/store/admin/submissions/{store_listing_version_id}/review": {+ "post": {+ "tags": ["v2", "admin", "store", "admin"],+ "summary": "Review Store Submission",+ "description": "Review a store listing submission.\n\nArgs:\n store_listing_version_id: ID of the submission to review\n request: Review details including approval status and comments\n user_id: Authenticated admin user performing the review\n\nReturns:\n StoreSubmission with updated review information",+ "operationId": "postV2Review store submission","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "library_agent_id",+ "name": "store_listing_version_id","in": "path","required": true,- "schema": { "type": "string", "title": "Library Agent Id" }+ "schema": { "type": "string", "title": "Store Listing Version Id" }}],"requestBody": {@@ -4873,21 +4938,23 @@"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/LibraryAgentUpdateRequest"+ "$ref": "#/components/schemas/ReviewSubmissionRequest"}}}},"responses": {"200": {- "description": "Agent updated successfully",+ "description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/LibraryAgent" }+ "schema": { "$ref": "#/components/schemas/StoreSubmission" }}}},- "500": { "description": "Server error" },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -4895,69 +4962,80 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}- },- "delete": {- "tags": ["v2", "library", "private"],- "summary": "Delete Library Agent",- "description": "Soft-delete the specified library agent.\n\nArgs:\n library_agent_id: ID of the library agent to delete.\n user_id: ID of the authenticated user.\n\nReturns:\n 204 No Content if successful.\n\nRaises:\n HTTPException(404): If the agent does not exist.\n HTTPException(500): If a server/database error occurs.",- "operationId": "deleteV2Delete library agent",- "security": [{ "HTTPBearerJWT": [] }],+ }+ },+ "/api/store/agents": {+ "get": {+ "tags": ["v2", "store", "public"],+ "summary": "List store agents",+ "description": "Get a paginated list of agents from the store with optional filtering and sorting.\n\nArgs:\n featured (bool, optional): Filter to only show featured agents. Defaults to False.\n creator (str | None, optional): Filter agents by creator username. Defaults to None.\n sorted_by (str | None, optional): Sort agents by \"runs\" or \"rating\". Defaults to None.\n search_query (str | None, optional): Search agents by name, subheading and description. Defaults to None.\n category (str | None, optional): Filter agents by category. Defaults to None.\n page (int, optional): Page number for pagination. Defaults to 1.\n page_size (int, optional): Number of agents per page. Defaults to 20.\n\nReturns:\n StoreAgentsResponse: Paginated list of agents matching the filters\n\nRaises:\n HTTPException: If page or page_size are less than 1\n\nUsed for:\n- Home Page Featured Agents\n- Home Page Top Agents\n- Search Results\n- Agent Details - Other Agents By Creator\n- Agent Details - Similar Agents\n- Creator Details - Agents By Creator",+ "operationId": "getV2List store agents","parameters": [{- "name": "library_agent_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Library Agent Id" }- }- ],- "responses": {- "200": {- "description": "Successful Response",- "content": { "application/json": { "schema": {} } }+ "name": "featured",+ "in": "query",+ "required": false,+ "schema": {+ "type": "boolean",+ "default": false,+ "title": "Featured"+ }},- "204": { "description": "Agent deleted successfully" },- "404": { "description": "Agent not found" },- "500": { "description": "Server error" },- "422": {- "description": "Validation Error",- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/HTTPValidationError" }- }+ {+ "name": "creator",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [{ "type": "string" }, { "type": "null" }],+ "title": "Creator"+ }+ },+ {+ "name": "sorted_by",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [+ {+ "enum": ["rating", "runs", "name", "updated_at"],+ "type": "string"+ },+ { "type": "null" }+ ],+ "title": "Sorted By"}},- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }- }- }- },- "/api/library/agents/by-graph/{graph_id}": {- "get": {- "tags": ["v2", "library", "private"],- "summary": "Get Library Agent By Graph Id",- "operationId": "getV2GetLibraryAgentByGraphId",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [{- "name": "graph_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Graph Id" }+ "name": "search_query",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [{ "type": "string" }, { "type": "null" }],+ "title": "Search Query"+ }},{- "name": "version",+ "name": "category","in": "query","required": false,"schema": {- "anyOf": [{ "type": "integer" }, { "type": "null" }],- "title": "Version"+ "anyOf": [{ "type": "string" }, { "type": "null" }],+ "title": "Category"}+ },+ {+ "name": "page",+ "in": "query",+ "required": false,+ "schema": { "type": "integer", "default": 1, "title": "Page" }+ },+ {+ "name": "page_size",+ "in": "query",+ "required": false,+ "schema": { "type": "integer", "default": 20, "title": "Page Size" }}],"responses": {@@ -4965,7 +5043,7 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/LibraryAgent" }+ "schema": { "$ref": "#/components/schemas/StoreAgentsResponse" }}}},@@ -4976,19 +5054,16 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/library/agents/marketplace/{store_listing_version_id}": {+ "/api/store/agents/{store_listing_version_id}": {"get": {- "tags": ["v2", "library", "private", "store", "library"],- "summary": "Get Agent By Store ID",- "description": "Get Library Agent from Store Listing Version ID.",- "operationId": "getV2Get agent by store id",+ "tags": ["v2", "store"],+ "summary": "Get agent by version",+ "description": "Get Store Agent Details from Store Listing Version ID.",+ "operationId": "getV2Get agent by version","security": [{ "HTTPBearerJWT": [] }],"parameters": [{@@ -5000,20 +5075,16 @@],"responses": {"200": {- "description": "Library agent found",+ "description": "Successful Response","content": {"application/json": {- "schema": {- "anyOf": [- { "$ref": "#/components/schemas/LibraryAgent" },- { "type": "null" }- ],- "title": "Response Getv2Get Agent By Store Id"- }+ "schema": { "$ref": "#/components/schemas/StoreAgentDetails" }}}},- "404": { "description": "Agent not found" },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -5021,25 +5092,28 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/library/agents/{library_agent_id}/fork": {- "post": {- "tags": ["v2", "library", "private"],- "summary": "Fork Library Agent",- "operationId": "postV2Fork library agent",- "security": [{ "HTTPBearerJWT": [] }],+ "/api/store/agents/{username}/{agent_name}": {+ "get": {+ "tags": ["v2", "store", "public"],+ "summary": "Get specific agent",+ "description": "This is only used on the AgentDetails Page.\n\nIt returns the store listing agents details.",+ "operationId": "getV2Get specific agent","parameters": [{- "name": "library_agent_id",+ "name": "username","in": "path","required": true,- "schema": { "type": "string", "title": "Library Agent Id" }+ "schema": { "type": "string", "title": "Username" }+ },+ {+ "name": "agent_name",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Agent Name" }}],"responses": {@@ -5047,7 +5121,7 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/LibraryAgent" }+ "schema": { "$ref": "#/components/schemas/StoreAgentDetails" }}}},@@ -5058,36 +5132,51 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/otto/ask": {+ "/api/store/agents/{username}/{agent_name}/review": {"post": {- "tags": ["v2", "otto"],- "summary": "Proxy Otto Chat Request",- "description": "Proxy requests to Otto API while adding necessary security headers and logging.\nRequires an authenticated user.",- "operationId": "postV2Proxy otto chat request",+ "tags": ["v2", "store"],+ "summary": "Create agent review",+ "description": "Create a review for a store agent.\n\nArgs:\n username: Creator's username\n agent_name: Name/slug of the agent\n review: Review details including score and optional comments\n user_id: ID of authenticated user creating the review\n\nReturns:\n The created review",+ "operationId": "postV2Create agent review",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "username",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Username" }+ },+ {+ "name": "agent_name",+ "in": "path",+ "required": true,+ "schema": { "type": "string", "title": "Agent Name" }+ }+ ],"requestBody": {+ "required": true,"content": {"application/json": {- "schema": { "$ref": "#/components/schemas/ChatRequest" }+ "schema": { "$ref": "#/components/schemas/StoreReviewCreate" }}- },- "required": true+ }},"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/ApiResponse" }+ "schema": { "$ref": "#/components/schemas/StoreReview" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -5095,86 +5184,33 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- },- "security": [{ "HTTPBearerJWT": [] }]+ }}},- "/api/email/unsubscribe": {- "post": {- "tags": ["v1", "email"],- "summary": "One Click Email Unsubscribe",- "operationId": "postV1One click email unsubscribe",+ "/api/store/creator/{username}": {+ "get": {+ "tags": ["v2", "store", "public"],+ "summary": "Get creator details",+ "description": "Get the details of a creator.\n- Creator Details Page",+ "operationId": "getV2Get creator details","parameters": [{- "name": "token",- "in": "query",+ "name": "username",+ "in": "path","required": true,- "schema": { "type": "string", "title": "Token" }+ "schema": { "type": "string", "title": "Username" }}],"responses": {"200": {"description": "Successful Response",- "content": { "application/json": { "schema": {} } }- },- "422": {- "description": "Validation Error","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/HTTPValidationError" }- }- }- }- }- }- },- "/api/email/": {- "post": {- "tags": ["v1", "email"],- "summary": "Handle Postmark Email Webhooks",- "operationId": "postV1Handle postmark email webhooks",- "requestBody": {- "content": {- "application/json": {- "schema": {- "oneOf": [- { "$ref": "#/components/schemas/PostmarkDeliveryWebhook" },- { "$ref": "#/components/schemas/PostmarkBounceWebhook" },- {- "$ref": "#/components/schemas/PostmarkSpamComplaintWebhook"- },- { "$ref": "#/components/schemas/PostmarkOpenWebhook" },- { "$ref": "#/components/schemas/PostmarkClickWebhook" },- {- "$ref": "#/components/schemas/PostmarkSubscriptionChangeWebhook"- }- ],- "title": "Webhook",- "discriminator": {- "propertyName": "RecordType",- "mapping": {- "Delivery": "#/components/schemas/PostmarkDeliveryWebhook",- "Bounce": "#/components/schemas/PostmarkBounceWebhook",- "SpamComplaint": "#/components/schemas/PostmarkSpamComplaintWebhook",- "Open": "#/components/schemas/PostmarkOpenWebhook",- "Click": "#/components/schemas/PostmarkClickWebhook",- "SubscriptionChange": "#/components/schemas/PostmarkSubscriptionChangeWebhook"- }- }+ "schema": { "$ref": "#/components/schemas/CreatorDetails" }}}},- "required": true- },- "responses": {- "200": {- "description": "Successful Response",- "content": { "application/json": { "schema": {} } }- },"422": {"description": "Validation Error","content": {@@ -5183,47 +5219,61 @@}}}- },- "security": [{ "APIKeyAuthenticator-X-Postmark-Webhook-Token": [] }]+ }}},- "/api/chat/sessions": {- "post": {- "tags": ["v2", "chat", "chat"],- "summary": "Create Session",- "description": "Create a new chat session.\n\nInitiates a new chat session for either an authenticated or anonymous user.\n\nArgs:\n user_id: The optional authenticated user ID parsed from the JWT. If missing, creates an anonymous session.\n\nReturns:\n CreateSessionResponse: Details of the created session.",- "operationId": "postV2CreateSession",- "responses": {- "200": {- "description": "Successful Response",- "content": {- "application/json": {- "schema": {- "$ref": "#/components/schemas/CreateSessionResponse"- }- }+ "/api/store/creators": {+ "get": {+ "tags": ["v2", "store", "public"],+ "summary": "List store creators",+ "description": "This is needed for:\n- Home Page Featured Creators\n- Search Results Page\n\n---\n\nTo support this functionality we need:\n- featured: bool - to limit the list to just featured agents\n- search_query: str - vector search based on the creators profile description.\n- sorted_by: [agent_rating, agent_runs] -",+ "operationId": "getV2List store creators",+ "parameters": [+ {+ "name": "featured",+ "in": "query",+ "required": false,+ "schema": {+ "type": "boolean",+ "default": false,+ "title": "Featured"+ }+ },+ {+ "name": "search_query",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [{ "type": "string" }, { "type": "null" }],+ "title": "Search Query"+ }+ },+ {+ "name": "sorted_by",+ "in": "query",+ "required": false,+ "schema": {+ "anyOf": [+ {+ "enum": ["agent_rating", "agent_runs", "num_agents"],+ "type": "string"+ },+ { "type": "null" }+ ],+ "title": "Sorted By"}},- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }- },- "security": [{ "HTTPBearerJWT": [] }]- }- },- "/api/chat/sessions/{session_id}": {- "get": {- "tags": ["v2", "chat", "chat"],- "summary": "Get Session",- "description": "Retrieve the details of a specific chat session.\n\nLooks up a chat session by ID for the given user (if authenticated) and returns all session data including messages.\n\nArgs:\n session_id: The unique identifier for the desired chat session.\n user_id: The optional authenticated user ID, or None for anonymous access.\n\nReturns:\n SessionDetailResponse: Details for the requested session; raises NotFoundError if not found.",- "operationId": "getV2GetSession",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [{- "name": "session_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Session Id" }+ "name": "page",+ "in": "query",+ "required": false,+ "schema": { "type": "integer", "default": 1, "title": "Page" }+ },+ {+ "name": "page_size",+ "in": "query",+ "required": false,+ "schema": { "type": "integer", "default": 20, "title": "Page Size" }}],"responses": {@@ -5231,9 +5281,7 @@"description": "Successful Response","content": {"application/json": {- "schema": {- "$ref": "#/components/schemas/SessionDetailResponse"- }+ "schema": { "$ref": "#/components/schemas/CreatorsResponse" }}}},@@ -5244,47 +5292,27 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/chat/sessions/{session_id}/stream": {+ "/api/store/download/agents/{store_listing_version_id}": {"get": {- "tags": ["v2", "chat", "chat"],- "summary": "Stream Chat",- "description": "Stream chat responses for a session.\n\nStreams the AI/completion responses in real time over Server-Sent Events (SSE), including:\n - Text fragments as they are generated\n - Tool call UI elements (if invoked)\n - Tool execution results\n\nArgs:\n session_id: The chat session identifier to associate with the streamed messages.\n message: The user's new message to process.\n user_id: Optional authenticated user ID.\n is_user_message: Whether the message is a user message.\nReturns:\n StreamingResponse: SSE-formatted response chunks.",- "operationId": "getV2StreamChat",- "security": [{ "HTTPBearerJWT": [] }],+ "tags": ["v2", "store", "public"],+ "summary": "Download agent file",+ "description": "Download the agent file by streaming its content.\n\nArgs:\n store_listing_version_id (str): The ID of the agent to download\n\nReturns:\n StreamingResponse: A streaming response containing the agent's graph data.\n\nRaises:\n HTTPException: If the agent is not found or an unexpected error occurs.",+ "operationId": "getV2Download agent file","parameters": [{- "name": "session_id",+ "name": "store_listing_version_id","in": "path","required": true,- "schema": { "type": "string", "title": "Session Id" }- },- {- "name": "message",- "in": "query",- "required": true,"schema": {"type": "string",- "minLength": 1,- "maxLength": 10000,- "title": "Message"- }- },- {- "name": "is_user_message",- "in": "query",- "required": false,- "schema": {- "type": "boolean",- "default": true,- "title": "Is User Message"- }+ "description": "The ID of the agent to download",+ "title": "Store Listing Version Id"+ },+ "description": "The ID of the agent to download"}],"responses": {@@ -5299,40 +5327,32 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/chat/sessions/{session_id}/assign-user": {- "patch": {- "tags": ["v2", "chat", "chat"],- "summary": "Session Assign User",- "description": "Assign an authenticated user to a chat session.\n\nUsed (typically post-login) to claim an existing anonymous session as the current authenticated user.\n\nArgs:\n session_id: The identifier for the (previously anonymous) session.\n user_id: The authenticated user's ID to associate with the session.\n\nReturns:\n dict: Status of the assignment.",- "operationId": "patchV2SessionAssignUser",+ "/api/store/graph/{store_listing_version_id}": {+ "get": {+ "tags": ["v2", "store"],+ "summary": "Get agent graph",+ "description": "Get Agent Graph from Store Listing Version ID.",+ "operationId": "getV2Get agent graph","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "session_id",+ "name": "store_listing_version_id","in": "path","required": true,- "schema": { "type": "string", "title": "Session Id" }+ "schema": { "type": "string", "title": "Store Listing Version Id" }}],"responses": {"200": {"description": "Successful Response",- "content": {- "application/json": {- "schema": {- "type": "object",- "additionalProperties": true,- "title": "Response Patchv2Sessionassignuser"- }- }- }+ "content": { "application/json": { "schema": {} } }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"},"422": {"description": "Validation Error",@@ -5341,48 +5361,53 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/chat/health": {+ "/api/store/metrics/cache": {"get": {- "tags": ["v2", "chat", "chat"],- "summary": "Health Check",- "description": "Health check endpoint for the chat service.\n\nPerforms a full cycle test of session creation, assignment, and retrieval. Should always return healthy\nif the service and data layer are operational.\n\nReturns:\n dict: A status dictionary indicating health, service name, and API version.",- "operationId": "getV2HealthCheck",+ "tags": ["v2", "store", "metrics"],+ "summary": "Get cache metrics in Prometheus format",+ "description": "Get cache metrics in Prometheus text format.\n\nReturns Prometheus-compatible metrics for monitoring cache performance.\nMetrics include size, maxsize, TTL, and hit rate for each cache.\n\nReturns:\n str: Prometheus-formatted metrics text",+ "operationId": "getV2Get cache metrics in prometheus format","responses": {"200": {"description": "Successful Response",- "content": {- "application/json": {- "schema": {- "additionalProperties": true,- "type": "object",- "title": "Response Getv2Healthcheck"- }- }- }+ "content": { "text/plain": { "schema": { "type": "string" } } }}}}},- "/api/oauth/app/{client_id}": {+ "/api/store/myagents": {"get": {- "tags": ["oauth"],- "summary": "Get Oauth App Info",- "description": "Get public information about an OAuth application.\n\nThis endpoint is used by the consent screen to display application details\nto the user before they authorize access.\n\nReturns:\n- name: Application name\n- description: Application description (if provided)\n- scopes: List of scopes the application is allowed to request",- "operationId": "getOauthGetOauthAppInfo",+ "tags": ["v2", "store", "private"],+ "summary": "Get my agents",+ "description": "Get user's own agents.",+ "operationId": "getV2Get my agents","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "client_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "Client Id" }+ "name": "page",+ "in": "query",+ "required": false,+ "schema": {+ "type": "integer",+ "minimum": 1,+ "default": 1,+ "title": "Page"+ }+ },+ {+ "name": "page_size",+ "in": "query",+ "required": false,+ "schema": {+ "type": "integer",+ "minimum": 1,+ "default": 20,+ "title": "Page Size"+ }}],"responses": {@@ -5390,13 +5415,13 @@"description": "Successful Response","content": {"application/json": {- "schema": {- "$ref": "#/components/schemas/OAuthApplicationPublicInfo"- }+ "schema": { "$ref": "#/components/schemas/MyAgentsResponse" }}}},- "404": { "description": "Application not found or disabled" },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -5404,23 +5429,40 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/oauth/authorize": {+ "/api/store/profile": {+ "get": {+ "tags": ["v2", "store", "private"],+ "summary": "Get user profile",+ "description": "Get the profile details for the authenticated user.\nCached for 1 hour per user.",+ "operationId": "getV2Get user profile",+ "responses": {+ "200": {+ "description": "Successful Response",+ "content": {+ "application/json": {+ "schema": { "$ref": "#/components/schemas/ProfileDetails" }+ }+ }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ }+ },+ "security": [{ "HTTPBearerJWT": [] }]+ },"post": {- "tags": ["oauth"],- "summary": "Authorize",- "description": "OAuth 2.0 Authorization Endpoint\n\nUser must be logged in (authenticated with Supabase JWT).\nThis endpoint creates an authorization code and returns a redirect URL.\n\nPKCE (Proof Key for Code Exchange) is REQUIRED for all authorization requests.\n\nThe frontend consent screen should call this endpoint after the user approves,\nthen redirect the user to the returned `redirect_url`.\n\nRequest Body:\n- client_id: The OAuth application's client ID\n- redirect_uri: Where to redirect after authorization (must match registered URI)\n- scopes: List of permissions (e.g., \"EXECUTE_GRAPH READ_GRAPH\")\n- state: Anti-CSRF token provided by client (will be returned in redirect)\n- response_type: Must be \"code\" (for authorization code flow)\n- code_challenge: PKCE code challenge (required)\n- code_challenge_method: \"S256\" (recommended) or \"plain\"\n\nReturns:\n- redirect_url: The URL to redirect the user to (includes authorization code)\n\nError cases return a redirect_url with error parameters, or raise HTTPException\nfor critical errors (like invalid redirect_uri).",- "operationId": "postOauthAuthorize",+ "tags": ["v2", "store", "private"],+ "summary": "Update user profile",+ "description": "Update the store profile for the authenticated user.\n\nArgs:\n profile (Profile): The updated profile details\n user_id (str): ID of the authenticated user\n\nReturns:\n CreatorDetails: The updated profile\n\nRaises:\n HTTPException: If there is an error updating the profile",+ "operationId": "postV2Update user profile","requestBody": {"content": {"application/json": {- "schema": { "$ref": "#/components/schemas/AuthorizeRequest" }+ "schema": { "$ref": "#/components/schemas/Profile" }}},"required": true@@ -5430,10 +5472,13 @@"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/AuthorizeResponse" }+ "schema": { "$ref": "#/components/schemas/CreatorDetails" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -5441,43 +5486,46 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}},"security": [{ "HTTPBearerJWT": [] }]}},- "/api/oauth/token": {- "post": {- "tags": ["oauth"],- "summary": "Token",- "description": "OAuth 2.0 Token Endpoint\n\nExchanges authorization code or refresh token for access token.\n\nGrant Types:\n1. authorization_code: Exchange authorization code for tokens\n - Required: grant_type, code, redirect_uri, client_id, client_secret\n - Optional: code_verifier (required if PKCE was used)\n\n2. refresh_token: Exchange refresh token for new access token\n - Required: grant_type, refresh_token, client_id, client_secret\n\nReturns:\n- access_token: Bearer token for API access (1 hour TTL)\n- token_type: \"Bearer\"\n- expires_in: Seconds until access token expires\n- refresh_token: Token for refreshing access (30 days TTL)\n- scopes: List of scopes",- "operationId": "postOauthToken",- "requestBody": {- "content": {- "application/json": {- "schema": {- "anyOf": [- { "$ref": "#/components/schemas/TokenRequestByCode" },- { "$ref": "#/components/schemas/TokenRequestByRefreshToken" }- ],- "title": "Request"- }- }+ "/api/store/submissions": {+ "get": {+ "tags": ["v2", "store", "private"],+ "summary": "List my submissions",+ "description": "Get a paginated list of store submissions for the authenticated user.\n\nArgs:\n user_id (str): ID of the authenticated user\n page (int, optional): Page number for pagination. Defaults to 1.\n page_size (int, optional): Number of submissions per page. Defaults to 20.\n\nReturns:\n StoreListingsResponse: Paginated list of store submissions\n\nRaises:\n HTTPException: If page or page_size are less than 1",+ "operationId": "getV2List my submissions",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "page",+ "in": "query",+ "required": false,+ "schema": { "type": "integer", "default": 1, "title": "Page" }},- "required": true- },+ {+ "name": "page_size",+ "in": "query",+ "required": false,+ "schema": { "type": "integer", "default": 20, "title": "Page Size" }+ }+ ],"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": { "$ref": "#/components/schemas/TokenResponse" }+ "schema": {+ "$ref": "#/components/schemas/StoreSubmissionsResponse"+ }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -5487,35 +5535,35 @@}}}- }- },- "/api/oauth/introspect": {+ },"post": {- "tags": ["oauth"],- "summary": "Introspect",- "description": "OAuth 2.0 Token Introspection Endpoint (RFC 7662)\n\nAllows clients to check if a token is valid and get its metadata.\n\nReturns:\n- active: Whether the token is currently active\n- scopes: List of authorized scopes (if active)\n- client_id: The client the token was issued to (if active)\n- user_id: The user the token represents (if active)\n- exp: Expiration timestamp (if active)\n- token_type: \"access_token\" or \"refresh_token\" (if active)",- "operationId": "postOauthIntrospect",+ "tags": ["v2", "store", "private"],+ "summary": "Create store submission",+ "description": "Create a new store listing submission.\n\nArgs:\n submission_request (StoreSubmissionRequest): The submission details\n user_id (str): ID of the authenticated user submitting the listing\n\nReturns:\n StoreSubmission: The created store submission\n\nRaises:\n HTTPException: If there is an error creating the submission",+ "operationId": "postV2Create store submission",+ "security": [{ "HTTPBearerJWT": [] }],"requestBody": {+ "required": true,"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/Body_postOauthIntrospect"+ "$ref": "#/components/schemas/StoreSubmissionRequest"}}- },- "required": true+ }},"responses": {"200": {"description": "Successful Response","content": {"application/json": {- "schema": {- "$ref": "#/components/schemas/TokenIntrospectionResult"- }+ "schema": { "$ref": "#/components/schemas/StoreSubmission" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -5527,25 +5575,29 @@}}},- "/api/oauth/revoke": {+ "/api/store/submissions/generate_image": {"post": {- "tags": ["oauth"],- "summary": "Revoke",- "description": "OAuth 2.0 Token Revocation Endpoint (RFC 7009)\n\nAllows clients to revoke an access or refresh token.\n\nNote: Revoking a refresh token does NOT revoke associated access tokens.\nRevoking an access token does NOT revoke the associated refresh token.",- "operationId": "postOauthRevoke",- "requestBody": {- "content": {- "application/json": {- "schema": { "$ref": "#/components/schemas/Body_postOauthRevoke" }- }- },- "required": true- },+ "tags": ["v2", "store", "private"],+ "summary": "Generate submission image",+ "description": "Generate an image for a store listing submission.\n\nArgs:\n agent_id (str): ID of the agent to generate an image for\n user_id (str): ID of the authenticated user\n\nReturns:\n JSONResponse: JSON containing the URL of the generated image",+ "operationId": "postV2Generate submission image",+ "security": [{ "HTTPBearerJWT": [] }],+ "parameters": [+ {+ "name": "agent_id",+ "in": "query",+ "required": true,+ "schema": { "type": "string", "title": "Agent Id" }+ }+ ],"responses": {"200": {"description": "Successful Response","content": { "application/json": { "schema": {} } }},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -5557,69 +5609,29 @@}}},- "/api/oauth/apps/mine": {- "get": {- "tags": ["oauth"],- "summary": "List My Oauth Apps",- "description": "List all OAuth applications owned by the current user.\n\nReturns a list of OAuth applications with their details including:\n- id, name, description, logo_url\n- client_id (public identifier)\n- redirect_uris, grant_types, scopes\n- is_active status\n- created_at, updated_at timestamps\n\nNote: client_secret is never returned for security reasons.",- "operationId": "getOauthListMyOauthApps",- "responses": {- "200": {- "description": "Successful Response",- "content": {- "application/json": {- "schema": {- "items": {- "$ref": "#/components/schemas/OAuthApplicationInfo"- },- "type": "array",- "title": "Response Getoauthlistmyoauthapps"- }- }- }- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"- }- },- "security": [{ "HTTPBearerJWT": [] }]- }- },- "/api/oauth/apps/{app_id}/status": {- "patch": {- "tags": ["oauth"],- "summary": "Update App Status",- "description": "Enable or disable an OAuth application.\n\nOnly the application owner can update the status.\nWhen disabled, the application cannot be used for new authorizations\nand existing access tokens will fail validation.\n\nReturns the updated application info.",- "operationId": "patchOauthUpdateAppStatus",- "security": [{ "HTTPBearerJWT": [] }],- "parameters": [- {- "name": "app_id",- "in": "path",- "required": true,- "schema": { "type": "string", "title": "App Id" }- }- ],+ "/api/store/submissions/media": {+ "post": {+ "tags": ["v2", "store", "private"],+ "summary": "Upload submission media",+ "description": "Upload media (images/videos) for a store listing submission.\n\nArgs:\n file (UploadFile): The media file to upload\n user_id (str): ID of the authenticated user uploading the media\n\nReturns:\n str: URL of the uploaded media file\n\nRaises:\n HTTPException: If there is an error uploading the media",+ "operationId": "postV2Upload submission media","requestBody": {- "required": true,"content": {- "application/json": {+ "multipart/form-data": {"schema": {- "$ref": "#/components/schemas/Body_patchOauthUpdateAppStatus"+ "$ref": "#/components/schemas/Body_postV2Upload_submission_media"}}- }+ },+ "required": true},"responses": {"200": {"description": "Successful Response",- "content": {- "application/json": {- "schema": {- "$ref": "#/components/schemas/OAuthApplicationInfo"- }- }- }+ "content": { "application/json": { "schema": {} } }+ },+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"},"422": {"description": "Validation Error",@@ -5628,33 +5640,33 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}- }+ },+ "security": [{ "HTTPBearerJWT": [] }]}},- "/api/oauth/apps/{app_id}/logo": {- "patch": {- "tags": ["oauth"],- "summary": "Update App Logo",- "description": "Update the logo URL for an OAuth application.\n\nOnly the application owner can update the logo.\nThe logo should be uploaded first using the media upload endpoint,\nthen this endpoint is called with the resulting URL.\n\nLogo requirements:\n- Must be square (1:1 aspect ratio)\n- Minimum 512x512 pixels\n- Maximum 2048x2048 pixels\n\nReturns the updated application info.",- "operationId": "patchOauthUpdateAppLogo",+ "/api/store/submissions/{store_listing_version_id}": {+ "put": {+ "tags": ["v2", "store", "private"],+ "summary": "Edit store submission",+ "description": "Edit an existing store listing submission.\n\nArgs:\n store_listing_version_id (str): ID of the store listing version to edit\n submission_request (StoreSubmissionRequest): The updated submission details\n user_id (str): ID of the authenticated user editing the listing\n\nReturns:\n StoreSubmission: The updated store submission\n\nRaises:\n HTTPException: If there is an error editing the submission",+ "operationId": "putV2Edit store submission","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "app_id",+ "name": "store_listing_version_id","in": "path","required": true,- "schema": { "type": "string", "title": "App Id" }+ "schema": { "type": "string", "title": "Store Listing Version Id" }}],"requestBody": {"required": true,"content": {"application/json": {- "schema": { "$ref": "#/components/schemas/UpdateAppLogoRequest" }+ "schema": {+ "$ref": "#/components/schemas/StoreSubmissionEditRequest"+ }}}},@@ -5663,12 +5675,13 @@"description": "Successful Response","content": {"application/json": {- "schema": {- "$ref": "#/components/schemas/OAuthApplicationInfo"- }+ "schema": { "$ref": "#/components/schemas/StoreSubmission" }}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -5676,49 +5689,40 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}},- "/api/oauth/apps/{app_id}/logo/upload": {- "post": {- "tags": ["oauth"],- "summary": "Upload App Logo",- "description": "Upload a logo image for an OAuth application.\n\nRequirements:\n- Image must be square (1:1 aspect ratio)\n- Minimum 512x512 pixels\n- Maximum 2048x2048 pixels\n- Allowed formats: JPEG, PNG, WebP\n- Maximum file size: 3MB\n\nThe image is uploaded to cloud storage and the app's logoUrl is updated.\nReturns the updated application info.",- "operationId": "postOauthUploadAppLogo",+ "/api/store/submissions/{submission_id}": {+ "delete": {+ "tags": ["v2", "store", "private"],+ "summary": "Delete store submission",+ "description": "Delete a store listing submission.\n\nArgs:\n user_id (str): ID of the authenticated user\n submission_id (str): ID of the submission to be deleted\n\nReturns:\n bool: True if the submission was successfully deleted, False otherwise",+ "operationId": "deleteV2Delete store submission","security": [{ "HTTPBearerJWT": [] }],"parameters": [{- "name": "app_id",+ "name": "submission_id","in": "path","required": true,- "schema": { "type": "string", "title": "App Id" }+ "schema": { "type": "string", "title": "Submission Id" }}],- "requestBody": {- "required": true,- "content": {- "multipart/form-data": {- "schema": {- "$ref": "#/components/schemas/Body_postOauthUploadAppLogo"- }- }- }- },"responses": {"200": {"description": "Successful Response","content": {"application/json": {"schema": {- "$ref": "#/components/schemas/OAuthApplicationInfo"+ "type": "boolean",+ "title": "Response Deletev2Delete Store Submission"}}}},+ "401": {+ "$ref": "#/components/responses/HTTP401NotAuthenticatedError"+ },"422": {"description": "Validation Error","content": {@@ -5726,9 +5730,6 @@"schema": { "$ref": "#/components/schemas/HTTPValidationError" }}}- },- "401": {- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"}}}@@ -6318,6 +6319,25 @@"required": ["is_active"],"title": "Body_patchOauthUpdateAppStatus"},+ "Body_postAnalyticsLogRawAnalytics": {+ "properties": {+ "type": { "type": "string", "title": "Type" },+ "data": {+ "additionalProperties": true,+ "type": "object",+ "title": "Data",+ "description": "The data to log"+ },+ "data_index": {+ "type": "string",+ "title": "Data Index",+ "description": "Indexable field for any count based analytical measures like page order clicking, tutorial step completion, etc."+ }+ },+ "type": "object",+ "required": ["type", "data", "data_index"],+ "title": "Body_postAnalyticsLogRawAnalytics"+ },"Body_postOauthIntrospect": {"properties": {"token": {@@ -6426,25 +6446,6 @@"type": "object","title": "Body_postV1Execute graph agent"},- "Body_postV1LogRawAnalytics": {- "properties": {- "type": { "type": "string", "title": "Type" },- "data": {- "additionalProperties": true,- "type": "object",- "title": "Data",- "description": "The data to log"- },- "data_index": {- "type": "string",- "title": "Data Index",- "description": "Indexable field for any count based analytical measures like page order clicking, tutorial step completion, etc."- }- },- "type": "object",- "required": ["type", "data", "data_index"],- "title": "Body_postV1LogRawAnalytics"- },"Body_postV1Upload_file_to_cloud_storage": {"properties": {"file": { "type": "string", "format": "binary", "title": "File" }@@ -11627,15 +11628,15 @@}},"securitySchemes": {- "HTTPBearerJWT": {- "type": "http",- "scheme": "bearer",- "bearerFormat": "jwt"- },"APIKeyAuthenticator-X-Postmark-Webhook-Token": {"type": "apiKey","in": "header","name": "X-Postmark-Webhook-Token"+ },+ "HTTPBearerJWT": {+ "type": "http",+ "scheme": "bearer",+ "bearerFormat": "jwt"}},"responses": {