* ✨ [Feature] Add frontend authentication page and 401 error interceptor (#21)
* feat: add frontend authentication page and 401 interceptor
Adds a new AuthPage component for user login and registration, integrates it into App.tsx to protect routes, and sets up an Axios interceptor to handle 401 Unauthorized responses by clearing local storage and reloading. Also fixes a missing logger attribute in WorkflowEngine for backend tests.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* fix: gracefully handle closed websockets
Updates the websocket endpoints in `pretor/api/cluster.py` and `pretor/api/workflow.py` to catch `RuntimeError` alongside `WebSocketDisconnect`. This prevents the application from crashing and spamming error logs when the frontend client unexpectedly closes the connection and the underlying TCP transport is closed.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* feat: add worker form and update global settings
Adds a new form in the Worker Individual Settings page to create custom worker individuals via the `/api/v1/agent/worker` endpoint. Also updates the System Settings page to remove the obsolete "Max Concurrent Workflows" setting and makes the system language and theme toggles functional by persisting to local storage and updating the document root class.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* fix: resolve provider owner type, resource UI, and db ready check
This commit fixes the following issues:
1. `provider_owner` type bug: Changed type from `int` to `str` in DB models and Pydantic schemas.
2. Frontend Provider Dropdown: `WorkerIndividualSettings.tsx` now uses a dropdown to select a created provider instead of a free-form input field.
3. Database Initialization Sync: Added an `asyncio.Event()` to `postgres.py` to prevent any DB actions from executing before `init_db()` is complete.
4. Resource Management UI: Added new pages `SkillSettings.tsx` and `WorkflowTemplateSettings.tsx` to handle frontend requests to manage skills and workflow templates.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* fix(backend): initialize async queue properly and fix auth login error handling (#18)
- Moved `self.workflow_queue = asyncio.Queue()` to the top of `WorkflowRunningEngine.run` to ensure the queue exists before coroutines start polling it, resolving initialization race conditions.
- Handled `user` object nullability check correctly in `/api/v1/auth/login` to raise `UserNotExistError` instead of crashing on attribute access.
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* feat: Integrate frontend dashboard and wire up settings endpoints
- Imported and moved the pretor_dashboard dev branch into `frontend/`.
- Configured FastAPI `PretorGateway` to mount `frontend/dist` out of the box and serve it effectively.
- Fixed `global_state_machine` Ray Actor hook references in `pretor/api/resource.py`.
- Added missing GET `/api/v1/auth/list` endpoint to list all users.
- Added missing DELETE `/api/v1/auth/{user_id}` endpoint to remove users.
- Plumbed API calls in the frontend's `UsersSettings.tsx` to get, delete, and alter the authority roles.
- Wired up provider deletion API endpoints within `ProvidersSettings.tsx`.
- Ran `npm run build` so `frontend/dist` is current.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* feat: Integrate frontend dashboard and wire up settings endpoints
- Imported and moved the pretor_dashboard dev branch into `frontend/`.
- Configured FastAPI `PretorGateway` to mount `frontend/dist` out of the box and serve it effectively.
- Fixed `global_state_machine` Ray Actor hook references in `pretor/api/resource.py`.
- Added missing GET `/api/v1/auth/list` endpoint to list all users.
- Added missing DELETE `/api/v1/auth/{user_id}` endpoint to remove users.
- Plumbed API calls in the frontend's `UsersSettings.tsx` to get, delete, and alter the authority roles.
- Wired up provider deletion API endpoints within `ProvidersSettings.tsx`.
- Ran `npm run build` so `frontend/dist` is current.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* fix(backend): Remove __call__ from PretorGateway and assign first user as SUPER_ADMINISTRATOR
- Removed `__call__` from `PretorGateway` in `pretor/core/api/__init__.py` to fix Ray Serve `ValueError` during initialization.
- Modified `AuthDatabase.add_user` in `pretor/core/database/module/user.py` to check for existing users. The first registered user now receives `UserAuthority.SUPER_ADMINISTRATOR` access while subsequent users get `USER` access.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* fix(backend): Remove __call__ from PretorGateway and assign first user as SUPER_ADMINISTRATOR
- Removed `__call__` from `PretorGateway` in `pretor/core/api/__init__.py` to fix Ray Serve `ValueError` during initialization.
- Added connection error handling in `PostgresDatabase.init_db()` to prevent startup crashes when PostgreSQL is unavailable.
- Updated `AuthDatabase.add_user` to automatically grant `SUPER_ADMINISTRATOR` privileges to the first registered user.
- Fixed unit tests in `user_test.py` that were improperly mocking `session.execute`, removing confusing stack traces during testing.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* fix(backend): Remove __call__ from PretorGateway and assign first user as SUPER_ADMINISTRATOR
- Removed `__call__` from `PretorGateway` in `pretor/core/api/__init__.py` to fix Ray Serve `ValueError` during initialization.
- Added connection error handling in `PostgresDatabase.init_db()` to prevent startup crashes when PostgreSQL is unavailable.
- Updated `AuthDatabase.add_user` to automatically grant `SUPER_ADMINISTRATOR` privileges to the first registered user.
- Fixed unit tests in `user_test.py` that were improperly mocking `session.execute`, removing confusing stack traces during testing.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* fix(backend): initialize async queue properly and fix auth login error handling (#18)
- Moved `self.workflow_queue = asyncio.Queue()` to the top of `WorkflowRunningEngine.run` to ensure the queue exists before coroutines start polling it, resolving initialization race conditions.
- Handled `user` object nullability check correctly in `/api/v1/auth/login` to raise `UserNotExistError` instead of crashing on attribute access.
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* feat: Integrate frontend dashboard and wire up settings endpoints
- Imported and moved the pretor_dashboard dev branch into `frontend/`.
- Configured FastAPI `PretorGateway` to mount `frontend/dist` out of the box and serve it effectively.
- Fixed `global_state_machine` Ray Actor hook references in `pretor/api/resource.py`.
- Added missing GET `/api/v1/auth/list` endpoint to list all users.
- Added missing DELETE `/api/v1/auth/{user_id}` endpoint to remove users.
- Plumbed API calls in the frontend's `UsersSettings.tsx` to get, delete, and alter the authority roles.
- Wired up provider deletion API endpoints within `ProvidersSettings.tsx`.
- Ran `npm run build` so `frontend/dist` is current.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* Add workflow agent nodes, memory RAG, and tool plugin outlines
- Add MemoryRAG class integrated with PostgresDatabase.
- Rewrite SupervisoryNode, ConsciousnessNode, and ControlNode as ray remote actors with an injected pydantic_ai Agent.
- Create initial tool plugin scaffolding for RAG, web_crawler, and docker_sandbox.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* Flesh out workflow agent nodes, memory RAG, and tool plugins
- Added concrete SQLModel implementations for WorkflowRecord and MemoryRecord with pgvector support.
- Defined a `Workflow` Pydantic model for protocol communication.
- Implemented core agent run logic in SupervisoryNode, ConsciousnessNode, and ControlNode.
- Implemented actual basic httpx and docker-py logic for the tool plugins.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* Refactor node logic to use existing PretorWorkflow
- Deleted redundant `workflow.py` created earlier under `protocol/`.
- Updated `SupervisoryNode`, `ConsciousnessNode`, and `ControlNode` to correctly import and handle the existing `PretorWorkflow`, `WorkerGroup`, and `WorkStep` models from `pretor.core.workflow_manager.workflow`.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* Add UserEvent routing and fix SQLAlchemy execute syntax
- Added `UserEvent` class to `pretor.core.workflow_manager.workflow` to represent user interactions.
- Updated `SupervisoryNode.process_event` to receive the event, analyze complexity with the LLM, and either directly reply or dispatch a `ConsciousnessNode` workflow generation.
- Fixed SQLAlchemy AsyncSession methods in `memory.py` from `.exec()` to `.execute()`.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* Rename UserEvent to PretorEvent
- Renamed `UserEvent` to `PretorEvent` in `pretor/core/workflow_manager/workflow.py`.
- Updated references in `pretor/individual_plugin/supervisory_node/supervisory_node.py` to use `PretorEvent`.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>