- Added `available_skills` to `ConsciousnessNodeDeps` and `ForWorkflowEngineInput`.
- Updated `WorkflowRunningEngine` to retrieve all available skills from `GlobalStateMachine` and pass them during `ForWorkflowEngineInput` creation.
- Updated `ConsciousnessNode` to dynamically inject these skills into the system prompt. This allows the AI to correctly insert `skill_individuals` into `PretorWorkflow` steps (as tools for `composite_individual` or `primary_individual`).
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: Clean up dashboard UI, shift workflow WS to SSE, and add file upload support
- Removed Monitoring view and associated `/ws/state` cluster websocket route.
- Modified workflow tracing from WebSocket (`/api/v1/workflow/ws/{trace_id}`) to Server-Sent Events (`/api/v1/workflow/sse/{trace_id}`) for unidirectional pushes, introducing a new `/api/v1/workflow/reply/{trace_id}` POST route to handle incoming client replies.
- Cleaned up dummy data and unneeded links in the chat layout (LeftPanel, ChatPanel).
- Implemented file upload functionality: added a `/api/v1/adapter/client/upload` endpoint to the backend which saves files to a local `uploads` directory, and added an integrated file input triggered via the `+` button in the frontend chat interface to facilitate uploading with an automated chat message confirmation.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* fix: prevent global_state_machine actor from being garbage collected
Added `lifetime="detached"` and kept a local reference to the `GlobalStateMachine`
actor in `main.py` so that it doesn't get cleaned up by Ray due to going out
of scope, which was causing `ray.get_actor('global_state_machine')` calls to fail
in API route handlers (resulting in 500 errors).
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* fix: resolve named actor addressing failure across Ray processes via explicit namespace
The `ray.get_actor` calls in API routes executing within a Ray Serve worker were failing to
resolve the actors created by the main process because the implicit random namespace of
`ray.init()` did not match the namespace of the Ray Serve application scope.
Instead of overriding garbage collection via `lifetime="detached"` (which can lead to actor
leakage), this assigns an explicit `namespace="pretor"` when initializing Ray in the main process,
and uses the identical namespace in `ray_hook.py` when looking up named actors. Also retains the
local variable assignments in `main.py` to prevent them from being eliminated as unused variables.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* fix: defer actor lookup in WorkflowRunningEngine to avoid startup race conditions
The `WorkflowRunningEngine` was trying to fetch the `global_state_machine` actor
during its `__init__` method via `ray_actor_hook()`. Since actor creation requests are
dispatched asynchronously, the `global_state_machine` might not be completely
registered and discoverable via `ray.get_actor()` by the time the `WorkflowRunningEngine`'s
`__init__` is evaluated.
Moved the actor lookup to the async `run()` method, which gets executed after the engine
itself is fully up, allowing time for other components to become available in the global
Ray namespace.
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: correct actorlist handle in supervisory node and ui form reset (#30)
- Fixed `AttributeError` for `workflow_template_manager` in `SupervisoryNode` by properly unpacking the `.global_state_machine` handle from `ray_actor_hook`.
- Removed overly broad blanket `Exception` swallowing for WebSocket cancellation that caused closed loops in Uvicorn handlers to leak and dump HTTP errors.
- UI: Reset `model_id` to blank whenever a user alters the `Provider Title` to prevent stale incompatible models from breaking submission.
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 provider manager and skill settings 17493544742337088454 (#31)
* fix: correct actorlist handle in supervisory node and ui form reset
- Fixed `AttributeError` for `workflow_template_manager` in `SupervisoryNode` by properly unpacking the `.global_state_machine` handle from `ray_actor_hook`.
- Removed overly broad blanket `Exception` swallowing for WebSocket cancellation that caused closed loops in Uvicorn handlers to leak and dump HTTP errors.
- UI: Reset `model_id` to blank whenever a user alters the `Provider Title` to prevent stale incompatible models from breaking submission.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* fix: dynamically resolve backend urls based on browser window location
- Updated `apiClient.ts` to use a relative base URL (`''`) if `VITE_API_BASE_URL` is omitted, allowing axios to infer the current domain in reverse-proxied environments.
- Updated WebSocket URL generation in `RightPanel.tsx` and `useClusterState.ts` to dynamically calculate protocol (`ws:` vs `wss:`) and host from `window.location`.
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>
* Refactor GlobalStateMachine/PostgresDatabase reflection, error retry mechanisms, and frontend worker individual UI.
- Replaced dynamic getattr reflection in GlobalStateMachine and PostgresDatabase with explicit wrapper methods to improve stability and avoid Missing Method AttributeErrors.
- Add `get_tool_list` explicit wrapper method resolving runtime crashes.
- Implemented `RetryableError` and `NonRetryableError` base exceptions, wrapping network errors and utilizing custom `@retry_on_retryable_error` decorator on Provider requests instead of Ray actor's unsupported `retry_exceptions`.
- Added exponential backoff algorithms for WebSocket reconnections in the frontend.
- Added strict TypeScript-based schema validation for WorkflowTemplate creation payloads.
- Redesigned the Worker Individual configuration UI into a unified list containing both System Nodes and Custom Workers, supporting Add, Edit, and Delete workflows, and resolving the provider-switching bug.
- Updated unit tests to align with architectural changes.
- Cleaned up temp scripts.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* Suppress GeneratorExit RuntimeError in WebSocket endpoints
- Adds `GeneratorExit` check to the `RuntimeError` exception handling block in FastAPI WebSocket routes (`pretor/api/cluster.py` and `pretor/api/workflow.py`). This prevents unhandled exception crashes in the Ray proxy actor when a client disconnects unexpectedly or closes the generator prematurely.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* Suppress GeneratorExit RuntimeError in WebSocket endpoints
- Adds `GeneratorExit` check to the `RuntimeError` exception handling block in FastAPI WebSocket routes (`pretor/api/cluster.py` and `pretor/api/workflow.py`). This prevents unhandled exception crashes in the Ray proxy actor when a client disconnects unexpectedly or closes the generator prematurely.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* Enhance backend token validation to trigger frontend re-login properly.
- Modified `RoleChecker` and `get_authority` in `pretor/utils/check_user/role_check.py` to catch `UserNotExistError`. If the database cannot find the user corresponding to the token's ID (e.g. the user was deleted), the backend now raises a standard `401 Unauthorized` exception instead of passing the error up.
- This ensures the frontend's `axios` interceptor in `apiClient.ts` will catch the 401, clear the stale token from localStorage, and seamlessly bounce the user back to the login screen.
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: correct actorlist handle in supervisory node and ui form reset (#30)
- Fixed `AttributeError` for `workflow_template_manager` in `SupervisoryNode` by properly unpacking the `.global_state_machine` handle from `ray_actor_hook`.
- Removed overly broad blanket `Exception` swallowing for WebSocket cancellation that caused closed loops in Uvicorn handlers to leak and dump HTTP errors.
- UI: Reset `model_id` to blank whenever a user alters the `Provider Title` to prevent stale incompatible models from breaking submission.
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 provider manager and skill settings 17493544742337088454 (#31)
* fix: correct actorlist handle in supervisory node and ui form reset
- Fixed `AttributeError` for `workflow_template_manager` in `SupervisoryNode` by properly unpacking the `.global_state_machine` handle from `ray_actor_hook`.
- Removed overly broad blanket `Exception` swallowing for WebSocket cancellation that caused closed loops in Uvicorn handlers to leak and dump HTTP errors.
- UI: Reset `model_id` to blank whenever a user alters the `Provider Title` to prevent stale incompatible models from breaking submission.
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
* fix: dynamically resolve backend urls based on browser window location
- Updated `apiClient.ts` to use a relative base URL (`''`) if `VITE_API_BASE_URL` is omitted, allowing axios to infer the current domain in reverse-proxied environments.
- Updated WebSocket URL generation in `RightPanel.tsx` and `useClusterState.ts` to dynamically calculate protocol (`ws:` vs `wss:`) and host from `window.location`.
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>
* Refactor GlobalStateMachine/PostgresDatabase reflection, error retry mechanisms, and frontend worker individual UI.
- Replaced dynamic getattr reflection in GlobalStateMachine and PostgresDatabase with explicit wrapper methods to improve stability and avoid Missing Method AttributeErrors.
- Add `get_tool_list` explicit wrapper method resolving runtime crashes.
- Implemented `RetryableError` and `NonRetryableError` base exceptions, wrapping network errors and utilizing custom `@retry_on_retryable_error` decorator on Provider requests instead of Ray actor's unsupported `retry_exceptions`.
- Added exponential backoff algorithms for WebSocket reconnections in the frontend.
- Added strict TypeScript-based schema validation for WorkflowTemplate creation payloads.
- Redesigned the Worker Individual configuration UI into a unified list containing both System Nodes and Custom Workers, supporting Add, Edit, and Delete workflows, and resolving the provider-switching bug.
- Updated unit tests to align with architectural changes.
- Cleaned up temp scripts.
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>
* 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(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>