cconnect 2.0.7__tar.gz → 2.0.9__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.7 → cconnect-2.0.9}/PKG-INFO +1 -1
- {cconnect-2.0.7 → cconnect-2.0.9}/cconnect.egg-info/PKG-INFO +1 -1
- {cconnect-2.0.7 → cconnect-2.0.9}/cconnect.egg-info/SOURCES.txt +3 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/app.py +4 -1
- {cconnect-2.0.7 → cconnect-2.0.9}/core/models.py +20 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect/pack.json +2 -2
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/schema.json +2 -1
- {cconnect-2.0.7 → cconnect-2.0.9}/core/paths.py +1 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/prompts/BROWSER.md +3 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/prompts/CCONNECT.md +2 -3
- {cconnect-2.0.7 → cconnect-2.0.9}/core/release.py +1 -1
- cconnect-2.0.9/core/scripts/browse.py +24 -0
- cconnect-2.0.9/core/scripts/mcp_bridge.py +23 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/mcps/packs.py +3 -1
- {cconnect-2.0.7 → cconnect-2.0.9}/middleware/public_auth.py +4 -2
- {cconnect-2.0.7 → cconnect-2.0.9}/pyproject.toml +1 -1
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/accounts.py +25 -3
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/agents.py +54 -1
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/chat.py +15 -1
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/claude.py +2 -2
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/sessions.py +19 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/schemas/chat.py +1 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/accounts.py +47 -10
- {cconnect-2.0.7 → cconnect-2.0.9}/services/agent_connections.py +69 -12
- cconnect-2.0.9/services/agent_mcp.py +83 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/agent_sessions.py +55 -6
- {cconnect-2.0.7 → cconnect-2.0.9}/services/categories.py +63 -29
- {cconnect-2.0.7 → cconnect-2.0.9}/services/chat_list.py +1 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/claude_runtime.py +44 -27
- {cconnect-2.0.7 → cconnect-2.0.9}/services/elicitation.py +4 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/live_sessions.py +10 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/pack_format.py +1 -1
- {cconnect-2.0.7 → cconnect-2.0.9}/services/packs.py +2 -1
- {cconnect-2.0.7 → cconnect-2.0.9}/services/project_files.py +51 -12
- {cconnect-2.0.7 → cconnect-2.0.9}/services/project_watch.py +14 -2
- {cconnect-2.0.7 → cconnect-2.0.9}/services/providers.py +6 -4
- {cconnect-2.0.7 → cconnect-2.0.9}/services/sessions.py +15 -2
- {cconnect-2.0.7 → cconnect-2.0.9}/services/system_monitor.py +3 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/usage.py +50 -29
- {cconnect-2.0.7 → cconnect-2.0.9}/cconnect.egg-info/dependency_links.txt +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/cconnect.egg-info/entry_points.txt +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/cconnect.egg-info/requires.txt +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/cconnect.egg-info/top_level.txt +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/__init__.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/access.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/cli.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/cli_manager.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/config.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/data_migration.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/db.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/display.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packages.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/builtin.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect/accents.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect/terminal/black.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect/themes/cconnect-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect/themes/cconnect-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/backgrounds/cyberpunk.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/backgrounds/darkwave.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/pack.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/campbell.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/catppuccin-latte.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/catppuccin-mocha.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/claude-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/claude-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/dark-plus.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/dracula.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/github-dark-hc.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/github-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/github-dimmed.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/github-light-hc.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/github-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/gruvbox-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/light-plus.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/monokai.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/nord.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/one-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/one-half-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/one-half-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/rose-pine.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/solarized-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/solarized-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/tango-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/tango-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/tokyo-night.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/ubuntu.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/vscode-dark-modern.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/vscode-hc-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/vscode-hc-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/vscode-light-modern.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/catppuccin-latte.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/catppuccin-mocha.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/claude-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/claude-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/dracula.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/github-dark-hc.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/github-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/github-dimmed.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/github-light-hc.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/github-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/gruvbox-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/nord.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/one-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/rose-pine.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/solarized-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/solarized-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/tokyo-night.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/vscode-dark-modern.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/vscode-dark-plus.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/vscode-hc-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/vscode-hc-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/vscode-light-modern.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/vscode-light-plus.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/process_job.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/prompts/BLOCKS.md +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/prompts/COMMIT.md +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/prompts/MODS.md +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/prompts/SUGGESTIONS.md +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/rate_limit.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/responses.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/scripts/page_icon.js +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/sdk.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/settings_defs.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/slugs.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/core/ws.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/mcps/__init__.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/mcps/browser.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/mcps/check_progress.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/mcps/components.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/mcps/delegate.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/mcps/media.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/mcps/session.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/mcps/shared_files.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/mcps/terminal.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/middleware/__init__.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/middleware/error_handler.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/middleware/security.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/__init__.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/browser.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/capabilities.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/cli.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/git.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/health.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/list.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/network.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/packs.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/projects.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/settings.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/shared.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/system.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/routers/terminal.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/schemas/__init__.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/schemas/accounts.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/schemas/network.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/__init__.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/account_login.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/acp_events.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/acp_peer.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/agent_registry.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/agents.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/api_errors.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/attachments.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/blocks.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/browser.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/claude_assets.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/claude_manage.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/claude_status.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/cli_info.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/cli_settings.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/control_requests.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/delegate_runner.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/delegate_runs.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/delegates.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/diffs.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/directories.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/directory_watch.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/event_rows.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/files.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/git.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/git_ops.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/mods.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/network.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/persistent_sessions.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/projects.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/prompt_cache.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/questions.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/repo.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/rewind.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/settings_store.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/shared.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/shared_links.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/shared_watch.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/speedtest.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/system_watch.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/terminal.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/todos.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/tool_calls.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/tool_props.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/trash.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/services/visibility.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.9}/setup.cfg +0 -0
|
@@ -94,6 +94,8 @@ core/prompts/CCONNECT.md
|
|
|
94
94
|
core/prompts/COMMIT.md
|
|
95
95
|
core/prompts/MODS.md
|
|
96
96
|
core/prompts/SUGGESTIONS.md
|
|
97
|
+
core/scripts/browse.py
|
|
98
|
+
core/scripts/mcp_bridge.py
|
|
97
99
|
core/scripts/page_icon.js
|
|
98
100
|
mcps/__init__.py
|
|
99
101
|
mcps/browser.py
|
|
@@ -138,6 +140,7 @@ services/accounts.py
|
|
|
138
140
|
services/acp_events.py
|
|
139
141
|
services/acp_peer.py
|
|
140
142
|
services/agent_connections.py
|
|
143
|
+
services/agent_mcp.py
|
|
141
144
|
services/agent_registry.py
|
|
142
145
|
services/agent_sessions.py
|
|
143
146
|
services/agents.py
|
|
@@ -18,7 +18,7 @@ from core.db import init_db
|
|
|
18
18
|
from core.rate_limit import limiter
|
|
19
19
|
from core.responses import api_response
|
|
20
20
|
from core.sdk import ensure_sdk_installed, ensure_subscription_auth
|
|
21
|
-
from services import cli_settings, settings_store, system_monitor
|
|
21
|
+
from services import agent_mcp, cli_settings, settings_store, system_monitor
|
|
22
22
|
from middleware.error_handler import register_error_handlers
|
|
23
23
|
from middleware.public_auth import register_public_auth_middleware
|
|
24
24
|
from middleware.security import register_security_middleware
|
|
@@ -34,6 +34,7 @@ async def lifespan(app: FastAPI):
|
|
|
34
34
|
from services import delegates
|
|
35
35
|
delegates.migrate()
|
|
36
36
|
from services import accounts
|
|
37
|
+
await asyncio.to_thread(accounts.purge_forgotten)
|
|
37
38
|
await asyncio.to_thread(accounts.link_all_shared_dirs)
|
|
38
39
|
paths.RUNTIME_FILE.write_text(f"PORT={PORT}\nPID={os.getpid()}\n", encoding="utf-8")
|
|
39
40
|
system_monitor.setup_log_capture()
|
|
@@ -97,6 +98,8 @@ for module_info in pkgutil.iter_modules(routers_pkg.__path__):
|
|
|
97
98
|
if hasattr(module, "router"):
|
|
98
99
|
app.include_router(module.router, prefix="/api")
|
|
99
100
|
|
|
101
|
+
app.mount(agent_mcp.PATH, agent_mcp.asgi)
|
|
102
|
+
|
|
100
103
|
|
|
101
104
|
@app.api_route(
|
|
102
105
|
"/{path:path}",
|
|
@@ -50,6 +50,26 @@ class SessionPlacement(Base):
|
|
|
50
50
|
)
|
|
51
51
|
|
|
52
52
|
|
|
53
|
+
class AgentSessionPlacement(Base):
|
|
54
|
+
__tablename__ = "agent_session_placement"
|
|
55
|
+
|
|
56
|
+
agent: Mapped[str] = mapped_column(
|
|
57
|
+
primary_key=True,
|
|
58
|
+
comment="ACP agent the chat runs on; its session ids are only unique within that agent",
|
|
59
|
+
)
|
|
60
|
+
session_id: Mapped[str] = mapped_column(
|
|
61
|
+
primary_key=True,
|
|
62
|
+
comment="Session id the agent gave the chat; the row goes when the chat is deleted from the app or the agent is removed",
|
|
63
|
+
)
|
|
64
|
+
category_id: Mapped[Optional[str]] = mapped_column(
|
|
65
|
+
nullable=True,
|
|
66
|
+
comment="Category holding the chat; NULL keeps it in the uncategorised group",
|
|
67
|
+
)
|
|
68
|
+
position: Mapped[float] = mapped_column(
|
|
69
|
+
comment="Sort key inside the category among that agent's chats, only read while the order is manual",
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
|
|
53
73
|
class TrashedSession(Base):
|
|
54
74
|
__tablename__ = "trashed_sessions"
|
|
55
75
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"schema":
|
|
2
|
+
"schema": 4,
|
|
3
3
|
"extension": ".ccpack",
|
|
4
4
|
"mime": "application/zip",
|
|
5
5
|
"manifest": "pack.json",
|
|
@@ -107,6 +107,7 @@
|
|
|
107
107
|
"y": { "min": 0, "max": 100 }
|
|
108
108
|
},
|
|
109
109
|
"backgroundFits": ["cover", "contain"],
|
|
110
|
+
"accentSources": { "dynamic": "dynamic", "theme": "theme" },
|
|
110
111
|
"fontKinds": ["text", "mono", "symbols", "emoji"],
|
|
111
112
|
"fontFormats": ["woff2", "woff", "ttf", "otf"],
|
|
112
113
|
"imageFormats": ["png", "jpg", "jpeg", "webp", "gif", "avif", "svg"],
|
|
@@ -60,6 +60,7 @@ CONTEXT_WINDOWS_FILE = CACHE_DIR / "context_windows.json"
|
|
|
60
60
|
BROWSER_PROFILE_DIR = Path(os.environ.get("BROWSER_PROFILE_DIR") or CACHE_DIR / "browser")
|
|
61
61
|
|
|
62
62
|
SERVER_LOG_FILE = LOGS_DIR / "server.jsonl"
|
|
63
|
+
PREVIOUS_SERVER_LOG_FILE = LOGS_DIR / "server.prev.jsonl"
|
|
63
64
|
DETACHED_LOG_FILE = LOGS_DIR / "detached.log"
|
|
64
65
|
|
|
65
66
|
|
|
@@ -8,3 +8,6 @@ Anything that speaks the DevTools Protocol reaches that same browser at `$CCONNE
|
|
|
8
8
|
— Playwright, Puppeteer, Selenium, or the Playwright MCP already pointed at it. Use one of those
|
|
9
9
|
to click through a flow, and the browser tools to open a page, read it or look at it. Never
|
|
10
10
|
close the browser or its last tab: it is the user's window, not yours.
|
|
11
|
+
|
|
12
|
+
A `<browser-element>` with `browser="server"` was picked in this browser, so you can open that
|
|
13
|
+
page and look further.
|
|
@@ -18,9 +18,8 @@ only linking it: `` for a file you wrote there,
|
|
|
18
18
|
|
|
19
19
|
A `<browser-element>` block in a message is an element the user picked in a browser beside
|
|
20
20
|
the chat: the page it sits on (`url`, `title`), a CSS `selector`, its rendered `size` and its
|
|
21
|
-
HTML, cut at 2000 characters. `browser="
|
|
22
|
-
|
|
23
|
-
you cannot reach it, so work from what the block carries.
|
|
21
|
+
HTML, cut at 2000 characters. `browser="device"` runs on the user's own device and you cannot
|
|
22
|
+
reach it, so work from what the block carries.
|
|
24
23
|
|
|
25
24
|
# The chat
|
|
26
25
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
import urllib.request
|
|
5
|
+
import webbrowser
|
|
6
|
+
|
|
7
|
+
url = sys.argv[1] if len(sys.argv) > 1 else ""
|
|
8
|
+
target = os.environ.pop("CCONNECT_BROWSE_URL", "")
|
|
9
|
+
token = os.environ.pop("CCONNECT_BROWSE_TOKEN", "")
|
|
10
|
+
os.environ.pop("BROWSER", None)
|
|
11
|
+
|
|
12
|
+
if url and target:
|
|
13
|
+
request = urllib.request.Request(
|
|
14
|
+
target,
|
|
15
|
+
data=json.dumps({"url": url, "token": token}).encode("utf-8"),
|
|
16
|
+
headers={"Content-Type": "application/json"},
|
|
17
|
+
)
|
|
18
|
+
try:
|
|
19
|
+
urllib.request.urlopen(request, timeout=5).close()
|
|
20
|
+
except OSError:
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
if url:
|
|
24
|
+
webbrowser.open(url)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import urllib.error
|
|
4
|
+
import urllib.request
|
|
5
|
+
|
|
6
|
+
target = os.environ.get("CCONNECT_MCP_URL", "")
|
|
7
|
+
headers = {"Content-Type": "application/json", "Accept": "application/json, text/event-stream"}
|
|
8
|
+
|
|
9
|
+
for line in sys.stdin.buffer:
|
|
10
|
+
body = line.strip()
|
|
11
|
+
if not body or not target:
|
|
12
|
+
continue
|
|
13
|
+
request = urllib.request.Request(target, data=body, headers=headers, method="POST")
|
|
14
|
+
try:
|
|
15
|
+
with urllib.request.urlopen(request, timeout=300) as response:
|
|
16
|
+
answer = response.read().strip()
|
|
17
|
+
except urllib.error.HTTPError as error:
|
|
18
|
+
answer = error.read().strip()
|
|
19
|
+
except OSError:
|
|
20
|
+
continue
|
|
21
|
+
if answer:
|
|
22
|
+
sys.stdout.buffer.write(answer + b"\n")
|
|
23
|
+
sys.stdout.buffer.flush()
|
|
@@ -46,7 +46,9 @@ GUIDE = "\n".join(
|
|
|
46
46
|
"motif of the pack's own and no text: a screenshot or fine detail turns to noise at that size.",
|
|
47
47
|
"Every other file is optional and takes its id from its name.",
|
|
48
48
|
"use is what the app's Use button applies, and without it the button is not offered: the first light "
|
|
49
|
-
"theme, dark theme, terminal, accent and background listed, and the first font of each kind."
|
|
49
|
+
"theme, dark theme, terminal, accent and background listed, and the first font of each kind. For the "
|
|
50
|
+
f"accent it also takes {' or '.join(SCHEMA['accentSources'].values())}, which follow the system's color or "
|
|
51
|
+
"the theme's own instead of one of the pack's.",
|
|
50
52
|
f"themes/<id>.json: {{name, kind: {' or '.join(SCHEMA['themeKinds'])}, extends?: theme id, accent?, "
|
|
51
53
|
"syntax?: syntax id, colors: {token: color}}. A token left out comes from extends, or from the default "
|
|
52
54
|
"theme of its kind, and the -bg, hover and scrollbar tokens derive from their base color.",
|
|
@@ -7,9 +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
11
|
|
|
11
12
|
# Open so the mobile app can probe connectivity before it has a token.
|
|
12
|
-
_OPEN_PATHS = frozenset({"/api/health"})
|
|
13
|
+
_OPEN_PATHS = frozenset({"/api/health", "/api/agents/browse"})
|
|
14
|
+
_OPEN_PREFIX = f"{agent_mcp.PATH}/"
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
def _provided_token(authorization: str, query_token: str) -> str:
|
|
@@ -42,7 +44,7 @@ class PublicAuthMiddleware(BaseHTTPMiddleware):
|
|
|
42
44
|
async def dispatch(self, request: Request, call_next):
|
|
43
45
|
if PUBLIC_ACCESS_TOKEN is None:
|
|
44
46
|
return await call_next(request)
|
|
45
|
-
if request.url.path in _OPEN_PATHS:
|
|
47
|
+
if request.url.path in _OPEN_PATHS or request.url.path.startswith(_OPEN_PREFIX):
|
|
46
48
|
return await call_next(request)
|
|
47
49
|
if not http_bearer_ok(request):
|
|
48
50
|
return api_response(status=401)
|
|
@@ -62,7 +62,7 @@ version = { attr = "core.release.VERSION" }
|
|
|
62
62
|
include = ["core*", "routers*", "schemas*", "middleware*", "services*", "mcps*"]
|
|
63
63
|
|
|
64
64
|
[tool.setuptools.package-data]
|
|
65
|
-
core = ["prompts/*.md", "scripts/*.js", "packs/**/*.json"]
|
|
65
|
+
core = ["prompts/*.md", "scripts/*.js", "scripts/*.py", "packs/**/*.json"]
|
|
66
66
|
|
|
67
67
|
[tool.pytest.ini_options]
|
|
68
68
|
asyncio_mode = "auto"
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""Claude accounts: list, create, rename, delegation, delete and remote OAuth login."""
|
|
2
2
|
|
|
3
|
+
import asyncio
|
|
4
|
+
|
|
3
5
|
from fastapi import APIRouter, Request, Response
|
|
4
6
|
|
|
5
7
|
from core.responses import api_response
|
|
@@ -12,7 +14,7 @@ from schemas.accounts import (
|
|
|
12
14
|
ProviderProbeRequest,
|
|
13
15
|
ProviderUpdateRequest,
|
|
14
16
|
)
|
|
15
|
-
from services import account_login, accounts, cli_info, providers
|
|
17
|
+
from services import account_login, accounts, cli_info, live_sessions, providers
|
|
16
18
|
|
|
17
19
|
router = APIRouter(tags=["accounts"])
|
|
18
20
|
|
|
@@ -99,12 +101,32 @@ def set_account_delegation(account_id: str, payload: AccountDelegationRequest):
|
|
|
99
101
|
|
|
100
102
|
|
|
101
103
|
@router.delete("/accounts/{account_id}")
|
|
102
|
-
def delete_account(account_id: str):
|
|
103
|
-
|
|
104
|
+
async def delete_account(account_id: str):
|
|
105
|
+
holders = live_sessions.registry.on_account(account_id)
|
|
106
|
+
if not accounts.forget(account_id):
|
|
104
107
|
return api_response(status=404)
|
|
108
|
+
account_login.cancel(account_id)
|
|
109
|
+
cli_info.invalidate()
|
|
110
|
+
_pending_purges.add(asyncio.create_task(_purge(account_id, holders)))
|
|
105
111
|
return api_response()
|
|
106
112
|
|
|
107
113
|
|
|
114
|
+
_PURGE_ATTEMPTS = 10
|
|
115
|
+
_PURGE_PAUSE = 1.0
|
|
116
|
+
_pending_purges: set[asyncio.Task] = set()
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
async def _purge(account_id: str, holders: list) -> None:
|
|
120
|
+
try:
|
|
121
|
+
await live_sessions.registry.release_all(holders)
|
|
122
|
+
for _ in range(_PURGE_ATTEMPTS):
|
|
123
|
+
if await asyncio.to_thread(accounts.purge, account_id):
|
|
124
|
+
return
|
|
125
|
+
await asyncio.sleep(_PURGE_PAUSE)
|
|
126
|
+
finally:
|
|
127
|
+
_pending_purges.discard(asyncio.current_task())
|
|
128
|
+
|
|
129
|
+
|
|
108
130
|
@router.post("/accounts/import")
|
|
109
131
|
async def import_account(request: Request, label: str = ""):
|
|
110
132
|
account = accounts.import_bundle(await request.body(), label)
|
|
@@ -12,7 +12,7 @@ from pydantic import BaseModel, Field
|
|
|
12
12
|
from core.access import key_matches
|
|
13
13
|
from core.responses import FILE_HEADERS, api_response
|
|
14
14
|
from core.ws import stream_watch
|
|
15
|
-
from services import agent_registry, agent_sessions, agents, terminal
|
|
15
|
+
from services import agent_registry, agent_sessions, agents, categories, chat_list, terminal
|
|
16
16
|
from services.acp_peer import AcpError
|
|
17
17
|
from services.agent_connections import pool
|
|
18
18
|
|
|
@@ -86,6 +86,20 @@ def _offered(item: dict, installed: dict[str, dict]) -> dict:
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
|
|
89
|
+
class BrowseRequest(BaseModel):
|
|
90
|
+
url: str
|
|
91
|
+
token: str
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@router.post("/agents/browse")
|
|
95
|
+
async def browse(payload: BrowseRequest):
|
|
96
|
+
connection = pool.by_browse_token(payload.token)
|
|
97
|
+
if connection is None or urlparse(payload.url).scheme not in ("http", "https"):
|
|
98
|
+
return api_response(status=404)
|
|
99
|
+
await connection.browsed(payload.url)
|
|
100
|
+
return api_response()
|
|
101
|
+
|
|
102
|
+
|
|
89
103
|
@router.get("/agents")
|
|
90
104
|
def list_agents():
|
|
91
105
|
return api_response(data={
|
|
@@ -165,9 +179,18 @@ async def remove_agent(agent_id: str):
|
|
|
165
179
|
await pool.restart(agent_id)
|
|
166
180
|
if agents.remove(agent_id) is None:
|
|
167
181
|
raise HTTPException(status_code=404, detail="not found")
|
|
182
|
+
_placements_removed(agent_id, categories.forget_agent(agent_id))
|
|
168
183
|
return api_response()
|
|
169
184
|
|
|
170
185
|
|
|
186
|
+
def _placements_removed(agent_id: str, session_ids: list[str]):
|
|
187
|
+
if session_ids:
|
|
188
|
+
chat_list.hub.publish([
|
|
189
|
+
{"type": "agent_placement_removed", "agent": agent_id, "session_id": session_id}
|
|
190
|
+
for session_id in session_ids
|
|
191
|
+
])
|
|
192
|
+
|
|
193
|
+
|
|
171
194
|
@router.get("/agents/{agent_id}/env")
|
|
172
195
|
def agent_env(agent_id: str, x_security_key: str = Header("")):
|
|
173
196
|
if not key_matches(x_security_key):
|
|
@@ -208,9 +231,39 @@ async def agent_session_delete(agent_id: str, cwd: str, session: str):
|
|
|
208
231
|
await agent_sessions.forget(agent_id, cwd, session)
|
|
209
232
|
except (AcpError, agents.AgentError, OSError) as exc:
|
|
210
233
|
return _failed(exc)
|
|
234
|
+
if categories.forget_session(session, agent_id):
|
|
235
|
+
_placements_removed(agent_id, [session])
|
|
211
236
|
return api_response()
|
|
212
237
|
|
|
213
238
|
|
|
239
|
+
class SessionPlace(BaseModel):
|
|
240
|
+
session: str = Field(min_length=1)
|
|
241
|
+
category_id: Optional[str] = None
|
|
242
|
+
index: Optional[int] = None
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
@router.post("/agents/{agent_id}/sessions/category")
|
|
246
|
+
async def agent_session_place(agent_id: str, body: SessionPlace):
|
|
247
|
+
try:
|
|
248
|
+
placement = categories.place_session(body.session, body.category_id, body.index, agent_id)
|
|
249
|
+
except ValueError as exc:
|
|
250
|
+
raise HTTPException(status_code=400, detail=str(exc))
|
|
251
|
+
chat_list.hub.publish([{"type": "agent_placement_changed", "placement": placement}])
|
|
252
|
+
return api_response(data=placement)
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
class SessionOrder(BaseModel):
|
|
256
|
+
sessions: list[str]
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
@router.post("/agents/{agent_id}/sessions/order")
|
|
260
|
+
async def agent_session_order(agent_id: str, body: SessionOrder):
|
|
261
|
+
created = categories.seed_order(body.sessions, agent_id)
|
|
262
|
+
if created:
|
|
263
|
+
chat_list.hub.publish([{"type": "agent_placement_changed", "placement": item} for item in created])
|
|
264
|
+
return api_response(data=created)
|
|
265
|
+
|
|
266
|
+
|
|
214
267
|
@router.post("/agents/{agent_id}/sessions/rename")
|
|
215
268
|
async def agent_session_rename(agent_id: str, body: SessionRename):
|
|
216
269
|
try:
|
|
@@ -15,6 +15,7 @@ from loguru import logger
|
|
|
15
15
|
from pydantic import BaseModel, ValidationError
|
|
16
16
|
|
|
17
17
|
from core import paths
|
|
18
|
+
from core.access import key_matches
|
|
18
19
|
from core.config import DEFAULT_CWD, permission_modes, resolve_permission_mode
|
|
19
20
|
from core.responses import api_response
|
|
20
21
|
from core.ws import send_event
|
|
@@ -119,6 +120,7 @@ def _build_turn_runner(session, text: str, attachments: list[str] | None = None,
|
|
|
119
120
|
try:
|
|
120
121
|
async for event in run_prompt(
|
|
121
122
|
resident=resident,
|
|
123
|
+
unlocked=lambda: session.unlocked,
|
|
122
124
|
prompt=prompt_text,
|
|
123
125
|
images=prompt_images,
|
|
124
126
|
cwd=state.cwd,
|
|
@@ -425,7 +427,14 @@ async def chat_ws(ws: WebSocket):
|
|
|
425
427
|
state.cwd = msg.cwd or DEFAULT_CWD
|
|
426
428
|
state.session_id = msg.resume
|
|
427
429
|
session = registry.create(state)
|
|
428
|
-
session.bind_agent(agent_sessions.AgentSession(
|
|
430
|
+
session.bind_agent(agent_sessions.AgentSession(
|
|
431
|
+
msg.agent,
|
|
432
|
+
state.cwd,
|
|
433
|
+
sessions_service.project_key_for(state.cwd),
|
|
434
|
+
msg.resume,
|
|
435
|
+
capabilities=msg.capabilities,
|
|
436
|
+
guided=True,
|
|
437
|
+
))
|
|
429
438
|
spawn(session.open_agent(msg.resume))
|
|
430
439
|
else:
|
|
431
440
|
state = _Session()
|
|
@@ -501,6 +510,7 @@ async def chat_ws(ws: WebSocket):
|
|
|
501
510
|
target = registry.get(msg.channel) if msg.channel and msg.channel != session.channel else session
|
|
502
511
|
if target is None:
|
|
503
512
|
continue
|
|
513
|
+
target.unlocked = key_matches(msg.security_key or "")
|
|
504
514
|
if target.running:
|
|
505
515
|
await target.enqueue(msg.id, msg.text, msg.attachments)
|
|
506
516
|
elif msg.id and target.already_consumed(msg.id):
|
|
@@ -564,6 +574,10 @@ async def chat_ws(ws: WebSocket):
|
|
|
564
574
|
if session is not None and session.agent is not None:
|
|
565
575
|
spawn(session.agent.login(msg.method))
|
|
566
576
|
|
|
577
|
+
elif mtype == "agent_login_cancel":
|
|
578
|
+
if session is not None and session.agent is not None:
|
|
579
|
+
session.agent.cancel_login()
|
|
580
|
+
|
|
567
581
|
elif mtype == "agent_logout":
|
|
568
582
|
if session is not None and session.agent is not None:
|
|
569
583
|
spawn(session.agent.logout())
|
|
@@ -16,8 +16,8 @@ router = APIRouter(tags=["Claude"])
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
@router.get("/claude/usage")
|
|
19
|
-
async def get_usage(account: str | None = None,
|
|
20
|
-
return api_response(data=await usage_service.usage_data(account,
|
|
19
|
+
async def get_usage(account: str | None = None, lang: str | None = None):
|
|
20
|
+
return api_response(data=await usage_service.usage_data(account, lang))
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
@router.get("/claude/status")
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Browse Claude Code projects and session transcripts."""
|
|
2
2
|
|
|
3
|
+
import asyncio
|
|
3
4
|
from typing import Optional
|
|
4
5
|
|
|
5
6
|
from fastapi import APIRouter, HTTPException
|
|
@@ -250,6 +251,24 @@ def set_session_color(session_id: str, body: ColorBody):
|
|
|
250
251
|
return api_response(message="updated")
|
|
251
252
|
|
|
252
253
|
|
|
254
|
+
class ForkBody(BaseModel):
|
|
255
|
+
project: str
|
|
256
|
+
up_to: Optional[str] = None
|
|
257
|
+
title: Optional[str] = None
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
@router.post("/sessions/{session_id}/fork")
|
|
261
|
+
async def fork_session(session_id: str, body: ForkBody):
|
|
262
|
+
try:
|
|
263
|
+
forked = await asyncio.to_thread(sessions_service.fork_session, body.project, session_id, body.up_to, body.title)
|
|
264
|
+
except (ValueError, FileNotFoundError) as exc:
|
|
265
|
+
raise HTTPException(status_code=400, detail=str(exc))
|
|
266
|
+
if forked is None:
|
|
267
|
+
raise HTTPException(status_code=404, detail="session not found")
|
|
268
|
+
await chat_list.hub.resync()
|
|
269
|
+
return api_response(data=forked)
|
|
270
|
+
|
|
271
|
+
|
|
253
272
|
class RewindPreviewBody(BaseModel):
|
|
254
273
|
project: str
|
|
255
274
|
user_message_id: str
|
|
@@ -16,8 +16,10 @@ import stat
|
|
|
16
16
|
import subprocess
|
|
17
17
|
import zipfile
|
|
18
18
|
|
|
19
|
+
import psutil
|
|
19
20
|
import sys
|
|
20
21
|
from base64 import b64encode
|
|
22
|
+
from contextlib import suppress
|
|
21
23
|
from pathlib import Path
|
|
22
24
|
from typing import Optional
|
|
23
25
|
|
|
@@ -43,6 +45,7 @@ _MODEL_ALIASES = ("SONNET", "OPUS", "HAIKU")
|
|
|
43
45
|
|
|
44
46
|
_synced: dict[str, tuple[int, ...]] = {}
|
|
45
47
|
_META_FILE = "account.json"
|
|
48
|
+
_DELETING = ".deleting"
|
|
46
49
|
_SHARED_DIRS = ("projects", "plugins", "skills")
|
|
47
50
|
_COPIED_FILES = ("settings.json",)
|
|
48
51
|
_ID_RE = re.compile(r"[^a-z0-9-]+")
|
|
@@ -67,7 +70,11 @@ def config_dir(account_id: Optional[str]) -> Optional[Path]:
|
|
|
67
70
|
if not account_id or account_id == PRIMARY_ID:
|
|
68
71
|
return None
|
|
69
72
|
path = paths.ACCOUNTS_DIR / account_id
|
|
70
|
-
return path if path.is_dir() else None
|
|
73
|
+
return path if path.is_dir() and not _tombstone(account_id).exists() else None
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _tombstone(account_id: str) -> Path:
|
|
77
|
+
return paths.ACCOUNTS_DIR / f"{account_id}{_DELETING}"
|
|
71
78
|
|
|
72
79
|
|
|
73
80
|
def provider_for(account_id: Optional[str]) -> dict:
|
|
@@ -146,7 +153,10 @@ def credentials_path(account_id: Optional[str] = None) -> Path:
|
|
|
146
153
|
|
|
147
154
|
def _claude_json(account_id: Optional[str]) -> Path:
|
|
148
155
|
path = config_dir(account_id)
|
|
149
|
-
|
|
156
|
+
if path:
|
|
157
|
+
return path / ".claude.json"
|
|
158
|
+
configured = os.environ.get("CLAUDE_CONFIG_DIR")
|
|
159
|
+
return Path(configured) / ".claude.json" if configured else Path.home() / ".claude.json"
|
|
150
160
|
|
|
151
161
|
|
|
152
162
|
def is_logged_in(account_id: Optional[str]) -> bool:
|
|
@@ -185,7 +195,7 @@ def list_accounts() -> list[dict]:
|
|
|
185
195
|
}]
|
|
186
196
|
if paths.ACCOUNTS_DIR.is_dir():
|
|
187
197
|
for entry in sorted(paths.ACCOUNTS_DIR.iterdir()):
|
|
188
|
-
if entry.is_dir() and not entry.name.endswith(".lock"):
|
|
198
|
+
if entry.is_dir() and not entry.name.endswith(".lock") and config_dir(entry.name) is not None:
|
|
189
199
|
provider = provider_for(entry.name)
|
|
190
200
|
items.append({
|
|
191
201
|
"id": entry.name,
|
|
@@ -304,7 +314,7 @@ def _slug(label: str, taken: set[str]) -> str:
|
|
|
304
314
|
|
|
305
315
|
|
|
306
316
|
def create(label: str) -> dict:
|
|
307
|
-
taken = {a["id"] for a in list_accounts()}
|
|
317
|
+
taken = {a["id"] for a in list_accounts()} | {marker.name.removesuffix(_DELETING) for marker in paths.ACCOUNTS_DIR.glob(f"*{_DELETING}")}
|
|
308
318
|
account_id = _slug(label, taken)
|
|
309
319
|
path = paths.ACCOUNTS_DIR / account_id
|
|
310
320
|
path.mkdir(parents=True, exist_ok=True)
|
|
@@ -319,18 +329,45 @@ def create(label: str) -> dict:
|
|
|
319
329
|
return {"id": account_id, "label": label, "logged_in": False, "primary": False, "provider": None}
|
|
320
330
|
|
|
321
331
|
|
|
322
|
-
def
|
|
323
|
-
|
|
324
|
-
if
|
|
332
|
+
def forget(account_id: str) -> bool:
|
|
333
|
+
"""Take an account out of every list at once; ``purge`` removes its folder once nothing holds it."""
|
|
334
|
+
if config_dir(account_id) is None:
|
|
325
335
|
return False
|
|
326
|
-
|
|
327
|
-
paths.unlink_dir(path / name)
|
|
328
|
-
shutil.rmtree(path, ignore_errors=True)
|
|
336
|
+
_tombstone(account_id).touch()
|
|
329
337
|
if settings_store.get("account") == account_id:
|
|
330
338
|
settings_store.set("account", None)
|
|
331
339
|
return True
|
|
332
340
|
|
|
333
341
|
|
|
342
|
+
def purge(account_id: str) -> bool:
|
|
343
|
+
path = paths.ACCOUNTS_DIR / account_id
|
|
344
|
+
if path.is_dir():
|
|
345
|
+
for name in _SHARED_DIRS:
|
|
346
|
+
paths.unlink_dir(path / name)
|
|
347
|
+
_stop_processes_in(path)
|
|
348
|
+
if not _remove_tree(path):
|
|
349
|
+
return False
|
|
350
|
+
_tombstone(account_id).unlink(missing_ok=True)
|
|
351
|
+
return True
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def purge_forgotten() -> None:
|
|
355
|
+
if not paths.ACCOUNTS_DIR.is_dir():
|
|
356
|
+
return
|
|
357
|
+
for marker in paths.ACCOUNTS_DIR.glob(f"*{_DELETING}"):
|
|
358
|
+
purge(marker.name.removesuffix(_DELETING))
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
def _stop_processes_in(folder: Path) -> None:
|
|
362
|
+
for process in psutil.process_iter(["exe"]):
|
|
363
|
+
exe = process.info.get("exe")
|
|
364
|
+
if exe and Path(exe).is_relative_to(folder):
|
|
365
|
+
with suppress(psutil.Error):
|
|
366
|
+
for child in process.children(recursive=True):
|
|
367
|
+
child.kill()
|
|
368
|
+
process.kill()
|
|
369
|
+
|
|
370
|
+
|
|
334
371
|
def _write_meta(account_id: str, changes: dict) -> bool:
|
|
335
372
|
path = config_dir(account_id) if account_id != PRIMARY_ID else primary_dir()
|
|
336
373
|
if path is None:
|