cconnect 2.0.4__tar.gz → 2.0.6__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.4 → cconnect-2.0.6}/PKG-INFO +1 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/cconnect.egg-info/PKG-INFO +1 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/cconnect.egg-info/SOURCES.txt +1 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/app.py +2 -3
- {cconnect-2.0.4 → cconnect-2.0.6}/core/cli.py +88 -10
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/catppuccin-mocha.json +1 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/claude-dark.json +1 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/claude-light.json +1 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/dracula.json +1 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/github-dark-hc.json +1 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/github-dark.json +1 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/github-dimmed.json +1 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/github-light-hc.json +1 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/nord.json +1 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/one-dark.json +1 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/tokyo-night.json +1 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/vscode-dark-plus.json +1 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/vscode-light-modern.json +1 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/schema.json +3 -3
- {cconnect-2.0.4 → cconnect-2.0.6}/core/paths.py +3 -1
- cconnect-2.0.6/core/process_job.py +89 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/release.py +2 -2
- {cconnect-2.0.4 → cconnect-2.0.6}/core/ws.py +8 -3
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/agents.py +31 -5
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/chat.py +11 -4
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/sessions.py +1 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/system.py +2 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/services/agent_connections.py +2 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/services/agent_sessions.py +234 -60
- {cconnect-2.0.4 → cconnect-2.0.6}/services/claude_runtime.py +2 -3
- {cconnect-2.0.4 → cconnect-2.0.6}/services/delegate_runner.py +1 -1
- {cconnect-2.0.4 → cconnect-2.0.6}/services/live_sessions.py +25 -2
- {cconnect-2.0.4 → cconnect-2.0.6}/services/sessions.py +38 -5
- {cconnect-2.0.4 → cconnect-2.0.6}/cconnect.egg-info/dependency_links.txt +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/cconnect.egg-info/entry_points.txt +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/cconnect.egg-info/requires.txt +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/cconnect.egg-info/top_level.txt +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/__init__.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/access.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/cli_manager.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/config.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/data_migration.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/db.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/display.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/models.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packages.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/builtin.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect/accents.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect/pack.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect/terminal/black.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect/themes/cconnect-dark.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect/themes/cconnect-light.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/backgrounds/cyberpunk.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/backgrounds/darkwave.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/pack.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/campbell.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/catppuccin-latte.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/catppuccin-mocha.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/claude-dark.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/claude-light.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/dark-plus.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/dracula.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/github-dark-hc.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/github-dark.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/github-dimmed.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/github-light-hc.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/github-light.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/gruvbox-dark.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/light-plus.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/monokai.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/nord.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/one-dark.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/one-half-dark.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/one-half-light.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/rose-pine.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/solarized-dark.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/solarized-light.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/tango-dark.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/tango-light.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/tokyo-night.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/ubuntu.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/vscode-dark-modern.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/vscode-hc-dark.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/vscode-hc-light.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/terminal/vscode-light-modern.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/catppuccin-latte.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/github-light.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/gruvbox-dark.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/rose-pine.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/solarized-dark.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/solarized-light.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/vscode-dark-modern.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/vscode-hc-dark.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/vscode-hc-light.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/packs/cconnect-extras/themes/vscode-light-plus.json +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/prompts/BLOCKS.md +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/prompts/BROWSER.md +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/prompts/CCONNECT.md +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/prompts/COMMIT.md +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/prompts/MODS.md +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/prompts/SUGGESTIONS.md +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/rate_limit.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/responses.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/scripts/page_icon.js +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/sdk.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/settings_defs.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/core/slugs.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/mcps/__init__.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/mcps/browser.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/mcps/check_progress.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/mcps/components.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/mcps/delegate.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/mcps/media.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/mcps/packs.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/mcps/session.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/mcps/shared_files.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/mcps/terminal.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/middleware/__init__.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/middleware/error_handler.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/middleware/public_auth.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/middleware/security.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/pyproject.toml +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/__init__.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/accounts.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/browser.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/capabilities.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/claude.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/cli.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/git.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/health.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/list.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/network.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/packs.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/projects.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/settings.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/shared.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/routers/terminal.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/schemas/__init__.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/schemas/accounts.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/schemas/chat.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/schemas/network.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/__init__.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/account_login.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/accounts.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/acp_events.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/acp_peer.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/agent_registry.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/agents.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/api_errors.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/attachments.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/blocks.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/browser.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/categories.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/chat_list.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/claude_assets.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/claude_manage.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/claude_status.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/cli_info.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/cli_settings.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/delegate_runs.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/delegates.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/diffs.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/directories.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/directory_watch.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/event_rows.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/files.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/git.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/git_ops.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/mods.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/network.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/pack_format.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/packs.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/persistent_sessions.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/project_files.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/project_watch.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/projects.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/prompt_cache.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/providers.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/questions.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/repo.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/rewind.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/settings_store.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/shared.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/shared_links.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/shared_watch.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/speedtest.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/system_monitor.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/system_watch.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/terminal.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/todos.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/tool_calls.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/tool_props.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/trash.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/usage.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/services/visibility.py +0 -0
- {cconnect-2.0.4 → cconnect-2.0.6}/setup.cfg +0 -0
|
@@ -57,9 +57,8 @@ async def lifespan(app: FastAPI):
|
|
|
57
57
|
project_watch.hub.stop()
|
|
58
58
|
system_watch.hub.stop()
|
|
59
59
|
network.watchdog.stop()
|
|
60
|
-
from services import
|
|
61
|
-
await
|
|
62
|
-
await agent_connections.pool.close_all()
|
|
60
|
+
from services import live_sessions
|
|
61
|
+
await live_sessions.close_processes()
|
|
63
62
|
paths.RUNTIME_FILE.unlink(missing_ok=True)
|
|
64
63
|
|
|
65
64
|
|
|
@@ -13,16 +13,18 @@ import shutil
|
|
|
13
13
|
import socket
|
|
14
14
|
import subprocess
|
|
15
15
|
import sys
|
|
16
|
+
import time
|
|
16
17
|
from contextlib import suppress
|
|
18
|
+
from datetime import datetime
|
|
17
19
|
from pathlib import Path
|
|
18
20
|
from urllib.parse import urlparse
|
|
19
21
|
|
|
20
22
|
import psutil
|
|
21
23
|
import qrcode
|
|
22
24
|
|
|
23
|
-
from core import data_migration, paths, release
|
|
25
|
+
from core import cli_manager, data_migration, paths, release, sdk
|
|
24
26
|
from core.config import PORT, RESTART_EXIT_CODE
|
|
25
|
-
from services import repo, system_monitor
|
|
27
|
+
from services import agent_registry, repo, system_monitor
|
|
26
28
|
|
|
27
29
|
_ENV_PATH = paths.ENV_FILE
|
|
28
30
|
_TOKEN_VAR = "PUBLIC_ACCESS_TOKEN"
|
|
@@ -34,7 +36,8 @@ _STOP_TIMEOUT = 10
|
|
|
34
36
|
_POLL_SECONDS = 0.5
|
|
35
37
|
_MODULE = "core.cli"
|
|
36
38
|
_APP = "core.app:app"
|
|
37
|
-
_COMMANDS = ("run", "expose", "stop", "status", "update", "migrate", "key")
|
|
39
|
+
_COMMANDS = ("run", "expose", "stop", "restart", "status", "logs", "doctor", "update", "migrate", "key")
|
|
40
|
+
_TOP_FLAGS = ("-h", "--help", "-v", "--version")
|
|
38
41
|
|
|
39
42
|
|
|
40
43
|
def _abort(msg: str) -> None:
|
|
@@ -408,21 +411,23 @@ def _flag_parser() -> argparse.ArgumentParser:
|
|
|
408
411
|
f"{_HOSTNAME_VAR}, then to <user>-<ip>.sslip.io.")
|
|
409
412
|
parser.add_argument("--detach", action="store_true",
|
|
410
413
|
help="Run in the background and return; the server outlives the terminal.")
|
|
414
|
+
parser.add_argument("--port", type=int, default=None, help=f"Port to serve on instead of {PORT}.")
|
|
411
415
|
parser.add_argument("--stop", action="store_true",
|
|
412
416
|
help="Stop a backend previously started with --detach.")
|
|
413
417
|
parser.add_argument("--security-key", action="store_true",
|
|
414
418
|
help="Print the key that unlocks the terminal and ignored files, generating it the first time.")
|
|
415
419
|
parser.add_argument("--rotate", action="store_true",
|
|
416
420
|
help="With --security-key, replace the existing key instead of printing it.")
|
|
417
|
-
parser.set_defaults(command="", source="", force=False, json=False)
|
|
421
|
+
parser.set_defaults(command="", source="", force=False, json=False, follow=False)
|
|
418
422
|
return parser
|
|
419
423
|
|
|
420
424
|
|
|
421
425
|
def _command_parser() -> argparse.ArgumentParser:
|
|
422
426
|
parser = argparse.ArgumentParser(prog="cconnect", description="CConnect backend.")
|
|
427
|
+
parser.add_argument("-v", "--version", action="version", version=f"cconnect {release.VERSION}")
|
|
423
428
|
parser.set_defaults(
|
|
424
|
-
production=False, expose="", public_host="", detach=False,
|
|
425
|
-
security_key=False, rotate=False, source="", force=False, json=False,
|
|
429
|
+
production=False, expose="", public_host="", detach=False, port=None,
|
|
430
|
+
security_key=False, rotate=False, source="", force=False, json=False, follow=False,
|
|
426
431
|
)
|
|
427
432
|
commands = parser.add_subparsers(dest="command")
|
|
428
433
|
|
|
@@ -431,6 +436,7 @@ def _command_parser() -> argparse.ArgumentParser:
|
|
|
431
436
|
help="No reload, multi-worker (Linux/macOS only).")
|
|
432
437
|
run.add_argument("--detach", action="store_true",
|
|
433
438
|
help="Run in the background; the server outlives the terminal.")
|
|
439
|
+
run.add_argument("--port", type=int, default=None, help=f"Port to serve on instead of {PORT}.")
|
|
434
440
|
|
|
435
441
|
expose = commands.add_parser("expose", help="Serve over the internet, token-gated.")
|
|
436
442
|
expose.add_argument("provider", choices=list(_PROVIDERS))
|
|
@@ -441,12 +447,20 @@ def _command_parser() -> argparse.ArgumentParser:
|
|
|
441
447
|
help="Run in the background; the server outlives the terminal.")
|
|
442
448
|
expose.add_argument("--production", action="store_true",
|
|
443
449
|
help="No reload, multi-worker (Linux/macOS only).")
|
|
450
|
+
expose.add_argument("--port", type=int, default=None, help=f"Port to serve on instead of {PORT}.")
|
|
444
451
|
|
|
445
452
|
commands.add_parser("stop", help="Stop a backend started with --detach.")
|
|
446
453
|
|
|
454
|
+
commands.add_parser("restart", help="Restart the backend that is running.")
|
|
455
|
+
|
|
447
456
|
status = commands.add_parser("status", help="Version, where the data lives and what is running.")
|
|
448
457
|
status.add_argument("--json", action="store_true", help="Print it as JSON, for other programs.")
|
|
449
458
|
|
|
459
|
+
logs = commands.add_parser("logs", help="Print the server log.")
|
|
460
|
+
logs.add_argument("-f", "--follow", action="store_true", help="Keep printing new entries as they arrive.")
|
|
461
|
+
|
|
462
|
+
commands.add_parser("doctor", help="Check what the backend needs on this machine.")
|
|
463
|
+
|
|
450
464
|
commands.add_parser("update", help="Upgrade this install to the latest release.")
|
|
451
465
|
|
|
452
466
|
migrate = commands.add_parser("migrate", help="Copy a previous data folder into this one.")
|
|
@@ -462,7 +476,7 @@ def _command_parser() -> argparse.ArgumentParser:
|
|
|
462
476
|
|
|
463
477
|
|
|
464
478
|
def _parse(argv: list[str]) -> argparse.Namespace:
|
|
465
|
-
legacy = bool(argv) and argv[0].startswith("-") and argv[0] not in
|
|
479
|
+
legacy = bool(argv) and argv[0].startswith("-") and argv[0] not in _TOP_FLAGS
|
|
466
480
|
if legacy:
|
|
467
481
|
args = _flag_parser().parse_args(argv)
|
|
468
482
|
args.command = "key" if args.security_key else "stop" if args.stop else "run"
|
|
@@ -511,6 +525,56 @@ def _print_status(as_json: bool) -> None:
|
|
|
511
525
|
_print_rows(rows)
|
|
512
526
|
|
|
513
527
|
|
|
528
|
+
def _print_entries(page: dict) -> int:
|
|
529
|
+
for entry in page["items"]:
|
|
530
|
+
stamp = datetime.fromtimestamp(entry["ts"]).strftime("%H:%M:%S")
|
|
531
|
+
print(f"{stamp} {entry['level']:<8} {entry['message']}", flush=True)
|
|
532
|
+
return page["offset"]
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
def _print_logs(follow: bool) -> None:
|
|
536
|
+
offset = _print_entries(system_monitor.logs())
|
|
537
|
+
with suppress(KeyboardInterrupt):
|
|
538
|
+
while follow:
|
|
539
|
+
time.sleep(_POLL_SECONDS)
|
|
540
|
+
offset = _print_entries(system_monitor.logs(offset))
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
def _restart() -> None:
|
|
544
|
+
live = _runtime()
|
|
545
|
+
if not live:
|
|
546
|
+
_abort("No backend is running.")
|
|
547
|
+
paths.RESTART_FLAG.touch()
|
|
548
|
+
print(f"Restarting the backend (pid {live['PID']}).")
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
def _port_state(port: int) -> str:
|
|
552
|
+
live = _runtime()
|
|
553
|
+
if live and int(live.get("PORT") or 0) == port:
|
|
554
|
+
return f"{port}, this backend (pid {live['PID']})"
|
|
555
|
+
with socket.socket() as probe:
|
|
556
|
+
probe.settimeout(1)
|
|
557
|
+
taken = probe.connect_ex(("127.0.0.1", port)) == 0
|
|
558
|
+
return f"{port}, taken by another program" if taken else f"{port}, free"
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
def _doctor(port: int) -> None:
|
|
562
|
+
system = cli_manager.system_cli()
|
|
563
|
+
tools = agent_registry.node_tools()
|
|
564
|
+
tailscale = (_tailscale_status().get("BackendState") or "installed, not running") if shutil.which("tailscale") else None
|
|
565
|
+
_print_rows([
|
|
566
|
+
("Version", release.VERSION),
|
|
567
|
+
("Data", str(paths.DATA_DIR)),
|
|
568
|
+
("Claude CLI", f"{system} ({cli_manager.cli_version(system) or 'version unknown'})" if system else "not on PATH"),
|
|
569
|
+
("Bundled CLI", cli_manager.bundled_version() or "missing"),
|
|
570
|
+
("Agent SDK", sdk.installed_version() or "missing"),
|
|
571
|
+
("Node.js", " and ".join(tools) if tools else "node or npm missing, agents from npm cannot install"),
|
|
572
|
+
("Tailscale", tailscale or "not installed"),
|
|
573
|
+
("Port", _port_state(port)),
|
|
574
|
+
("Security key", "set" if os.environ.get(_SECURITY_KEY_VAR) else f"not set, run {_invocation()} key"),
|
|
575
|
+
])
|
|
576
|
+
|
|
577
|
+
|
|
514
578
|
def _update() -> None:
|
|
515
579
|
if not paths.INSTALLED:
|
|
516
580
|
_abort("this is a git checkout, not an installed release: update it with git pull.")
|
|
@@ -553,6 +617,8 @@ def _migrate(source: str, force: bool) -> None:
|
|
|
553
617
|
|
|
554
618
|
def main():
|
|
555
619
|
args = _parse(sys.argv[1:])
|
|
620
|
+
port = args.port or PORT
|
|
621
|
+
os.environ["PORT"] = str(port)
|
|
556
622
|
|
|
557
623
|
try:
|
|
558
624
|
moved = data_migration.migrate()
|
|
@@ -571,6 +637,18 @@ def main():
|
|
|
571
637
|
_print_status(args.json)
|
|
572
638
|
return
|
|
573
639
|
|
|
640
|
+
if args.command == "logs":
|
|
641
|
+
_print_logs(args.follow)
|
|
642
|
+
return
|
|
643
|
+
|
|
644
|
+
if args.command == "doctor":
|
|
645
|
+
_doctor(port)
|
|
646
|
+
return
|
|
647
|
+
|
|
648
|
+
if args.command == "restart":
|
|
649
|
+
_restart()
|
|
650
|
+
return
|
|
651
|
+
|
|
574
652
|
if args.command == "update":
|
|
575
653
|
_update()
|
|
576
654
|
return
|
|
@@ -592,7 +670,7 @@ def main():
|
|
|
592
670
|
system_monitor.reset_log_file()
|
|
593
671
|
key_generated = _ensure_security_key()
|
|
594
672
|
if args.expose:
|
|
595
|
-
_expose(args.expose,
|
|
673
|
+
_expose(args.expose, port, args.public_host, keep_running=True, key_generated=key_generated)
|
|
596
674
|
paths.DETACHED_PROVIDER_FILE.write_text(args.expose, encoding="utf-8")
|
|
597
675
|
else:
|
|
598
676
|
_print_security_key(key_generated)
|
|
@@ -608,14 +686,14 @@ def main():
|
|
|
608
686
|
system_monitor.reset_log_file()
|
|
609
687
|
key_generated = _ensure_security_key()
|
|
610
688
|
if args.expose:
|
|
611
|
-
_expose(args.expose,
|
|
689
|
+
_expose(args.expose, port, args.public_host, key_generated=key_generated)
|
|
612
690
|
else:
|
|
613
691
|
_print_security_key(key_generated)
|
|
614
692
|
|
|
615
693
|
reload = not args.production and not is_windows
|
|
616
694
|
workers = int(os.environ.get("WEB_CONCURRENCY", "2")) if (args.production and not is_windows) else 1
|
|
617
695
|
|
|
618
|
-
cmd = [sys.executable, "-m", "uvicorn", _APP, "--host", "0.0.0.0", "--port", str(
|
|
696
|
+
cmd = [sys.executable, "-m", "uvicorn", _APP, "--host", "0.0.0.0", "--port", str(port)]
|
|
619
697
|
if reload:
|
|
620
698
|
cmd += ["--reload", "--reload-exclude", str(paths.DATA_DIR)]
|
|
621
699
|
elif workers > 1:
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"colorRoles": {
|
|
41
41
|
"background": "the window behind everything: the chat, the panels and the browser's start page",
|
|
42
42
|
"on-background": "main text and icons",
|
|
43
|
-
"surface": "panels, dialogs and cards on the background: the chat list, blocks in the chat
|
|
44
|
-
"surface-variant": "raised controls
|
|
45
|
-
"surface-nested": "a block inside another block,
|
|
43
|
+
"surface": "panels, dialogs and cards on the background: the chat list, the composer, and Thinking and the other blocks in the chat",
|
|
44
|
+
"surface-variant": "raised controls and your own messages: fields, chips, buttons, the date separator and the selected row of a list",
|
|
45
|
+
"surface-nested": "code and command output in the chat and a block inside another block, a tone between surface and surface-variant",
|
|
46
46
|
"float": "menus, popovers and floating cards",
|
|
47
47
|
"on-surface-variant": "secondary text and icons: summaries, captions, inactive icons",
|
|
48
48
|
"faint": "the faintest text and marks: placeholders, timestamps and hints",
|
|
@@ -50,7 +50,9 @@ DETACHED_PROVIDER_FILE = STATE_DIR / ".detached.provider"
|
|
|
50
50
|
REWIND_FILE = STATE_DIR / "rewind_pending.json"
|
|
51
51
|
TODOS_FILE = STATE_DIR / "session_todos.json"
|
|
52
52
|
DELEGATE_RUNS_DIR = STATE_DIR / "delegate_runs"
|
|
53
|
-
|
|
53
|
+
AGENT_SESSIONS_FILE = STATE_DIR / "agent_sessions.json"
|
|
54
|
+
AGENT_DEFAULTS_FILE = STATE_DIR / "agent_defaults.json"
|
|
55
|
+
AGENT_TITLES_FILE = STATE_DIR / "agent_titles.json"
|
|
54
56
|
AI_WORKDIR = Path(os.environ.get("AI_WORKDIR") or STATE_DIR / "internal_task")
|
|
55
57
|
|
|
56
58
|
NETWORK_STATE_FILE = CACHE_DIR / "network_state.json"
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import ctypes
|
|
2
|
+
import sys
|
|
3
|
+
from ctypes import wintypes
|
|
4
|
+
from functools import cache
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
7
|
+
_KILL_ON_JOB_CLOSE = 0x2000
|
|
8
|
+
_EXTENDED_LIMIT_INFORMATION = 9
|
|
9
|
+
_PROCESS_TERMINATE = 0x0001
|
|
10
|
+
_PROCESS_SET_QUOTA = 0x0100
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class _BasicLimits(ctypes.Structure):
|
|
14
|
+
_fields_ = [
|
|
15
|
+
("PerProcessUserTimeLimit", ctypes.c_int64),
|
|
16
|
+
("PerJobUserTimeLimit", ctypes.c_int64),
|
|
17
|
+
("LimitFlags", wintypes.DWORD),
|
|
18
|
+
("MinimumWorkingSetSize", ctypes.c_size_t),
|
|
19
|
+
("MaximumWorkingSetSize", ctypes.c_size_t),
|
|
20
|
+
("ActiveProcessLimit", wintypes.DWORD),
|
|
21
|
+
("Affinity", ctypes.c_size_t),
|
|
22
|
+
("PriorityClass", wintypes.DWORD),
|
|
23
|
+
("SchedulingClass", wintypes.DWORD),
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class _IoCounters(ctypes.Structure):
|
|
28
|
+
_fields_ = [
|
|
29
|
+
(name, ctypes.c_uint64)
|
|
30
|
+
for name in (
|
|
31
|
+
"ReadOperationCount", "WriteOperationCount", "OtherOperationCount",
|
|
32
|
+
"ReadTransferCount", "WriteTransferCount", "OtherTransferCount",
|
|
33
|
+
)
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class _ExtendedLimits(ctypes.Structure):
|
|
38
|
+
_fields_ = [
|
|
39
|
+
("BasicLimitInformation", _BasicLimits),
|
|
40
|
+
("IoInfo", _IoCounters),
|
|
41
|
+
("ProcessMemoryLimit", ctypes.c_size_t),
|
|
42
|
+
("JobMemoryLimit", ctypes.c_size_t),
|
|
43
|
+
("PeakProcessMemoryUsed", ctypes.c_size_t),
|
|
44
|
+
("PeakJobMemoryUsed", ctypes.c_size_t),
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
_job: Optional[int] = None
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@cache
|
|
52
|
+
def _kernel32():
|
|
53
|
+
kernel32 = ctypes.WinDLL("kernel32", use_last_error=True)
|
|
54
|
+
kernel32.CreateJobObjectW.restype = wintypes.HANDLE
|
|
55
|
+
kernel32.CreateJobObjectW.argtypes = [ctypes.c_void_p, wintypes.LPCWSTR]
|
|
56
|
+
kernel32.SetInformationJobObject.restype = wintypes.BOOL
|
|
57
|
+
kernel32.SetInformationJobObject.argtypes = [wintypes.HANDLE, ctypes.c_int, ctypes.c_void_p, wintypes.DWORD]
|
|
58
|
+
kernel32.OpenProcess.restype = wintypes.HANDLE
|
|
59
|
+
kernel32.OpenProcess.argtypes = [wintypes.DWORD, wintypes.BOOL, wintypes.DWORD]
|
|
60
|
+
kernel32.AssignProcessToJobObject.restype = wintypes.BOOL
|
|
61
|
+
kernel32.AssignProcessToJobObject.argtypes = [wintypes.HANDLE, wintypes.HANDLE]
|
|
62
|
+
kernel32.CloseHandle.argtypes = [wintypes.HANDLE]
|
|
63
|
+
return kernel32
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _ensure_job(kernel32) -> Optional[int]:
|
|
67
|
+
global _job
|
|
68
|
+
if _job is None:
|
|
69
|
+
job = kernel32.CreateJobObjectW(None, None)
|
|
70
|
+
limits = _ExtendedLimits()
|
|
71
|
+
limits.BasicLimitInformation.LimitFlags = _KILL_ON_JOB_CLOSE
|
|
72
|
+
if job and kernel32.SetInformationJobObject(
|
|
73
|
+
job, _EXTENDED_LIMIT_INFORMATION, ctypes.byref(limits), ctypes.sizeof(limits)
|
|
74
|
+
):
|
|
75
|
+
_job = job
|
|
76
|
+
return _job
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def tie(pid: int) -> None:
|
|
80
|
+
if sys.platform != "win32":
|
|
81
|
+
return
|
|
82
|
+
kernel32 = _kernel32()
|
|
83
|
+
job = _ensure_job(kernel32)
|
|
84
|
+
if job is None:
|
|
85
|
+
return
|
|
86
|
+
process = kernel32.OpenProcess(_PROCESS_TERMINATE | _PROCESS_SET_QUOTA, False, pid)
|
|
87
|
+
if process:
|
|
88
|
+
kernel32.AssignProcessToJobObject(job, process)
|
|
89
|
+
kernel32.CloseHandle(process)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""WebSocket frames: orjson instead of the stdlib encoder Starlette's send_json uses."""
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
|
-
from typing import Any, Callable, Optional
|
|
4
|
+
from typing import Any, Callable, Optional, Protocol
|
|
5
5
|
|
|
6
6
|
import orjson
|
|
7
7
|
from fastapi import WebSocket, WebSocketDisconnect
|
|
@@ -9,7 +9,12 @@ from fastapi.encoders import jsonable_encoder
|
|
|
9
9
|
from loguru import logger
|
|
10
10
|
|
|
11
11
|
from middleware.public_auth import ws_bearer_ok
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class WatchHub(Protocol):
|
|
15
|
+
def subscribe(self) -> asyncio.Queue: ...
|
|
16
|
+
|
|
17
|
+
def unsubscribe(self, queue: asyncio.Queue) -> None: ...
|
|
13
18
|
|
|
14
19
|
|
|
15
20
|
async def send_event(ws: WebSocket, payload: Any) -> None:
|
|
@@ -18,7 +23,7 @@ async def send_event(ws: WebSocket, payload: Any) -> None:
|
|
|
18
23
|
|
|
19
24
|
async def stream_watch(
|
|
20
25
|
ws: WebSocket,
|
|
21
|
-
hub:
|
|
26
|
+
hub: WatchHub,
|
|
22
27
|
on_message: Optional[Callable[[asyncio.Queue, dict], None]] = None,
|
|
23
28
|
) -> None:
|
|
24
29
|
if not ws_bearer_ok(ws):
|
|
@@ -5,12 +5,13 @@ import os
|
|
|
5
5
|
from typing import Literal, Optional
|
|
6
6
|
from urllib.parse import urlparse
|
|
7
7
|
|
|
8
|
-
from fastapi import APIRouter, Header, HTTPException
|
|
8
|
+
from fastapi import APIRouter, Header, HTTPException, WebSocket
|
|
9
9
|
from fastapi.responses import FileResponse, Response
|
|
10
10
|
from pydantic import BaseModel, Field
|
|
11
11
|
|
|
12
12
|
from core.access import key_matches
|
|
13
13
|
from core.responses import FILE_HEADERS, api_response
|
|
14
|
+
from core.ws import stream_watch
|
|
14
15
|
from services import agent_registry, agent_sessions, agents, terminal
|
|
15
16
|
from services.acp_peer import AcpError
|
|
16
17
|
from services.agent_connections import pool
|
|
@@ -51,6 +52,12 @@ class TerminalLogin(BaseModel):
|
|
|
51
52
|
cwd: str
|
|
52
53
|
|
|
53
54
|
|
|
55
|
+
class SessionRename(BaseModel):
|
|
56
|
+
cwd: str
|
|
57
|
+
session: str = Field(min_length=1)
|
|
58
|
+
title: str = Field("", max_length=200)
|
|
59
|
+
|
|
60
|
+
|
|
54
61
|
def _failed(exc: Exception) -> Response:
|
|
55
62
|
if isinstance(exc, agents.AgentError):
|
|
56
63
|
return api_response(status=422, data={"reason": exc.reason, "detail": exc.detail})
|
|
@@ -176,13 +183,23 @@ def agent_log(agent_id: str):
|
|
|
176
183
|
return api_response(data={"lines": pool.log(agent_id)})
|
|
177
184
|
|
|
178
185
|
|
|
179
|
-
|
|
180
|
-
|
|
186
|
+
def _watch_message(queue: asyncio.Queue, message: dict):
|
|
187
|
+
if message.get("type") == "watch":
|
|
188
|
+
agent_sessions.watch.watch(queue, message.get("agent") or "", message.get("cwd") or "")
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
@router.websocket("/agents/ws")
|
|
192
|
+
async def agents_ws(ws: WebSocket):
|
|
193
|
+
await stream_watch(ws, agent_sessions.watch, _watch_message)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
@router.post("/agents/{agent_id}/sessions/fork")
|
|
197
|
+
async def agent_session_fork(agent_id: str, cwd: str, session: str):
|
|
181
198
|
try:
|
|
182
|
-
|
|
199
|
+
forked = await agent_sessions.fork(agent_id, cwd, session)
|
|
183
200
|
except (AcpError, agents.AgentError, OSError) as exc:
|
|
184
201
|
return _failed(exc)
|
|
185
|
-
return api_response(data=
|
|
202
|
+
return api_response(data={"session_id": forked})
|
|
186
203
|
|
|
187
204
|
|
|
188
205
|
@router.delete("/agents/{agent_id}/sessions")
|
|
@@ -194,6 +211,15 @@ async def agent_session_delete(agent_id: str, cwd: str, session: str):
|
|
|
194
211
|
return api_response()
|
|
195
212
|
|
|
196
213
|
|
|
214
|
+
@router.post("/agents/{agent_id}/sessions/rename")
|
|
215
|
+
async def agent_session_rename(agent_id: str, body: SessionRename):
|
|
216
|
+
try:
|
|
217
|
+
await agent_sessions.rename(agent_id, body.cwd, body.session, body.title)
|
|
218
|
+
except OSError as exc:
|
|
219
|
+
return _failed(exc)
|
|
220
|
+
return api_response()
|
|
221
|
+
|
|
222
|
+
|
|
197
223
|
async def _signed_in(agent_id: str, held: terminal.Terminal) -> None:
|
|
198
224
|
await held.exited.wait()
|
|
199
225
|
if held.exit_status in (None, 0):
|
|
@@ -92,7 +92,7 @@ def _build_turn_runner(session, text: str, attachments: list[str] | None = None,
|
|
|
92
92
|
|
|
93
93
|
def factory(ask_user, emit):
|
|
94
94
|
async def one(text, attachments, seed_id, drain, request_compact, adopted=False):
|
|
95
|
-
|
|
95
|
+
fresh = state.session_id is None
|
|
96
96
|
compacted = False
|
|
97
97
|
is_compact_cmd = text.strip() == "/compact" or text.strip().startswith("/compact ")
|
|
98
98
|
is_local_cmd = text.strip().startswith("/") and not is_compact_cmd
|
|
@@ -129,7 +129,6 @@ def _build_turn_runner(session, text: str, attachments: list[str] | None = None,
|
|
|
129
129
|
account=accounts.resolve(state.account),
|
|
130
130
|
effort=state.effort,
|
|
131
131
|
partial=state.partial,
|
|
132
|
-
name=name,
|
|
133
132
|
ask_user=ask_user,
|
|
134
133
|
emit=emit,
|
|
135
134
|
drain=drain() if drain else None,
|
|
@@ -173,6 +172,14 @@ def _build_turn_runner(session, text: str, attachments: list[str] | None = None,
|
|
|
173
172
|
written_from if state.session_id == resumed_sid else 0,
|
|
174
173
|
)
|
|
175
174
|
if state.cwd and state.session_id:
|
|
175
|
+
if fresh and not adopted and not is_local_cmd and not is_compact_cmd:
|
|
176
|
+
asyncio.get_running_loop().create_task(
|
|
177
|
+
sessions_service.name_untitled(
|
|
178
|
+
sessions_service.project_key_for(state.cwd),
|
|
179
|
+
state.session_id,
|
|
180
|
+
accounts.resolve(state.account),
|
|
181
|
+
)
|
|
182
|
+
)
|
|
176
183
|
# The token counts and summary are written to the transcript only after the turn.
|
|
177
184
|
if is_compact_cmd:
|
|
178
185
|
after = sessions_service.compact_boundary_count(state.cwd, state.session_id)
|
|
@@ -240,7 +247,7 @@ def _turn_start(session, prefs=None) -> int:
|
|
|
240
247
|
|
|
241
248
|
def _committed_index(session, prefs=None) -> int | None:
|
|
242
249
|
items = _session_items(session, prefs) if session.running and session.agent is None else None
|
|
243
|
-
return None if items is None else sessions_service.committed_index(items, session.turn_start_index)
|
|
250
|
+
return None if items is None else sessions_service.committed_index(items, session.turn_start_index, session.turn_split)
|
|
244
251
|
|
|
245
252
|
|
|
246
253
|
async def _start_turn(session, mid, text, attachments, prefs=None, capabilities=None):
|
|
@@ -415,7 +422,7 @@ async def chat_ws(ws: WebSocket):
|
|
|
415
422
|
state.cwd = msg.cwd or DEFAULT_CWD
|
|
416
423
|
state.session_id = msg.resume
|
|
417
424
|
session = registry.create(state)
|
|
418
|
-
session.bind_agent(agent_sessions.AgentSession(msg.agent, state.cwd, sessions_service.project_key_for(state.cwd)))
|
|
425
|
+
session.bind_agent(agent_sessions.AgentSession(msg.agent, state.cwd, sessions_service.project_key_for(state.cwd), msg.resume))
|
|
419
426
|
spawn(session.open_agent(msg.resume))
|
|
420
427
|
else:
|
|
421
428
|
state = _Session()
|