cconnect 2.0.7__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.7 → cconnect-2.0.8}/PKG-INFO +1 -1
- {cconnect-2.0.7 → cconnect-2.0.8}/cconnect.egg-info/PKG-INFO +1 -1
- {cconnect-2.0.7 → cconnect-2.0.8}/core/models.py +20 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/paths.py +1 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/release.py +1 -1
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/agents.py +40 -1
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/sessions.py +19 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/categories.py +63 -29
- {cconnect-2.0.7 → cconnect-2.0.8}/services/chat_list.py +1 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/claude_runtime.py +5 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/project_files.py +51 -12
- {cconnect-2.0.7 → cconnect-2.0.8}/services/project_watch.py +14 -2
- {cconnect-2.0.7 → cconnect-2.0.8}/services/sessions.py +15 -2
- {cconnect-2.0.7 → cconnect-2.0.8}/services/system_monitor.py +3 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/cconnect.egg-info/SOURCES.txt +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/cconnect.egg-info/dependency_links.txt +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/cconnect.egg-info/entry_points.txt +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/cconnect.egg-info/requires.txt +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/cconnect.egg-info/top_level.txt +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/__init__.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/access.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/app.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/cli.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/cli_manager.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/config.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/data_migration.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/db.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/display.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packages.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/builtin.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect/accents.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect/pack.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect/terminal/black.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect/themes/cconnect-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect/themes/cconnect-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/backgrounds/cyberpunk.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/backgrounds/darkwave.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/pack.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/campbell.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/catppuccin-latte.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/catppuccin-mocha.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/claude-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/claude-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/dark-plus.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/dracula.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/github-dark-hc.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/github-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/github-dimmed.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/github-light-hc.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/github-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/gruvbox-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/light-plus.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/monokai.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/nord.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/one-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/one-half-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/one-half-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/rose-pine.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/solarized-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/solarized-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/tango-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/tango-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/tokyo-night.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/ubuntu.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/vscode-dark-modern.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/vscode-hc-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/vscode-hc-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/terminal/vscode-light-modern.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/catppuccin-latte.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/catppuccin-mocha.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/claude-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/claude-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/dracula.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/github-dark-hc.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/github-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/github-dimmed.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/github-light-hc.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/github-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/gruvbox-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/nord.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/one-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/rose-pine.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/solarized-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/solarized-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/tokyo-night.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/vscode-dark-modern.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/vscode-dark-plus.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/vscode-hc-dark.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/vscode-hc-light.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/vscode-light-modern.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/cconnect-extras/themes/vscode-light-plus.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/packs/schema.json +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/process_job.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/prompts/BLOCKS.md +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/prompts/BROWSER.md +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/prompts/CCONNECT.md +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/prompts/COMMIT.md +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/prompts/MODS.md +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/prompts/SUGGESTIONS.md +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/rate_limit.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/responses.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/scripts/page_icon.js +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/sdk.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/settings_defs.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/slugs.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/core/ws.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/mcps/__init__.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/mcps/browser.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/mcps/check_progress.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/mcps/components.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/mcps/delegate.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/mcps/media.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/mcps/packs.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/mcps/session.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/mcps/shared_files.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/mcps/terminal.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/middleware/__init__.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/middleware/error_handler.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/middleware/public_auth.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/middleware/security.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/pyproject.toml +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/__init__.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/accounts.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/browser.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/capabilities.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/chat.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/claude.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/cli.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/git.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/health.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/list.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/network.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/packs.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/projects.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/settings.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/shared.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/system.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/routers/terminal.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/schemas/__init__.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/schemas/accounts.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/schemas/chat.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/schemas/network.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/__init__.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/account_login.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/accounts.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/acp_events.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/acp_peer.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/agent_connections.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/agent_registry.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/agent_sessions.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/agents.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/api_errors.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/attachments.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/blocks.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/browser.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/claude_assets.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/claude_manage.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/claude_status.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/cli_info.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/cli_settings.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/control_requests.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/delegate_runner.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/delegate_runs.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/delegates.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/diffs.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/directories.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/directory_watch.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/elicitation.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/event_rows.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/files.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/git.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/git_ops.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/live_sessions.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/mods.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/network.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/pack_format.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/packs.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/persistent_sessions.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/projects.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/prompt_cache.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/providers.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/questions.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/repo.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/rewind.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/settings_store.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/shared.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/shared_links.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/shared_watch.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/speedtest.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/system_watch.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/terminal.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/todos.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/tool_calls.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/tool_props.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/trash.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/usage.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/services/visibility.py +0 -0
- {cconnect-2.0.7 → cconnect-2.0.8}/setup.cfg +0 -0
|
@@ -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
|
|
|
@@ -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:
|
|
@@ -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
|
|
@@ -4,11 +4,13 @@ import uuid
|
|
|
4
4
|
from typing import Optional
|
|
5
5
|
|
|
6
6
|
from core.db import Session
|
|
7
|
-
from core.models import SessionCategory, SessionPlacement
|
|
7
|
+
from core.models import AgentSessionPlacement, SessionCategory, SessionPlacement
|
|
8
8
|
|
|
9
9
|
_STEP = 1024.0
|
|
10
10
|
_MIN_GAP = 1e-4
|
|
11
11
|
|
|
12
|
+
Placement = SessionPlacement | AgentSessionPlacement
|
|
13
|
+
|
|
12
14
|
|
|
13
15
|
def _category_dict(row: SessionCategory) -> dict:
|
|
14
16
|
return {
|
|
@@ -20,12 +22,34 @@ def _category_dict(row: SessionCategory) -> dict:
|
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
|
|
23
|
-
def _placement_dict(row:
|
|
24
|
-
|
|
25
|
+
def _placement_dict(row: Placement) -> dict:
|
|
26
|
+
placed = {
|
|
25
27
|
"session_id": row.session_id,
|
|
26
28
|
"category_id": row.category_id,
|
|
27
29
|
"position": row.position,
|
|
28
30
|
}
|
|
31
|
+
if isinstance(row, AgentSessionPlacement):
|
|
32
|
+
placed["agent"] = row.agent
|
|
33
|
+
return placed
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _model(agent: Optional[str]) -> type[Placement]:
|
|
37
|
+
return SessionPlacement if agent is None else AgentSessionPlacement
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _scope(s, agent: Optional[str]):
|
|
41
|
+
query = s.query(_model(agent))
|
|
42
|
+
return query if agent is None else query.filter(AgentSessionPlacement.agent == agent)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _find(s, session_id: str, agent: Optional[str]) -> Optional[Placement]:
|
|
46
|
+
return s.get(SessionPlacement, session_id) if agent is None else s.get(AgentSessionPlacement, (agent, session_id))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _created(session_id: str, category_id: Optional[str], position: float, agent: Optional[str]) -> Placement:
|
|
50
|
+
if agent is None:
|
|
51
|
+
return SessionPlacement(session_id=session_id, category_id=category_id, position=position)
|
|
52
|
+
return AgentSessionPlacement(agent=agent, session_id=session_id, category_id=category_id, position=position)
|
|
29
53
|
|
|
30
54
|
|
|
31
55
|
def _between(previous: Optional[float], following: Optional[float]) -> float:
|
|
@@ -38,21 +62,17 @@ def _between(previous: Optional[float], following: Optional[float]) -> float:
|
|
|
38
62
|
return (previous + following) / 2
|
|
39
63
|
|
|
40
64
|
|
|
41
|
-
def
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
.filter(SessionPlacement.category_id.is_(category_id) if category_id is None else SessionPlacement.category_id == category_id)
|
|
45
|
-
.all()
|
|
46
|
-
)
|
|
47
|
-
return sorted(row.position for row in rows if row.session_id != skip)
|
|
65
|
+
def _in_category(s, category_id: Optional[str], agent: Optional[str]) -> list[Placement]:
|
|
66
|
+
column = _model(agent).category_id
|
|
67
|
+
return _scope(s, agent).filter(column.is_(None) if category_id is None else column == category_id).all()
|
|
48
68
|
|
|
49
69
|
|
|
50
|
-
def
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
)
|
|
70
|
+
def _positions_in(s, category_id: Optional[str], skip: Optional[str], agent: Optional[str] = None) -> list[float]:
|
|
71
|
+
return sorted(row.position for row in _in_category(s, category_id, agent) if row.session_id != skip)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _normalize_placements(s, category_id: Optional[str], agent: Optional[str] = None) -> None:
|
|
75
|
+
rows = _in_category(s, category_id, agent)
|
|
56
76
|
for index, row in enumerate(sorted(rows, key=lambda item: item.position)):
|
|
57
77
|
row.position = index * _STEP
|
|
58
78
|
|
|
@@ -61,9 +81,11 @@ def snapshot() -> dict:
|
|
|
61
81
|
with Session() as s:
|
|
62
82
|
categories = sorted(s.query(SessionCategory).all(), key=lambda row: row.position)
|
|
63
83
|
placement = s.query(SessionPlacement).all()
|
|
84
|
+
agent_placement = s.query(AgentSessionPlacement).all()
|
|
64
85
|
return {
|
|
65
86
|
"categories": [_category_dict(row) for row in categories],
|
|
66
87
|
"placement": [_placement_dict(row) for row in placement],
|
|
88
|
+
"agent_placement": [_placement_dict(row) for row in agent_placement],
|
|
67
89
|
}
|
|
68
90
|
|
|
69
91
|
|
|
@@ -126,50 +148,52 @@ def delete_category(category_id: str) -> bool:
|
|
|
126
148
|
row = s.get(SessionCategory, category_id)
|
|
127
149
|
if row is None:
|
|
128
150
|
return False
|
|
129
|
-
for
|
|
130
|
-
placement.category_id
|
|
151
|
+
for model in (SessionPlacement, AgentSessionPlacement):
|
|
152
|
+
for placement in s.query(model).filter(model.category_id == category_id).all():
|
|
153
|
+
placement.category_id = None
|
|
131
154
|
s.delete(row)
|
|
132
155
|
s.commit()
|
|
133
156
|
return True
|
|
134
157
|
|
|
135
158
|
|
|
136
|
-
def place_session(session_id: str, category_id: Optional[str], index: Optional[int]) -> dict:
|
|
159
|
+
def place_session(session_id: str, category_id: Optional[str], index: Optional[int], agent: Optional[str] = None) -> dict:
|
|
137
160
|
if not session_id:
|
|
138
161
|
raise ValueError("session id is required")
|
|
139
162
|
with Session() as s:
|
|
140
163
|
if category_id is not None and s.get(SessionCategory, category_id) is None:
|
|
141
164
|
raise ValueError("unknown category")
|
|
142
|
-
row = s
|
|
143
|
-
positions = _positions_in(s, category_id, skip=session_id)
|
|
165
|
+
row = _find(s, session_id, agent)
|
|
166
|
+
positions = _positions_in(s, category_id, skip=session_id, agent=agent)
|
|
144
167
|
spot = len(positions) if index is None else max(0, min(index, len(positions)))
|
|
145
168
|
previous = positions[spot - 1] if spot > 0 else None
|
|
146
169
|
following = positions[spot] if spot < len(positions) else None
|
|
147
170
|
position = _between(previous, following)
|
|
148
171
|
if row is None:
|
|
149
|
-
row =
|
|
172
|
+
row = _created(session_id, category_id, position, agent)
|
|
150
173
|
s.add(row)
|
|
151
174
|
else:
|
|
152
175
|
row.category_id = category_id
|
|
153
176
|
row.position = position
|
|
154
177
|
if previous is not None and following is not None and following - previous < _MIN_GAP:
|
|
155
|
-
_normalize_placements(s, category_id)
|
|
178
|
+
_normalize_placements(s, category_id, agent)
|
|
156
179
|
s.commit()
|
|
157
180
|
return _placement_dict(row)
|
|
158
181
|
|
|
159
182
|
|
|
160
|
-
def seed_order(session_ids: list[str]) -> list[dict]:
|
|
183
|
+
def seed_order(session_ids: list[str], agent: Optional[str] = None) -> list[dict]:
|
|
161
184
|
"""Give every chat without a placement one, following the order it is listed in."""
|
|
162
185
|
if not session_ids:
|
|
163
186
|
return []
|
|
164
187
|
with Session() as s:
|
|
165
|
-
|
|
188
|
+
placed = _scope(s, agent).all()
|
|
189
|
+
known = {row.session_id for row in placed}
|
|
166
190
|
missing = [session_id for session_id in session_ids if session_id not in known]
|
|
167
191
|
if not missing:
|
|
168
192
|
return []
|
|
169
|
-
lowest = min((row.position for row in
|
|
193
|
+
lowest = min((row.position for row in placed), default=0.0)
|
|
170
194
|
created = []
|
|
171
195
|
for offset, session_id in enumerate(reversed(missing), start=1):
|
|
172
|
-
row =
|
|
196
|
+
row = _created(session_id, None, lowest - offset * _STEP, agent)
|
|
173
197
|
s.add(row)
|
|
174
198
|
created.append(row)
|
|
175
199
|
s.commit()
|
|
@@ -200,9 +224,9 @@ def restore_placement(session_id: str, category_id: Optional[str], position: Opt
|
|
|
200
224
|
return _placement_dict(row)
|
|
201
225
|
|
|
202
226
|
|
|
203
|
-
def forget_session(session_id: str) -> bool:
|
|
227
|
+
def forget_session(session_id: str, agent: Optional[str] = None) -> bool:
|
|
204
228
|
with Session() as s:
|
|
205
|
-
row = s
|
|
229
|
+
row = _find(s, session_id, agent)
|
|
206
230
|
if row is None:
|
|
207
231
|
return False
|
|
208
232
|
s.delete(row)
|
|
@@ -210,6 +234,16 @@ def forget_session(session_id: str) -> bool:
|
|
|
210
234
|
return True
|
|
211
235
|
|
|
212
236
|
|
|
237
|
+
def forget_agent(agent: str) -> list[str]:
|
|
238
|
+
with Session() as s:
|
|
239
|
+
rows = _scope(s, agent).all()
|
|
240
|
+
for row in rows:
|
|
241
|
+
s.delete(row)
|
|
242
|
+
if rows:
|
|
243
|
+
s.commit()
|
|
244
|
+
return [row.session_id for row in rows]
|
|
245
|
+
|
|
246
|
+
|
|
213
247
|
def prune(known_session_ids: set[str]) -> list[str]:
|
|
214
248
|
"""Drop placements whose transcript is gone; callers must pass a complete scan."""
|
|
215
249
|
if not known_session_ids:
|
|
@@ -1195,6 +1195,11 @@ async def run_prompt(
|
|
|
1195
1195
|
if parent:
|
|
1196
1196
|
event["parent"] = parent
|
|
1197
1197
|
yield event
|
|
1198
|
+
if not parent and message.uuid and any(
|
|
1199
|
+
type(block).__name__ == "TextBlock" and (getattr(block, "text", "") or "").strip()
|
|
1200
|
+
for block in message.content or []
|
|
1201
|
+
):
|
|
1202
|
+
yield {"type": "anchor", "uuid": message.uuid}
|
|
1198
1203
|
if not parent:
|
|
1199
1204
|
usage = getattr(message, "usage", None)
|
|
1200
1205
|
total = _usage_context(usage)
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import re
|
|
4
4
|
import subprocess
|
|
5
|
+
import threading
|
|
5
6
|
from pathlib import Path
|
|
6
|
-
from typing import Optional
|
|
7
|
+
from typing import Callable, Optional, TypeVar
|
|
7
8
|
|
|
8
9
|
from loguru import logger
|
|
9
10
|
|
|
@@ -18,6 +19,11 @@ _HUNK = re.compile(r"^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))?")
|
|
|
18
19
|
_repos: dict[str, Optional[Path]] = {}
|
|
19
20
|
_indexes: dict[str, Optional[set[str]]] = {}
|
|
20
21
|
_statuses: dict[str, dict[str, str]] = {}
|
|
22
|
+
_generations: dict[str, int] = {}
|
|
23
|
+
_builds: dict[tuple[int, str], threading.Lock] = {}
|
|
24
|
+
_guard = threading.Lock()
|
|
25
|
+
|
|
26
|
+
Cached = TypeVar("Cached")
|
|
21
27
|
|
|
22
28
|
|
|
23
29
|
def root_for(project_key: str) -> Optional[Path]:
|
|
@@ -68,11 +74,25 @@ def _build_index(repo: Path) -> Optional[set[str]]:
|
|
|
68
74
|
return tracked
|
|
69
75
|
|
|
70
76
|
|
|
71
|
-
def
|
|
77
|
+
def _cached(cache: dict[str, Cached], repo: Path, build: Callable[[Path], Cached]) -> Cached:
|
|
72
78
|
key = str(repo)
|
|
73
|
-
if key
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
if key in cache:
|
|
80
|
+
return cache[key]
|
|
81
|
+
with _guard:
|
|
82
|
+
lock = _builds.setdefault((id(cache), key), threading.Lock())
|
|
83
|
+
with lock:
|
|
84
|
+
if key in cache:
|
|
85
|
+
return cache[key]
|
|
86
|
+
generation = _generations.get(key, 0)
|
|
87
|
+
value = build(repo)
|
|
88
|
+
with _guard:
|
|
89
|
+
if _generations.get(key, 0) == generation:
|
|
90
|
+
cache[key] = value
|
|
91
|
+
return value
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def index_of(repo: Path) -> Optional[set[str]]:
|
|
95
|
+
return _cached(_indexes, repo, _build_index)
|
|
76
96
|
|
|
77
97
|
|
|
78
98
|
def _build_status(repo: Path) -> dict[str, str]:
|
|
@@ -94,10 +114,7 @@ def _build_status(repo: Path) -> dict[str, str]:
|
|
|
94
114
|
|
|
95
115
|
|
|
96
116
|
def statuses(repo: Path) -> dict[str, str]:
|
|
97
|
-
|
|
98
|
-
if key not in _statuses:
|
|
99
|
-
_statuses[key] = _build_status(repo)
|
|
100
|
-
return _statuses[key]
|
|
117
|
+
return _cached(_statuses, repo, _build_status)
|
|
101
118
|
|
|
102
119
|
|
|
103
120
|
def _relative(base: Path, path: Path) -> str:
|
|
@@ -334,7 +351,29 @@ def deleted_at_head(root: Path, relpath: str) -> bool:
|
|
|
334
351
|
return statuses(repo).get(_relative(repo, path), "").strip().startswith("D")
|
|
335
352
|
|
|
336
353
|
|
|
337
|
-
def
|
|
354
|
+
def _affected(touched: list[Path], known: set[str]) -> set[str]:
|
|
355
|
+
owners = {str(repo) for repo in map(repo_of, touched) if repo is not None}
|
|
356
|
+
return owners | {key for key in known if any(Path(key).is_relative_to(path) for path in touched)}
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
def _drop(stale: set[str], overtake: bool) -> None:
|
|
360
|
+
with _guard:
|
|
361
|
+
for key in stale:
|
|
362
|
+
_indexes.pop(key, None)
|
|
363
|
+
_statuses.pop(key, None)
|
|
364
|
+
if overtake:
|
|
365
|
+
_generations[key] = _generations.get(key, 0) + 1
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
def invalidate(touched: Optional[list[Path]] = None) -> None:
|
|
369
|
+
_repos.clear()
|
|
370
|
+
with _guard:
|
|
371
|
+
known = set(_indexes) | set(_statuses) | {key for _, key in _builds}
|
|
372
|
+
_drop(known if touched is None else _affected(touched, known), overtake=True)
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
def forget(root: Path) -> None:
|
|
338
376
|
_repos.clear()
|
|
339
|
-
|
|
340
|
-
|
|
377
|
+
with _guard:
|
|
378
|
+
cached = set(_indexes) | set(_statuses)
|
|
379
|
+
_drop(_affected([root], cached), overtake=False)
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
One recursive watcher per project a client is looking at, started on the first subscriber
|
|
4
4
|
and stopped with the last, so nothing runs while the explorer is closed. A burst drops the
|
|
5
|
-
git caches
|
|
5
|
+
git caches of the repositories it touched, every one of them once it is truncated past
|
|
6
|
+
`_MAX_PATHS`, and carries the paths.
|
|
6
7
|
"""
|
|
7
8
|
|
|
8
9
|
import asyncio
|
|
@@ -27,6 +28,12 @@ def _inside(root: Path, path: str) -> str:
|
|
|
27
28
|
return ""
|
|
28
29
|
|
|
29
30
|
|
|
31
|
+
def _touched(changed: dict[str, set[str]], overflowed: set[str], roots: dict[str, Path]) -> Optional[list[Path]]:
|
|
32
|
+
if overflowed or any(key not in roots for key in changed):
|
|
33
|
+
return None
|
|
34
|
+
return [roots[key] / path for key, paths in changed.items() for path in paths]
|
|
35
|
+
|
|
36
|
+
|
|
30
37
|
def _relevant(path: str) -> bool:
|
|
31
38
|
"""Ignored paths are noise, and the backend writes plenty of it inside its own project."""
|
|
32
39
|
target = Path(path)
|
|
@@ -51,6 +58,7 @@ class ProjectWatchHub:
|
|
|
51
58
|
def __init__(self):
|
|
52
59
|
self._subscribers: dict[asyncio.Queue, str] = {}
|
|
53
60
|
self._observers: dict[str, object] = {}
|
|
61
|
+
self._roots: dict[str, Path] = {}
|
|
54
62
|
self._loop: Optional[asyncio.AbstractEventLoop] = None
|
|
55
63
|
self._lock = threading.Lock()
|
|
56
64
|
self._pending: dict[str, set[str]] = {}
|
|
@@ -101,6 +109,7 @@ class ProjectWatchHub:
|
|
|
101
109
|
root = project_files.root_for(project_key)
|
|
102
110
|
if root is None:
|
|
103
111
|
return
|
|
112
|
+
project_files.forget(root)
|
|
104
113
|
try:
|
|
105
114
|
from watchdog.events import FileSystemEventHandler
|
|
106
115
|
from watchdog.observers import Observer
|
|
@@ -122,10 +131,12 @@ class ProjectWatchHub:
|
|
|
122
131
|
return
|
|
123
132
|
with self._lock:
|
|
124
133
|
self._observers[project_key] = observer
|
|
134
|
+
self._roots[project_key] = root
|
|
125
135
|
|
|
126
136
|
def _release(self, project_key: str):
|
|
127
137
|
with self._lock:
|
|
128
138
|
observer = self._observers.pop(project_key, None)
|
|
139
|
+
self._roots.pop(project_key, None)
|
|
129
140
|
if observer is None:
|
|
130
141
|
return
|
|
131
142
|
try:
|
|
@@ -155,9 +166,10 @@ class ProjectWatchHub:
|
|
|
155
166
|
self._overflowed = set()
|
|
156
167
|
self._timer = None
|
|
157
168
|
targets = [(q, key) for q, key in self._subscribers.items() if key in changed]
|
|
169
|
+
roots = dict(self._roots)
|
|
158
170
|
if not changed:
|
|
159
171
|
return
|
|
160
|
-
project_files.invalidate()
|
|
172
|
+
project_files.invalidate(_touched(changed, overflowed, roots))
|
|
161
173
|
if loop is None:
|
|
162
174
|
return
|
|
163
175
|
for queue, key in targets:
|
|
@@ -721,6 +721,17 @@ def session_cwd(project_key: str, session_id: str) -> Optional[str]:
|
|
|
721
721
|
return _read_cwd(file)
|
|
722
722
|
|
|
723
723
|
|
|
724
|
+
def fork_session(project_key: str, session_id: str, up_to: Optional[str], title: Optional[str]) -> Optional[dict]:
|
|
725
|
+
from claude_agent_sdk import fork_session as fork
|
|
726
|
+
from services import rewind
|
|
727
|
+
|
|
728
|
+
cwd = session_cwd(project_key, session_id)
|
|
729
|
+
if not cwd:
|
|
730
|
+
return None
|
|
731
|
+
forked = fork(session_id, up_to_message_id=up_to or rewind.get_pending(session_id), title=title)
|
|
732
|
+
return {"session_id": forked.session_id, "project_key": project_key, "path": cwd}
|
|
733
|
+
|
|
734
|
+
|
|
724
735
|
def _parse_ask_result(content: object, qtexts: list[str]) -> dict[str, tuple[str, str]]:
|
|
725
736
|
"""Parse an AskUserQuestion tool_result into {question: (answer, note)}."""
|
|
726
737
|
from services.claude_runtime import _flatten_result_content
|
|
@@ -842,6 +853,7 @@ def session_context(cwd: str, session_id: str, max_chars: int = 4000) -> str:
|
|
|
842
853
|
|
|
843
854
|
|
|
844
855
|
_BRANCH_KEYS = ("uuid", "parentUuid", "logicalParentUuid", "isSidechain", "type", "subtype", "isCompactSummary")
|
|
856
|
+
_CHAIN_TYPES = frozenset({"user", "assistant", "attachment", "system", "progress"})
|
|
845
857
|
|
|
846
858
|
|
|
847
859
|
def _conversation_row(entry: dict) -> Optional[dict]:
|
|
@@ -1078,7 +1090,7 @@ def _active_entries(entries: list[dict], session_id: str) -> list[dict]:
|
|
|
1078
1090
|
leaf = None
|
|
1079
1091
|
for e in entries:
|
|
1080
1092
|
u = e.get("uuid")
|
|
1081
|
-
if not u or e.get("isSidechain"):
|
|
1093
|
+
if not u or e.get("isSidechain") or e.get("type") not in _CHAIN_TYPES:
|
|
1082
1094
|
continue
|
|
1083
1095
|
by_uuid[u] = e
|
|
1084
1096
|
if _is_compact_marker(e):
|
|
@@ -1103,6 +1115,7 @@ def _active_entries(entries: list[dict], session_id: str) -> list[dict]:
|
|
|
1103
1115
|
return [
|
|
1104
1116
|
e for e in entries
|
|
1105
1117
|
if not e.get("uuid")
|
|
1118
|
+
or e.get("type") not in _CHAIN_TYPES
|
|
1106
1119
|
or e.get("isSidechain")
|
|
1107
1120
|
or _is_compact_marker(e)
|
|
1108
1121
|
or e.get("uuid") in active
|
|
@@ -1685,7 +1698,7 @@ def get_session_messages(
|
|
|
1685
1698
|
text = block.get("text", "").strip()
|
|
1686
1699
|
text, notifs = _split_notifications(text)
|
|
1687
1700
|
if text and not _COMMAND_META_RE.search(text) and not _INTERRUPT_RE.match(text):
|
|
1688
|
-
item = {"type": "text", "role": role, "text": text}
|
|
1701
|
+
item = {"type": "text", "role": role, "text": text, "uuid": entry.get("uuid")}
|
|
1689
1702
|
if user_images:
|
|
1690
1703
|
item["images"] = user_images
|
|
1691
1704
|
user_images = None
|
|
@@ -11,6 +11,7 @@ import re
|
|
|
11
11
|
import subprocess
|
|
12
12
|
import sys
|
|
13
13
|
import time
|
|
14
|
+
from contextlib import suppress
|
|
14
15
|
from functools import lru_cache
|
|
15
16
|
from pathlib import Path
|
|
16
17
|
|
|
@@ -51,6 +52,8 @@ def _redact(record) -> None:
|
|
|
51
52
|
|
|
52
53
|
|
|
53
54
|
def reset_log_file() -> None:
|
|
55
|
+
with suppress(OSError):
|
|
56
|
+
paths.SERVER_LOG_FILE.replace(paths.PREVIOUS_SERVER_LOG_FILE)
|
|
54
57
|
paths.SERVER_LOG_FILE.write_text("", encoding="utf-8")
|
|
55
58
|
|
|
56
59
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|