cconnect 2.0.6__tar.gz → 2.0.8__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.6 → cconnect-2.0.8}/PKG-INFO +1 -1
- {cconnect-2.0.6 → cconnect-2.0.8}/cconnect.egg-info/PKG-INFO +1 -1
- {cconnect-2.0.6 → cconnect-2.0.8}/cconnect.egg-info/SOURCES.txt +2 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/models.py +20 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/paths.py +1 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/release.py +1 -1
- {cconnect-2.0.6 → cconnect-2.0.8}/mcps/session.py +4 -6
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/agents.py +41 -1
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/capabilities.py +1 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/chat.py +12 -3
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/claude.py +2 -2
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/sessions.py +19 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/schemas/chat.py +1 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/accounts.py +12 -5
- {cconnect-2.0.6 → cconnect-2.0.8}/services/acp_events.py +0 -108
- {cconnect-2.0.6 → cconnect-2.0.8}/services/agent_connections.py +2 -2
- {cconnect-2.0.6 → cconnect-2.0.8}/services/agent_sessions.py +19 -6
- {cconnect-2.0.6 → cconnect-2.0.8}/services/categories.py +63 -29
- {cconnect-2.0.6 → cconnect-2.0.8}/services/chat_list.py +1 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/claude_runtime.py +14 -2
- {cconnect-2.0.6 → cconnect-2.0.8}/services/cli_info.py +12 -4
- {cconnect-2.0.6 → cconnect-2.0.8}/services/cli_settings.py +56 -8
- cconnect-2.0.8/services/control_requests.py +70 -0
- cconnect-2.0.8/services/elicitation.py +157 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/mods.py +13 -22
- {cconnect-2.0.6 → cconnect-2.0.8}/services/persistent_sessions.py +2 -1
- {cconnect-2.0.6 → cconnect-2.0.8}/services/project_files.py +51 -12
- {cconnect-2.0.6 → cconnect-2.0.8}/services/project_watch.py +14 -2
- {cconnect-2.0.6 → cconnect-2.0.8}/services/sessions.py +15 -2
- {cconnect-2.0.6 → cconnect-2.0.8}/services/system_monitor.py +3 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/usage.py +59 -35
- {cconnect-2.0.6 → cconnect-2.0.8}/cconnect.egg-info/dependency_links.txt +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/cconnect.egg-info/entry_points.txt +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/cconnect.egg-info/requires.txt +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/cconnect.egg-info/top_level.txt +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/__init__.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/access.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/app.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/cli.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/cli_manager.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/config.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/data_migration.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/db.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/display.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packages.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/builtin.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect/accents.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect/pack.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect/terminal/black.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect/themes/cconnect-dark.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect/themes/cconnect-light.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/backgrounds/cyberpunk.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/backgrounds/darkwave.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/pack.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/campbell.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/catppuccin-latte.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/catppuccin-mocha.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/claude-dark.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/claude-light.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/dark-plus.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/dracula.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/github-dark-hc.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/github-dark.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/github-dimmed.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/github-light-hc.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/github-light.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/gruvbox-dark.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/light-plus.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/monokai.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/nord.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/one-dark.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/one-half-dark.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/one-half-light.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/rose-pine.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/solarized-dark.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/solarized-light.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/tango-dark.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/tango-light.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/tokyo-night.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/ubuntu.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/vscode-dark-modern.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/vscode-hc-dark.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/vscode-hc-light.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/vscode-light-modern.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/catppuccin-latte.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/catppuccin-mocha.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/claude-dark.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/claude-light.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/dracula.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/github-dark-hc.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/github-dark.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/github-dimmed.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/github-light-hc.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/github-light.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/gruvbox-dark.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/nord.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/one-dark.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/rose-pine.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/solarized-dark.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/solarized-light.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/tokyo-night.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/vscode-dark-modern.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/vscode-dark-plus.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/vscode-hc-dark.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/vscode-hc-light.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/vscode-light-modern.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/vscode-light-plus.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/packs/schema.json +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/process_job.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/prompts/BLOCKS.md +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/prompts/BROWSER.md +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/prompts/CCONNECT.md +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/prompts/COMMIT.md +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/prompts/MODS.md +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/prompts/SUGGESTIONS.md +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/rate_limit.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/responses.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/scripts/page_icon.js +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/sdk.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/settings_defs.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/slugs.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/core/ws.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/mcps/__init__.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/mcps/browser.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/mcps/check_progress.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/mcps/components.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/mcps/delegate.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/mcps/media.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/mcps/packs.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/mcps/shared_files.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/mcps/terminal.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/middleware/__init__.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/middleware/error_handler.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/middleware/public_auth.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/middleware/security.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/pyproject.toml +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/__init__.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/accounts.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/browser.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/cli.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/git.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/health.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/list.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/network.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/packs.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/projects.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/settings.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/shared.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/system.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/routers/terminal.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/schemas/__init__.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/schemas/accounts.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/schemas/network.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/__init__.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/account_login.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/acp_peer.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/agent_registry.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/agents.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/api_errors.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/attachments.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/blocks.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/browser.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/claude_assets.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/claude_manage.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/claude_status.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/delegate_runner.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/delegate_runs.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/delegates.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/diffs.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/directories.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/directory_watch.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/event_rows.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/files.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/git.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/git_ops.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/live_sessions.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/network.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/pack_format.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/packs.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/projects.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/prompt_cache.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/providers.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/questions.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/repo.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/rewind.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/settings_store.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/shared.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/shared_links.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/shared_watch.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/speedtest.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/system_watch.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/terminal.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/todos.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/tool_calls.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/tool_props.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/trash.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/services/visibility.py +0 -0
- {cconnect-2.0.6 → cconnect-2.0.8}/setup.cfg +0 -0
|
@@ -153,12 +153,14 @@ services/claude_runtime.py
|
|
|
153
153
|
services/claude_status.py
|
|
154
154
|
services/cli_info.py
|
|
155
155
|
services/cli_settings.py
|
|
156
|
+
services/control_requests.py
|
|
156
157
|
services/delegate_runner.py
|
|
157
158
|
services/delegate_runs.py
|
|
158
159
|
services/delegates.py
|
|
159
160
|
services/diffs.py
|
|
160
161
|
services/directories.py
|
|
161
162
|
services/directory_watch.py
|
|
163
|
+
services/elicitation.py
|
|
162
164
|
services/event_rows.py
|
|
163
165
|
services/files.py
|
|
164
166
|
services/git.py
|
|
@@ -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
|
|
|
@@ -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
|
|
|
@@ -184,6 +184,7 @@ def make_tools(context: dict) -> list:
|
|
|
184
184
|
account = context.get("account")
|
|
185
185
|
info = context.get("session_info")
|
|
186
186
|
capabilities = context.get("capabilities") or ()
|
|
187
|
+
locale = context.get("locale")
|
|
187
188
|
on_provider = bool(accounts.provider_for(account))
|
|
188
189
|
|
|
189
190
|
if info is not None:
|
|
@@ -246,9 +247,9 @@ def make_tools(context: dict) -> list:
|
|
|
246
247
|
|
|
247
248
|
@tool("usage", USAGE, {})
|
|
248
249
|
async def usage(args):
|
|
249
|
-
from services.usage import CAPABILITY as USAGE, usage_blocks, usage_data,
|
|
250
|
+
from services.usage import CAPABILITY as USAGE, usage_blocks, usage_data, window_line
|
|
250
251
|
|
|
251
|
-
data = await usage_data(account)
|
|
252
|
+
data = await usage_data(account, language=locale)
|
|
252
253
|
if "error" in data:
|
|
253
254
|
return {"content": [{"type": "text", "text": data["error"]}]}
|
|
254
255
|
windows = data.get("windows") or []
|
|
@@ -257,10 +258,7 @@ def make_tools(context: dict) -> list:
|
|
|
257
258
|
elif emit is not None and COMPONENTS in capabilities and windows:
|
|
258
259
|
await emit({"type": "component", "blocks": await usage_blocks(account)})
|
|
259
260
|
lines = [f"Plan: {data['plan']}"] if data.get("plan") else []
|
|
260
|
-
lines += [
|
|
261
|
-
f"{window_label(win['id'])}: {round(win['percent'])}%" + (" (not used yet)" if win["unused"] else "")
|
|
262
|
-
for win in windows
|
|
263
|
-
]
|
|
261
|
+
lines += [window_line(win) for win in windows]
|
|
264
262
|
return {"content": [{"type": "text", "text": "\n".join(lines) or "No usage data available."}]}
|
|
265
263
|
|
|
266
264
|
tools.append(usage)
|
|
@@ -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
|
|
|
@@ -165,9 +165,18 @@ async def remove_agent(agent_id: str):
|
|
|
165
165
|
await pool.restart(agent_id)
|
|
166
166
|
if agents.remove(agent_id) is None:
|
|
167
167
|
raise HTTPException(status_code=404, detail="not found")
|
|
168
|
+
_placements_removed(agent_id, categories.forget_agent(agent_id))
|
|
168
169
|
return api_response()
|
|
169
170
|
|
|
170
171
|
|
|
172
|
+
def _placements_removed(agent_id: str, session_ids: list[str]):
|
|
173
|
+
if session_ids:
|
|
174
|
+
chat_list.hub.publish([
|
|
175
|
+
{"type": "agent_placement_removed", "agent": agent_id, "session_id": session_id}
|
|
176
|
+
for session_id in session_ids
|
|
177
|
+
])
|
|
178
|
+
|
|
179
|
+
|
|
171
180
|
@router.get("/agents/{agent_id}/env")
|
|
172
181
|
def agent_env(agent_id: str, x_security_key: str = Header("")):
|
|
173
182
|
if not key_matches(x_security_key):
|
|
@@ -208,9 +217,39 @@ async def agent_session_delete(agent_id: str, cwd: str, session: str):
|
|
|
208
217
|
await agent_sessions.forget(agent_id, cwd, session)
|
|
209
218
|
except (AcpError, agents.AgentError, OSError) as exc:
|
|
210
219
|
return _failed(exc)
|
|
220
|
+
if categories.forget_session(session, agent_id):
|
|
221
|
+
_placements_removed(agent_id, [session])
|
|
211
222
|
return api_response()
|
|
212
223
|
|
|
213
224
|
|
|
225
|
+
class SessionPlace(BaseModel):
|
|
226
|
+
session: str = Field(min_length=1)
|
|
227
|
+
category_id: Optional[str] = None
|
|
228
|
+
index: Optional[int] = None
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
@router.post("/agents/{agent_id}/sessions/category")
|
|
232
|
+
async def agent_session_place(agent_id: str, body: SessionPlace):
|
|
233
|
+
try:
|
|
234
|
+
placement = categories.place_session(body.session, body.category_id, body.index, agent_id)
|
|
235
|
+
except ValueError as exc:
|
|
236
|
+
raise HTTPException(status_code=400, detail=str(exc))
|
|
237
|
+
chat_list.hub.publish([{"type": "agent_placement_changed", "placement": placement}])
|
|
238
|
+
return api_response(data=placement)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
class SessionOrder(BaseModel):
|
|
242
|
+
sessions: list[str]
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
@router.post("/agents/{agent_id}/sessions/order")
|
|
246
|
+
async def agent_session_order(agent_id: str, body: SessionOrder):
|
|
247
|
+
created = categories.seed_order(body.sessions, agent_id)
|
|
248
|
+
if created:
|
|
249
|
+
chat_list.hub.publish([{"type": "agent_placement_changed", "placement": item} for item in created])
|
|
250
|
+
return api_response(data=created)
|
|
251
|
+
|
|
252
|
+
|
|
214
253
|
@router.post("/agents/{agent_id}/sessions/rename")
|
|
215
254
|
async def agent_session_rename(agent_id: str, body: SessionRename):
|
|
216
255
|
try:
|
|
@@ -224,6 +263,7 @@ async def _signed_in(agent_id: str, held: terminal.Terminal) -> None:
|
|
|
224
263
|
await held.exited.wait()
|
|
225
264
|
if held.exit_status in (None, 0):
|
|
226
265
|
await pool.restart(agent_id)
|
|
266
|
+
agent_sessions.watch.refresh(agent_id)
|
|
227
267
|
|
|
228
268
|
|
|
229
269
|
async def _login_command(agent_id: str, method: str, cwd: str) -> tuple[str, list[str], dict[str, str]]:
|
|
@@ -41,6 +41,7 @@ async def get_capabilities(capabilities: str = Query(""), account: str = Query("
|
|
|
41
41
|
"supported_cli": SUPPORTED_CLI,
|
|
42
42
|
"permission_modes": [{"id": m, "label": PERMISSION_LABELS.get(m, m)} for m in permission_modes()],
|
|
43
43
|
"models": listed,
|
|
44
|
+
"subagent_efforts": cli_info.subagent_efforts(info),
|
|
44
45
|
"request_limit": REQUEST_LIMIT_BYTES,
|
|
45
46
|
"shared_scheme": SHARED_SCHEME,
|
|
46
47
|
"pack_schema": PACK_SCHEMA["schema"],
|
|
@@ -81,6 +81,7 @@ class _Session:
|
|
|
81
81
|
self.effort: str = "max"
|
|
82
82
|
self.partial: bool = False
|
|
83
83
|
self.agent: str | None = None
|
|
84
|
+
self.locale: str | None = None
|
|
84
85
|
|
|
85
86
|
|
|
86
87
|
def _build_turn_runner(session, text: str, attachments: list[str] | None = None, seed_id: str | None = None, wanted=None, capabilities=None, on_transport=None, adopt=False, shown=None):
|
|
@@ -137,6 +138,7 @@ def _build_turn_runner(session, text: str, attachments: list[str] | None = None,
|
|
|
137
138
|
request_compact=request_compact,
|
|
138
139
|
reload=lambda kind: session.reload(f"reload-{kind}"),
|
|
139
140
|
capabilities=capabilities,
|
|
141
|
+
locale=state.locale,
|
|
140
142
|
on_transport=on_transport,
|
|
141
143
|
adopt=adopted,
|
|
142
144
|
read_from=shown if adopted else None,
|
|
@@ -311,6 +313,7 @@ def _build_side_runner(main_state: _Session, side_state: _Session, question: str
|
|
|
311
313
|
model=_side_model(main_state),
|
|
312
314
|
emit=emit,
|
|
313
315
|
capabilities=capabilities,
|
|
316
|
+
locale=main_state.locale,
|
|
314
317
|
session_info=lambda: {
|
|
315
318
|
"session_id": side_state.session_id,
|
|
316
319
|
"cwd": str(paths.AI_WORKDIR),
|
|
@@ -325,14 +328,14 @@ def _build_side_runner(main_state: _Session, side_state: _Session, question: str
|
|
|
325
328
|
return factory
|
|
326
329
|
|
|
327
330
|
|
|
328
|
-
async def _run_usage(send, account: str | None = None, capabilities=None):
|
|
331
|
+
async def _run_usage(send, account: str | None = None, capabilities=None, locale: str | None = None):
|
|
329
332
|
"""Send the plan-usage report as a one-off markdown message."""
|
|
330
333
|
from mcps.components import CAPABILITY as COMPONENTS
|
|
331
334
|
from services.usage import CAPABILITY as USAGE, usage_blocks, usage_data, usage_markdown
|
|
332
335
|
|
|
333
336
|
try:
|
|
334
337
|
if USAGE in (capabilities or ()):
|
|
335
|
-
await send({"type": "usage", **await usage_data(account), "local": True})
|
|
338
|
+
await send({"type": "usage", **await usage_data(account, language=locale), "local": True})
|
|
336
339
|
elif COMPONENTS in (capabilities or ()):
|
|
337
340
|
await send({"type": "component", "blocks": await usage_blocks(account), "local": True})
|
|
338
341
|
else:
|
|
@@ -437,6 +440,7 @@ async def chat_ws(ws: WebSocket):
|
|
|
437
440
|
state.effort = msg.effort or settings_store.get("effort")
|
|
438
441
|
state.partial = msg.partial if msg.partial is not None else settings_store.get("streaming")
|
|
439
442
|
session = registry.create(state)
|
|
443
|
+
session.state.locale = msg.locale or session.state.locale
|
|
440
444
|
if previous is not None and previous is not session:
|
|
441
445
|
await previous.detach(sink)
|
|
442
446
|
await send({
|
|
@@ -635,7 +639,12 @@ async def chat_ws(ws: WebSocket):
|
|
|
635
639
|
await send({"type": "error", "message": "busy: a side question is already running", "channel": side_session.channel})
|
|
636
640
|
|
|
637
641
|
elif mtype == "usage":
|
|
638
|
-
spawn(_run_usage(
|
|
642
|
+
spawn(_run_usage(
|
|
643
|
+
send,
|
|
644
|
+
accounts.resolve(session.state.account if session else None),
|
|
645
|
+
seen["capabilities"],
|
|
646
|
+
session.state.locale if session else None,
|
|
647
|
+
))
|
|
639
648
|
|
|
640
649
|
elif mtype == "reload":
|
|
641
650
|
if session is not None:
|
|
@@ -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, force: bool = False):
|
|
20
|
-
return api_response(data=await usage_service.usage_data(account, force))
|
|
19
|
+
async def get_usage(account: str | None = None, force: bool = False, lang: str | None = None):
|
|
20
|
+
return api_response(data=await usage_service.usage_data(account, force, 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
|
|
@@ -407,6 +407,12 @@ def _identity(account_id: Optional[str]) -> dict:
|
|
|
407
407
|
return {key: data[key] for key in _IDENTITY_KEYS if key in data}
|
|
408
408
|
|
|
409
409
|
|
|
410
|
+
def plan_name(account_id: Optional[str]) -> Optional[str]:
|
|
411
|
+
account =_identity(account_id).get("oauthAccount")
|
|
412
|
+
name = account.get("planDisplayName") if isinstance(account, dict) else None
|
|
413
|
+
return name if isinstance(name, str) and name.strip() else None
|
|
414
|
+
|
|
415
|
+
|
|
410
416
|
def export_bundle(account_id: str) -> Optional[bytes]:
|
|
411
417
|
"""Zip the credentials and the account's own config. History, caches, the
|
|
412
418
|
machine id and the linked projects/plugins/skills are all left out."""
|
|
@@ -520,13 +526,14 @@ def _merge_shared(source: Path, target: Path, keys: tuple[str, ...]) -> None:
|
|
|
520
526
|
current = json.loads(target.read_text(encoding="utf-8"))
|
|
521
527
|
except (OSError, json.JSONDecodeError):
|
|
522
528
|
current = {}
|
|
523
|
-
before = {key:
|
|
529
|
+
before = {key: cli_settings.lookup(current, key) for key in keys}
|
|
524
530
|
for key in keys:
|
|
525
|
-
|
|
526
|
-
|
|
531
|
+
value = cli_settings.lookup(primary, key)
|
|
532
|
+
if value is None:
|
|
533
|
+
cli_settings.discard(current, key)
|
|
527
534
|
else:
|
|
528
|
-
|
|
529
|
-
if target.is_file() and before == {key:
|
|
535
|
+
cli_settings.assign(current, key, value)
|
|
536
|
+
if target.is_file() and before == {key: cli_settings.lookup(current, key) for key in keys}:
|
|
530
537
|
return
|
|
531
538
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
532
539
|
target.write_text(json.dumps(current, indent=2), encoding="utf-8")
|
|
@@ -23,14 +23,6 @@ FINISHED = ("completed", "failed")
|
|
|
23
23
|
COMPACTION_DONE = "completed"
|
|
24
24
|
COMPACTION_RUNNING = "in_progress"
|
|
25
25
|
PERMISSION_IDS = {"allow_once": "allow", "allow_always": "allow_always", "reject_once": "deny", "reject_always": "deny"}
|
|
26
|
-
ACCEPT = "accept"
|
|
27
|
-
DECLINE = "decline"
|
|
28
|
-
URL_MODE = "url"
|
|
29
|
-
URL_ACTION = "action"
|
|
30
|
-
INTEGER = "integer"
|
|
31
|
-
NUMBER = "number"
|
|
32
|
-
BOOLEAN = "boolean"
|
|
33
|
-
ARRAY = "array"
|
|
34
26
|
|
|
35
27
|
Share = Callable[[bytes, str, str], Awaitable[Optional[dict]]]
|
|
36
28
|
Watch = Callable[[str, str], None]
|
|
@@ -248,103 +240,3 @@ def permission_outcome(answer: dict, params: dict) -> dict:
|
|
|
248
240
|
def resolved_id(option_id: Optional[str], options: list) -> Optional[str]:
|
|
249
241
|
kind = next((option.get("kind") for option in options if isinstance(option, dict) and option.get("id") == option_id), None)
|
|
250
242
|
return PERMISSION_IDS.get(kind or "", option_id)
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
def _field(name: str, spec: dict, required: bool) -> list[dict]:
|
|
254
|
-
kind = spec.get("type")
|
|
255
|
-
label = str(spec.get("title") or name)
|
|
256
|
-
base: dict = {"id": name, "label": label, **({"required": True} if required else {})}
|
|
257
|
-
about = [{"type": "text", "text": str(spec["description"])}] if spec.get("description") else []
|
|
258
|
-
if kind == BOOLEAN:
|
|
259
|
-
return [*about, {**base, "type": "toggle", "value": bool(spec.get("default"))}]
|
|
260
|
-
if kind in (NUMBER, INTEGER):
|
|
261
|
-
bounds = {key: spec[key] for key in ("minimum", "maximum") if isinstance(spec.get(key), (int, float))}
|
|
262
|
-
return [*about, {
|
|
263
|
-
**base,
|
|
264
|
-
"type": "input",
|
|
265
|
-
"format": "number",
|
|
266
|
-
**({"min": bounds["minimum"]} if "minimum" in bounds else {}),
|
|
267
|
-
**({"max": bounds["maximum"]} if "maximum" in bounds else {}),
|
|
268
|
-
**({"step": 1} if kind == INTEGER else {}),
|
|
269
|
-
**({"value": str(spec["default"])} if spec.get("default") is not None else {}),
|
|
270
|
-
}]
|
|
271
|
-
if kind == ARRAY:
|
|
272
|
-
items = spec.get("items") or {}
|
|
273
|
-
return [*about, {**base, "type": "select", "multiple": True, "options": _choices(items)}]
|
|
274
|
-
choices = _choices(spec)
|
|
275
|
-
if choices:
|
|
276
|
-
return [*about, {**base, "type": "select", "display": "dropdown", "options": choices}]
|
|
277
|
-
return [*about, {
|
|
278
|
-
**base,
|
|
279
|
-
"type": "input",
|
|
280
|
-
**{key: spec[key] for key in ("pattern",) if isinstance(spec.get(key), str)},
|
|
281
|
-
**({"min_length": spec["minLength"]} if isinstance(spec.get("minLength"), int) else {}),
|
|
282
|
-
**({"max_length": spec["maxLength"]} if isinstance(spec.get("maxLength"), int) else {}),
|
|
283
|
-
**({"value": str(spec["default"])} if spec.get("default") is not None else {}),
|
|
284
|
-
}]
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
def _choices(spec: dict) -> list[dict]:
|
|
288
|
-
listed = spec.get("oneOf") or spec.get("anyOf")
|
|
289
|
-
if isinstance(listed, list):
|
|
290
|
-
return [
|
|
291
|
-
{"value": str(item.get("const")), "label": str(item.get("title") or item.get("const")), **({"description": str(item["description"])} if item.get("description") else {})}
|
|
292
|
-
for item in listed
|
|
293
|
-
if isinstance(item, dict) and item.get("const") is not None
|
|
294
|
-
]
|
|
295
|
-
if isinstance(spec.get("enum"), list):
|
|
296
|
-
return [{"value": str(value), "label": str(value)} for value in spec["enum"]]
|
|
297
|
-
return []
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
def _typed(value: Any, spec: dict) -> Any:
|
|
301
|
-
kind = spec.get("type")
|
|
302
|
-
if kind == BOOLEAN:
|
|
303
|
-
return value if isinstance(value, bool) else str(value).lower() == "true"
|
|
304
|
-
if kind in (NUMBER, INTEGER):
|
|
305
|
-
try:
|
|
306
|
-
number = float(value)
|
|
307
|
-
except (TypeError, ValueError):
|
|
308
|
-
return value
|
|
309
|
-
return int(number) if kind == INTEGER or number.is_integer() else number
|
|
310
|
-
if kind == ARRAY:
|
|
311
|
-
return value if isinstance(value, list) else [value] if value else []
|
|
312
|
-
return value
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
def elicitation(params: dict) -> dict:
|
|
316
|
-
"""The form the user answers for an agent's request."""
|
|
317
|
-
message = str(params.get("message") or "")
|
|
318
|
-
if params.get("mode") == URL_MODE:
|
|
319
|
-
url = str(params.get("url") or "")
|
|
320
|
-
return {
|
|
321
|
-
"kind": "component",
|
|
322
|
-
"title": message,
|
|
323
|
-
"blocks": [
|
|
324
|
-
{"type": "text", "text": f"[{url}]({url})"},
|
|
325
|
-
{"type": "buttons", "id": URL_ACTION, "options": [
|
|
326
|
-
{"value": ACCEPT, "label": "", "label_key": "link_done", "style": "primary", "icon": "check"},
|
|
327
|
-
{"value": DECLINE, "label": "", "label_key": "cancel", "style": "plain", "icon": "x"},
|
|
328
|
-
]},
|
|
329
|
-
],
|
|
330
|
-
}
|
|
331
|
-
schema = params.get("requestedSchema") or {}
|
|
332
|
-
required = set(schema.get("required") or [])
|
|
333
|
-
blocks = [
|
|
334
|
-
element
|
|
335
|
-
for name, spec in (schema.get("properties") or {}).items()
|
|
336
|
-
if isinstance(spec, dict)
|
|
337
|
-
for element in _field(str(name), spec, name in required)
|
|
338
|
-
]
|
|
339
|
-
return {"kind": "component", "title": message, "blocks": blocks}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
def elicitation_answer(answer: dict, params: dict) -> dict:
|
|
343
|
-
if answer.get("chat"):
|
|
344
|
-
return {"action": DECLINE}
|
|
345
|
-
values = answer.get("values") or {}
|
|
346
|
-
if params.get("mode") == URL_MODE:
|
|
347
|
-
return {"action": ACCEPT if values.get(URL_ACTION) == ACCEPT else DECLINE}
|
|
348
|
-
properties = (params.get("requestedSchema") or {}).get("properties") or {}
|
|
349
|
-
content = {name: _typed(values[name], spec) for name, spec in properties.items() if name in values and isinstance(spec, dict)}
|
|
350
|
-
return {"action": ACCEPT, "content": content}
|
|
@@ -10,7 +10,7 @@ from typing import Any, Awaitable, Callable, Optional, Protocol
|
|
|
10
10
|
import psutil
|
|
11
11
|
|
|
12
12
|
from core import packages, process_job, release
|
|
13
|
-
from services import
|
|
13
|
+
from services import agents, elicitation, persistent_sessions
|
|
14
14
|
from services.acp_peer import AUTH_REQUIRED, INTERNAL_ERROR, RESOURCE_NOT_FOUND, STREAM_LIMIT, AcpError, AcpPeer
|
|
15
15
|
|
|
16
16
|
PROTOCOL_VERSION = 1
|
|
@@ -146,7 +146,7 @@ class AgentConnection:
|
|
|
146
146
|
if receiver is not None:
|
|
147
147
|
return await receiver.requested(method, params)
|
|
148
148
|
if method == ELICIT and self._login_ask is not None:
|
|
149
|
-
return
|
|
149
|
+
return elicitation.answer(await self._login_ask(elicitation.form(params)), params)
|
|
150
150
|
raise AcpError(RESOURCE_NOT_FOUND, f"no session for {method}")
|
|
151
151
|
|
|
152
152
|
async def _notified(self, method: str, params: dict) -> None:
|
|
@@ -12,7 +12,7 @@ from urllib.parse import urlparse
|
|
|
12
12
|
|
|
13
13
|
from core import paths
|
|
14
14
|
from mcps.shared_files import listing
|
|
15
|
-
from services import acp_events, agents, attachments, event_rows, shared, terminal
|
|
15
|
+
from services import acp_events, agents, attachments, elicitation, event_rows, shared, terminal
|
|
16
16
|
from services.acp_peer import AUTH_REQUIRED, INVALID_PARAMS, METHOD_NOT_FOUND, RESOURCE_NOT_FOUND, AcpError
|
|
17
17
|
from services.agent_connections import AgentConnection, pool
|
|
18
18
|
from services.live_sessions import registry
|
|
@@ -255,6 +255,7 @@ class AgentSession:
|
|
|
255
255
|
|
|
256
256
|
async def open(self, resume: Optional[str] = None, signing_in: bool = False, create_now: bool = False) -> None:
|
|
257
257
|
self.released = False
|
|
258
|
+
signed_out = self.status == SIGN_IN
|
|
258
259
|
self.status = LOADING if self._process_up() else CONNECTING
|
|
259
260
|
self.reason, self.detail = None, ""
|
|
260
261
|
await self._announce()
|
|
@@ -275,6 +276,8 @@ class AgentSession:
|
|
|
275
276
|
except OSError as exc:
|
|
276
277
|
self._fail(FAILED, str(exc))
|
|
277
278
|
await self._announce()
|
|
279
|
+
if signed_out and self.status == READY:
|
|
280
|
+
watch.refresh(self.agent_id)
|
|
278
281
|
if resume and self._emit is not None:
|
|
279
282
|
await self._emit(self.history())
|
|
280
283
|
|
|
@@ -513,6 +516,7 @@ class AgentSession:
|
|
|
513
516
|
return
|
|
514
517
|
self._fail(SIGN_IN, "")
|
|
515
518
|
await self._announce()
|
|
519
|
+
watch.refresh(self.agent_id)
|
|
516
520
|
|
|
517
521
|
async def _wait(self, asked: Awaitable[dict]) -> Optional[dict]:
|
|
518
522
|
answer = asyncio.ensure_future(asked)
|
|
@@ -556,9 +560,9 @@ class AgentSession:
|
|
|
556
560
|
|
|
557
561
|
async def _elicit(self, params: dict) -> dict:
|
|
558
562
|
if self._ask is None:
|
|
559
|
-
return
|
|
560
|
-
answer = await self._wait(self._ask(
|
|
561
|
-
return
|
|
563
|
+
return elicitation.cancelled()
|
|
564
|
+
answer = await self._wait(self._ask(elicitation.form(params)))
|
|
565
|
+
return elicitation.answer(answer, params) if answer is not None else elicitation.cancelled()
|
|
562
566
|
|
|
563
567
|
def _path(self, raw: Any) -> Path:
|
|
564
568
|
path = Path(str(raw or ""))
|
|
@@ -806,11 +810,16 @@ async def fork(agent_id: str, cwd: str, session_id: str) -> str:
|
|
|
806
810
|
|
|
807
811
|
|
|
808
812
|
async def _snapshot(agent_id: str, cwd: str) -> dict:
|
|
813
|
+
reason = None
|
|
809
814
|
try:
|
|
810
815
|
listed = await all_sessions(agent_id, cwd)
|
|
811
|
-
except
|
|
816
|
+
except AcpError as exc:
|
|
812
817
|
listed = None
|
|
813
|
-
|
|
818
|
+
reason = SIGN_IN if exc.code == AUTH_REQUIRED else FAILED
|
|
819
|
+
except (agents.AgentError, OSError):
|
|
820
|
+
listed = None
|
|
821
|
+
reason = FAILED
|
|
822
|
+
return {"type": "sessions", "agent": agent_id, "cwd": cwd, "sessions": listed, "reason": reason}
|
|
814
823
|
|
|
815
824
|
|
|
816
825
|
class SessionsWatch:
|
|
@@ -835,6 +844,10 @@ class SessionsWatch:
|
|
|
835
844
|
if watching:
|
|
836
845
|
asyncio.get_running_loop().create_task(self._push(agent_id, cwd, watching))
|
|
837
846
|
|
|
847
|
+
def refresh(self, agent_id: str) -> None:
|
|
848
|
+
for folder in {cwd for agent, cwd in self._watching.values() if agent == agent_id}:
|
|
849
|
+
self.changed(agent_id, folder)
|
|
850
|
+
|
|
838
851
|
def activity(self, agent_id: str, cwd: str, session_id: str, activity: Optional[str]) -> None:
|
|
839
852
|
update = {"type": "activity", "agent": agent_id, "cwd": cwd, "session_id": session_id, "activity": activity}
|
|
840
853
|
for queue, key in self._watching.items():
|