cconnect 2.0.8__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.8 → cconnect-2.0.9}/PKG-INFO +1 -1
- {cconnect-2.0.8 → cconnect-2.0.9}/cconnect.egg-info/PKG-INFO +1 -1
- {cconnect-2.0.8 → cconnect-2.0.9}/cconnect.egg-info/SOURCES.txt +3 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/app.py +4 -1
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect/pack.json +2 -2
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/schema.json +2 -1
- {cconnect-2.0.8 → cconnect-2.0.9}/core/prompts/BROWSER.md +3 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/prompts/CCONNECT.md +2 -3
- {cconnect-2.0.8 → 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.8 → cconnect-2.0.9}/mcps/packs.py +3 -1
- {cconnect-2.0.8 → cconnect-2.0.9}/middleware/public_auth.py +4 -2
- {cconnect-2.0.8 → cconnect-2.0.9}/pyproject.toml +1 -1
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/accounts.py +25 -3
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/agents.py +14 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/chat.py +15 -1
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/claude.py +2 -2
- {cconnect-2.0.8 → cconnect-2.0.9}/schemas/chat.py +1 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/accounts.py +47 -10
- {cconnect-2.0.8 → cconnect-2.0.9}/services/agent_connections.py +69 -12
- cconnect-2.0.9/services/agent_mcp.py +83 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/agent_sessions.py +55 -6
- {cconnect-2.0.8 → cconnect-2.0.9}/services/claude_runtime.py +39 -27
- {cconnect-2.0.8 → cconnect-2.0.9}/services/elicitation.py +4 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/live_sessions.py +10 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/pack_format.py +1 -1
- {cconnect-2.0.8 → cconnect-2.0.9}/services/packs.py +2 -1
- {cconnect-2.0.8 → cconnect-2.0.9}/services/providers.py +6 -4
- {cconnect-2.0.8 → cconnect-2.0.9}/services/usage.py +50 -29
- {cconnect-2.0.8 → cconnect-2.0.9}/cconnect.egg-info/dependency_links.txt +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/cconnect.egg-info/entry_points.txt +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/cconnect.egg-info/requires.txt +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/cconnect.egg-info/top_level.txt +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/__init__.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/access.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/cli.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/cli_manager.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/config.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/data_migration.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/db.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/display.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/models.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packages.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/builtin.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect/accents.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect/terminal/black.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect/themes/cconnect-dark.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect/themes/cconnect-light.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/backgrounds/cyberpunk.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/backgrounds/darkwave.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/pack.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/campbell.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/catppuccin-latte.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/catppuccin-mocha.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/claude-dark.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/claude-light.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/dark-plus.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/dracula.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/github-dark-hc.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/github-dark.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/github-dimmed.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/github-light-hc.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/github-light.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/gruvbox-dark.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/light-plus.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/monokai.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/nord.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/one-dark.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/one-half-dark.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/one-half-light.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/rose-pine.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/solarized-dark.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/solarized-light.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/tango-dark.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/tango-light.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/tokyo-night.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/ubuntu.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/vscode-dark-modern.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/vscode-hc-dark.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/vscode-hc-light.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/terminal/vscode-light-modern.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/catppuccin-latte.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/catppuccin-mocha.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/claude-dark.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/claude-light.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/dracula.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/github-dark-hc.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/github-dark.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/github-dimmed.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/github-light-hc.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/github-light.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/gruvbox-dark.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/nord.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/one-dark.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/rose-pine.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/solarized-dark.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/solarized-light.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/tokyo-night.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/vscode-dark-modern.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/vscode-dark-plus.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/vscode-hc-dark.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/vscode-hc-light.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/vscode-light-modern.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/packs/cconnect-extras/themes/vscode-light-plus.json +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/paths.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/process_job.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/prompts/BLOCKS.md +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/prompts/COMMIT.md +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/prompts/MODS.md +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/prompts/SUGGESTIONS.md +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/rate_limit.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/responses.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/scripts/page_icon.js +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/sdk.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/settings_defs.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/slugs.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/core/ws.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/mcps/__init__.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/mcps/browser.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/mcps/check_progress.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/mcps/components.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/mcps/delegate.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/mcps/media.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/mcps/session.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/mcps/shared_files.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/mcps/terminal.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/middleware/__init__.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/middleware/error_handler.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/middleware/security.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/__init__.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/browser.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/capabilities.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/cli.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/git.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/health.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/list.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/network.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/packs.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/projects.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/sessions.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/settings.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/shared.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/system.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/routers/terminal.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/schemas/__init__.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/schemas/accounts.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/schemas/network.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/__init__.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/account_login.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/acp_events.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/acp_peer.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/agent_registry.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/agents.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/api_errors.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/attachments.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/blocks.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/browser.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/categories.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/chat_list.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/claude_assets.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/claude_manage.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/claude_status.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/cli_info.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/cli_settings.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/control_requests.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/delegate_runner.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/delegate_runs.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/delegates.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/diffs.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/directories.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/directory_watch.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/event_rows.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/files.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/git.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/git_ops.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/mods.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/network.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/persistent_sessions.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/project_files.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/project_watch.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/projects.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/prompt_cache.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/questions.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/repo.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/rewind.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/sessions.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/settings_store.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/shared.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/shared_links.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/shared_watch.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/speedtest.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/system_monitor.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/system_watch.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/terminal.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/todos.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/tool_calls.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/tool_props.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/trash.py +0 -0
- {cconnect-2.0.8 → cconnect-2.0.9}/services/visibility.py +0 -0
- {cconnect-2.0.8 → 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}",
|
|
@@ -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"],
|
|
@@ -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)
|
|
@@ -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={
|
|
@@ -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")
|
|
@@ -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:
|
|
@@ -2,19 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
4
|
import collections
|
|
5
|
+
import hmac
|
|
6
|
+
import secrets
|
|
5
7
|
import shutil
|
|
8
|
+
import sys
|
|
6
9
|
from contextlib import suppress
|
|
7
10
|
from pathlib import Path
|
|
8
11
|
from typing import Any, Awaitable, Callable, Optional, Protocol
|
|
9
12
|
|
|
10
13
|
import psutil
|
|
11
14
|
|
|
12
|
-
from core import packages, process_job, release
|
|
15
|
+
from core import packages, paths, process_job, release
|
|
16
|
+
from core.config import PORT
|
|
13
17
|
from services import agents, elicitation, persistent_sessions
|
|
14
18
|
from services.acp_peer import AUTH_REQUIRED, INTERNAL_ERROR, RESOURCE_NOT_FOUND, STREAM_LIMIT, AcpError, AcpPeer
|
|
15
19
|
|
|
16
20
|
PROTOCOL_VERSION = 1
|
|
17
21
|
ELICIT = "elicitation/create"
|
|
22
|
+
ELICIT_COMPLETE = "elicitation/complete"
|
|
23
|
+
BROWSE_PATH = "/api/agents/browse"
|
|
24
|
+
BROWSE_SCRIPT = paths.SCRIPTS_DIR / "browse.py"
|
|
18
25
|
LOG_LINES = 400
|
|
19
26
|
TERMINAL_METHOD = "terminal"
|
|
20
27
|
LEGACY_TERMINAL_AUTH = "terminal-auth"
|
|
@@ -37,6 +44,8 @@ class Receiver(Protocol):
|
|
|
37
44
|
|
|
38
45
|
async def requested(self, method: str, params: dict) -> Any: ...
|
|
39
46
|
|
|
47
|
+
async def linked(self) -> None: ...
|
|
48
|
+
|
|
40
49
|
def dropped(self) -> None: ...
|
|
41
50
|
|
|
42
51
|
|
|
@@ -76,6 +85,9 @@ class AgentConnection:
|
|
|
76
85
|
self._peer: Optional[AcpPeer] = None
|
|
77
86
|
self._tasks: list[asyncio.Task] = []
|
|
78
87
|
self._login_ask: Optional[Ask] = None
|
|
88
|
+
self._completions: dict[str, asyncio.Event] = {}
|
|
89
|
+
self.browse_token = secrets.token_urlsafe(24)
|
|
90
|
+
self.login_url: Optional[str] = None
|
|
79
91
|
self.expiry: Optional[asyncio.Task] = None
|
|
80
92
|
|
|
81
93
|
@property
|
|
@@ -99,8 +111,18 @@ class AgentConnection:
|
|
|
99
111
|
def auth_methods(self) -> list[dict]:
|
|
100
112
|
return [method for method in self.info.get("authMethods") or [] if isinstance(method, dict) and method.get("id")]
|
|
101
113
|
|
|
102
|
-
|
|
114
|
+
def _launch(self) -> tuple[list[str], dict[str, str]]:
|
|
103
115
|
argv, env = agents.launch(self.agent)
|
|
116
|
+
return argv, {
|
|
117
|
+
**env,
|
|
118
|
+
"BROWSER": f'"{sys.executable}" "{BROWSE_SCRIPT}" %s',
|
|
119
|
+
"CCONNECT_BROWSE_URL": f"http://127.0.0.1:{PORT}{BROWSE_PATH}",
|
|
120
|
+
"CCONNECT_BROWSE_TOKEN": self.browse_token,
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async def open(self) -> None:
|
|
124
|
+
argv, env = self._launch()
|
|
125
|
+
launchable = Path(argv[0]).suffix.lower() not in BATCH_SUFFIXES
|
|
104
126
|
self._process = await asyncio.create_subprocess_exec(
|
|
105
127
|
*argv,
|
|
106
128
|
cwd=self.cwd,
|
|
@@ -117,7 +139,7 @@ class AgentConnection:
|
|
|
117
139
|
try:
|
|
118
140
|
self.info = await self._peer.call("initialize", {
|
|
119
141
|
"protocolVersion": PROTOCOL_VERSION,
|
|
120
|
-
"clientCapabilities": CLIENT_CAPABILITIES,
|
|
142
|
+
"clientCapabilities": {**CLIENT_CAPABILITIES, "auth": {"terminal": launchable}},
|
|
121
143
|
"clientInfo": CLIENT_INFO,
|
|
122
144
|
}) or {}
|
|
123
145
|
except BaseException:
|
|
@@ -146,14 +168,39 @@ class AgentConnection:
|
|
|
146
168
|
if receiver is not None:
|
|
147
169
|
return await receiver.requested(method, params)
|
|
148
170
|
if method == ELICIT and self._login_ask is not None:
|
|
149
|
-
return
|
|
171
|
+
return await self._login_elicit(params)
|
|
150
172
|
raise AcpError(RESOURCE_NOT_FOUND, f"no session for {method}")
|
|
151
173
|
|
|
174
|
+
async def _login_elicit(self, params: dict) -> dict:
|
|
175
|
+
key = str(params.get("elicitationId") or "")
|
|
176
|
+
completed = self._completions.setdefault(key, asyncio.Event()) if key else asyncio.Event()
|
|
177
|
+
asked = asyncio.ensure_future(self._login_ask(elicitation.form(params)))
|
|
178
|
+
closing = asyncio.ensure_future(completed.wait())
|
|
179
|
+
try:
|
|
180
|
+
await asyncio.wait({asked, closing}, return_when=asyncio.FIRST_COMPLETED)
|
|
181
|
+
finally:
|
|
182
|
+
closing.cancel()
|
|
183
|
+
self._completions.pop(key, None)
|
|
184
|
+
if asked.done():
|
|
185
|
+
return elicitation.answer(asked.result(), params)
|
|
186
|
+
asked.cancel()
|
|
187
|
+
return elicitation.accepted()
|
|
188
|
+
|
|
152
189
|
async def _notified(self, method: str, params: dict) -> None:
|
|
190
|
+
if method == ELICIT_COMPLETE:
|
|
191
|
+
completed = self._completions.get(str(params.get("elicitationId") or ""))
|
|
192
|
+
if completed is not None:
|
|
193
|
+
completed.set()
|
|
194
|
+
return
|
|
153
195
|
receiver = self.receivers.get(params.get("sessionId") or "")
|
|
154
196
|
if receiver is not None and method == "session/update":
|
|
155
197
|
await receiver.received(params.get("update") or {})
|
|
156
198
|
|
|
199
|
+
async def browsed(self, url: str) -> None:
|
|
200
|
+
self.login_url = url
|
|
201
|
+
for receiver in list(self.receivers.values()):
|
|
202
|
+
await receiver.linked()
|
|
203
|
+
|
|
157
204
|
async def call(self, method: str, params: dict) -> Any:
|
|
158
205
|
if self._peer is None:
|
|
159
206
|
raise AcpError(INTERNAL_ERROR, "the agent is not running")
|
|
@@ -175,23 +222,26 @@ class AgentConnection:
|
|
|
175
222
|
self.receivers.pop(session_id, None)
|
|
176
223
|
|
|
177
224
|
def methods(self) -> list[dict]:
|
|
178
|
-
"""The ways to sign in this agent offers, as the app lists them."""
|
|
179
|
-
|
|
180
|
-
|
|
225
|
+
"""The ways to sign in this agent offers, as the app lists them; a terminal one only when it can be launched."""
|
|
226
|
+
listed = []
|
|
227
|
+
for method in self.auth_methods:
|
|
228
|
+
terminal = self.terminal_login(method["id"]) is not None
|
|
229
|
+
if method.get("type") == TERMINAL_METHOD and not terminal:
|
|
230
|
+
continue
|
|
231
|
+
listed.append({
|
|
181
232
|
"id": method["id"],
|
|
182
233
|
"name": str(method.get("name") or method["id"]),
|
|
183
234
|
"description": str(method.get("description") or ""),
|
|
184
|
-
"terminal":
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
]
|
|
235
|
+
"terminal": terminal,
|
|
236
|
+
})
|
|
237
|
+
return listed
|
|
188
238
|
|
|
189
239
|
def terminal_login(self, method_id: str) -> Optional[tuple[list[str], dict[str, str]]]:
|
|
190
240
|
"""The program and environment a terminal runs to sign this agent in, when the method is a terminal one."""
|
|
191
241
|
method = next((item for item in self.auth_methods if item["id"] == method_id), None)
|
|
192
242
|
if method is None:
|
|
193
243
|
return None
|
|
194
|
-
argv, env =
|
|
244
|
+
argv, env = self._launch()
|
|
195
245
|
if Path(argv[0]).suffix.lower() in BATCH_SUFFIXES:
|
|
196
246
|
return None
|
|
197
247
|
if method.get("type") == TERMINAL_METHOD:
|
|
@@ -210,6 +260,7 @@ class AgentConnection:
|
|
|
210
260
|
await self.call("authenticate", {"methodId": method_id})
|
|
211
261
|
finally:
|
|
212
262
|
self._login_ask = None
|
|
263
|
+
self.login_url = None
|
|
213
264
|
self.auth_required = False
|
|
214
265
|
|
|
215
266
|
async def logout(self) -> None:
|
|
@@ -243,6 +294,12 @@ class ConnectionPool:
|
|
|
243
294
|
connection = self._connections.get((agent_id, cwd))
|
|
244
295
|
return connection if connection is not None and connection.alive else None
|
|
245
296
|
|
|
297
|
+
def by_browse_token(self, token: str) -> Optional[AgentConnection]:
|
|
298
|
+
return next(
|
|
299
|
+
(connection for connection in self._connections.values() if token and hmac.compare_digest(connection.browse_token, token)),
|
|
300
|
+
None,
|
|
301
|
+
)
|
|
302
|
+
|
|
246
303
|
async def take(self, agent_id: str, cwd: str) -> AgentConnection:
|
|
247
304
|
key = (agent_id, cwd)
|
|
248
305
|
async with self._locks.setdefault(key, asyncio.Lock()):
|