Commit Graph

23 Commits

Author SHA1 Message Date
朝夕 5eab42758b
feat: Make skill individuals directly accessible to consciousness node (#54)
- 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>
2026-04-28 17:45:15 +08:00
朝夕 0ee8139902 fix: 修复了逻辑 2026-04-28 14:57:32 +08:00
朝夕 65652399e0 fix: 修复了actor调用问题 2026-04-28 14:25:48 +08:00
朝夕 fa22999d8c
Revert "Feat/deepseek adapter dropin 14224636701039833263 (#51)" (#52)
This reverts commit 9d7b980769.
2026-04-28 14:21:00 +08:00
朝夕 9d7b980769
Feat/deepseek adapter dropin 14224636701039833263 (#51)
* fix: resolve 422 error adding deepseek provider

- Updated `pretor/api/provider.py` to allow "deepseek" as a valid Literal in `ProviderRegister` Pydantic model.
- Validated tests to ensure the backend can correctly receive deepseek configurations.

Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>

* fix: complete deepseek provider registration wiring

- Updated `pretor/core/global_state_machine/provider_manager.py` to correctly map `"deepseek"` to `DeepseekProvider`.
- Updated `pretor/core/global_state_machine/model_provider/__init__.py` to export `DeepseekProvider`.
- Confirmed this fully resolves the Provider Manager failing to instantiate DeepSeek despite passing API validation.

Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>

* fix: support pydantic-ai decorator proxying on DeepSeekReasonerAgent

- Implemented `__getattr__` on `DeepSeekReasonerAgent` to safely proxy all unrecognized attributes (such as `@agent.system_prompt` and `@agent.tool`) directly to the underlying PydanticAI `Agent` object.
- Resolves the crash where `SupervisoryNode.create_agent()` threw an `AttributeError` when trying to decorate `system_prompt`.

Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>

* refactor: remove gemini provider from frontend and backend

- Removed `gemini` from `ProviderRegister` API validator.
- Removed `GeminiProvider` files, tests, and its mappings from `AgentFactory` and `ProviderManager`.
- Removed `gemini` from frontend TypeScript types and UI selection dropdown.

Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>

* fix: parse output with TypeAdapter to support Union types

- Refactored `_parse_output` in `DeepSeekReasonerAgent` to use Pydantic's `TypeAdapter`.
- Resolves a bug where Union types (like `Union[ForConsciousnessNode, ForUser]`) evaluated `hasattr(..., 'model_validate_json')` as `False`, causing the parser to fall back to `json.loads` and return a raw `dict`.
- The `SupervisoryNode` now correctly receives Pydantic objects instead of dictionaries, resolving the `未知响应类型: <class 'dict'>` crash.
- Cleaned up debug scripts to adhere to repository standards.

Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>

* fix: resolve module and attribute errors to complete deepseek provider

- Fixed `ActorList 对象没有属性 'put_event'` in `SupervisoryNode` by correctly referencing the inner `workflow_running_engine` handle.
- Mapped `deepseek` to `OpenAIProvider` in the `ProviderManager` to correctly process it via its OpenAI-compatible REST API, fixing the fatal `ModuleNotFoundError`.
- Finalized removal of all temporary debug files.

Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>

* fix: ensure correct attribute extraction for ray_actor_hook

- Audited all uses of `ray_actor_hook` in the codebase.
- Verified that all hooks properly extract the actual actor object (e.g. `.global_state_machine` or `.postgres_database`) from the returned `ActorList` to avoid invalid attribute runtime errors on proxy objects.

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>
2026-04-28 14:13:41 +08:00
朝夕 b62212d8bf fix: 修复部分错误 2026-04-28 04:23:57 +08:00
朝夕 a1adbd00af
Refactor Agent Tool Assignments to Database-Driven Static Loading (#45)
* Refactor tool loading to use static database assignment

- Add `tools` field to `WorkerIndividual` and `SystemNodeConfig` models
- Update frontend WorkerIndividualSettings to support multi-select tools and select `bound_skill` from available backend API
- Deprecate dynamic `get_tool` method during agent execution, replacing it with `load_tools_from_list` via absolute paths during agent initialization
- Fix deprecated tool loading usage across `SupervisoryNode`, `ConsciousnessNode`, `ControlNode`, and `BaseIndividual`
- Provide `reload` API route to clear `GlobalIndividualManager` state to rebuild nodes cleanly upon next request
- Fix `user_test.py` related to unhashed password assignments in testing mock object

Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>

* Refactor tool loading to use static database assignment part 2

- Restore BaseIndividual's `_init_agent` method to inject parsed `tools_list` via absolute paths dynamically using `load_tools_from_list`
- Restore React component multi-select support for tools dropdown via `/api/v1/resource/tool` backend response integration
- Restore `user_test.py` compatibility related to access hasher assignments
- Passed 75 tests with no errors

Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>

* Refactor tool loading to use static database assignment

- Add `tools` field to `WorkerIndividual` and `SystemNodeConfig` models
- Update frontend WorkerIndividualSettings to support multi-select tools and select `bound_skill` from available backend API
- Deprecate dynamic `get_tool` method during agent execution, replacing it with `load_tools_from_list` via absolute paths during agent initialization
- Fix deprecated tool loading usage across `SupervisoryNode`, `ConsciousnessNode`, `ControlNode`, and `BaseIndividual`
- Provide `reload` API route to clear `GlobalIndividualManager` state to rebuild nodes cleanly upon next request
- Fix `user_test.py` related to unhashed password assignments in testing mock object

Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>

* Finalize all tool loading refactoring with complete changes

- Merged database schema enhancements for `tools` multi-select list
- Completed the `load_tools_from_list` via absolute paths utility update
- Refactored `AgentFactory` and corresponding initialization calls in `BaseIndividual`, `SupervisoryNode`, `ConsciousnessNode`, and `ControlNode` to inject statically via constructor
- Updated frontend UI `WorkerIndividualSettings` with UI for `bound_skill` selection and dynamic multi-tool selector array
- Removed all legacy usages of dynamic `tools=tool` invocation
- Provided backend `/reload` API and automatic clearing of instance cache upon individual configuration update
- Repaired mock password assignment logic in testing suite

Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>

* Restore complete tool loading refactor logic

- Re-apply BaseIndividual tools resolution logic
- Correctly patch API, UI files, system nodes and testing scripts avoiding checkout loss
- Passed all 75 integration and unit tests successfully

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>
2026-04-28 03:53:33 +08:00
朝夕 d322826c87 fix: 修复了get_tool调用缓存协程对象的bug 2026-04-27 22:18:50 +08:00
朝夕 dc1c440703 fix: 修复了严重bug 2026-04-26 23:36:07 +08:00
朝夕 913648a071 fix: 修复了字段名bug 2026-04-26 21:37:20 +08:00
朝夕 e6bf9e2ce4
Jules refactor backend and frontend 3736339600030847383 (#35)
* 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>
2026-04-26 14:54:46 +08:00
朝夕 5f4754718f
Jules refactor backend and frontend 3736339600030847383 (#33)
* 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>
2026-04-26 11:34:46 +08:00
朝夕 66306ffd01
[feature integration] frontend dashboard and API endpoints (#19)
* 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>
2026-04-24 09:12:12 +08:00
朝夕 be0d78c855 wip: 增加了api的简单权限校验,使用反射对于actor进行重构 2026-04-22 11:36:59 +08:00
朝夕 446e208193 wip: 初步增加了worker_individual,修改了trace_id 2026-04-21 15:06:50 +08:00
朝夕 1a8277ad88 wip: 优化调度逻辑,增加了工具管理 2026-04-20 20:00:15 +08:00
朝夕 fe49340106 wip: 优化了control_node consciousness_node和supervisory_node 2026-04-20 16:20:38 +08:00
朝夕 1715b64d17 wip: 优化 2026-04-11 18:14:07 +08:00
朝夕 6c5849f3d0 wip:增加control_node 2026-04-11 14:00:37 +08:00
朝夕 dc857cbff7 wip:优化individual,加了基本的启动页面 2026-04-10 23:17:06 +08:00
朝夕 2e5b2bce3a wip:更新版权 2026-04-10 10:50:25 +08:00
朝夕 a7bd7f786e wip:改进 2026-04-09 23:06:01 +08:00
朝夕 2552017ea7 wip:对于api接口进行了完善,完善了global_state_machine(全局状态机),进行了大规模重构 2026-04-08 22:09:54 +08:00