cconnect 2.0.9__tar.gz → 2.1.0__tar.gz
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.
- {cconnect-2.0.9 → cconnect-2.1.0}/PKG-INFO +1 -1
- {cconnect-2.0.9 → cconnect-2.1.0}/cconnect.egg-info/PKG-INFO +1 -1
- {cconnect-2.0.9 → cconnect-2.1.0}/cconnect.egg-info/SOURCES.txt +4 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/app.py +1 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/cli.py +23 -9
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/schema.json +2 -2
- {cconnect-2.0.9 → cconnect-2.1.0}/core/paths.py +9 -0
- cconnect-2.1.0/core/prompts/INSTALL.md +33 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/release.py +1 -1
- {cconnect-2.0.9 → cconnect-2.1.0}/core/responses.py +13 -1
- {cconnect-2.0.9 → cconnect-2.1.0}/mcps/media.py +2 -1
- {cconnect-2.0.9 → cconnect-2.1.0}/middleware/public_auth.py +3 -3
- {cconnect-2.0.9 → cconnect-2.1.0}/middleware/security.py +6 -2
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/browser.py +2 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/chat.py +1 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/claude.py +31 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/network.py +4 -11
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/packs.py +13 -1
- cconnect-2.1.0/routers/pages.py +46 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/projects.py +8 -8
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/shared.py +5 -5
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/system.py +11 -2
- {cconnect-2.0.9 → cconnect-2.1.0}/services/accounts.py +2 -11
- {cconnect-2.0.9 → cconnect-2.1.0}/services/agent_connections.py +28 -5
- {cconnect-2.0.9 → cconnect-2.1.0}/services/agent_sessions.py +1 -4
- {cconnect-2.0.9 → cconnect-2.1.0}/services/browser.py +49 -2
- {cconnect-2.0.9 → cconnect-2.1.0}/services/claude_manage.py +95 -16
- {cconnect-2.0.9 → cconnect-2.1.0}/services/claude_runtime.py +9 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/directory_watch.py +45 -41
- {cconnect-2.0.9 → cconnect-2.1.0}/services/network.py +12 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/pack_format.py +1 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/packs.py +23 -0
- cconnect-2.1.0/services/pages.py +85 -0
- cconnect-2.1.0/services/processes.py +179 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/project_watch.py +19 -15
- {cconnect-2.0.9 → cconnect-2.1.0}/services/shared.py +3 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/system_monitor.py +4 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/system_watch.py +44 -18
- {cconnect-2.0.9 → cconnect-2.1.0}/services/terminal.py +4 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/cconnect.egg-info/dependency_links.txt +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/cconnect.egg-info/entry_points.txt +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/cconnect.egg-info/requires.txt +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/cconnect.egg-info/top_level.txt +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/__init__.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/access.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/cli_manager.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/config.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/data_migration.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/db.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/display.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/models.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packages.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/builtin.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect/accents.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect/pack.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect/terminal/black.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect/themes/cconnect-dark.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect/themes/cconnect-light.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/backgrounds/cyberpunk.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/backgrounds/darkwave.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/pack.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/campbell.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/catppuccin-latte.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/catppuccin-mocha.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/claude-dark.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/claude-light.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/dark-plus.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/dracula.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/github-dark-hc.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/github-dark.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/github-dimmed.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/github-light-hc.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/github-light.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/gruvbox-dark.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/light-plus.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/monokai.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/nord.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/one-dark.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/one-half-dark.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/one-half-light.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/rose-pine.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/solarized-dark.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/solarized-light.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/tango-dark.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/tango-light.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/tokyo-night.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/ubuntu.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/vscode-dark-modern.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/vscode-hc-dark.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/vscode-hc-light.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/terminal/vscode-light-modern.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/catppuccin-latte.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/catppuccin-mocha.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/claude-dark.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/claude-light.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/dracula.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/github-dark-hc.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/github-dark.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/github-dimmed.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/github-light-hc.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/github-light.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/gruvbox-dark.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/nord.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/one-dark.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/rose-pine.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/solarized-dark.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/solarized-light.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/tokyo-night.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/vscode-dark-modern.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/vscode-dark-plus.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/vscode-hc-dark.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/vscode-hc-light.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/vscode-light-modern.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/packs/cconnect-extras/themes/vscode-light-plus.json +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/process_job.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/prompts/BLOCKS.md +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/prompts/BROWSER.md +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/prompts/CCONNECT.md +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/prompts/COMMIT.md +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/prompts/MODS.md +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/prompts/SUGGESTIONS.md +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/rate_limit.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/scripts/browse.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/scripts/mcp_bridge.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/scripts/page_icon.js +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/sdk.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/settings_defs.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/slugs.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/core/ws.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/mcps/__init__.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/mcps/browser.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/mcps/check_progress.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/mcps/components.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/mcps/delegate.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/mcps/packs.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/mcps/session.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/mcps/shared_files.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/mcps/terminal.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/middleware/__init__.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/middleware/error_handler.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/pyproject.toml +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/__init__.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/accounts.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/agents.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/capabilities.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/cli.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/git.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/health.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/list.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/sessions.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/settings.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/routers/terminal.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/schemas/__init__.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/schemas/accounts.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/schemas/chat.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/schemas/network.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/__init__.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/account_login.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/acp_events.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/acp_peer.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/agent_mcp.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/agent_registry.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/agents.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/api_errors.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/attachments.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/blocks.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/categories.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/chat_list.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/claude_assets.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/claude_status.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/cli_info.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/cli_settings.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/control_requests.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/delegate_runner.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/delegate_runs.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/delegates.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/diffs.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/directories.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/elicitation.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/event_rows.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/files.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/git.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/git_ops.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/live_sessions.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/mods.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/persistent_sessions.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/project_files.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/projects.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/prompt_cache.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/providers.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/questions.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/repo.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/rewind.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/sessions.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/settings_store.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/shared_links.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/shared_watch.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/speedtest.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/todos.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/tool_calls.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/tool_props.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/trash.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/usage.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/services/visibility.py +0 -0
- {cconnect-2.0.9 → cconnect-2.1.0}/setup.cfg +0 -0
|
@@ -92,6 +92,7 @@ core/prompts/BLOCKS.md
|
|
|
92
92
|
core/prompts/BROWSER.md
|
|
93
93
|
core/prompts/CCONNECT.md
|
|
94
94
|
core/prompts/COMMIT.md
|
|
95
|
+
core/prompts/INSTALL.md
|
|
95
96
|
core/prompts/MODS.md
|
|
96
97
|
core/prompts/SUGGESTIONS.md
|
|
97
98
|
core/scripts/browse.py
|
|
@@ -124,6 +125,7 @@ routers/health.py
|
|
|
124
125
|
routers/list.py
|
|
125
126
|
routers/network.py
|
|
126
127
|
routers/packs.py
|
|
128
|
+
routers/pages.py
|
|
127
129
|
routers/projects.py
|
|
128
130
|
routers/sessions.py
|
|
129
131
|
routers/settings.py
|
|
@@ -173,7 +175,9 @@ services/mods.py
|
|
|
173
175
|
services/network.py
|
|
174
176
|
services/pack_format.py
|
|
175
177
|
services/packs.py
|
|
178
|
+
services/pages.py
|
|
176
179
|
services/persistent_sessions.py
|
|
180
|
+
services/processes.py
|
|
177
181
|
services/project_files.py
|
|
178
182
|
services/project_watch.py
|
|
179
183
|
services/projects.py
|
|
@@ -13,6 +13,7 @@ import shutil
|
|
|
13
13
|
import socket
|
|
14
14
|
import subprocess
|
|
15
15
|
import sys
|
|
16
|
+
import threading
|
|
16
17
|
import time
|
|
17
18
|
from contextlib import suppress
|
|
18
19
|
from datetime import datetime
|
|
@@ -30,6 +31,7 @@ _ENV_PATH = paths.ENV_FILE
|
|
|
30
31
|
_TOKEN_VAR = "PUBLIC_ACCESS_TOKEN"
|
|
31
32
|
_SECURITY_KEY_VAR = "SECURITY_KEY"
|
|
32
33
|
_HOSTNAME_VAR = "PUBLIC_HOSTNAME"
|
|
34
|
+
_LIFELINE_VAR = "CCONNECT_LIFELINE"
|
|
33
35
|
_PROVIDERS = ("tailscale", "tailnet", "caddy")
|
|
34
36
|
_PRIVATE_PROVIDERS = ("tailnet",)
|
|
35
37
|
_STOP_TIMEOUT = 10
|
|
@@ -402,7 +404,7 @@ def _flag_parser() -> argparse.ArgumentParser:
|
|
|
402
404
|
"""The launcher's original flags, accepted alongside the subcommands."""
|
|
403
405
|
parser = argparse.ArgumentParser(description="CConnect backend launcher.")
|
|
404
406
|
parser.add_argument("--production", action="store_true",
|
|
405
|
-
help="No reload
|
|
407
|
+
help="No reload (Linux/macOS only).")
|
|
406
408
|
parser.add_argument("--expose", choices=list(_PROVIDERS), default="",
|
|
407
409
|
help="Serve the backend through the given provider: tailnet keeps it "
|
|
408
410
|
"inside your tailnet, tailscale and caddy publish it.")
|
|
@@ -433,7 +435,7 @@ def _command_parser() -> argparse.ArgumentParser:
|
|
|
433
435
|
|
|
434
436
|
run = commands.add_parser("run", help="Serve on this machine and its network. The default.")
|
|
435
437
|
run.add_argument("--production", action="store_true",
|
|
436
|
-
help="No reload
|
|
438
|
+
help="No reload (Linux/macOS only).")
|
|
437
439
|
run.add_argument("--detach", action="store_true",
|
|
438
440
|
help="Run in the background; the server outlives the terminal.")
|
|
439
441
|
run.add_argument("--port", type=int, default=None, help=f"Port to serve on instead of {PORT}.")
|
|
@@ -446,7 +448,7 @@ def _command_parser() -> argparse.ArgumentParser:
|
|
|
446
448
|
expose.add_argument("--detach", action="store_true",
|
|
447
449
|
help="Run in the background; the server outlives the terminal.")
|
|
448
450
|
expose.add_argument("--production", action="store_true",
|
|
449
|
-
help="No reload
|
|
451
|
+
help="No reload (Linux/macOS only).")
|
|
450
452
|
expose.add_argument("--port", type=int, default=None, help=f"Port to serve on instead of {PORT}.")
|
|
451
453
|
|
|
452
454
|
commands.add_parser("stop", help="Stop a backend started with --detach.")
|
|
@@ -548,6 +550,20 @@ def _restart() -> None:
|
|
|
548
550
|
print(f"Restarting the backend (pid {live['PID']}).")
|
|
549
551
|
|
|
550
552
|
|
|
553
|
+
def _watch_lifeline() -> None:
|
|
554
|
+
stream = sys.stdin.buffer if sys.stdin else None
|
|
555
|
+
if stream is None:
|
|
556
|
+
return
|
|
557
|
+
|
|
558
|
+
def wait() -> None:
|
|
559
|
+
with suppress(OSError, ValueError):
|
|
560
|
+
while stream.read(4096):
|
|
561
|
+
pass
|
|
562
|
+
paths.STOP_FLAG.touch()
|
|
563
|
+
|
|
564
|
+
threading.Thread(target=wait, name="lifeline", daemon=True).start()
|
|
565
|
+
|
|
566
|
+
|
|
551
567
|
def _port_state(port: int) -> str:
|
|
552
568
|
live = _runtime()
|
|
553
569
|
if live and int(live.get("PORT") or 0) == port:
|
|
@@ -691,18 +707,16 @@ def main():
|
|
|
691
707
|
_print_security_key(key_generated)
|
|
692
708
|
|
|
693
709
|
reload = not args.production and not is_windows
|
|
694
|
-
workers = int(os.environ.get("WEB_CONCURRENCY", "2")) if (args.production and not is_windows) else 1
|
|
695
710
|
|
|
696
711
|
cmd = [sys.executable, "-m", "uvicorn", _APP, "--host", "0.0.0.0", "--port", str(port)]
|
|
697
|
-
if reload
|
|
698
|
-
cmd += ["--reload", "--reload-exclude", str(paths.DATA_DIR)]
|
|
699
|
-
elif workers > 1:
|
|
700
|
-
cmd += ["--workers", str(workers)]
|
|
712
|
+
cmd += ["--reload", "--reload-exclude", str(paths.DATA_DIR)] if reload else ["--workers", "1"]
|
|
701
713
|
|
|
702
714
|
paths.RESTART_FLAG.unlink(missing_ok=True)
|
|
703
715
|
paths.STOP_FLAG.unlink(missing_ok=True)
|
|
716
|
+
if os.environ.pop(_LIFELINE_VAR, None):
|
|
717
|
+
_watch_lifeline()
|
|
704
718
|
while True:
|
|
705
|
-
process = subprocess.Popen(cmd, cwd=paths.BACKEND_DIR)
|
|
719
|
+
process = subprocess.Popen(cmd, cwd=paths.BACKEND_DIR, stdin=subprocess.DEVNULL)
|
|
706
720
|
asked = False
|
|
707
721
|
stopped = False
|
|
708
722
|
try:
|
|
@@ -111,6 +111,6 @@
|
|
|
111
111
|
"fontKinds": ["text", "mono", "symbols", "emoji"],
|
|
112
112
|
"fontFormats": ["woff2", "woff", "ttf", "otf"],
|
|
113
113
|
"imageFormats": ["png", "jpg", "jpeg", "webp", "gif", "avif", "svg"],
|
|
114
|
-
"maxFileBytes":
|
|
115
|
-
"maxPackBytes":
|
|
114
|
+
"maxFileBytes": 524288000,
|
|
115
|
+
"maxPackBytes": 524288000
|
|
116
116
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Every path the backend owns, grouped by what the data is."""
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
|
+
import shutil
|
|
4
5
|
import stat
|
|
5
6
|
import subprocess
|
|
6
7
|
import sys
|
|
@@ -87,6 +88,14 @@ def unlink_dir(target: Path) -> None:
|
|
|
87
88
|
target.unlink()
|
|
88
89
|
|
|
89
90
|
|
|
91
|
+
def remove_tree(target: Path) -> bool:
|
|
92
|
+
for item in target.rglob("*"):
|
|
93
|
+
if item.is_file() and not os.access(item, os.W_OK):
|
|
94
|
+
item.chmod(stat.S_IWRITE)
|
|
95
|
+
shutil.rmtree(target, ignore_errors=True)
|
|
96
|
+
return not target.exists()
|
|
97
|
+
|
|
98
|
+
|
|
90
99
|
OWNED_DIRS = (
|
|
91
100
|
CONFIG_DIR,
|
|
92
101
|
STATE_DIR,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Install cards
|
|
2
|
+
|
|
3
|
+
The user can install MCP servers, plugins, marketplaces, skills, ACP agents and this app's packs
|
|
4
|
+
(themes, fonts, chat backgrounds) from the chat. When you find one worth adding, offer it as a
|
|
5
|
+
block of cards instead of telling them how to set it up:
|
|
6
|
+
|
|
7
|
+
````
|
|
8
|
+
```cconnect
|
|
9
|
+
{ "type": "install", "items": [
|
|
10
|
+
{ "kind": "mcp", "name": "fetch", "command": "uvx", "args": ["mcp-server-fetch"] },
|
|
11
|
+
{ "kind": "mcp", "name": "linear", "url": "https://mcp.linear.app/mcp" },
|
|
12
|
+
{ "kind": "plugin", "name": "<plugin>@<marketplace>", "source": "<owner/repo>" },
|
|
13
|
+
{ "kind": "marketplace", "source": "<owner/repo or git url>" },
|
|
14
|
+
{ "kind": "skill", "source": "<owner/repo>", "path": "<folder holding SKILL.md>" },
|
|
15
|
+
{ "kind": "agent", "id": "<ACP registry id>" },
|
|
16
|
+
{ "kind": "pack", "url": "https://<host>/<name>.ccpack" }
|
|
17
|
+
] }
|
|
18
|
+
```
|
|
19
|
+
````
|
|
20
|
+
|
|
21
|
+
An `mcp` item is the entry `.mcp.json` holds: `command` with `args` and `env`, or `url` with
|
|
22
|
+
`headers` and `type` (`http` or `sse`). A `plugin` names its marketplace after the `@`, and
|
|
23
|
+
`source` is where that marketplace is added from when the user lacks it. A pack is served over
|
|
24
|
+
https.
|
|
25
|
+
|
|
26
|
+
A `skill` is a folder of a git repository that holds its `SKILL.md`. `source` is `owner/repo` on
|
|
27
|
+
GitHub or an https git URL, `path` the folder, left out for the root, and `ref` the branch when it
|
|
28
|
+
is not the default. The folder's address on GitHub, as the user copies it
|
|
29
|
+
(`https://github.com/<owner>/<repo>/tree/<branch>/<folder>`), also works as the `source` alone.
|
|
30
|
+
|
|
31
|
+
A card installs nothing by itself: it opens a dialog that shows exactly what runs and waits for
|
|
32
|
+
the user. The same request also works as a link, `cconnect://install/<kind>?…` with those fields
|
|
33
|
+
as query parameters, where `arg`, `env=KEY=value` and `header=Name: value` repeat.
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
"""Standardized API response helpers."""
|
|
2
2
|
|
|
3
|
+
import os
|
|
3
4
|
from http import HTTPStatus
|
|
4
5
|
from math import ceil
|
|
6
|
+
from pathlib import Path
|
|
5
7
|
from typing import Any, Iterable, Optional
|
|
6
8
|
|
|
7
9
|
import orjson
|
|
10
|
+
from fastapi import Request
|
|
8
11
|
from fastapi.encoders import jsonable_encoder
|
|
9
|
-
from fastapi.responses import JSONResponse
|
|
12
|
+
from fastapi.responses import FileResponse, JSONResponse, Response
|
|
13
|
+
from starlette.staticfiles import NotModifiedResponse
|
|
10
14
|
|
|
11
15
|
FILE_HEADERS = {"Content-Encoding": "identity", "Cache-Control": "no-cache"}
|
|
12
16
|
|
|
13
17
|
|
|
18
|
+
def file_response(request: Request, path: Path, **options: Any) -> Response:
|
|
19
|
+
response = FileResponse(path, stat_result=os.stat(path), headers=FILE_HEADERS, **options)
|
|
20
|
+
held = request.headers.get("if-none-match", "")
|
|
21
|
+
if response.headers["etag"] in [tag.strip(" W/") for tag in held.split(",")]:
|
|
22
|
+
return NotModifiedResponse(response.headers)
|
|
23
|
+
return response
|
|
24
|
+
|
|
25
|
+
|
|
14
26
|
class ORJSONResponse(JSONResponse):
|
|
15
27
|
"""orjson serializes plain payloads; jsonable_encoder covers the types it rejects."""
|
|
16
28
|
|
|
@@ -29,7 +29,8 @@ MEDIA = (
|
|
|
29
29
|
"capability": "media.html",
|
|
30
30
|
"inline": "an html page",
|
|
31
31
|
"outside": "an html page",
|
|
32
|
-
"block": "`html` — takes `url` and `title
|
|
32
|
+
"block": "`html` — takes `url` and `title`; the page loads the files of its folder and its "
|
|
33
|
+
"subfolders by relative path, a reference by the name it shows",
|
|
33
34
|
},
|
|
34
35
|
)
|
|
35
36
|
|
|
@@ -7,11 +7,11 @@ from starlette.middleware.base import BaseHTTPMiddleware
|
|
|
7
7
|
|
|
8
8
|
from core.config import PUBLIC_ACCESS_TOKEN
|
|
9
9
|
from core.responses import api_response
|
|
10
|
-
from services import agent_mcp
|
|
10
|
+
from services import agent_mcp, pages
|
|
11
11
|
|
|
12
12
|
# Open so the mobile app can probe connectivity before it has a token.
|
|
13
13
|
_OPEN_PATHS = frozenset({"/api/health", "/api/agents/browse"})
|
|
14
|
-
|
|
14
|
+
_OPEN_PREFIXES = (f"{agent_mcp.PATH}/", f"{pages.PATH}/")
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
def _provided_token(authorization: str, query_token: str) -> str:
|
|
@@ -44,7 +44,7 @@ class PublicAuthMiddleware(BaseHTTPMiddleware):
|
|
|
44
44
|
async def dispatch(self, request: Request, call_next):
|
|
45
45
|
if PUBLIC_ACCESS_TOKEN is None:
|
|
46
46
|
return await call_next(request)
|
|
47
|
-
if request.url.path in _OPEN_PATHS or request.url.path.startswith(
|
|
47
|
+
if request.url.path in _OPEN_PATHS or request.url.path.startswith(_OPEN_PREFIXES):
|
|
48
48
|
return await call_next(request)
|
|
49
49
|
if not http_bearer_ok(request):
|
|
50
50
|
return api_response(status=401)
|
|
@@ -4,10 +4,12 @@ from fastapi import FastAPI, Request, Response
|
|
|
4
4
|
from starlette.middleware.base import BaseHTTPMiddleware
|
|
5
5
|
|
|
6
6
|
from core.responses import api_response
|
|
7
|
+
from services import pages
|
|
7
8
|
|
|
8
9
|
MAX_BODY_SIZE = 500 * 1_048_576
|
|
10
|
+
STREAMED_UPLOAD = ("PUT", "/api/shared/")
|
|
9
11
|
|
|
10
|
-
FRAMEABLE_PATHS = ("/api/shared/", "/api/shared-archive-file")
|
|
12
|
+
FRAMEABLE_PATHS = ("/api/shared/", "/api/shared-archive-file", f"{pages.PATH}/")
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
class SecurityHeadersMiddleware(BaseHTTPMiddleware):
|
|
@@ -29,8 +31,10 @@ class SecurityHeadersMiddleware(BaseHTTPMiddleware):
|
|
|
29
31
|
|
|
30
32
|
class RequestSizeLimitMiddleware(BaseHTTPMiddleware):
|
|
31
33
|
async def dispatch(self, request: Request, call_next):
|
|
34
|
+
method, prefix = STREAMED_UPLOAD
|
|
35
|
+
streamed = request.method == method and request.url.path.startswith(prefix)
|
|
32
36
|
content_length = request.headers.get("content-length")
|
|
33
|
-
if content_length and int(content_length) > MAX_BODY_SIZE:
|
|
37
|
+
if not streamed and content_length and int(content_length) > MAX_BODY_SIZE:
|
|
34
38
|
return api_response(status=413)
|
|
35
39
|
return await call_next(request)
|
|
36
40
|
|
|
@@ -37,6 +37,8 @@ async def _dispatch(session: BrowserSession, payload: dict):
|
|
|
37
37
|
await session.insert(str(payload.get("value") or ""))
|
|
38
38
|
elif kind == "navigate":
|
|
39
39
|
await session.navigate(str(payload.get("url") or ""))
|
|
40
|
+
elif kind == "home":
|
|
41
|
+
await session.go_home()
|
|
40
42
|
elif kind == "reload":
|
|
41
43
|
await session.reload()
|
|
42
44
|
elif kind == "back":
|
|
@@ -120,6 +120,7 @@ def _build_turn_runner(session, text: str, attachments: list[str] | None = None,
|
|
|
120
120
|
try:
|
|
121
121
|
async for event in run_prompt(
|
|
122
122
|
resident=resident,
|
|
123
|
+
channel=session.channel,
|
|
123
124
|
unlocked=lambda: session.unlocked,
|
|
124
125
|
prompt=prompt_text,
|
|
125
126
|
images=prompt_images,
|
|
@@ -47,6 +47,12 @@ class PluginReloadBody(BaseModel):
|
|
|
47
47
|
force: bool = False
|
|
48
48
|
|
|
49
49
|
|
|
50
|
+
class SkillInstallBody(BaseModel):
|
|
51
|
+
source: str
|
|
52
|
+
path: str = ""
|
|
53
|
+
ref: str = ""
|
|
54
|
+
|
|
55
|
+
|
|
50
56
|
class MarketplaceActionBody(BaseModel):
|
|
51
57
|
action: str # add | remove | update
|
|
52
58
|
target: str # source for add, name otherwise
|
|
@@ -60,6 +66,20 @@ class McpAddBody(BaseModel):
|
|
|
60
66
|
env: list[str] = Field(default_factory=list)
|
|
61
67
|
|
|
62
68
|
|
|
69
|
+
class McpConfig(BaseModel):
|
|
70
|
+
command: str = ""
|
|
71
|
+
args: list[str] = Field(default_factory=list)
|
|
72
|
+
env: dict[str, str] = Field(default_factory=dict)
|
|
73
|
+
url: str = ""
|
|
74
|
+
type: str = ""
|
|
75
|
+
headers: dict[str, str] = Field(default_factory=dict)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class McpConfigBody(BaseModel):
|
|
79
|
+
name: str
|
|
80
|
+
config: McpConfig
|
|
81
|
+
|
|
82
|
+
|
|
63
83
|
class ToggleBody(BaseModel):
|
|
64
84
|
name: str
|
|
65
85
|
enabled: bool
|
|
@@ -200,6 +220,12 @@ def get_skill_file(skill: str, plugin: str | None = None, file: str = "SKILL.md"
|
|
|
200
220
|
return Response(content=text, media_type="text/markdown; charset=utf-8")
|
|
201
221
|
|
|
202
222
|
|
|
223
|
+
@router.post("/claude/skills/install")
|
|
224
|
+
async def install_skill(body: SkillInstallBody):
|
|
225
|
+
result = await asyncio.to_thread(claude_manage.install_skill, body.source, body.path, body.ref)
|
|
226
|
+
return api_response(data=await claude_manage.reload_after(result, "reload-skills"))
|
|
227
|
+
|
|
228
|
+
|
|
203
229
|
@router.get("/claude/mcp")
|
|
204
230
|
def get_mcp():
|
|
205
231
|
return api_response(data=claude_assets.list_mcp_servers())
|
|
@@ -212,6 +238,11 @@ def add_mcp(body: McpAddBody):
|
|
|
212
238
|
)
|
|
213
239
|
|
|
214
240
|
|
|
241
|
+
@router.post("/claude/mcp/config")
|
|
242
|
+
def add_mcp_config(body: McpConfigBody):
|
|
243
|
+
return api_response(data=claude_manage.mcp_add_config(body.name, body.config.model_dump()))
|
|
244
|
+
|
|
245
|
+
|
|
215
246
|
@router.post("/claude/mcp/toggle")
|
|
216
247
|
def toggle_mcp(body: ToggleBody):
|
|
217
248
|
return api_response(data=claude_manage.mcp_set_enabled(body.name, body.enabled))
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""Host network status, Wi-Fi control and bandwidth tests."""
|
|
2
2
|
|
|
3
|
+
import asyncio
|
|
4
|
+
|
|
3
5
|
from fastapi import APIRouter, WebSocket, WebSocketDisconnect
|
|
4
6
|
|
|
5
7
|
from core.responses import api_response
|
|
@@ -15,23 +17,14 @@ router = APIRouter(tags=["network"])
|
|
|
15
17
|
async def get_network():
|
|
16
18
|
if not network.SUPPORTED:
|
|
17
19
|
return api_response(data={"supported": False})
|
|
18
|
-
return api_response(data={
|
|
19
|
-
"supported": True,
|
|
20
|
-
"wired_control": network.WIRED_CONTROL,
|
|
21
|
-
"needs_password": network.WIRED_CONTROL and not network.has_sudo_password(),
|
|
22
|
-
"speedtest": speedtest.available(),
|
|
23
|
-
"connectivity": network.connectivity(),
|
|
24
|
-
"wifi_radio": network.wifi_radio_state(),
|
|
25
|
-
"wifi_ssid": network.wifi_current(),
|
|
26
|
-
"interfaces": network.interfaces(),
|
|
27
|
-
})
|
|
20
|
+
return api_response(data={**await asyncio.to_thread(network.status), "speedtest": speedtest.available()})
|
|
28
21
|
|
|
29
22
|
|
|
30
23
|
@router.get("/network/wifi")
|
|
31
24
|
async def scan_wifi():
|
|
32
25
|
if not network.SUPPORTED:
|
|
33
26
|
return api_response(status=404)
|
|
34
|
-
return api_response(data={"networks": network.wifi_scan
|
|
27
|
+
return api_response(data={"networks": await asyncio.to_thread(network.wifi_scan)})
|
|
35
28
|
|
|
36
29
|
|
|
37
30
|
@router.post("/network/wifi/connect")
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import mimetypes
|
|
2
2
|
|
|
3
|
+
import httpx
|
|
3
4
|
from fastapi import APIRouter, Header, HTTPException, WebSocket
|
|
4
5
|
from fastapi.responses import FileResponse, Response
|
|
5
6
|
|
|
@@ -7,7 +8,7 @@ from core.access import key_matches
|
|
|
7
8
|
from core.responses import FILE_HEADERS, api_response
|
|
8
9
|
from core.ws import stream_watch
|
|
9
10
|
from services import packs
|
|
10
|
-
from services.pack_format import MIME
|
|
11
|
+
from services.pack_format import MIME, PackFormatError
|
|
11
12
|
|
|
12
13
|
router = APIRouter(tags=["Packs"])
|
|
13
14
|
|
|
@@ -17,6 +18,17 @@ async def packs_ws(ws: WebSocket):
|
|
|
17
18
|
await stream_watch(ws, packs.watch, lambda queue, _message: packs.watch.set_path(queue, ""))
|
|
18
19
|
|
|
19
20
|
|
|
21
|
+
@router.get("/packs/fetch")
|
|
22
|
+
def fetch_pack(url: str):
|
|
23
|
+
try:
|
|
24
|
+
data = packs.fetch(url)
|
|
25
|
+
except PackFormatError as exc:
|
|
26
|
+
return api_response(status=422, message=str(exc))
|
|
27
|
+
except httpx.HTTPError as exc:
|
|
28
|
+
return api_response(status=502, message=str(exc))
|
|
29
|
+
return Response(content=data, media_type=MIME, headers=FILE_HEADERS)
|
|
30
|
+
|
|
31
|
+
|
|
20
32
|
@router.get("/packs/{name}")
|
|
21
33
|
async def download_pack(name: str):
|
|
22
34
|
target = packs.file_of(name)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from fastapi import APIRouter, Header, HTTPException, Request
|
|
4
|
+
from fastapi.responses import HTMLResponse
|
|
5
|
+
from pydantic import BaseModel
|
|
6
|
+
|
|
7
|
+
from core.access import key_matches
|
|
8
|
+
from core.responses import FILE_HEADERS, api_response, file_response
|
|
9
|
+
from services import pages
|
|
10
|
+
|
|
11
|
+
router = APIRouter(tags=["Pages"])
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class PageBody(BaseModel):
|
|
15
|
+
entry: str
|
|
16
|
+
html: str
|
|
17
|
+
path: str
|
|
18
|
+
shared: bool = False
|
|
19
|
+
project: Optional[str] = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@router.post("/pages")
|
|
23
|
+
def open_page(body: PageBody, x_security_key: str = Header("")):
|
|
24
|
+
resolve = pages.resolver_for(body.shared, body.project, key_matches(x_security_key))
|
|
25
|
+
if resolve is None:
|
|
26
|
+
raise HTTPException(status_code=404, detail="folder not found")
|
|
27
|
+
return api_response(data={"id": pages.open_page(body.entry, body.html, body.path, resolve)})
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@router.delete("/pages/{page_id}")
|
|
31
|
+
def close_page(page_id: str):
|
|
32
|
+
pages.close_page(page_id)
|
|
33
|
+
return api_response()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@router.get("/pages/{page_id}/{rest:path}")
|
|
37
|
+
def page_file(page_id: str, rest: str, request: Request):
|
|
38
|
+
found = pages.page(page_id)
|
|
39
|
+
if found is None:
|
|
40
|
+
raise HTTPException(status_code=404, detail="page not found")
|
|
41
|
+
if rest == found.entry:
|
|
42
|
+
return HTMLResponse(found.html, headers=FILE_HEADERS)
|
|
43
|
+
resolved = pages.file_of(found, rest)
|
|
44
|
+
if resolved is None:
|
|
45
|
+
raise HTTPException(status_code=404, detail="file not found")
|
|
46
|
+
return file_response(request, resolved)
|
|
@@ -4,12 +4,12 @@ import asyncio
|
|
|
4
4
|
|
|
5
5
|
from urllib.parse import quote
|
|
6
6
|
|
|
7
|
-
from fastapi import APIRouter, Header, HTTPException, Query, Response, WebSocket, WebSocketDisconnect
|
|
8
|
-
from fastapi.responses import
|
|
7
|
+
from fastapi import APIRouter, Header, HTTPException, Query, Request, Response, WebSocket, WebSocketDisconnect
|
|
8
|
+
from fastapi.responses import StreamingResponse
|
|
9
9
|
from loguru import logger
|
|
10
10
|
|
|
11
11
|
from core.access import key_matches
|
|
12
|
-
from core.responses import
|
|
12
|
+
from core.responses import api_response, file_response
|
|
13
13
|
from core.ws import send_event
|
|
14
14
|
from middleware.public_auth import ws_bearer_ok
|
|
15
15
|
from services import project_files, project_watch
|
|
@@ -69,14 +69,14 @@ async def projects_ws(ws: WebSocket):
|
|
|
69
69
|
while True:
|
|
70
70
|
msg = await ws.receive_json()
|
|
71
71
|
if msg.get("type") == "watch":
|
|
72
|
-
project_watch.hub.watch
|
|
72
|
+
await asyncio.to_thread(project_watch.hub.watch, queue, str(msg.get("project_key") or ""))
|
|
73
73
|
except WebSocketDisconnect:
|
|
74
74
|
pass
|
|
75
75
|
except Exception as exc:
|
|
76
76
|
logger.debug(f"projects_ws ended: {type(exc).__name__}: {exc}")
|
|
77
77
|
finally:
|
|
78
78
|
pump_task.cancel()
|
|
79
|
-
project_watch.hub.unsubscribe
|
|
79
|
+
await asyncio.to_thread(project_watch.hub.unsubscribe, queue)
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
@router.get("/projects/{project_key}/archive")
|
|
@@ -105,7 +105,7 @@ def project_archive_file(project_key: str, path: str, inner: str, x_security_key
|
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
@router.get("/projects/{project_key}/file")
|
|
108
|
-
def project_file(project_key: str, path: str, x_security_key: str = Header("")):
|
|
108
|
+
def project_file(project_key: str, path: str, request: Request, x_security_key: str = Header("")):
|
|
109
109
|
try:
|
|
110
110
|
resolved = project_files.resolve_file(_root(project_key), path, key_matches(x_security_key))
|
|
111
111
|
except ValueError as exc:
|
|
@@ -114,9 +114,9 @@ def project_file(project_key: str, path: str, x_security_key: str = Header("")):
|
|
|
114
114
|
if project_files.deleted_at_head(_root(project_key), path):
|
|
115
115
|
return Response(content=b"", media_type="text/plain")
|
|
116
116
|
raise HTTPException(status_code=404, detail="file not found")
|
|
117
|
-
return
|
|
117
|
+
return file_response(
|
|
118
|
+
request,
|
|
118
119
|
resolved,
|
|
119
120
|
filename=resolved.name,
|
|
120
121
|
content_disposition_type="inline",
|
|
121
|
-
headers=FILE_HEADERS,
|
|
122
122
|
)
|
|
@@ -5,12 +5,12 @@ from typing import Literal
|
|
|
5
5
|
from urllib.parse import quote
|
|
6
6
|
|
|
7
7
|
from fastapi import APIRouter, Header, HTTPException, Request, WebSocket
|
|
8
|
-
from fastapi.responses import
|
|
8
|
+
from fastapi.responses import StreamingResponse
|
|
9
9
|
from starlette.requests import ClientDisconnect
|
|
10
10
|
from pydantic import BaseModel
|
|
11
11
|
|
|
12
12
|
from core.access import key_matches
|
|
13
|
-
from core.responses import
|
|
13
|
+
from core.responses import api_response, file_response
|
|
14
14
|
from core.ws import stream_watch
|
|
15
15
|
from services import shared as shared_service
|
|
16
16
|
from services.shared_watch import hub as watch_hub
|
|
@@ -212,18 +212,18 @@ async def upload_shared(path: str, request: Request, policy: Literal["keep", "re
|
|
|
212
212
|
|
|
213
213
|
|
|
214
214
|
@router.get("/shared/{path:path}")
|
|
215
|
-
def download_shared(path: str):
|
|
215
|
+
def download_shared(path: str, request: Request):
|
|
216
216
|
try:
|
|
217
217
|
resolved = shared_service.resolve_file(path)
|
|
218
218
|
except ValueError as exc:
|
|
219
219
|
raise HTTPException(status_code=400, detail=str(exc))
|
|
220
220
|
if resolved is None:
|
|
221
221
|
raise HTTPException(status_code=404, detail="file not found")
|
|
222
|
-
return
|
|
222
|
+
return file_response(
|
|
223
|
+
request,
|
|
223
224
|
resolved,
|
|
224
225
|
filename=shared_service.visible_of(path),
|
|
225
226
|
content_disposition_type="inline",
|
|
226
|
-
headers=FILE_HEADERS,
|
|
227
227
|
)
|
|
228
228
|
|
|
229
229
|
|
|
@@ -3,18 +3,27 @@
|
|
|
3
3
|
import asyncio
|
|
4
4
|
import os
|
|
5
5
|
|
|
6
|
-
from fastapi import APIRouter, Query, WebSocket, WebSocketDisconnect
|
|
6
|
+
from fastapi import APIRouter, Header, Query, WebSocket, WebSocketDisconnect
|
|
7
7
|
|
|
8
8
|
from core import paths
|
|
9
|
+
from core.access import key_matches
|
|
9
10
|
from core.config import RESTART_EXIT_CODE
|
|
10
11
|
from core.responses import api_response
|
|
11
12
|
from core.ws import send_event
|
|
12
13
|
from middleware.public_auth import ws_bearer_ok
|
|
13
|
-
from services import directories, live_sessions, repo, system_monitor, system_watch
|
|
14
|
+
from services import directories, live_sessions, processes, repo, system_monitor, system_watch
|
|
14
15
|
|
|
15
16
|
router = APIRouter(tags=["system"])
|
|
16
17
|
|
|
17
18
|
_EXIT_DELAY = 0.5
|
|
19
|
+
_STOP_STATUS = {processes.STOPPED: 200, processes.LOCKED: 403}
|
|
20
|
+
_STOP_MISSING = 404
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@router.post("/system/processes/{pid}/stop")
|
|
24
|
+
async def stop_process(pid: int, x_security_key: str = Header("")):
|
|
25
|
+
stopped = await processes.stop(pid, key_matches(x_security_key))
|
|
26
|
+
return api_response(status=_STOP_STATUS.get(stopped, _STOP_MISSING))
|
|
18
27
|
|
|
19
28
|
|
|
20
29
|
@router.get("/system")
|
|
@@ -12,7 +12,6 @@ import json
|
|
|
12
12
|
import os
|
|
13
13
|
import re
|
|
14
14
|
import shutil
|
|
15
|
-
import stat
|
|
16
15
|
import subprocess
|
|
17
16
|
import zipfile
|
|
18
17
|
|
|
@@ -254,14 +253,6 @@ def _merge_dir(source: Path, target: Path) -> tuple[list[Path], bool]:
|
|
|
254
253
|
return adopted, merged
|
|
255
254
|
|
|
256
255
|
|
|
257
|
-
def _remove_tree(target: Path) -> bool:
|
|
258
|
-
for item in target.rglob("*"):
|
|
259
|
-
if item.is_file() and not os.access(item, os.W_OK):
|
|
260
|
-
item.chmod(stat.S_IWRITE)
|
|
261
|
-
shutil.rmtree(target, ignore_errors=True)
|
|
262
|
-
return not target.exists()
|
|
263
|
-
|
|
264
|
-
|
|
265
256
|
def _link_dir(source: Path, target: Path) -> None:
|
|
266
257
|
if paths.is_link(target):
|
|
267
258
|
if target.resolve() == source.resolve():
|
|
@@ -269,7 +260,7 @@ def _link_dir(source: Path, target: Path) -> None:
|
|
|
269
260
|
paths.unlink_dir(target)
|
|
270
261
|
elif target.is_dir():
|
|
271
262
|
adopted, merged = _merge_dir(target, source)
|
|
272
|
-
if not merged or not
|
|
263
|
+
if not merged or not paths.remove_tree(target):
|
|
273
264
|
logger.warning(f"accounts: {target} could not be emptied to share {source}")
|
|
274
265
|
return
|
|
275
266
|
for path in adopted:
|
|
@@ -345,7 +336,7 @@ def purge(account_id: str) -> bool:
|
|
|
345
336
|
for name in _SHARED_DIRS:
|
|
346
337
|
paths.unlink_dir(path / name)
|
|
347
338
|
_stop_processes_in(path)
|
|
348
|
-
if not
|
|
339
|
+
if not paths.remove_tree(path):
|
|
349
340
|
return False
|
|
350
341
|
_tombstone(account_id).unlink(missing_ok=True)
|
|
351
342
|
return True
|