flowent 0.0.1 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -8
- package/backend/.python-version +1 -0
- package/backend/pyproject.toml +57 -0
- package/backend/src/flowent/__init__.py +3 -0
- package/backend/src/flowent/__pycache__/__init__.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/_version.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/access.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/agent.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/assistant_commands.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/cli.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/config.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/events.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/graph_runtime.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/graph_service.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/image_assets.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/logging.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/main.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/mcp_service.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/model_metadata.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/network.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/registry.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/role_management.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/runtime.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/sandbox.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/security.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/settings.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/settings_management.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/state_db.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/stats_service.cpython-313.pyc +0 -0
- package/backend/src/flowent/__pycache__/workspace_store.cpython-313.pyc +0 -0
- package/backend/src/flowent/_version.py +7 -0
- package/backend/src/flowent/access.py +247 -0
- package/backend/src/flowent/agent.py +2808 -0
- package/backend/src/flowent/assistant_commands.py +106 -0
- package/backend/src/flowent/channels/__init__.py +3 -0
- package/backend/src/flowent/channels/__pycache__/__init__.cpython-313.pyc +0 -0
- package/backend/src/flowent/channels/__pycache__/telegram.cpython-313.pyc +0 -0
- package/backend/src/flowent/channels/telegram.py +615 -0
- package/backend/src/flowent/cli.py +85 -0
- package/backend/src/flowent/config.py +14 -0
- package/backend/src/flowent/dev.py +3 -0
- package/backend/src/flowent/events.py +157 -0
- package/backend/src/flowent/graph_runtime.py +60 -0
- package/backend/src/flowent/graph_service.py +1346 -0
- package/backend/src/flowent/image_assets.py +356 -0
- package/backend/src/flowent/logging.py +155 -0
- package/backend/src/flowent/main.py +124 -0
- package/backend/src/flowent/mcp_service.py +1904 -0
- package/backend/src/flowent/model_metadata.py +98 -0
- package/backend/src/flowent/models/__init__.py +121 -0
- package/backend/src/flowent/models/__pycache__/__init__.cpython-313.pyc +0 -0
- package/backend/src/flowent/models/__pycache__/agent.cpython-313.pyc +0 -0
- package/backend/src/flowent/models/__pycache__/base.cpython-313.pyc +0 -0
- package/backend/src/flowent/models/__pycache__/blueprint.cpython-313.pyc +0 -0
- package/backend/src/flowent/models/__pycache__/content.cpython-313.pyc +0 -0
- package/backend/src/flowent/models/__pycache__/delta.cpython-313.pyc +0 -0
- package/backend/src/flowent/models/__pycache__/event.cpython-313.pyc +0 -0
- package/backend/src/flowent/models/__pycache__/graph.cpython-313.pyc +0 -0
- package/backend/src/flowent/models/__pycache__/history.cpython-313.pyc +0 -0
- package/backend/src/flowent/models/__pycache__/llm.cpython-313.pyc +0 -0
- package/backend/src/flowent/models/__pycache__/message.cpython-313.pyc +0 -0
- package/backend/src/flowent/models/__pycache__/tab.cpython-313.pyc +0 -0
- package/backend/src/flowent/models/__pycache__/todo.cpython-313.pyc +0 -0
- package/backend/src/flowent/models/agent.py +33 -0
- package/backend/src/flowent/models/base.py +24 -0
- package/backend/src/flowent/models/blueprint.py +176 -0
- package/backend/src/flowent/models/content.py +164 -0
- package/backend/src/flowent/models/delta.py +44 -0
- package/backend/src/flowent/models/event.py +51 -0
- package/backend/src/flowent/models/graph.py +437 -0
- package/backend/src/flowent/models/history.py +214 -0
- package/backend/src/flowent/models/llm.py +61 -0
- package/backend/src/flowent/models/message.py +27 -0
- package/backend/src/flowent/models/tab.py +48 -0
- package/backend/src/flowent/models/todo.py +10 -0
- package/backend/src/flowent/network.py +146 -0
- package/backend/src/flowent/prompts/__init__.py +67 -0
- package/backend/src/flowent/prompts/__pycache__/__init__.cpython-313.pyc +0 -0
- package/backend/src/flowent/prompts/__pycache__/common.cpython-313.pyc +0 -0
- package/backend/src/flowent/prompts/__pycache__/steward.cpython-313.pyc +0 -0
- package/backend/src/flowent/prompts/common.py +250 -0
- package/backend/src/flowent/prompts/steward.py +64 -0
- package/backend/src/flowent/providers/__init__.py +23 -0
- package/backend/src/flowent/providers/__pycache__/__init__.cpython-313.pyc +0 -0
- package/backend/src/flowent/providers/__pycache__/anthropic.cpython-313.pyc +0 -0
- package/backend/src/flowent/providers/__pycache__/base_url.cpython-313.pyc +0 -0
- package/backend/src/flowent/providers/__pycache__/configuration.cpython-313.pyc +0 -0
- package/backend/src/flowent/providers/__pycache__/content.cpython-313.pyc +0 -0
- package/backend/src/flowent/providers/__pycache__/errors.cpython-313.pyc +0 -0
- package/backend/src/flowent/providers/__pycache__/gateway.cpython-313.pyc +0 -0
- package/backend/src/flowent/providers/__pycache__/headers.cpython-313.pyc +0 -0
- package/backend/src/flowent/providers/__pycache__/management.cpython-313.pyc +0 -0
- package/backend/src/flowent/providers/__pycache__/openai.cpython-313.pyc +0 -0
- package/backend/src/flowent/providers/__pycache__/openai_responses.cpython-313.pyc +0 -0
- package/backend/src/flowent/providers/__pycache__/registry.cpython-313.pyc +0 -0
- package/backend/src/flowent/providers/__pycache__/sse.cpython-313.pyc +0 -0
- package/backend/src/flowent/providers/__pycache__/thinking.cpython-313.pyc +0 -0
- package/backend/src/flowent/providers/anthropic.py +468 -0
- package/backend/src/flowent/providers/base_url.py +60 -0
- package/backend/src/flowent/providers/configuration.py +182 -0
- package/backend/src/flowent/providers/content.py +122 -0
- package/backend/src/flowent/providers/errors.py +223 -0
- package/backend/src/flowent/providers/gateway.py +169 -0
- package/backend/src/flowent/providers/gemini.py +447 -0
- package/backend/src/flowent/providers/headers.py +20 -0
- package/backend/src/flowent/providers/management.py +96 -0
- package/backend/src/flowent/providers/ollama.py +293 -0
- package/backend/src/flowent/providers/openai.py +422 -0
- package/backend/src/flowent/providers/openai_responses.py +655 -0
- package/backend/src/flowent/providers/registry.py +144 -0
- package/backend/src/flowent/providers/sse.py +31 -0
- package/backend/src/flowent/providers/thinking.py +79 -0
- package/backend/src/flowent/registry.py +73 -0
- package/backend/src/flowent/role_management.py +255 -0
- package/backend/src/flowent/routes/__init__.py +30 -0
- package/backend/src/flowent/routes/__pycache__/__init__.cpython-313.pyc +0 -0
- package/backend/src/flowent/routes/__pycache__/access.cpython-313.pyc +0 -0
- package/backend/src/flowent/routes/__pycache__/assistant.cpython-313.pyc +0 -0
- package/backend/src/flowent/routes/__pycache__/image_assets.cpython-313.pyc +0 -0
- package/backend/src/flowent/routes/__pycache__/mcp.cpython-313.pyc +0 -0
- package/backend/src/flowent/routes/__pycache__/meta.cpython-313.pyc +0 -0
- package/backend/src/flowent/routes/__pycache__/nodes.cpython-313.pyc +0 -0
- package/backend/src/flowent/routes/__pycache__/prompts.cpython-313.pyc +0 -0
- package/backend/src/flowent/routes/__pycache__/providers_route.cpython-313.pyc +0 -0
- package/backend/src/flowent/routes/__pycache__/roles.cpython-313.pyc +0 -0
- package/backend/src/flowent/routes/__pycache__/settings.cpython-313.pyc +0 -0
- package/backend/src/flowent/routes/__pycache__/stats.cpython-313.pyc +0 -0
- package/backend/src/flowent/routes/__pycache__/tabs.cpython-313.pyc +0 -0
- package/backend/src/flowent/routes/__pycache__/ws.cpython-313.pyc +0 -0
- package/backend/src/flowent/routes/access.py +48 -0
- package/backend/src/flowent/routes/assistant.py +155 -0
- package/backend/src/flowent/routes/image_assets.py +33 -0
- package/backend/src/flowent/routes/mcp.py +125 -0
- package/backend/src/flowent/routes/meta.py +28 -0
- package/backend/src/flowent/routes/nodes.py +365 -0
- package/backend/src/flowent/routes/prompts.py +46 -0
- package/backend/src/flowent/routes/providers_route.py +364 -0
- package/backend/src/flowent/routes/roles.py +207 -0
- package/backend/src/flowent/routes/settings.py +324 -0
- package/backend/src/flowent/routes/stats.py +229 -0
- package/backend/src/flowent/routes/tabs.py +292 -0
- package/backend/src/flowent/routes/ws.py +33 -0
- package/backend/src/flowent/runtime.py +188 -0
- package/backend/src/flowent/sandbox.py +45 -0
- package/backend/src/flowent/security.py +42 -0
- package/backend/src/flowent/settings.py +2467 -0
- package/backend/src/flowent/settings_management.py +286 -0
- package/backend/src/flowent/state_db.py +120 -0
- package/backend/src/flowent/static/assets/AssistantPage-B3Xc08AS.js +1 -0
- package/backend/src/flowent/static/assets/ChannelsPage-ByLd28xk.js +1 -0
- package/backend/src/flowent/static/assets/HomePage-C0hAx9_l.js +3 -0
- package/backend/src/flowent/static/assets/McpPage-DkrYLvBv.js +7 -0
- package/backend/src/flowent/static/assets/PageScaffold-D4jO9ooX.js +1 -0
- package/backend/src/flowent/static/assets/PromptsPage-DWA7rRJd.js +1 -0
- package/backend/src/flowent/static/assets/ProvidersPage-PUWT8seJ.js +3 -0
- package/backend/src/flowent/static/assets/RolesPage-CqcclGRw.js +1 -0
- package/backend/src/flowent/static/assets/SettingsPage-8tS2cJgX.js +3 -0
- package/backend/src/flowent/static/assets/StatsPage-BX9khYzu.js +1 -0
- package/backend/src/flowent/static/assets/ToolsPage-9Tl9FdeD.js +1 -0
- package/backend/src/flowent/static/assets/WorkspaceCommandDialog-CCXxjDL8.js +1 -0
- package/backend/src/flowent/static/assets/WorkspacePanels-aMdJ7ZH7.js +1 -0
- package/backend/src/flowent/static/assets/alert-dialog-kFYVQ7oX.js +1 -0
- package/backend/src/flowent/static/assets/badge-74-3jsCg.js +1 -0
- package/backend/src/flowent/static/assets/constants-XUzFf6i1.js +1 -0
- package/backend/src/flowent/static/assets/datetime-m6_O_Ci9.js +1 -0
- package/backend/src/flowent/static/assets/dialog-BeGSweF6.js +1 -0
- package/backend/src/flowent/static/assets/elk-worker.min-C9JGDOE-.js +6312 -0
- package/backend/src/flowent/static/assets/graph-vendor-CHpVij2M.css +1 -0
- package/backend/src/flowent/static/assets/graph-vendor-DRq_-6fV.js +7 -0
- package/backend/src/flowent/static/assets/index-BHC1Vhy8.css +1 -0
- package/backend/src/flowent/static/assets/index-CL1ALZ3r.js +10 -0
- package/backend/src/flowent/static/assets/layout.worker-jMHqAFbP.js +24 -0
- package/backend/src/flowent/static/assets/markdown-vendor-DVdy_w12.js +29 -0
- package/backend/src/flowent/static/assets/modelParams-CaHd0903.js +1 -0
- package/backend/src/flowent/static/assets/react-vendor-mEs_JJxa.js +9 -0
- package/backend/src/flowent/static/assets/roles-2OLDeTc5.js +1 -0
- package/backend/src/flowent/static/assets/rolldown-runtime-BYbx6iT9.js +1 -0
- package/backend/src/flowent/static/assets/select-DL_LPeDj.js +1 -0
- package/backend/src/flowent/static/assets/shared-CMxbpLeQ.js +1 -0
- package/backend/src/flowent/static/assets/triState-DEr3NkXV.js +1 -0
- package/backend/src/flowent/static/assets/ui-vendor-Dg9NNnWX.js +51 -0
- package/backend/src/flowent/static/index.html +36 -0
- package/backend/src/flowent/stats_service.py +218 -0
- package/backend/src/flowent/tools/__init__.py +201 -0
- package/backend/src/flowent/tools/__pycache__/__init__.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/connect.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/contacts.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/create_agent.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/create_tab.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/delete_tab.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/edit.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/exec.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/fetch.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/idle.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/list_roles.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/list_tabs.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/list_tools.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/manage_prompts.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/manage_providers.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/manage_roles.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/manage_settings.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/mcp.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/read.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/send.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/set_permissions.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/sleep.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/__pycache__/todo.cpython-313.pyc +0 -0
- package/backend/src/flowent/tools/connect.py +156 -0
- package/backend/src/flowent/tools/contacts.py +22 -0
- package/backend/src/flowent/tools/create_agent.py +270 -0
- package/backend/src/flowent/tools/create_tab.py +59 -0
- package/backend/src/flowent/tools/delete_tab.py +39 -0
- package/backend/src/flowent/tools/edit.py +142 -0
- package/backend/src/flowent/tools/exec.py +117 -0
- package/backend/src/flowent/tools/fetch.py +85 -0
- package/backend/src/flowent/tools/idle.py +27 -0
- package/backend/src/flowent/tools/list_roles.py +50 -0
- package/backend/src/flowent/tools/list_tabs.py +96 -0
- package/backend/src/flowent/tools/list_tools.py +24 -0
- package/backend/src/flowent/tools/manage_prompts.py +102 -0
- package/backend/src/flowent/tools/manage_providers.py +220 -0
- package/backend/src/flowent/tools/manage_roles.py +275 -0
- package/backend/src/flowent/tools/manage_settings.py +346 -0
- package/backend/src/flowent/tools/mcp.py +199 -0
- package/backend/src/flowent/tools/read.py +152 -0
- package/backend/src/flowent/tools/send.py +50 -0
- package/backend/src/flowent/tools/set_permissions.py +84 -0
- package/backend/src/flowent/tools/sleep.py +41 -0
- package/backend/src/flowent/tools/todo.py +51 -0
- package/backend/src/flowent/workspace_store.py +479 -0
- package/backend/tests/__init__.py +0 -0
- package/backend/tests/__pycache__/__init__.cpython-313.pyc +0 -0
- package/backend/tests/__pycache__/conftest.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/conftest.py +6 -0
- package/backend/tests/integration/api/__pycache__/conftest.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/integration/api/__pycache__/test_access_api.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/integration/api/__pycache__/test_assistant_api.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/integration/api/__pycache__/test_frontend_mounting.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/integration/api/__pycache__/test_mcp_api.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/integration/api/__pycache__/test_meta_api.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/integration/api/__pycache__/test_nodes_api.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/integration/api/__pycache__/test_prompts_api.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/integration/api/__pycache__/test_roles_api.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/integration/api/__pycache__/test_tabs_api.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/integration/api/conftest.py +29 -0
- package/backend/tests/integration/api/test_access_api.py +182 -0
- package/backend/tests/integration/api/test_assistant_api.py +354 -0
- package/backend/tests/integration/api/test_frontend_mounting.py +61 -0
- package/backend/tests/integration/api/test_mcp_api.py +116 -0
- package/backend/tests/integration/api/test_meta_api.py +33 -0
- package/backend/tests/integration/api/test_nodes_api.py +486 -0
- package/backend/tests/integration/api/test_prompts_api.py +47 -0
- package/backend/tests/integration/api/test_roles_api.py +227 -0
- package/backend/tests/integration/api/test_tabs_api.py +501 -0
- package/backend/tests/unit/__pycache__/test_access.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/__pycache__/test_cli.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/__pycache__/test_graph_runtime.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/__pycache__/test_network.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/__pycache__/test_state_sqlite_storage.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/__pycache__/test_workspace_store.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/agent/__pycache__/test_agent_public_api.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/agent/__pycache__/test_agent_runtime.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/agent/test_agent_public_api.py +746 -0
- package/backend/tests/unit/agent/test_agent_runtime.py +2726 -0
- package/backend/tests/unit/channels/__pycache__/test_telegram_channel.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/channels/test_telegram_channel.py +552 -0
- package/backend/tests/unit/logging/__pycache__/test_logging.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/logging/test_logging.py +132 -0
- package/backend/tests/unit/prompts/__pycache__/test_prompts.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/prompts/test_prompts.py +569 -0
- package/backend/tests/unit/providers/__pycache__/test_anthropic_provider.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/providers/__pycache__/test_errors.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/providers/__pycache__/test_extract_delta_parts.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/providers/__pycache__/test_openai_provider.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/providers/__pycache__/test_openai_responses.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/providers/__pycache__/test_provider_gateway.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/providers/__pycache__/test_think_tag_parser.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/providers/test_anthropic_provider.py +185 -0
- package/backend/tests/unit/providers/test_errors.py +68 -0
- package/backend/tests/unit/providers/test_extract_delta_parts.py +22 -0
- package/backend/tests/unit/providers/test_openai_provider.py +139 -0
- package/backend/tests/unit/providers/test_openai_responses.py +402 -0
- package/backend/tests/unit/providers/test_provider_gateway.py +359 -0
- package/backend/tests/unit/providers/test_think_tag_parser.py +36 -0
- package/backend/tests/unit/routes/__pycache__/test_prompts_routes.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/routes/__pycache__/test_providers_route.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/routes/__pycache__/test_roles_routes.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/routes/__pycache__/test_settings_routes.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/routes/__pycache__/test_stats_routes.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/routes/test_prompts_routes.py +104 -0
- package/backend/tests/unit/routes/test_providers_route.py +368 -0
- package/backend/tests/unit/routes/test_roles_routes.py +426 -0
- package/backend/tests/unit/routes/test_settings_routes.py +1138 -0
- package/backend/tests/unit/routes/test_stats_routes.py +149 -0
- package/backend/tests/unit/runtime/__pycache__/test_bootstrap_runtime.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/runtime/test_bootstrap_runtime.py +1012 -0
- package/backend/tests/unit/sandbox/__pycache__/test_sandbox_tools.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/sandbox/test_sandbox_tools.py +78 -0
- package/backend/tests/unit/security/__pycache__/test_security.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/security/test_security.py +110 -0
- package/backend/tests/unit/settings/__pycache__/test_settings_roles.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/settings/test_settings_roles.py +711 -0
- package/backend/tests/unit/test_access.py +45 -0
- package/backend/tests/unit/test_cli.py +124 -0
- package/backend/tests/unit/test_graph_runtime.py +72 -0
- package/backend/tests/unit/test_network.py +51 -0
- package/backend/tests/unit/test_state_sqlite_storage.py +93 -0
- package/backend/tests/unit/test_workspace_store.py +231 -0
- package/backend/tests/unit/tools/__pycache__/test_connect_tool.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/tools/__pycache__/test_create_agent_tool.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/tools/__pycache__/test_delete_tab_tool.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/tools/__pycache__/test_edit_tool.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/tools/__pycache__/test_exec_tool.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/tools/__pycache__/test_fetch_tool.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/tools/__pycache__/test_manage_prompts_tool.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/tools/__pycache__/test_manage_providers_tool.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/tools/__pycache__/test_manage_roles_tool.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/tools/__pycache__/test_manage_settings_tool.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/tools/__pycache__/test_read_tool.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/tools/__pycache__/test_set_permissions_tool.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/tools/__pycache__/test_todo_tool.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/tools/__pycache__/test_tool_registry.cpython-313-pytest-9.0.3.pyc +0 -0
- package/backend/tests/unit/tools/test_connect_tool.py +229 -0
- package/backend/tests/unit/tools/test_create_agent_tool.py +524 -0
- package/backend/tests/unit/tools/test_delete_tab_tool.py +83 -0
- package/backend/tests/unit/tools/test_edit_tool.py +115 -0
- package/backend/tests/unit/tools/test_exec_tool.py +81 -0
- package/backend/tests/unit/tools/test_fetch_tool.py +65 -0
- package/backend/tests/unit/tools/test_manage_prompts_tool.py +117 -0
- package/backend/tests/unit/tools/test_manage_providers_tool.py +458 -0
- package/backend/tests/unit/tools/test_manage_roles_tool.py +411 -0
- package/backend/tests/unit/tools/test_manage_settings_tool.py +608 -0
- package/backend/tests/unit/tools/test_read_tool.py +33 -0
- package/backend/tests/unit/tools/test_set_permissions_tool.py +391 -0
- package/backend/tests/unit/tools/test_todo_tool.py +37 -0
- package/backend/tests/unit/tools/test_tool_registry.py +91 -0
- package/backend/uv.lock +1144 -0
- package/bin/flowent.mjs +62 -36
- package/dist/frontend/assets/AssistantPage-B3Xc08AS.js +1 -0
- package/dist/frontend/assets/ChannelsPage-ByLd28xk.js +1 -0
- package/dist/frontend/assets/HomePage-C0hAx9_l.js +3 -0
- package/dist/frontend/assets/McpPage-DkrYLvBv.js +7 -0
- package/dist/frontend/assets/PageScaffold-D4jO9ooX.js +1 -0
- package/dist/frontend/assets/PromptsPage-DWA7rRJd.js +1 -0
- package/dist/frontend/assets/ProvidersPage-PUWT8seJ.js +3 -0
- package/dist/frontend/assets/RolesPage-CqcclGRw.js +1 -0
- package/dist/frontend/assets/SettingsPage-8tS2cJgX.js +3 -0
- package/dist/frontend/assets/StatsPage-BX9khYzu.js +1 -0
- package/dist/frontend/assets/ToolsPage-9Tl9FdeD.js +1 -0
- package/dist/frontend/assets/WorkspaceCommandDialog-CCXxjDL8.js +1 -0
- package/dist/frontend/assets/WorkspacePanels-aMdJ7ZH7.js +1 -0
- package/dist/frontend/assets/alert-dialog-kFYVQ7oX.js +1 -0
- package/dist/frontend/assets/badge-74-3jsCg.js +1 -0
- package/dist/frontend/assets/constants-XUzFf6i1.js +1 -0
- package/dist/frontend/assets/datetime-m6_O_Ci9.js +1 -0
- package/dist/frontend/assets/dialog-BeGSweF6.js +1 -0
- package/dist/frontend/assets/elk-worker.min-C9JGDOE-.js +6312 -0
- package/dist/frontend/assets/graph-vendor-CHpVij2M.css +1 -0
- package/dist/frontend/assets/graph-vendor-DRq_-6fV.js +7 -0
- package/dist/frontend/assets/index-BHC1Vhy8.css +1 -0
- package/dist/frontend/assets/index-CL1ALZ3r.js +10 -0
- package/dist/frontend/assets/layout.worker-jMHqAFbP.js +24 -0
- package/dist/frontend/assets/markdown-vendor-DVdy_w12.js +29 -0
- package/dist/frontend/assets/modelParams-CaHd0903.js +1 -0
- package/dist/frontend/assets/react-vendor-mEs_JJxa.js +9 -0
- package/dist/frontend/assets/roles-2OLDeTc5.js +1 -0
- package/dist/frontend/assets/rolldown-runtime-BYbx6iT9.js +1 -0
- package/dist/frontend/assets/select-DL_LPeDj.js +1 -0
- package/dist/frontend/assets/shared-CMxbpLeQ.js +1 -0
- package/dist/frontend/assets/triState-DEr3NkXV.js +1 -0
- package/dist/frontend/assets/ui-vendor-Dg9NNnWX.js +51 -0
- package/dist/frontend/index.html +36 -0
- package/package.json +27 -41
- package/dist/.next/BUILD_ID +0 -1
- package/dist/.next/app-path-routes-manifest.json +0 -6
- package/dist/.next/build-manifest.json +0 -20
- package/dist/.next/package.json +0 -1
- package/dist/.next/prerender-manifest.json +0 -114
- package/dist/.next/required-server-files.json +0 -333
- package/dist/.next/routes-manifest.json +0 -69
- package/dist/.next/server/app/_global-error/page/app-paths-manifest.json +0 -3
- package/dist/.next/server/app/_global-error/page/build-manifest.json +0 -16
- package/dist/.next/server/app/_global-error/page/next-font-manifest.json +0 -6
- package/dist/.next/server/app/_global-error/page/react-loadable-manifest.json +0 -1
- package/dist/.next/server/app/_global-error/page/server-reference-manifest.json +0 -4
- package/dist/.next/server/app/_global-error/page.js +0 -9
- package/dist/.next/server/app/_global-error/page.js.map +0 -5
- package/dist/.next/server/app/_global-error/page.js.nft.json +0 -1
- package/dist/.next/server/app/_global-error/page_client-reference-manifest.js +0 -3
- package/dist/.next/server/app/_global-error.html +0 -1
- package/dist/.next/server/app/_global-error.meta +0 -15
- package/dist/.next/server/app/_global-error.rsc +0 -14
- package/dist/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +0 -5
- package/dist/.next/server/app/_global-error.segments/_full.segment.rsc +0 -14
- package/dist/.next/server/app/_global-error.segments/_head.segment.rsc +0 -5
- package/dist/.next/server/app/_global-error.segments/_index.segment.rsc +0 -5
- package/dist/.next/server/app/_global-error.segments/_tree.segment.rsc +0 -1
- package/dist/.next/server/app/_not-found/page/app-paths-manifest.json +0 -3
- package/dist/.next/server/app/_not-found/page/build-manifest.json +0 -16
- package/dist/.next/server/app/_not-found/page/next-font-manifest.json +0 -10
- package/dist/.next/server/app/_not-found/page/react-loadable-manifest.json +0 -1
- package/dist/.next/server/app/_not-found/page/server-reference-manifest.json +0 -4
- package/dist/.next/server/app/_not-found/page.js +0 -13
- package/dist/.next/server/app/_not-found/page.js.map +0 -5
- package/dist/.next/server/app/_not-found/page.js.nft.json +0 -1
- package/dist/.next/server/app/_not-found/page_client-reference-manifest.js +0 -3
- package/dist/.next/server/app/_not-found.html +0 -1
- package/dist/.next/server/app/_not-found.meta +0 -16
- package/dist/.next/server/app/_not-found.rsc +0 -16
- package/dist/.next/server/app/_not-found.segments/_full.segment.rsc +0 -16
- package/dist/.next/server/app/_not-found.segments/_head.segment.rsc +0 -6
- package/dist/.next/server/app/_not-found.segments/_index.segment.rsc +0 -5
- package/dist/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +0 -5
- package/dist/.next/server/app/_not-found.segments/_not-found.segment.rsc +0 -5
- package/dist/.next/server/app/_not-found.segments/_tree.segment.rsc +0 -2
- package/dist/.next/server/app/icon.svg/route/app-paths-manifest.json +0 -3
- package/dist/.next/server/app/icon.svg/route/build-manifest.json +0 -9
- package/dist/.next/server/app/icon.svg/route.js +0 -6
- package/dist/.next/server/app/icon.svg/route.js.map +0 -5
- package/dist/.next/server/app/icon.svg/route.js.nft.json +0 -1
- package/dist/.next/server/app/icon.svg.meta +0 -1
- package/dist/.next/server/app/index.html +0 -1
- package/dist/.next/server/app/index.meta +0 -14
- package/dist/.next/server/app/index.rsc +0 -15
- package/dist/.next/server/app/index.segments/__PAGE__.segment.rsc +0 -5
- package/dist/.next/server/app/index.segments/_full.segment.rsc +0 -15
- package/dist/.next/server/app/index.segments/_head.segment.rsc +0 -6
- package/dist/.next/server/app/index.segments/_index.segment.rsc +0 -5
- package/dist/.next/server/app/index.segments/_tree.segment.rsc +0 -3
- package/dist/.next/server/app/page/app-paths-manifest.json +0 -3
- package/dist/.next/server/app/page/build-manifest.json +0 -16
- package/dist/.next/server/app/page/next-font-manifest.json +0 -10
- package/dist/.next/server/app/page/react-loadable-manifest.json +0 -1
- package/dist/.next/server/app/page/server-reference-manifest.json +0 -4
- package/dist/.next/server/app/page.js +0 -14
- package/dist/.next/server/app/page.js.map +0 -5
- package/dist/.next/server/app/page.js.nft.json +0 -1
- package/dist/.next/server/app/page_client-reference-manifest.js +0 -3
- package/dist/.next/server/app-paths-manifest.json +0 -6
- package/dist/.next/server/chunks/[externals]_next_dist_0arv.vj._.js +0 -3
- package/dist/.next/server/chunks/[root-of-the-server]__0vcj1q1._.js +0 -13
- package/dist/.next/server/chunks/[turbopack]_runtime.js +0 -903
- package/dist/.next/server/chunks/_next-internal_server_app_icon_svg_route_actions_0-0ehc~.js +0 -3
- package/dist/.next/server/chunks/ssr/05w9_next_dist_0ihu0u9._.js +0 -6
- package/dist/.next/server/chunks/ssr/05w9_next_dist_client_components_12u3mib._.js +0 -3
- package/dist/.next/server/chunks/ssr/05w9_next_dist_client_components_builtin_forbidden_04fbe_..js +0 -3
- package/dist/.next/server/chunks/ssr/05w9_next_dist_client_components_builtin_global-error_0brpl_..js +0 -3
- package/dist/.next/server/chunks/ssr/05w9_next_dist_client_components_builtin_unauthorized_0~2g66g.js +0 -3
- package/dist/.next/server/chunks/ssr/05w9_next_dist_esm_build_templates_app-page_0~cyr1_.js +0 -4
- package/dist/.next/server/chunks/ssr/05w9_next_dist_esm_build_templates_app-page_1105emf.js +0 -4
- package/dist/.next/server/chunks/ssr/05w9_next_dist_esm_build_templates_app-page_11uhyqv.js +0 -4
- package/dist/.next/server/chunks/ssr/[root-of-the-server]__0.t9_75._.js +0 -33
- package/dist/.next/server/chunks/ssr/[root-of-the-server]__0c0ud_z._.js +0 -3
- package/dist/.next/server/chunks/ssr/[root-of-the-server]__0f9_8d4._.js +0 -3
- package/dist/.next/server/chunks/ssr/[root-of-the-server]__0l5ko41._.js +0 -19
- package/dist/.next/server/chunks/ssr/[root-of-the-server]__0mn6z7i._.js +0 -3
- package/dist/.next/server/chunks/ssr/[root-of-the-server]__0npxxst._.js +0 -33
- package/dist/.next/server/chunks/ssr/[root-of-the-server]__0qjhaca._.js +0 -3
- package/dist/.next/server/chunks/ssr/[root-of-the-server]__0rwgw3s._.js +0 -3
- package/dist/.next/server/chunks/ssr/[turbopack]_runtime.js +0 -903
- package/dist/.next/server/chunks/ssr/_next-internal_server_app__global-error_page_actions_0k77kol.js +0 -3
- package/dist/.next/server/chunks/ssr/_next-internal_server_app__not-found_page_actions_0eq97pa.js +0 -3
- package/dist/.next/server/chunks/ssr/_next-internal_server_app_page_actions_09-gtaw.js +0 -3
- package/dist/.next/server/chunks/ssr/node_modules__pnpm_056~6.6._.js +0 -3
- package/dist/.next/server/chunks/ssr/node_modules__pnpm_0~j0k.e._.js +0 -33
- package/dist/.next/server/functions-config-manifest.json +0 -4
- package/dist/.next/server/middleware-build-manifest.js +0 -20
- package/dist/.next/server/middleware-manifest.json +0 -6
- package/dist/.next/server/next-font-manifest.js +0 -1
- package/dist/.next/server/next-font-manifest.json +0 -13
- package/dist/.next/server/pages/404.html +0 -1
- package/dist/.next/server/pages/500.html +0 -1
- package/dist/.next/server/pages-manifest.json +0 -4
- package/dist/.next/server/prefetch-hints.json +0 -1
- package/dist/.next/server/server-reference-manifest.js +0 -1
- package/dist/.next/server/server-reference-manifest.json +0 -5
- package/dist/.next/static/SMWpxFVvkpYFxY7uuFvGB/_buildManifest.js +0 -11
- package/dist/.next/static/SMWpxFVvkpYFxY7uuFvGB/_clientMiddlewareManifest.js +0 -1
- package/dist/.next/static/SMWpxFVvkpYFxY7uuFvGB/_ssgManifest.js +0 -1
- package/dist/.next/static/chunks/01qk2~bgf76vu.js +0 -1
- package/dist/.next/static/chunks/03~yq9q893hmn.js +0 -1
- package/dist/.next/static/chunks/080queev.r2uy.js +0 -31
- package/dist/.next/static/chunks/0v3lyuj75aq50.js +0 -1
- package/dist/.next/static/chunks/10b~xdx5c-i7s.js +0 -5
- package/dist/.next/static/chunks/14gla2ascffgv.css +0 -2
- package/dist/.next/static/chunks/turbopack-0m-970~qvs7sc.js +0 -1
- package/dist/.next/static/media/7178b3e590c64307-s.11.cyxs5p-0z~.woff2 +0 -0
- package/dist/.next/static/media/8a480f0b521d4e75-s.06d3mdzz5bre_.woff2 +0 -0
- package/dist/.next/static/media/caa3a2e1cccd8315-s.p.16t1db8_9y2o~.woff2 +0 -0
- package/dist/package.json +0 -88
- package/dist/server.js +0 -38
- /package/{dist/.next/server/app/icon.svg.body → backend/src/flowent/static/favicon.svg} +0 -0
- /package/dist/{.next/static/media/icon.0.r~afrtrocz9.svg → frontend/favicon.svg} +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import time
|
|
4
|
+
from dataclasses import dataclass, field
|
|
5
|
+
from enum import StrEnum
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class EventType(StrEnum):
|
|
10
|
+
TAB_CREATED = "tab_created"
|
|
11
|
+
TAB_UPDATED = "tab_updated"
|
|
12
|
+
TAB_DELETED = "tab_deleted"
|
|
13
|
+
NODE_CREATED = "node_created"
|
|
14
|
+
NODE_STATE_CHANGED = "node_state_changed"
|
|
15
|
+
NODE_TODOS_CHANGED = "node_todos_changed"
|
|
16
|
+
NODE_MESSAGE = "node_message"
|
|
17
|
+
NODE_TERMINATED = "node_terminated"
|
|
18
|
+
NODE_DELETED = "node_deleted"
|
|
19
|
+
NODE_CONNECTED = "node_connected"
|
|
20
|
+
NODE_DISCONNECTED = "node_disconnected"
|
|
21
|
+
ASSISTANT_CONTENT = "assistant_content"
|
|
22
|
+
TOOL_CALLED = "tool_called"
|
|
23
|
+
HISTORY_CLEARED = "history_cleared"
|
|
24
|
+
HISTORY_REPLACED = "history_replaced"
|
|
25
|
+
HISTORY_ENTRY_ADDED = "history_entry_added"
|
|
26
|
+
HISTORY_ENTRY_DELTA = "history_entry_delta"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
DISPLAY_EVENTS: set[EventType] = {
|
|
30
|
+
EventType.TAB_CREATED,
|
|
31
|
+
EventType.TAB_UPDATED,
|
|
32
|
+
EventType.TAB_DELETED,
|
|
33
|
+
EventType.NODE_CREATED,
|
|
34
|
+
EventType.NODE_STATE_CHANGED,
|
|
35
|
+
EventType.NODE_TODOS_CHANGED,
|
|
36
|
+
EventType.NODE_MESSAGE,
|
|
37
|
+
EventType.NODE_TERMINATED,
|
|
38
|
+
EventType.NODE_DELETED,
|
|
39
|
+
EventType.NODE_CONNECTED,
|
|
40
|
+
EventType.NODE_DISCONNECTED,
|
|
41
|
+
EventType.ASSISTANT_CONTENT,
|
|
42
|
+
EventType.TOOL_CALLED,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@dataclass
|
|
47
|
+
class Event:
|
|
48
|
+
type: EventType
|
|
49
|
+
agent_id: str
|
|
50
|
+
data: dict[str, Any] = field(default_factory=dict)
|
|
51
|
+
timestamp: float = field(default_factory=time.time)
|
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import time
|
|
4
|
+
from dataclasses import dataclass, field
|
|
5
|
+
from enum import StrEnum
|
|
6
|
+
|
|
7
|
+
from flowent.models.agent import AgentState, NodeConfig, NodeType
|
|
8
|
+
from flowent.models.history import HistoryEntry, deserialize_history_entries
|
|
9
|
+
from flowent.models.todo import TodoItem
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class WorkflowNodeKind(StrEnum):
|
|
13
|
+
TRIGGER = "trigger"
|
|
14
|
+
AGENT = "agent"
|
|
15
|
+
CODE = "code"
|
|
16
|
+
IF = "if"
|
|
17
|
+
MERGE = "merge"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class PortDirection(StrEnum):
|
|
21
|
+
INPUT = "input"
|
|
22
|
+
OUTPUT = "output"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class EdgeKind(StrEnum):
|
|
26
|
+
CONTROL = "control"
|
|
27
|
+
DATA = "data"
|
|
28
|
+
EVENT = "event"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass
|
|
32
|
+
class NodePosition:
|
|
33
|
+
x: float
|
|
34
|
+
y: float
|
|
35
|
+
|
|
36
|
+
def serialize(self) -> dict[str, float]:
|
|
37
|
+
return {"x": self.x, "y": self.y}
|
|
38
|
+
|
|
39
|
+
@classmethod
|
|
40
|
+
def from_mapping(cls, data: dict[str, object] | None) -> NodePosition | None:
|
|
41
|
+
if not isinstance(data, dict):
|
|
42
|
+
return None
|
|
43
|
+
x = data.get("x")
|
|
44
|
+
y = data.get("y")
|
|
45
|
+
if not isinstance(x, (int, float)) or not isinstance(y, (int, float)):
|
|
46
|
+
return None
|
|
47
|
+
return cls(x=float(x), y=float(y))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass
|
|
51
|
+
class WorkflowPort:
|
|
52
|
+
key: str
|
|
53
|
+
direction: PortDirection
|
|
54
|
+
kind: EdgeKind
|
|
55
|
+
required: bool = False
|
|
56
|
+
multiple: bool = False
|
|
57
|
+
|
|
58
|
+
def serialize(self) -> dict[str, object]:
|
|
59
|
+
return {
|
|
60
|
+
"key": self.key,
|
|
61
|
+
"direction": self.direction.value,
|
|
62
|
+
"kind": self.kind.value,
|
|
63
|
+
"required": self.required,
|
|
64
|
+
"multiple": self.multiple,
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@classmethod
|
|
68
|
+
def from_mapping(cls, data: dict[str, object]) -> WorkflowPort | None:
|
|
69
|
+
key = data.get("key")
|
|
70
|
+
direction = data.get("direction")
|
|
71
|
+
kind = data.get("kind")
|
|
72
|
+
if not isinstance(key, str) or not key.strip():
|
|
73
|
+
return None
|
|
74
|
+
try:
|
|
75
|
+
parsed_direction = PortDirection(str(direction))
|
|
76
|
+
parsed_kind = EdgeKind(str(kind))
|
|
77
|
+
except ValueError:
|
|
78
|
+
return None
|
|
79
|
+
return cls(
|
|
80
|
+
key=key.strip(),
|
|
81
|
+
direction=parsed_direction,
|
|
82
|
+
kind=parsed_kind,
|
|
83
|
+
required=bool(data.get("required", False)),
|
|
84
|
+
multiple=bool(data.get("multiple", False)),
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@dataclass
|
|
89
|
+
class GraphEdge:
|
|
90
|
+
id: str
|
|
91
|
+
from_node_id: str
|
|
92
|
+
from_port_key: str
|
|
93
|
+
to_node_id: str
|
|
94
|
+
to_port_key: str
|
|
95
|
+
kind: EdgeKind = EdgeKind.CONTROL
|
|
96
|
+
tab_id: str | None = None
|
|
97
|
+
created_at: float = field(default_factory=time.time)
|
|
98
|
+
|
|
99
|
+
def serialize(self) -> dict[str, object]:
|
|
100
|
+
payload: dict[str, object] = {
|
|
101
|
+
"id": self.id,
|
|
102
|
+
"from_node_id": self.from_node_id,
|
|
103
|
+
"from_port_key": self.from_port_key,
|
|
104
|
+
"to_node_id": self.to_node_id,
|
|
105
|
+
"to_port_key": self.to_port_key,
|
|
106
|
+
"kind": self.kind.value,
|
|
107
|
+
"created_at": self.created_at,
|
|
108
|
+
}
|
|
109
|
+
if self.tab_id is not None:
|
|
110
|
+
payload["tab_id"] = self.tab_id
|
|
111
|
+
return payload
|
|
112
|
+
|
|
113
|
+
@classmethod
|
|
114
|
+
def from_mapping(cls, data: dict[str, object]) -> GraphEdge:
|
|
115
|
+
created_at = data.get("created_at")
|
|
116
|
+
kind = data.get("kind")
|
|
117
|
+
try:
|
|
118
|
+
parsed_kind = EdgeKind(str(kind))
|
|
119
|
+
except ValueError:
|
|
120
|
+
parsed_kind = EdgeKind.CONTROL
|
|
121
|
+
from_port_key = data.get("from_port_key")
|
|
122
|
+
to_port_key = data.get("to_port_key")
|
|
123
|
+
return cls(
|
|
124
|
+
id=str(data.get("id", "")),
|
|
125
|
+
tab_id=str(data["tab_id"]) if isinstance(data.get("tab_id"), str) else None,
|
|
126
|
+
from_node_id=str(data.get("from_node_id", "")),
|
|
127
|
+
from_port_key=(
|
|
128
|
+
str(from_port_key)
|
|
129
|
+
if isinstance(from_port_key, str) and from_port_key.strip()
|
|
130
|
+
else "out"
|
|
131
|
+
),
|
|
132
|
+
to_node_id=str(data.get("to_node_id", "")),
|
|
133
|
+
to_port_key=(
|
|
134
|
+
str(to_port_key)
|
|
135
|
+
if isinstance(to_port_key, str) and to_port_key.strip()
|
|
136
|
+
else "in"
|
|
137
|
+
),
|
|
138
|
+
kind=parsed_kind,
|
|
139
|
+
created_at=created_at
|
|
140
|
+
if isinstance(created_at, (int, float))
|
|
141
|
+
else time.time(),
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
@dataclass
|
|
146
|
+
class WorkflowNodeDefinition:
|
|
147
|
+
id: str
|
|
148
|
+
type: WorkflowNodeKind
|
|
149
|
+
config: dict[str, object] = field(default_factory=dict)
|
|
150
|
+
inputs: list[WorkflowPort] = field(default_factory=list)
|
|
151
|
+
outputs: list[WorkflowPort] = field(default_factory=list)
|
|
152
|
+
|
|
153
|
+
def serialize(self) -> dict[str, object]:
|
|
154
|
+
return {
|
|
155
|
+
"id": self.id,
|
|
156
|
+
"type": self.type.value,
|
|
157
|
+
"config": dict(self.config),
|
|
158
|
+
"inputs": [port.serialize() for port in self.inputs],
|
|
159
|
+
"outputs": [port.serialize() for port in self.outputs],
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@classmethod
|
|
163
|
+
def from_mapping(
|
|
164
|
+
cls,
|
|
165
|
+
data: dict[str, object],
|
|
166
|
+
) -> WorkflowNodeDefinition | None:
|
|
167
|
+
node_id = data.get("id")
|
|
168
|
+
node_type = data.get("type")
|
|
169
|
+
if not isinstance(node_id, str) or not node_id.strip():
|
|
170
|
+
return None
|
|
171
|
+
try:
|
|
172
|
+
parsed_type = WorkflowNodeKind(str(node_type))
|
|
173
|
+
except ValueError:
|
|
174
|
+
return None
|
|
175
|
+
raw_config = data.get("config")
|
|
176
|
+
raw_inputs = data.get("inputs")
|
|
177
|
+
raw_outputs = data.get("outputs")
|
|
178
|
+
return cls(
|
|
179
|
+
id=node_id.strip(),
|
|
180
|
+
type=parsed_type,
|
|
181
|
+
config=dict(raw_config) if isinstance(raw_config, dict) else {},
|
|
182
|
+
inputs=[
|
|
183
|
+
port
|
|
184
|
+
for port in (
|
|
185
|
+
WorkflowPort.from_mapping(item)
|
|
186
|
+
for item in (raw_inputs if isinstance(raw_inputs, list) else [])
|
|
187
|
+
if isinstance(item, dict)
|
|
188
|
+
)
|
|
189
|
+
if port is not None
|
|
190
|
+
],
|
|
191
|
+
outputs=[
|
|
192
|
+
port
|
|
193
|
+
for port in (
|
|
194
|
+
WorkflowPort.from_mapping(item)
|
|
195
|
+
for item in (raw_outputs if isinstance(raw_outputs, list) else [])
|
|
196
|
+
if isinstance(item, dict)
|
|
197
|
+
)
|
|
198
|
+
if port is not None
|
|
199
|
+
],
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
@dataclass
|
|
204
|
+
class WorkflowViewDefinition:
|
|
205
|
+
positions: dict[str, NodePosition] = field(default_factory=dict)
|
|
206
|
+
|
|
207
|
+
def serialize(self) -> dict[str, object]:
|
|
208
|
+
if not self.positions:
|
|
209
|
+
return {}
|
|
210
|
+
return {
|
|
211
|
+
"positions": {
|
|
212
|
+
node_id: position.serialize()
|
|
213
|
+
for node_id, position in self.positions.items()
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
@classmethod
|
|
218
|
+
def from_mapping(cls, data: dict[str, object] | None) -> WorkflowViewDefinition:
|
|
219
|
+
if not isinstance(data, dict):
|
|
220
|
+
return cls()
|
|
221
|
+
raw_positions = data.get("positions")
|
|
222
|
+
if not isinstance(raw_positions, dict):
|
|
223
|
+
return cls()
|
|
224
|
+
positions = {
|
|
225
|
+
str(node_id): position
|
|
226
|
+
for node_id, position in (
|
|
227
|
+
(
|
|
228
|
+
node_id,
|
|
229
|
+
NodePosition.from_mapping(payload),
|
|
230
|
+
)
|
|
231
|
+
for node_id, payload in raw_positions.items()
|
|
232
|
+
if isinstance(node_id, str) and isinstance(payload, dict)
|
|
233
|
+
)
|
|
234
|
+
if position is not None
|
|
235
|
+
}
|
|
236
|
+
return cls(positions=positions)
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
@dataclass
|
|
240
|
+
class WorkflowDefinition:
|
|
241
|
+
version: int = 1
|
|
242
|
+
nodes: list[WorkflowNodeDefinition] = field(default_factory=list)
|
|
243
|
+
edges: list[GraphEdge] = field(default_factory=list)
|
|
244
|
+
view: WorkflowViewDefinition = field(default_factory=WorkflowViewDefinition)
|
|
245
|
+
|
|
246
|
+
def serialize(self) -> dict[str, object]:
|
|
247
|
+
payload: dict[str, object] = {
|
|
248
|
+
"version": self.version,
|
|
249
|
+
"nodes": [node.serialize() for node in self.nodes],
|
|
250
|
+
"edges": [edge.serialize() for edge in self.edges],
|
|
251
|
+
}
|
|
252
|
+
serialized_view = self.view.serialize()
|
|
253
|
+
if serialized_view:
|
|
254
|
+
payload["view"] = serialized_view
|
|
255
|
+
return payload
|
|
256
|
+
|
|
257
|
+
@classmethod
|
|
258
|
+
def from_mapping(cls, data: dict[str, object] | None) -> WorkflowDefinition:
|
|
259
|
+
if not isinstance(data, dict):
|
|
260
|
+
return cls()
|
|
261
|
+
raw_version = data.get("version")
|
|
262
|
+
raw_nodes = data.get("nodes")
|
|
263
|
+
raw_edges = data.get("edges")
|
|
264
|
+
raw_view = data.get("view")
|
|
265
|
+
return cls(
|
|
266
|
+
version=raw_version
|
|
267
|
+
if isinstance(raw_version, int) and raw_version > 0
|
|
268
|
+
else 1,
|
|
269
|
+
nodes=[
|
|
270
|
+
node
|
|
271
|
+
for node in (
|
|
272
|
+
WorkflowNodeDefinition.from_mapping(item)
|
|
273
|
+
for item in (raw_nodes if isinstance(raw_nodes, list) else [])
|
|
274
|
+
if isinstance(item, dict)
|
|
275
|
+
)
|
|
276
|
+
if node is not None
|
|
277
|
+
],
|
|
278
|
+
edges=[
|
|
279
|
+
GraphEdge.from_mapping(item)
|
|
280
|
+
for item in (raw_edges if isinstance(raw_edges, list) else [])
|
|
281
|
+
if isinstance(item, dict)
|
|
282
|
+
],
|
|
283
|
+
view=WorkflowViewDefinition.from_mapping(
|
|
284
|
+
raw_view if isinstance(raw_view, dict) else None
|
|
285
|
+
),
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
def get_node(self, node_id: str) -> WorkflowNodeDefinition | None:
|
|
289
|
+
return next((node for node in self.nodes if node.id == node_id), None)
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
@dataclass
|
|
293
|
+
class GraphNodeRecord:
|
|
294
|
+
id: str
|
|
295
|
+
config: NodeConfig
|
|
296
|
+
state: AgentState
|
|
297
|
+
todos: list[TodoItem] = field(default_factory=list)
|
|
298
|
+
history: list[HistoryEntry] = field(default_factory=list)
|
|
299
|
+
execution_context_summary: str = ""
|
|
300
|
+
execution_context_history_cutoff: int = 0
|
|
301
|
+
position: NodePosition | None = None
|
|
302
|
+
created_at: float = field(default_factory=time.time)
|
|
303
|
+
updated_at: float = field(default_factory=time.time)
|
|
304
|
+
|
|
305
|
+
def serialize(self) -> dict[str, object]:
|
|
306
|
+
return {
|
|
307
|
+
"id": self.id,
|
|
308
|
+
"config": {
|
|
309
|
+
"node_type": self.config.node_type.value,
|
|
310
|
+
"role_name": self.config.role_name,
|
|
311
|
+
"tab_id": self.config.tab_id,
|
|
312
|
+
"name": self.config.name,
|
|
313
|
+
"tools": list(self.config.tools),
|
|
314
|
+
"write_dirs": list(self.config.write_dirs),
|
|
315
|
+
"allow_network": self.config.allow_network,
|
|
316
|
+
},
|
|
317
|
+
"state": self.state.value,
|
|
318
|
+
"todos": [item.serialize() for item in self.todos],
|
|
319
|
+
"history": [entry.serialize() for entry in self.history],
|
|
320
|
+
"execution_context_summary": self.execution_context_summary,
|
|
321
|
+
"execution_context_history_cutoff": self.execution_context_history_cutoff,
|
|
322
|
+
"position": self.position.serialize()
|
|
323
|
+
if self.position is not None
|
|
324
|
+
else None,
|
|
325
|
+
"created_at": self.created_at,
|
|
326
|
+
"updated_at": self.updated_at,
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
@classmethod
|
|
330
|
+
def from_mapping(cls, data: dict[str, object]) -> GraphNodeRecord:
|
|
331
|
+
from flowent.settings import (
|
|
332
|
+
build_assistant_write_dirs,
|
|
333
|
+
normalize_tool_names,
|
|
334
|
+
)
|
|
335
|
+
|
|
336
|
+
raw_config = data.get("config")
|
|
337
|
+
config = raw_config if isinstance(raw_config, dict) else {}
|
|
338
|
+
raw_todos = data.get("todos")
|
|
339
|
+
raw_history = data.get("history")
|
|
340
|
+
raw_execution_context_summary = data.get("execution_context_summary")
|
|
341
|
+
raw_execution_context_history_cutoff = data.get(
|
|
342
|
+
"execution_context_history_cutoff"
|
|
343
|
+
)
|
|
344
|
+
created_at = data.get("created_at")
|
|
345
|
+
updated_at = data.get("updated_at")
|
|
346
|
+
raw_state = data.get("state")
|
|
347
|
+
|
|
348
|
+
node_type = config.get("node_type")
|
|
349
|
+
try:
|
|
350
|
+
parsed_node_type = NodeType(str(node_type))
|
|
351
|
+
except ValueError:
|
|
352
|
+
parsed_node_type = NodeType.AGENT
|
|
353
|
+
|
|
354
|
+
try:
|
|
355
|
+
state = AgentState(str(raw_state))
|
|
356
|
+
except ValueError:
|
|
357
|
+
state = AgentState.INITIALIZING
|
|
358
|
+
|
|
359
|
+
todos = []
|
|
360
|
+
if isinstance(raw_todos, list):
|
|
361
|
+
todos = [
|
|
362
|
+
TodoItem(text=str(item.get("text", "")))
|
|
363
|
+
for item in raw_todos
|
|
364
|
+
if isinstance(item, dict)
|
|
365
|
+
]
|
|
366
|
+
|
|
367
|
+
history_items: list[HistoryEntry] = []
|
|
368
|
+
if isinstance(raw_history, list):
|
|
369
|
+
history_items = deserialize_history_entries(
|
|
370
|
+
[item for item in raw_history if isinstance(item, dict)]
|
|
371
|
+
)
|
|
372
|
+
raw_position = data.get("position")
|
|
373
|
+
|
|
374
|
+
raw_write_dirs = (
|
|
375
|
+
[
|
|
376
|
+
str(item)
|
|
377
|
+
for item in config.get("write_dirs", [])
|
|
378
|
+
if isinstance(item, str)
|
|
379
|
+
]
|
|
380
|
+
if isinstance(config.get("write_dirs"), list)
|
|
381
|
+
else []
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
return cls(
|
|
385
|
+
id=str(data.get("id", "")),
|
|
386
|
+
config=NodeConfig(
|
|
387
|
+
node_type=parsed_node_type,
|
|
388
|
+
role_name=(
|
|
389
|
+
str(config["role_name"])
|
|
390
|
+
if isinstance(config.get("role_name"), str)
|
|
391
|
+
else None
|
|
392
|
+
),
|
|
393
|
+
tab_id=str(config["tab_id"])
|
|
394
|
+
if isinstance(config.get("tab_id"), str)
|
|
395
|
+
else None,
|
|
396
|
+
name=str(config["name"])
|
|
397
|
+
if isinstance(config.get("name"), str)
|
|
398
|
+
else None,
|
|
399
|
+
tools=normalize_tool_names(
|
|
400
|
+
[
|
|
401
|
+
str(item)
|
|
402
|
+
for item in config.get("tools", [])
|
|
403
|
+
if isinstance(item, str)
|
|
404
|
+
]
|
|
405
|
+
if isinstance(config.get("tools"), list)
|
|
406
|
+
else []
|
|
407
|
+
),
|
|
408
|
+
write_dirs=build_assistant_write_dirs(
|
|
409
|
+
raw_write_dirs,
|
|
410
|
+
field_name="write_dirs",
|
|
411
|
+
),
|
|
412
|
+
allow_network=bool(config.get("allow_network", False)),
|
|
413
|
+
),
|
|
414
|
+
state=state,
|
|
415
|
+
todos=todos,
|
|
416
|
+
history=history_items,
|
|
417
|
+
execution_context_summary=(
|
|
418
|
+
str(raw_execution_context_summary)
|
|
419
|
+
if isinstance(raw_execution_context_summary, str)
|
|
420
|
+
else ""
|
|
421
|
+
),
|
|
422
|
+
execution_context_history_cutoff=(
|
|
423
|
+
raw_execution_context_history_cutoff
|
|
424
|
+
if isinstance(raw_execution_context_history_cutoff, int)
|
|
425
|
+
and raw_execution_context_history_cutoff >= 0
|
|
426
|
+
else 0
|
|
427
|
+
),
|
|
428
|
+
position=NodePosition.from_mapping(
|
|
429
|
+
raw_position if isinstance(raw_position, dict) else None
|
|
430
|
+
),
|
|
431
|
+
created_at=created_at
|
|
432
|
+
if isinstance(created_at, (int, float))
|
|
433
|
+
else time.time(),
|
|
434
|
+
updated_at=updated_at
|
|
435
|
+
if isinstance(updated_at, (int, float))
|
|
436
|
+
else time.time(),
|
|
437
|
+
)
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import time
|
|
4
|
+
from dataclasses import dataclass, field
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from flowent.models.base import Serializable
|
|
8
|
+
from flowent.models.content import (
|
|
9
|
+
ContentPart,
|
|
10
|
+
content_parts_to_text,
|
|
11
|
+
deserialize_content_parts,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class SystemEntry(Serializable):
|
|
17
|
+
content: str
|
|
18
|
+
timestamp: float = field(default_factory=time.time)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass
|
|
22
|
+
class ReceivedMessage(Serializable):
|
|
23
|
+
from_id: str
|
|
24
|
+
parts: list[ContentPart] = field(default_factory=list)
|
|
25
|
+
content: str = ""
|
|
26
|
+
message_id: str | None = None
|
|
27
|
+
timestamp: float = field(default_factory=time.time)
|
|
28
|
+
|
|
29
|
+
def __post_init__(self) -> None:
|
|
30
|
+
if self.parts and not self.content:
|
|
31
|
+
self.content = content_parts_to_text(self.parts)
|
|
32
|
+
elif self.content and not self.parts:
|
|
33
|
+
self.parts = deserialize_content_parts(None, fallback_text=self.content)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclass
|
|
37
|
+
class AssistantText(Serializable):
|
|
38
|
+
parts: list[ContentPart] = field(default_factory=list)
|
|
39
|
+
content: str = ""
|
|
40
|
+
timestamp: float = field(default_factory=time.time)
|
|
41
|
+
|
|
42
|
+
def __post_init__(self) -> None:
|
|
43
|
+
if self.parts and not self.content:
|
|
44
|
+
self.content = content_parts_to_text(self.parts)
|
|
45
|
+
elif self.content and not self.parts:
|
|
46
|
+
self.parts = deserialize_content_parts(None, fallback_text=self.content)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@dataclass
|
|
50
|
+
class SentMessage(Serializable):
|
|
51
|
+
to_id: str
|
|
52
|
+
parts: list[ContentPart] = field(default_factory=list)
|
|
53
|
+
content: str = ""
|
|
54
|
+
message_id: str | None = None
|
|
55
|
+
timestamp: float = field(default_factory=time.time)
|
|
56
|
+
|
|
57
|
+
def __post_init__(self) -> None:
|
|
58
|
+
if self.parts and not self.content:
|
|
59
|
+
self.content = content_parts_to_text(self.parts)
|
|
60
|
+
elif self.content and not self.parts:
|
|
61
|
+
self.parts = deserialize_content_parts(None, fallback_text=self.content)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@dataclass
|
|
65
|
+
class AssistantThinking(Serializable):
|
|
66
|
+
content: str
|
|
67
|
+
timestamp: float = field(default_factory=time.time)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@dataclass
|
|
71
|
+
class StateEntry(Serializable):
|
|
72
|
+
state: str
|
|
73
|
+
reason: str = ""
|
|
74
|
+
timestamp: float = field(default_factory=time.time)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@dataclass
|
|
78
|
+
class ToolCall(Serializable):
|
|
79
|
+
tool_name: str
|
|
80
|
+
tool_call_id: str
|
|
81
|
+
arguments: dict[str, Any]
|
|
82
|
+
result: str | None = None
|
|
83
|
+
streaming: bool = False
|
|
84
|
+
timestamp: float = field(default_factory=time.time)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@dataclass
|
|
88
|
+
class ErrorEntry(Serializable):
|
|
89
|
+
content: str
|
|
90
|
+
timestamp: float = field(default_factory=time.time)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@dataclass
|
|
94
|
+
class CommandResultEntry(Serializable):
|
|
95
|
+
command_name: str
|
|
96
|
+
content: str
|
|
97
|
+
include_in_context: bool = False
|
|
98
|
+
timestamp: float = field(default_factory=time.time)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
HistoryEntry = (
|
|
102
|
+
SystemEntry
|
|
103
|
+
| ReceivedMessage
|
|
104
|
+
| AssistantText
|
|
105
|
+
| SentMessage
|
|
106
|
+
| AssistantThinking
|
|
107
|
+
| StateEntry
|
|
108
|
+
| ToolCall
|
|
109
|
+
| ErrorEntry
|
|
110
|
+
| CommandResultEntry
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def deserialize_history_entry(data: dict[str, Any]) -> HistoryEntry:
|
|
115
|
+
entry_type = data.get("type")
|
|
116
|
+
timestamp = data.get("timestamp")
|
|
117
|
+
timestamp_value = timestamp if isinstance(timestamp, (int, float)) else time.time()
|
|
118
|
+
|
|
119
|
+
if entry_type == "SystemEntry":
|
|
120
|
+
return SystemEntry(
|
|
121
|
+
content=str(data.get("content", "")),
|
|
122
|
+
timestamp=timestamp_value,
|
|
123
|
+
)
|
|
124
|
+
if entry_type == "ReceivedMessage":
|
|
125
|
+
parts = deserialize_content_parts(
|
|
126
|
+
data.get("parts"),
|
|
127
|
+
fallback_text=str(data.get("content", "")),
|
|
128
|
+
)
|
|
129
|
+
return ReceivedMessage(
|
|
130
|
+
from_id=str(data.get("from_id", "")),
|
|
131
|
+
parts=parts,
|
|
132
|
+
content=content_parts_to_text(parts),
|
|
133
|
+
message_id=(
|
|
134
|
+
str(data["message_id"])
|
|
135
|
+
if isinstance(data.get("message_id"), str)
|
|
136
|
+
else None
|
|
137
|
+
),
|
|
138
|
+
timestamp=timestamp_value,
|
|
139
|
+
)
|
|
140
|
+
if entry_type == "AssistantText":
|
|
141
|
+
parts = deserialize_content_parts(
|
|
142
|
+
data.get("parts"),
|
|
143
|
+
fallback_text=str(data.get("content", "")),
|
|
144
|
+
)
|
|
145
|
+
return AssistantText(
|
|
146
|
+
parts=parts,
|
|
147
|
+
content=content_parts_to_text(parts),
|
|
148
|
+
timestamp=timestamp_value,
|
|
149
|
+
)
|
|
150
|
+
if entry_type == "SentMessage":
|
|
151
|
+
parts = deserialize_content_parts(
|
|
152
|
+
data.get("parts"),
|
|
153
|
+
fallback_text=str(data.get("content", "")),
|
|
154
|
+
)
|
|
155
|
+
to_id = (
|
|
156
|
+
str(data["to_id"])
|
|
157
|
+
if isinstance(data.get("to_id"), str)
|
|
158
|
+
else (
|
|
159
|
+
str(data["to_ids"][0])
|
|
160
|
+
if isinstance(data.get("to_ids"), list)
|
|
161
|
+
and data["to_ids"]
|
|
162
|
+
and isinstance(data["to_ids"][0], str)
|
|
163
|
+
else ""
|
|
164
|
+
)
|
|
165
|
+
)
|
|
166
|
+
return SentMessage(
|
|
167
|
+
to_id=to_id,
|
|
168
|
+
parts=parts,
|
|
169
|
+
content=content_parts_to_text(parts),
|
|
170
|
+
message_id=(
|
|
171
|
+
str(data["message_id"])
|
|
172
|
+
if isinstance(data.get("message_id"), str)
|
|
173
|
+
else None
|
|
174
|
+
),
|
|
175
|
+
timestamp=timestamp_value,
|
|
176
|
+
)
|
|
177
|
+
if entry_type == "AssistantThinking":
|
|
178
|
+
return AssistantThinking(
|
|
179
|
+
content=str(data.get("content", "")),
|
|
180
|
+
timestamp=timestamp_value,
|
|
181
|
+
)
|
|
182
|
+
if entry_type == "StateEntry":
|
|
183
|
+
return StateEntry(
|
|
184
|
+
state=str(data.get("state", "")),
|
|
185
|
+
reason=str(data.get("reason", "")),
|
|
186
|
+
timestamp=timestamp_value,
|
|
187
|
+
)
|
|
188
|
+
if entry_type == "ToolCall":
|
|
189
|
+
arguments = data.get("arguments")
|
|
190
|
+
return ToolCall(
|
|
191
|
+
tool_name=str(data.get("tool_name", "")),
|
|
192
|
+
tool_call_id=str(data.get("tool_call_id", "")),
|
|
193
|
+
arguments=arguments if isinstance(arguments, dict) else {},
|
|
194
|
+
result=str(data["result"]) if isinstance(data.get("result"), str) else None,
|
|
195
|
+
streaming=bool(data.get("streaming", False)),
|
|
196
|
+
timestamp=timestamp_value,
|
|
197
|
+
)
|
|
198
|
+
if entry_type == "ErrorEntry":
|
|
199
|
+
return ErrorEntry(
|
|
200
|
+
content=str(data.get("content", "")),
|
|
201
|
+
timestamp=timestamp_value,
|
|
202
|
+
)
|
|
203
|
+
if entry_type == "CommandResultEntry":
|
|
204
|
+
return CommandResultEntry(
|
|
205
|
+
command_name=str(data.get("command_name", "")),
|
|
206
|
+
content=str(data.get("content", "")),
|
|
207
|
+
include_in_context=bool(data.get("include_in_context", False)),
|
|
208
|
+
timestamp=timestamp_value,
|
|
209
|
+
)
|
|
210
|
+
raise ValueError(f"Unknown history entry type: {entry_type}")
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def deserialize_history_entries(items: list[dict[str, Any]]) -> list[HistoryEntry]:
|
|
214
|
+
return [deserialize_history_entry(item) for item in items]
|