leashd 2.1.0__tar.gz → 2.2.0__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.
- {leashd-2.1.0 → leashd-2.2.0}/CHANGELOG.md +7 -0
- {leashd-2.1.0 → leashd-2.2.0}/PKG-INFO +5 -3
- {leashd-2.1.0 → leashd-2.2.0}/README.md +4 -2
- {leashd-2.1.0 → leashd-2.2.0}/leashd/__init__.py +1 -1
- {leashd-2.1.0 → leashd-2.2.0}/leashd/agents/runtimes/_helpers.py +3 -1
- {leashd-2.1.0 → leashd-2.2.0}/leashd/agents/runtimes/tmux_session.py +20 -1
- {leashd-2.1.0 → leashd-2.2.0}/leashd/connectors/base.py +17 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/connectors/multi.py +8 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/connectors/telegram.py +44 -5
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/chat_sessions.py +15 -4
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/engine.py +42 -13
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/events.py +1 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/safety/analyzer.py +4 -1
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/session.py +12 -0
- leashd-2.2.0/leashd/core/session_title.py +27 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/policies/autonomous.yaml +1 -1
- {leashd-2.1.0 → leashd-2.2.0}/leashd/policies/default.yaml +28 -1
- {leashd-2.1.0 → leashd-2.2.0}/leashd/policies/dev-tools.yaml +1 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/storage/sqlite.py +6 -2
- {leashd-2.1.0 → leashd-2.2.0}/pyproject.toml +1 -1
- {leashd-2.1.0 → leashd-2.2.0}/.claude/settings.json +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/.gitignore +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/LICENSE +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/__main__.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/agents/base.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/agents/capabilities.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/agents/registry.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/agents/runtimes/tmux.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/agents/runtimes/tmux_manifest.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/agents/types.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/app.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/browser_profile.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/cc_plugins.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/cli.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/cli_run.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/config_store.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/connectors/telegram_approval.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/connectors/telegram_commands.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/connectors/telegram_markdown.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/connectors/telegram_sessions.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/connectors/web.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/config.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/file_delivery.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/interactions.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/message_logger.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/plan_gate.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/queue.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/runtime_settings.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/safety/approval_card.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/safety/approvals.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/safety/audit.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/safety/gatekeeper.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/safety/policy.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/safety/sandbox.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/task.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/task_events.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/task_memory.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/task_profile.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/test_output.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/core/workspace.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/daemon.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/SKILL.md +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/authentication.md +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/commands.md +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/profiling.md +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/proxy-support.md +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/session-management.md +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/snapshot-refs.md +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/trust-boundaries.md +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/video-recording.md +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/webgpu.md +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/templates/authenticated-session.sh +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/templates/capture-workflow.sh +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/templates/form-automation.sh +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/search-batch.sh +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/webui/app.js +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/webui/icons/icon-192.png +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/webui/icons/icon-512.png +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/webui/index.html +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/webui/manifest.json +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/webui/service-worker.js +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/data/webui/style.css +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/exceptions.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/git/formatter.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/git/handler.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/git/models.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/git/service.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/main.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/middleware/auth.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/middleware/base.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/middleware/rate_limit.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/plugins/base.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/plugins/builtin/_task_prompts.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/plugins/builtin/audit_plugin.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/plugins/builtin/browser_tools.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/plugins/builtin/merge_resolver.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/plugins/builtin/playbooks/linkedin_comment.yaml +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/plugins/builtin/task_orchestrator.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/plugins/builtin/test_config_loader.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/plugins/builtin/web_agent.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/plugins/builtin/web_checkpoint.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/plugins/builtin/web_interaction_logger.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/plugins/builtin/workflow.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/plugins/registry.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/policies/.gitkeep +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/policies/permissive.yaml +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/policies/strict.yaml +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/setup.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/skills.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/storage/base.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/storage/memory.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/tunnel.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/web/app.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/web/auth.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/web/models.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/web/push.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/web/routes.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/web/tmux_hooks.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/web/tmux_jsonl.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/web/tmux_server.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/leashd/web/ws_handler.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/scripts/_harness/drive.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/scripts/_harness/multisession_suite.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/scripts/_harness/soak_model.py +0 -0
- {leashd-2.1.0 → leashd-2.2.0}/scripts/_harness/tmux_harness.py +0 -0
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.2.0] - 2026-10-03
|
|
4
|
+
- **added**: conversations name themselves, so `/session`, the switch banner and the "replied" / "waiting on you" notices read `#2 · Login test fix · api`. The name is Claude Code's own session title, or the first line of your first message until it has one.
|
|
5
|
+
- **added**: fewer prompts: read-only `gh` commands (`gh run list`, `gh pr view`…), `git fetch`, `git add`, `mkdir`, `node --check` and `vitest`/`jest` no longer ask when chained to an approved `curl` or `ssh`.
|
|
6
|
+
- **changed**: `git remote add`, `set-url`, `remove` and `rename` now ask instead of running as reads.
|
|
7
|
+
- **fixed**: `/clear`, `/stop` or `/session kill` on a turn that survived a daemon restart no longer makes that conversation's next answer get dropped as "Task interrupted".
|
|
8
|
+
- **fixed**: a Telegram message sent while the daemon is restarting is no longer thrown away; it runs once the daemon is back. Anything older than 10 minutes is skipped and the chat is told.
|
|
9
|
+
|
|
3
10
|
## [2.1.0] - 2026-10-03
|
|
4
11
|
- **added**: `leashd ssh trust <host>` runs read-only commands on that host without asking; writes, restarts and credential reads still ask. `--full` approves every command on the host.
|
|
5
12
|
- **added**: the Telegram bot fills its `/` command menu on startup, so leashd's commands and `/model`, `/effort`, `/compact`, `/context` show up with descriptions.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: leashd
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: Run Claude Code as a governed daemon: a real claude TUI in tmux behind a sandbox, YAML policies and human-in-the-loop approval
|
|
5
5
|
Project-URL: Homepage, https://github.com/vmehera123/leashd
|
|
6
6
|
Project-URL: Repository, https://github.com/vmehera123/leashd
|
|
@@ -156,7 +156,7 @@ The pipeline is connector-agnostic: same sandbox, same rules, same buttons wheth
|
|
|
156
156
|
|
|
157
157
|
| Policy | Auto-allows | Requires approval |
|
|
158
158
|
|---|---|---|
|
|
159
|
-
| **`default.yaml`** *(recommended)* | reads, search, read-only shell (`ls`, `grep`, `ps`, `awk`, `git log/diff`, `docker ps/logs`, reads inside `docker exec`, `--version`), loopback GETs, linters/formatters/type checkers (`ruff`, `mypy`, `tsc`, `pnpm lint`, `make check` …), read-only browser | git push/rebase/merge, network, browser mutations |
|
|
159
|
+
| **`default.yaml`** *(recommended)* | reads, search, read-only shell (`ls`, `grep`, `ps`, `awk`, `git log/diff`, `docker ps/logs`, reads inside `docker exec`, `gh pr/run view`, `--version`), `git fetch`, `git add`, `mkdir`, loopback GETs, linters/formatters/type checkers (`ruff`, `mypy`, `tsc`, `pnpm lint`, `make check` …), read-only browser | git push/rebase/merge, network, browser mutations |
|
|
160
160
|
| **`strict.yaml`** | `Read`, `Glob`, `Grep`, `LS` only | everything else (2-min timeout) |
|
|
161
161
|
| **`permissive.yaml`** | reads, writes, package managers, test runners, `git add/commit/stash`, all browser | git push, network, browser cookies/auth/storage, anything unlisted (10-min timeout) |
|
|
162
162
|
| **`dev-tools.yaml`** *(overlay)* | linters, test runners, package managers | — |
|
|
@@ -179,7 +179,7 @@ LEASHD_POLICY_FILES=policies/default.yaml,policies/my-overrides.yaml # merged,
|
|
|
179
179
|
|
|
180
180
|
leashd spawns a real interactive `claude` TUI in a tmux pane and talks to it the way a human would — so native slash commands pass straight through from chat, dialogs the CLI opens (model picker, consent prompts) get bridged to inline buttons, and `/screen` gives you a live snapshot of the terminal. Tool calls are intercepted by Claude Code `PreToolUse` hooks and routed back into leashd's gatekeeper, so nothing escapes the pipeline.
|
|
181
181
|
|
|
182
|
-
**Restarting is safe.** tmux panes live on a tmux server of their own, so `leashd restart` — to pick up a fix, a config change, a new build — no longer ends the work in them. The daemon writes what it needs to find each pane again, leaves them running on the way out, and re-adopts them on the way in: same conversation, same session, same directory. A turn that was still running keeps streaming into the chat where it left off. `leashd stop --end-agents` ends them instead. See [docs/agents.md](docs/agents.md#restarting-without-losing-work).
|
|
182
|
+
**Restarting is safe.** tmux panes live on a tmux server of their own, so `leashd restart` — to pick up a fix, a config change, a new build — no longer ends the work in them. The daemon writes what it needs to find each pane again, leaves them running on the way out, and re-adopts them on the way in: same conversation, same session, same directory. A turn that was still running keeps streaming into the chat where it left off, and a Telegram message you send during the restart runs once the daemon is back. `leashd stop --end-agents` ends them instead. See [docs/agents.md](docs/agents.md#restarting-without-losing-work).
|
|
183
183
|
|
|
184
184
|
**Adding a runtime** — the runtime registry (`agents/registry.py`) is kept for that: register a factory and select it with `LEASHD_AGENT_RUNTIME`. Embedders can also pass any `BaseAgent` to `build_engine(agent=...)` to put their own agent behind the same pipeline.
|
|
185
185
|
|
|
@@ -253,6 +253,8 @@ The Web UI has always had conversation tabs. `/session` gives a Telegram chat th
|
|
|
253
253
|
|
|
254
254
|
Switching pauses nothing — a conversation you leave keeps working. What it stops doing is writing into the chat, so two agents can't interleave into one message stream. Instead you get a one-line notice with an **Open** button: `#2 replied` when its turn lands, `#2 is waiting on you` when it hits an approval, a question or a plan review. **The prompt itself is held and rendered under #2 when you open it**, so it is always read in the conversation that raised it rather than pasted under the one you happen to be looking at. Walking away from a prompt you have not answered takes it back down with you and reissues it when you return.
|
|
255
255
|
|
|
256
|
+
Each conversation names itself, so several in the same repo stay tell-apart: the list, the switch banner and the notices read `#2 · Login test fix · api` rather than `#2 · api`. The name starts as the first line of your first message and becomes Claude Code's own session title as soon as it writes one. `/clear` drops it.
|
|
257
|
+
|
|
256
258
|
Conversation #1 is the chat itself, so nothing changes about an existing chat until you open a second one — and for the same reason it is the one conversation with no `✕`. There is no slot to free: `/session kill 1` stops its agent and clears its history, like `/clear`, and it stays on the list.
|
|
257
259
|
|
|
258
260
|
### CLI
|
|
@@ -108,7 +108,7 @@ The pipeline is connector-agnostic: same sandbox, same rules, same buttons wheth
|
|
|
108
108
|
|
|
109
109
|
| Policy | Auto-allows | Requires approval |
|
|
110
110
|
|---|---|---|
|
|
111
|
-
| **`default.yaml`** *(recommended)* | reads, search, read-only shell (`ls`, `grep`, `ps`, `awk`, `git log/diff`, `docker ps/logs`, reads inside `docker exec`, `--version`), loopback GETs, linters/formatters/type checkers (`ruff`, `mypy`, `tsc`, `pnpm lint`, `make check` …), read-only browser | git push/rebase/merge, network, browser mutations |
|
|
111
|
+
| **`default.yaml`** *(recommended)* | reads, search, read-only shell (`ls`, `grep`, `ps`, `awk`, `git log/diff`, `docker ps/logs`, reads inside `docker exec`, `gh pr/run view`, `--version`), `git fetch`, `git add`, `mkdir`, loopback GETs, linters/formatters/type checkers (`ruff`, `mypy`, `tsc`, `pnpm lint`, `make check` …), read-only browser | git push/rebase/merge, network, browser mutations |
|
|
112
112
|
| **`strict.yaml`** | `Read`, `Glob`, `Grep`, `LS` only | everything else (2-min timeout) |
|
|
113
113
|
| **`permissive.yaml`** | reads, writes, package managers, test runners, `git add/commit/stash`, all browser | git push, network, browser cookies/auth/storage, anything unlisted (10-min timeout) |
|
|
114
114
|
| **`dev-tools.yaml`** *(overlay)* | linters, test runners, package managers | — |
|
|
@@ -131,7 +131,7 @@ LEASHD_POLICY_FILES=policies/default.yaml,policies/my-overrides.yaml # merged,
|
|
|
131
131
|
|
|
132
132
|
leashd spawns a real interactive `claude` TUI in a tmux pane and talks to it the way a human would — so native slash commands pass straight through from chat, dialogs the CLI opens (model picker, consent prompts) get bridged to inline buttons, and `/screen` gives you a live snapshot of the terminal. Tool calls are intercepted by Claude Code `PreToolUse` hooks and routed back into leashd's gatekeeper, so nothing escapes the pipeline.
|
|
133
133
|
|
|
134
|
-
**Restarting is safe.** tmux panes live on a tmux server of their own, so `leashd restart` — to pick up a fix, a config change, a new build — no longer ends the work in them. The daemon writes what it needs to find each pane again, leaves them running on the way out, and re-adopts them on the way in: same conversation, same session, same directory. A turn that was still running keeps streaming into the chat where it left off. `leashd stop --end-agents` ends them instead. See [docs/agents.md](docs/agents.md#restarting-without-losing-work).
|
|
134
|
+
**Restarting is safe.** tmux panes live on a tmux server of their own, so `leashd restart` — to pick up a fix, a config change, a new build — no longer ends the work in them. The daemon writes what it needs to find each pane again, leaves them running on the way out, and re-adopts them on the way in: same conversation, same session, same directory. A turn that was still running keeps streaming into the chat where it left off, and a Telegram message you send during the restart runs once the daemon is back. `leashd stop --end-agents` ends them instead. See [docs/agents.md](docs/agents.md#restarting-without-losing-work).
|
|
135
135
|
|
|
136
136
|
**Adding a runtime** — the runtime registry (`agents/registry.py`) is kept for that: register a factory and select it with `LEASHD_AGENT_RUNTIME`. Embedders can also pass any `BaseAgent` to `build_engine(agent=...)` to put their own agent behind the same pipeline.
|
|
137
137
|
|
|
@@ -205,6 +205,8 @@ The Web UI has always had conversation tabs. `/session` gives a Telegram chat th
|
|
|
205
205
|
|
|
206
206
|
Switching pauses nothing — a conversation you leave keeps working. What it stops doing is writing into the chat, so two agents can't interleave into one message stream. Instead you get a one-line notice with an **Open** button: `#2 replied` when its turn lands, `#2 is waiting on you` when it hits an approval, a question or a plan review. **The prompt itself is held and rendered under #2 when you open it**, so it is always read in the conversation that raised it rather than pasted under the one you happen to be looking at. Walking away from a prompt you have not answered takes it back down with you and reissues it when you return.
|
|
207
207
|
|
|
208
|
+
Each conversation names itself, so several in the same repo stay tell-apart: the list, the switch banner and the notices read `#2 · Login test fix · api` rather than `#2 · api`. The name starts as the first line of your first message and becomes Claude Code's own session title as soon as it writes one. `/clear` drops it.
|
|
209
|
+
|
|
208
210
|
Conversation #1 is the chat itself, so nothing changes about an existing chat until you open a second one — and for the same reason it is the one conversation with no `✕`. There is no slot to free: `/session kill 1` stops its agent and clears its history, like `/clear`, and it stays on the list.
|
|
209
211
|
|
|
210
212
|
### CLI
|
|
@@ -70,7 +70,9 @@ AUTO_MODE_INSTRUCTION = (
|
|
|
70
70
|
NATIVE_AUTO_INSTRUCTION = (
|
|
71
71
|
"Auto mode: implement directly. Claude Code's auto policy runs safe actions "
|
|
72
72
|
"without asking; leashd reviews the risky ones and may ask the user. "
|
|
73
|
-
|
|
73
|
+
"A Bash call is approved as a whole, so run curl, ssh and anything that "
|
|
74
|
+
"reads a .env file in a call of its own instead of chaining other commands "
|
|
75
|
+
"to it, and parse JSON with jq rather than python -c. " + _DIRECT_EDIT_RULES
|
|
74
76
|
)
|
|
75
77
|
|
|
76
78
|
UV_PROJECT_GUIDANCE = (
|
|
@@ -54,7 +54,7 @@ from leashd.agents.runtimes.tmux_manifest import (
|
|
|
54
54
|
session_id_from_tmux_name,
|
|
55
55
|
write_manifest,
|
|
56
56
|
)
|
|
57
|
-
from leashd.core.events import LATE_REPLY, Event
|
|
57
|
+
from leashd.core.events import LATE_REPLY, SESSION_TITLED, Event
|
|
58
58
|
from leashd.core.safety.gatekeeper import FILE_EDIT_TOOLS
|
|
59
59
|
from leashd.core.safety.policy import normalize_tool_name
|
|
60
60
|
from leashd.exceptions import AgentError
|
|
@@ -2256,6 +2256,7 @@ class TmuxClaudeSession:
|
|
|
2256
2256
|
self.append_system_prompt_path: Path | None = None
|
|
2257
2257
|
self.pane_token: str | None = None
|
|
2258
2258
|
self.claude_uuid: str | None = None
|
|
2259
|
+
self.title: str | None = None
|
|
2259
2260
|
self.turn: TmuxTurn | None = None
|
|
2260
2261
|
# Per-turn plan-gate state — shared logic with the engine's
|
|
2261
2262
|
# can_use_tool. Recreated each turn in begin_turn() so it survives
|
|
@@ -7102,6 +7103,10 @@ class TmuxSessionManager:
|
|
|
7102
7103
|
self._handle_queue_operation(cs, turn, obj)
|
|
7103
7104
|
return
|
|
7104
7105
|
|
|
7106
|
+
if obj_type == "ai-title":
|
|
7107
|
+
await self._announce_title(cs, obj)
|
|
7108
|
+
return
|
|
7109
|
+
|
|
7105
7110
|
if (
|
|
7106
7111
|
obj_type == "system"
|
|
7107
7112
|
and obj.get("subtype") == "turn_duration"
|
|
@@ -7114,6 +7119,20 @@ class TmuxSessionManager:
|
|
|
7114
7119
|
):
|
|
7115
7120
|
self._spawn_late_reply(cs, turn)
|
|
7116
7121
|
|
|
7122
|
+
async def _announce_title(self, cs: TmuxClaudeSession, obj: dict[str, Any]) -> None:
|
|
7123
|
+
title = obj.get("aiTitle")
|
|
7124
|
+
if not isinstance(title, str) or not title.strip() or title == cs.title:
|
|
7125
|
+
return
|
|
7126
|
+
cs.title = title
|
|
7127
|
+
if self._event_bus is None:
|
|
7128
|
+
return
|
|
7129
|
+
await self._event_bus.emit(
|
|
7130
|
+
Event(
|
|
7131
|
+
name=SESSION_TITLED,
|
|
7132
|
+
data={"chat_id": cs.chat_id, "user_id": cs.user_id, "title": title},
|
|
7133
|
+
)
|
|
7134
|
+
)
|
|
7135
|
+
|
|
7117
7136
|
@staticmethod
|
|
7118
7137
|
def _handle_queue_operation(
|
|
7119
7138
|
cs: TmuxClaudeSession, turn: TmuxTurn | None, obj: dict[str, Any]
|
|
@@ -6,6 +6,8 @@ from typing import Any
|
|
|
6
6
|
|
|
7
7
|
from pydantic import BaseModel, ConfigDict, field_validator
|
|
8
8
|
|
|
9
|
+
from leashd.core.chat_sessions import index_of, slot_label
|
|
10
|
+
|
|
9
11
|
ATTACHMENT_MAX_BYTES = 10 * 1024 * 1024 # 10 MB per file
|
|
10
12
|
ATTACHMENT_MAX_COUNT = 5
|
|
11
13
|
ATTACHMENT_SUPPORTED_TYPES = frozenset(
|
|
@@ -103,6 +105,7 @@ class BaseConnector(ABC):
|
|
|
103
105
|
self._interrupt_resolver: (
|
|
104
106
|
Callable[[str, bool], Coroutine[Any, Any, bool]] | None
|
|
105
107
|
) = None
|
|
108
|
+
self._session_title_resolver: Callable[[str], str | None] | None = None
|
|
106
109
|
|
|
107
110
|
@abstractmethod
|
|
108
111
|
async def start(self) -> None: ...
|
|
@@ -264,6 +267,20 @@ class BaseConnector(ABC):
|
|
|
264
267
|
"""Register resolver(interrupt_id, send_now) for interrupt callbacks."""
|
|
265
268
|
self._interrupt_resolver = resolver
|
|
266
269
|
|
|
270
|
+
def set_session_title_resolver(
|
|
271
|
+
self,
|
|
272
|
+
resolver: Callable[[str], str | None],
|
|
273
|
+
) -> None:
|
|
274
|
+
"""Register resolver(chat_id) returning that conversation's title."""
|
|
275
|
+
self._session_title_resolver = resolver
|
|
276
|
+
|
|
277
|
+
def chat_session_label(self, chat_id: str) -> str:
|
|
278
|
+
"""``#<slot>``, followed by the conversation's title once it has one."""
|
|
279
|
+
label = slot_label(index_of(chat_id))
|
|
280
|
+
resolver = self._session_title_resolver
|
|
281
|
+
title = resolver(chat_id) if resolver is not None else None
|
|
282
|
+
return f"{label} · {title}" if title else label
|
|
283
|
+
|
|
267
284
|
async def send_question( # noqa: B027
|
|
268
285
|
self,
|
|
269
286
|
chat_id: str,
|
|
@@ -267,3 +267,11 @@ class MultiConnector(BaseConnector):
|
|
|
267
267
|
super().set_interrupt_resolver(resolver)
|
|
268
268
|
for c in self._connectors:
|
|
269
269
|
c.set_interrupt_resolver(resolver)
|
|
270
|
+
|
|
271
|
+
def set_session_title_resolver(
|
|
272
|
+
self,
|
|
273
|
+
resolver: Callable[[str], str | None],
|
|
274
|
+
) -> None:
|
|
275
|
+
super().set_session_title_resolver(resolver)
|
|
276
|
+
for c in self._connectors:
|
|
277
|
+
c.set_session_title_resolver(resolver)
|
|
@@ -7,7 +7,7 @@ import re
|
|
|
7
7
|
from collections.abc import Awaitable, Callable, Coroutine
|
|
8
8
|
from contextvars import ContextVar
|
|
9
9
|
from dataclasses import dataclass, field
|
|
10
|
-
from datetime import timedelta
|
|
10
|
+
from datetime import datetime, timedelta, timezone
|
|
11
11
|
from pathlib import Path
|
|
12
12
|
from typing import TYPE_CHECKING, Any, TypeVar, cast
|
|
13
13
|
|
|
@@ -24,9 +24,11 @@ from telegram.constants import ChatAction, ParseMode
|
|
|
24
24
|
from telegram.error import BadRequest, NetworkError, RetryAfter, TelegramError
|
|
25
25
|
from telegram.ext import (
|
|
26
26
|
Application,
|
|
27
|
+
ApplicationHandlerStop,
|
|
27
28
|
CallbackQueryHandler,
|
|
28
29
|
CommandHandler,
|
|
29
30
|
MessageHandler,
|
|
31
|
+
TypeHandler,
|
|
30
32
|
filters,
|
|
31
33
|
)
|
|
32
34
|
|
|
@@ -96,6 +98,7 @@ _DELETED_ID_MEMORY = 256
|
|
|
96
98
|
_STARTUP_MAX_RETRIES = 5
|
|
97
99
|
_STARTUP_BASE_DELAY = 2.0
|
|
98
100
|
_STARTUP_MAX_DELAY = 60.0
|
|
101
|
+
_STALE_UPDATE_SECONDS = 600.0
|
|
99
102
|
_SEND_MAX_RETRIES = 3
|
|
100
103
|
_SEND_BASE_DELAY = 1.0
|
|
101
104
|
_SEND_MAX_DELAY = 10.0
|
|
@@ -381,6 +384,7 @@ class TelegramConnector(BaseConnector):
|
|
|
381
384
|
self._approval_tool_names: dict[str, str] = {}
|
|
382
385
|
self._approval_cards: dict[str, ApprovalCard] = {}
|
|
383
386
|
self._prompt_chats: dict[str, str] = {}
|
|
387
|
+
self._stale_notified: set[str] = set()
|
|
384
388
|
self._router = ChatSessionRouter()
|
|
385
389
|
self._deferred: dict[str, list[_Prompt]] = {}
|
|
386
390
|
self._onscreen: dict[str, list[_Prompt]] = {}
|
|
@@ -517,8 +521,7 @@ class TelegramConnector(BaseConnector):
|
|
|
517
521
|
|
|
518
522
|
def _deferred_notice_text(self, chat_id: str) -> str:
|
|
519
523
|
queue = self._deferred.get(chat_id, [])
|
|
520
|
-
|
|
521
|
-
head = f"🔔 #{slot} is waiting on you"
|
|
524
|
+
head = f"🔔 {self.chat_session_label(chat_id)} is waiting on you"
|
|
522
525
|
lines = [f"• {p.summary}" for p in queue[:3]]
|
|
523
526
|
if len(queue) > 3:
|
|
524
527
|
lines.append(f"• …and {len(queue) - 3} more")
|
|
@@ -623,6 +626,8 @@ class TelegramConnector(BaseConnector):
|
|
|
623
626
|
f"{self._api_base_url}/file/bot"
|
|
624
627
|
)
|
|
625
628
|
self._app = builder.build()
|
|
629
|
+
self._stale_notified.clear()
|
|
630
|
+
self._app.add_handler(TypeHandler(Update, self._drop_stale_update), group=-1)
|
|
626
631
|
self._app.add_handler(
|
|
627
632
|
CommandHandler(
|
|
628
633
|
[
|
|
@@ -672,7 +677,7 @@ class TelegramConnector(BaseConnector):
|
|
|
672
677
|
await self._app.start()
|
|
673
678
|
await self._app.updater.start_polling( # type: ignore[union-attr]
|
|
674
679
|
allowed_updates=Update.ALL_TYPES,
|
|
675
|
-
drop_pending_updates=
|
|
680
|
+
drop_pending_updates=False,
|
|
676
681
|
)
|
|
677
682
|
await self._register_command_menu()
|
|
678
683
|
logger.info("telegram_connector_started")
|
|
@@ -757,7 +762,7 @@ class TelegramConnector(BaseConnector):
|
|
|
757
762
|
else body[:_BACKGROUND_PREVIEW_CHARS].rstrip() + "…"
|
|
758
763
|
)
|
|
759
764
|
slot = index_of(chat_id)
|
|
760
|
-
label =
|
|
765
|
+
label = self.chat_session_label(chat_id)
|
|
761
766
|
chunk = Chunk(
|
|
762
767
|
f"🔔 {label} replied\n\n{preview}",
|
|
763
768
|
f"🔔 {escape(label)} replied\n\n{quote_block(preview)}",
|
|
@@ -1470,6 +1475,40 @@ class TelegramConnector(BaseConnector):
|
|
|
1470
1475
|
plan_ids.append(review_msg_id)
|
|
1471
1476
|
self._plan_message_ids[chat_id] = plan_ids
|
|
1472
1477
|
|
|
1478
|
+
async def _drop_stale_update(
|
|
1479
|
+
self, update: Update, _context: ContextTypes.DEFAULT_TYPE
|
|
1480
|
+
) -> None:
|
|
1481
|
+
"""Stop a message that waited too long for the daemon from running now.
|
|
1482
|
+
|
|
1483
|
+
Telegram holds what was sent while the daemon was down and hands it
|
|
1484
|
+
over on the next poll. A message from the seconds a restart takes is
|
|
1485
|
+
one the user is still waiting on, so it runs; one that sat through a
|
|
1486
|
+
long outage would start work nobody is expecting any more, so it is
|
|
1487
|
+
dropped and the chat is told once.
|
|
1488
|
+
"""
|
|
1489
|
+
message = update.message or update.edited_message
|
|
1490
|
+
if message is None:
|
|
1491
|
+
return
|
|
1492
|
+
sent_at = message.edit_date or message.date
|
|
1493
|
+
age_seconds = (datetime.now(timezone.utc) - sent_at).total_seconds()
|
|
1494
|
+
if age_seconds <= _STALE_UPDATE_SECONDS:
|
|
1495
|
+
return
|
|
1496
|
+
raw_chat_id = str(message.chat_id)
|
|
1497
|
+
logger.warning(
|
|
1498
|
+
"telegram_stale_update_dropped",
|
|
1499
|
+
chat_id=raw_chat_id,
|
|
1500
|
+
age_seconds=int(age_seconds),
|
|
1501
|
+
)
|
|
1502
|
+
if raw_chat_id not in self._stale_notified:
|
|
1503
|
+
self._stale_notified.add(raw_chat_id)
|
|
1504
|
+
await self.send_message(
|
|
1505
|
+
self._router.inbound(raw_chat_id),
|
|
1506
|
+
"Skipped what you sent while leashd was offline, it is more "
|
|
1507
|
+
f"than {int(_STALE_UPDATE_SECONDS // 60)} minutes old. "
|
|
1508
|
+
"Send it again if you still need it.",
|
|
1509
|
+
)
|
|
1510
|
+
raise ApplicationHandlerStop
|
|
1511
|
+
|
|
1473
1512
|
async def _on_command(
|
|
1474
1513
|
self, update: Update, _context: ContextTypes.DEFAULT_TYPE
|
|
1475
1514
|
) -> None:
|
|
@@ -82,6 +82,17 @@ class ChatSessionInfo:
|
|
|
82
82
|
foreground: bool
|
|
83
83
|
message_count: int
|
|
84
84
|
total_cost: float
|
|
85
|
+
title: str = ""
|
|
86
|
+
|
|
87
|
+
@property
|
|
88
|
+
def label(self) -> str:
|
|
89
|
+
if self.title:
|
|
90
|
+
return f"{slot_label(self.index)} · {self.title}"
|
|
91
|
+
return slot_label(self.index)
|
|
92
|
+
|
|
93
|
+
@property
|
|
94
|
+
def name(self) -> str:
|
|
95
|
+
return f"{self.label} · {self.directory}"
|
|
85
96
|
|
|
86
97
|
@property
|
|
87
98
|
def is_primary(self) -> bool:
|
|
@@ -97,14 +108,13 @@ class ChatSessionInfo:
|
|
|
97
108
|
|
|
98
109
|
def render(self) -> str:
|
|
99
110
|
marker = "▸" if self.foreground else " "
|
|
100
|
-
return
|
|
101
|
-
f"{marker} {slot_label(self.index)} · {self.directory} · "
|
|
102
|
-
f"{self.mode} · {self.status}"
|
|
103
|
-
)
|
|
111
|
+
return f"{marker} {self.name} · {self.mode} · {self.status}"
|
|
104
112
|
|
|
105
113
|
def button_text(self) -> str:
|
|
106
114
|
dot = "🟢" if self.busy else ("🟡" if self.live else "⚪")
|
|
107
115
|
marker = "▸ " if self.foreground else ""
|
|
116
|
+
if self.title:
|
|
117
|
+
return f"{marker}{dot} {slot_label(self.index)} {self.title} · {self.directory}"
|
|
108
118
|
return f"{marker}{dot} {slot_label(self.index)} {self.directory}"
|
|
109
119
|
|
|
110
120
|
|
|
@@ -157,6 +167,7 @@ class ChatSessionDirectory:
|
|
|
157
167
|
foreground=session.chat_id == foreground,
|
|
158
168
|
message_count=session.message_count,
|
|
159
169
|
total_cost=session.total_cost,
|
|
170
|
+
title=session.title or "",
|
|
160
171
|
)
|
|
161
172
|
for session in sessions
|
|
162
173
|
]
|
|
@@ -44,6 +44,7 @@ from leashd.core.events import (
|
|
|
44
44
|
MESSAGE_QUEUED,
|
|
45
45
|
SESSION_COMPLETED,
|
|
46
46
|
SESSION_FAILED,
|
|
47
|
+
SESSION_TITLED,
|
|
47
48
|
TASK_SUBMITTED,
|
|
48
49
|
Event,
|
|
49
50
|
EventBus,
|
|
@@ -67,6 +68,7 @@ from leashd.core.safety.audit import AuditLogger
|
|
|
67
68
|
from leashd.core.safety.gatekeeper import ToolGatekeeper
|
|
68
69
|
from leashd.core.safety.policy import PolicyEngine
|
|
69
70
|
from leashd.core.safety.sandbox import SandboxEnforcer, sandbox_directories
|
|
71
|
+
from leashd.core.session_title import clean_title, title_from_prompt
|
|
70
72
|
from leashd.core.workspace import load_workspaces
|
|
71
73
|
from leashd.exceptions import AgentError
|
|
72
74
|
from leashd.middleware.base import MessageContext
|
|
@@ -788,6 +790,7 @@ class Engine:
|
|
|
788
790
|
self._reattach_tasks: set[asyncio.Task[None]] = set()
|
|
789
791
|
|
|
790
792
|
self.event_bus.subscribe(LATE_REPLY, self._deliver_late_reply)
|
|
793
|
+
self.event_bus.subscribe(SESSION_TITLED, self._apply_session_title)
|
|
791
794
|
|
|
792
795
|
self._chat_sessions = ChatSessionDirectory(
|
|
793
796
|
self.session_manager,
|
|
@@ -811,6 +814,7 @@ class Engine:
|
|
|
811
814
|
connector.set_auto_approve_handler(self._gatekeeper.grant_approve_all)
|
|
812
815
|
connector.set_command_handler(self.handle_command)
|
|
813
816
|
connector.set_interrupt_resolver(self._resolve_interrupt)
|
|
817
|
+
connector.set_session_title_resolver(self.session_manager.title_of)
|
|
814
818
|
if git_handler:
|
|
815
819
|
connector.set_git_handler(self._handle_git_callback)
|
|
816
820
|
|
|
@@ -1409,6 +1413,8 @@ class Engine:
|
|
|
1409
1413
|
)
|
|
1410
1414
|
await self._realign_paths_for_session(session)
|
|
1411
1415
|
self._ensure_session_leashd_dir(session)
|
|
1416
|
+
if session.title is None and not session.task_run_id:
|
|
1417
|
+
session.title = title_from_prompt(text) or None
|
|
1412
1418
|
self._executing_sessions[chat_id] = session.session_id
|
|
1413
1419
|
turn_session_id = session.session_id
|
|
1414
1420
|
structlog.contextvars.bind_contextvars(session_id=session.session_id)
|
|
@@ -2314,6 +2320,8 @@ class Engine:
|
|
|
2314
2320
|
0,
|
|
2315
2321
|
f"Conversation: {slot_label(index_of(chat_id))} of {len(siblings)}",
|
|
2316
2322
|
)
|
|
2323
|
+
if session.title:
|
|
2324
|
+
lines.insert(1 if len(siblings) > 1 else 0, f"Title: {session.title}")
|
|
2317
2325
|
if session.workspace_name:
|
|
2318
2326
|
lines.append(f"Workspace: {session.workspace_name}")
|
|
2319
2327
|
lines.extend(
|
|
@@ -2903,9 +2911,7 @@ class Engine:
|
|
|
2903
2911
|
return "Usage: /session <n>"
|
|
2904
2912
|
return f"No conversation {slot_label(int(token))} in this chat."
|
|
2905
2913
|
if target.chat_id == chat_id:
|
|
2906
|
-
await self._send_transient(
|
|
2907
|
-
chat_id, f"▸ {slot_label(target.index)} · {target.directory}"
|
|
2908
|
-
)
|
|
2914
|
+
await self._send_transient(chat_id, f"▸ {target.name}")
|
|
2909
2915
|
if chat_id not in self._active_responders:
|
|
2910
2916
|
session = await self.session_manager.get_or_create(
|
|
2911
2917
|
user_id, target.chat_id, target.working_directory
|
|
@@ -2982,10 +2988,7 @@ class Engine:
|
|
|
2982
2988
|
self._ensure_session_leashd_dir(session)
|
|
2983
2989
|
await self._persist_foreground(session, user_id, leaving=leaving)
|
|
2984
2990
|
|
|
2985
|
-
header =
|
|
2986
|
-
f"▸ {slot_label(target.index)} · {target.directory} · "
|
|
2987
|
-
f"{target.mode} · {target.status}"
|
|
2988
|
-
)
|
|
2991
|
+
header = f"▸ {target.name} · {target.mode} · {target.status}"
|
|
2989
2992
|
mid_turn = target.chat_id in self._active_responders
|
|
2990
2993
|
if banner:
|
|
2991
2994
|
await self._post_chat_session_banner(target.chat_id, header)
|
|
@@ -3070,6 +3073,7 @@ class Engine:
|
|
|
3070
3073
|
async def _finish_reattached_turn(self, session: Session) -> None:
|
|
3071
3074
|
"""Stream and deliver a turn that started under a previous daemon."""
|
|
3072
3075
|
chat_id = session.chat_id
|
|
3076
|
+
turn_session_id = session.session_id
|
|
3073
3077
|
start = time.monotonic()
|
|
3074
3078
|
responder: _StreamingResponder | None = None
|
|
3075
3079
|
if self.connector and self.config.streaming_enabled:
|
|
@@ -3091,6 +3095,18 @@ class Engine:
|
|
|
3091
3095
|
)
|
|
3092
3096
|
if response is None:
|
|
3093
3097
|
return
|
|
3098
|
+
if self._turn_superseded(chat_id, session, turn_session_id):
|
|
3099
|
+
if responder:
|
|
3100
|
+
await responder.deactivate()
|
|
3101
|
+
if session.session_id != turn_session_id:
|
|
3102
|
+
await responder.delete_all_messages()
|
|
3103
|
+
logger.info(
|
|
3104
|
+
"reattached_turn_discarded",
|
|
3105
|
+
chat_id=chat_id,
|
|
3106
|
+
turn_session_id=turn_session_id,
|
|
3107
|
+
session_id=session.session_id,
|
|
3108
|
+
)
|
|
3109
|
+
return
|
|
3094
3110
|
await self.session_manager.update_from_result(
|
|
3095
3111
|
session, agent_resume_token=response.session_id, cost=response.cost
|
|
3096
3112
|
)
|
|
@@ -3145,8 +3161,10 @@ class Engine:
|
|
|
3145
3161
|
finally:
|
|
3146
3162
|
if self._active_responders.get(chat_id) is responder:
|
|
3147
3163
|
self._active_responders.pop(chat_id, None)
|
|
3148
|
-
if self._executing_sessions.get(chat_id) ==
|
|
3164
|
+
if self._executing_sessions.get(chat_id) == turn_session_id:
|
|
3149
3165
|
self._executing_sessions.pop(chat_id, None)
|
|
3166
|
+
if chat_id not in self._executing_chats:
|
|
3167
|
+
self._interrupted_chats.discard(chat_id)
|
|
3150
3168
|
|
|
3151
3169
|
async def _restore_chat_session_foreground(self) -> None:
|
|
3152
3170
|
"""Reattach every chat to the conversation it was showing.
|
|
@@ -3249,6 +3267,18 @@ class Engine:
|
|
|
3249
3267
|
Event(name=MESSAGE_OUT, data={"chat_id": chat_id, "content": content})
|
|
3250
3268
|
)
|
|
3251
3269
|
|
|
3270
|
+
async def _apply_session_title(self, event: Event) -> None:
|
|
3271
|
+
chat_id = str(event.data["chat_id"])
|
|
3272
|
+
session = self.session_manager.get(str(event.data["user_id"]), chat_id)
|
|
3273
|
+
title = clean_title(str(event.data["title"]))
|
|
3274
|
+
if session is None or not session.is_active or not title:
|
|
3275
|
+
return
|
|
3276
|
+
if session.title == title:
|
|
3277
|
+
return
|
|
3278
|
+
session.title = title
|
|
3279
|
+
await self.session_manager.save(session)
|
|
3280
|
+
logger.info("chat_session_titled", chat_id=chat_id, title=title)
|
|
3281
|
+
|
|
3252
3282
|
def _note_chat_stream_tail(self, chat_id: str, content: str) -> None:
|
|
3253
3283
|
"""Record which conversation's reply now ends the chat it went to.
|
|
3254
3284
|
|
|
@@ -3422,8 +3452,7 @@ class Engine:
|
|
|
3422
3452
|
|
|
3423
3453
|
await self.connector.send_message(
|
|
3424
3454
|
chat_id,
|
|
3425
|
-
f"{verb} {
|
|
3426
|
-
f"{outcome}",
|
|
3455
|
+
f"{verb} {target.name}?{warning}\n{outcome}",
|
|
3427
3456
|
buttons=[
|
|
3428
3457
|
[
|
|
3429
3458
|
InlineButton(
|
|
@@ -3475,7 +3504,7 @@ class Engine:
|
|
|
3475
3504
|
if target.is_primary:
|
|
3476
3505
|
await self._send_transient(
|
|
3477
3506
|
chat_id,
|
|
3478
|
-
f"Cleared {
|
|
3507
|
+
f"Cleared {target.name}. "
|
|
3479
3508
|
"The first conversation is this chat, so it is reset rather "
|
|
3480
3509
|
"than removed.",
|
|
3481
3510
|
)
|
|
@@ -3484,7 +3513,7 @@ class Engine:
|
|
|
3484
3513
|
return await self._land_after_kill(user_id, base, target)
|
|
3485
3514
|
await self._send_transient(
|
|
3486
3515
|
chat_id,
|
|
3487
|
-
f"Terminated {
|
|
3516
|
+
f"Terminated {target.name}.",
|
|
3488
3517
|
)
|
|
3489
3518
|
return ""
|
|
3490
3519
|
|
|
@@ -3499,7 +3528,7 @@ class Engine:
|
|
|
3499
3528
|
"""
|
|
3500
3529
|
await self._retire_foreground_stream(killed.chat_id)
|
|
3501
3530
|
remaining = await self._fallback_chat_sessions(user_id, base, killed.chat_id)
|
|
3502
|
-
terminated = f"Terminated {
|
|
3531
|
+
terminated = f"Terminated {killed.name}."
|
|
3503
3532
|
if not remaining:
|
|
3504
3533
|
if self.connector is not None:
|
|
3505
3534
|
await self.connector.activate_chat_session(base)
|
|
@@ -15,6 +15,7 @@ TOOL_DENIED = "tool.denied"
|
|
|
15
15
|
MESSAGE_IN = "message.in"
|
|
16
16
|
MESSAGE_OUT = "message.out"
|
|
17
17
|
LATE_REPLY = "agent.late_reply"
|
|
18
|
+
SESSION_TITLED = "session.titled"
|
|
18
19
|
ENGINE_STARTED = "engine.started"
|
|
19
20
|
ENGINE_STOPPED = "engine.stopped"
|
|
20
21
|
INTERACTION_REQUESTED = "interaction.requested"
|
|
@@ -1061,7 +1061,10 @@ def _url_host(token: str) -> str | None:
|
|
|
1061
1061
|
if not _URL_TOKEN_RE.match(token):
|
|
1062
1062
|
match = _SCHEMELESS_URL_RE.fullmatch(token)
|
|
1063
1063
|
return match.group("host").strip("[]").lower() if match else None
|
|
1064
|
-
|
|
1064
|
+
try:
|
|
1065
|
+
parts = urlsplit(token)
|
|
1066
|
+
except ValueError:
|
|
1067
|
+
return None
|
|
1065
1068
|
if "$" in parts.netloc or "`" in parts.netloc:
|
|
1066
1069
|
return None
|
|
1067
1070
|
return parts.hostname.lower() if parts.hostname else None
|
|
@@ -45,6 +45,7 @@ class Session(BaseModel):
|
|
|
45
45
|
is_active: bool = True
|
|
46
46
|
is_foreground: bool = False
|
|
47
47
|
workspace_name: str | None = None
|
|
48
|
+
title: str | None = None
|
|
48
49
|
workspace_directories: list[str] = Field(default_factory=list)
|
|
49
50
|
task_run_id: str | None = None
|
|
50
51
|
# Per-task RuntimeSettings overlay (populated by the task orchestrator
|
|
@@ -133,6 +134,16 @@ class SessionManager:
|
|
|
133
134
|
None,
|
|
134
135
|
)
|
|
135
136
|
|
|
137
|
+
def title_of(self, chat_id: str) -> str | None:
|
|
138
|
+
return next(
|
|
139
|
+
(
|
|
140
|
+
session.title
|
|
141
|
+
for session in self._sessions.values()
|
|
142
|
+
if session.chat_id == chat_id and session.is_active
|
|
143
|
+
),
|
|
144
|
+
None,
|
|
145
|
+
)
|
|
146
|
+
|
|
136
147
|
def active_for_user(self, user_id: str) -> list[Session]:
|
|
137
148
|
"""Every cached live session belonging to *user_id*."""
|
|
138
149
|
return [
|
|
@@ -210,6 +221,7 @@ class SessionManager:
|
|
|
210
221
|
session.is_active = True
|
|
211
222
|
session.workspace_name = None
|
|
212
223
|
session.workspace_directories = []
|
|
224
|
+
session.title = None
|
|
213
225
|
if self._store:
|
|
214
226
|
await self._store.save(session)
|
|
215
227
|
logger.info(
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
MAX_TITLE_CHARS = 40
|
|
4
|
+
_ELLIPSIS = "…"
|
|
5
|
+
_WRAPPING = "\"'` "
|
|
6
|
+
_TRAILING = ".,;:!?"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def clean_title(raw: str) -> str:
|
|
10
|
+
collapsed = " ".join(raw.split()).strip(_WRAPPING)
|
|
11
|
+
if len(collapsed) <= MAX_TITLE_CHARS:
|
|
12
|
+
return collapsed.rstrip(_TRAILING)
|
|
13
|
+
head = collapsed[:MAX_TITLE_CHARS]
|
|
14
|
+
cut = head.rfind(" ")
|
|
15
|
+
if cut >= MAX_TITLE_CHARS // 2:
|
|
16
|
+
head = head[:cut]
|
|
17
|
+
return head.rstrip(_TRAILING + " ") + _ELLIPSIS
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def title_from_prompt(text: str) -> str:
|
|
21
|
+
first_line = next(
|
|
22
|
+
(line.strip() for line in text.splitlines() if line.strip()),
|
|
23
|
+
"",
|
|
24
|
+
)
|
|
25
|
+
if first_line.startswith("/"):
|
|
26
|
+
return ""
|
|
27
|
+
return clean_title(first_line)
|
|
@@ -258,7 +258,7 @@ rules:
|
|
|
258
258
|
command_patterns:
|
|
259
259
|
- "^(cd|ls|cat|head|tail|grep|wc|du|df|pwd|echo|date|whoami|which|type|file|stat|read)\\b"
|
|
260
260
|
- "^find\\b(?![^|]*\\s-(delete|exec|execdir|ok|okdir|fprint|fprint0|fprintf|fls)\\b)"
|
|
261
|
-
- "^git\\s+(-(?!c\\s)[a-zA-Z]\\s+\\S+\\s+|--(?!config-env|exec-path)[a-z-]+(=\\S+)?\\s+)*?(status|log|diff|show|branch|remote|tag|rev-parse|rev-list|ls-files|ls-tree|blame|describe|shortlog|merge-base|cat-file|check-ignore|name-rev|count-objects|for-each-ref|show-ref|reflog(?!\\s+(expire|delete)\\b)|stash\\s+(list|show)|worktree\\s+list|config\\s+(--get|--get-all|--get-regexp|--list|-l))\\b"
|
|
261
|
+
- "^git\\s+(-(?!c\\s)[a-zA-Z]\\s+\\S+\\s+|--(?!config-env|exec-path)[a-z-]+(=\\S+)?\\s+)*?(status|log|diff|show|branch|remote(?!\\s+(add|remove|rm|rename|set-url|set-head|set-branches|prune|update)\\b)|tag|rev-parse|rev-list|ls-files|ls-tree|blame|describe|shortlog|merge-base|cat-file|check-ignore|name-rev|count-objects|for-each-ref|show-ref|reflog(?!\\s+(expire|delete)\\b)|stash\\s+(list|show)|worktree\\s+list|config\\s+(--get|--get-all|--get-regexp|--list|-l))\\b"
|
|
262
262
|
- "^(sort|uniq|cut|tr|column|nl|rev|tac|comm|join|paste|fold|expand|unexpand|fmt|shuf|jq|tree|printf|seq|true|false|test|sleep|yes)\\b"
|
|
263
263
|
- "^rg\\b(?![^|]*\\s--pre(=|\\s|$))"
|
|
264
264
|
- "^ag\\b(?![^|]*\\s--pager\\b)"
|
|
@@ -225,7 +225,7 @@ rules:
|
|
|
225
225
|
command_patterns:
|
|
226
226
|
- "^(cd|ls|cat|head|tail|grep|wc|du|df|pwd|echo|date|whoami|which|type|file|stat|read)\\b"
|
|
227
227
|
- "^find\\b(?![^|]*\\s-(delete|exec|execdir|ok|okdir|fprint|fprint0|fprintf|fls)\\b)"
|
|
228
|
-
- "^git\\s+(-(?!c\\s)[a-zA-Z]\\s+\\S+\\s+|--(?!config-env|exec-path)[a-z-]+(=\\S+)?\\s+)*?(status|log|diff|show|branch|remote|tag|rev-parse|rev-list|ls-files|ls-tree|blame|describe|shortlog|merge-base|cat-file|check-ignore|name-rev|count-objects|for-each-ref|show-ref|reflog(?!\\s+(expire|delete)\\b)|stash\\s+(list|show)|worktree\\s+list|config\\s+(--get|--get-all|--get-regexp|--list|-l))\\b"
|
|
228
|
+
- "^git\\s+(-(?!c\\s)[a-zA-Z]\\s+\\S+\\s+|--(?!config-env|exec-path)[a-z-]+(=\\S+)?\\s+)*?(status|log|diff|show|branch|remote(?!\\s+(add|remove|rm|rename|set-url|set-head|set-branches|prune|update)\\b)|tag|rev-parse|rev-list|ls-files|ls-tree|blame|describe|shortlog|merge-base|cat-file|check-ignore|name-rev|count-objects|for-each-ref|show-ref|reflog(?!\\s+(expire|delete)\\b)|stash\\s+(list|show)|worktree\\s+list|config\\s+(--get|--get-all|--get-regexp|--list|-l))\\b"
|
|
229
229
|
# `tee` and `split` are absent because writing files is what they are for.
|
|
230
230
|
- "^(sort|uniq|cut|tr|column|nl|rev|tac|comm|join|paste|fold|expand|unexpand|fmt|shuf|jq|tree|printf|seq|true|false|test|sleep|yes)\\b"
|
|
231
231
|
- "^rg\\b(?![^|]*\\s--pre(=|\\s|$))"
|
|
@@ -275,6 +275,32 @@ rules:
|
|
|
275
275
|
action: allow
|
|
276
276
|
description: "Read-only Docker/Podman inspection"
|
|
277
277
|
|
|
278
|
+
- name: github-cli-readonly
|
|
279
|
+
tool: Bash
|
|
280
|
+
command_patterns:
|
|
281
|
+
- "^gh\\s+(pr|issue)\\s+(view|list|status|diff|checks)(\\s|$)"
|
|
282
|
+
- "^gh\\s+run\\s+(view|list|watch)(\\s|$)"
|
|
283
|
+
- "^gh\\s+(repo|release|workflow)\\s+(view|list)(\\s|$)"
|
|
284
|
+
- "^gh\\s+search\\s+(repos|issues|prs|commits|code)(\\s|$)"
|
|
285
|
+
- "^gh\\s+status(\\s|$)"
|
|
286
|
+
action: allow
|
|
287
|
+
description: "Read-only GitHub CLI query"
|
|
288
|
+
|
|
289
|
+
- name: git-fetch-and-stage
|
|
290
|
+
tool: Bash
|
|
291
|
+
command_patterns:
|
|
292
|
+
- "^git\\s+(-C\\s+\\S+\\s+)?fetch(\\s+(--all|--prune|-p|--prune-tags|--tags|-t|--no-tags|--quiet|-q|--verbose|-v|--dry-run|--force|-f|--unshallow|--depth=\\d+))*(\\s+[A-Za-z0-9_][A-Za-z0-9_.-]*(\\s+[+A-Za-z0-9_][A-Za-z0-9_./:+-]*)*)?\\s*$"
|
|
293
|
+
- "^git\\s+(-C\\s+\\S+\\s+)?add(\\s|$)"
|
|
294
|
+
action: allow
|
|
295
|
+
description: "Fetch from a configured remote, or stage files"
|
|
296
|
+
|
|
297
|
+
- name: make-directory
|
|
298
|
+
tool: Bash
|
|
299
|
+
command_patterns:
|
|
300
|
+
- "^mkdir(\\s|$)"
|
|
301
|
+
action: allow
|
|
302
|
+
description: "Create a directory"
|
|
303
|
+
|
|
278
304
|
- name: dev-checks
|
|
279
305
|
tool: Bash
|
|
280
306
|
command_patterns:
|
|
@@ -283,6 +309,7 @@ rules:
|
|
|
283
309
|
- "^(make|just)(\\s+(-C\\s*\\S+|--directory(=|\\s+)\\S+|-f\\s*\\S+|--file(=|\\s+)\\S+|-j\\s*\\d*|--jobs(=\\d+)?|-[sknw]+))*\\s+(lint|format|fmt|typecheck|type-check|types|check)([:-][\\w:-]*)?(\\s|$)"
|
|
284
310
|
- "^go\\s+(vet|fmt)(\\s|$)"
|
|
285
311
|
- "^cargo\\s+(fmt|clippy|check)(\\s|$)"
|
|
312
|
+
- "^node\\s+(--check|-c)\\s+[A-Za-z0-9_][A-Za-z0-9_./-]*\\s*$"
|
|
286
313
|
action: allow
|
|
287
314
|
description: "Linter, formatter or type checker"
|
|
288
315
|
|
|
@@ -7,6 +7,7 @@ rules:
|
|
|
7
7
|
- "^(pytest|ruff|jest|vitest|mypy|black|flake8|eslint|prettier)\\b"
|
|
8
8
|
# python/python3 -m variants
|
|
9
9
|
- "^python3?\\s+-m\\s+(pytest|ruff|mypy|black|flake8)\\b"
|
|
10
|
+
- "^((pnpm|yarn|bun)\\s+(exec\\s+)?|(npx|bunx)\\s+)(vitest|jest)(\\s|$)"
|
|
10
11
|
action: allow
|
|
11
12
|
description: "Standalone linters, formatters, and test runners"
|
|
12
13
|
|
|
@@ -136,6 +136,8 @@ class SqliteSessionStore:
|
|
|
136
136
|
await self._db.execute(
|
|
137
137
|
"ALTER TABLE sessions ADD COLUMN resumable_token TEXT"
|
|
138
138
|
)
|
|
139
|
+
if "title" not in existing:
|
|
140
|
+
await self._db.execute("ALTER TABLE sessions ADD COLUMN title TEXT")
|
|
139
141
|
if "is_foreground" not in existing:
|
|
140
142
|
await self._db.execute(
|
|
141
143
|
"ALTER TABLE sessions ADD COLUMN is_foreground INTEGER DEFAULT 0"
|
|
@@ -186,8 +188,8 @@ class SqliteSessionStore:
|
|
|
186
188
|
(user_id, chat_id, session_id, working_directory,
|
|
187
189
|
agent_resume_token, resumable_token, created_at, last_used,
|
|
188
190
|
total_cost, message_count, is_active, is_foreground,
|
|
189
|
-
workspace_name, mode, mode_instruction, task_run_id)
|
|
190
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
|
191
|
+
workspace_name, mode, mode_instruction, task_run_id, title)
|
|
192
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
|
191
193
|
(
|
|
192
194
|
session.user_id,
|
|
193
195
|
session.chat_id,
|
|
@@ -205,6 +207,7 @@ class SqliteSessionStore:
|
|
|
205
207
|
session.mode,
|
|
206
208
|
session.mode_instruction,
|
|
207
209
|
session.task_run_id,
|
|
210
|
+
session.title,
|
|
208
211
|
),
|
|
209
212
|
)
|
|
210
213
|
await self._db.commit()
|
|
@@ -310,6 +313,7 @@ class SqliteSessionStore:
|
|
|
310
313
|
if "mode_instruction" in keys
|
|
311
314
|
else None,
|
|
312
315
|
task_run_id=row["task_run_id"] if "task_run_id" in keys else None,
|
|
316
|
+
title=row["title"] if "title" in keys else None,
|
|
313
317
|
)
|
|
314
318
|
|
|
315
319
|
async def save_message(
|
|
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
|
|
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
|
{leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/session-management.md
RENAMED
|
File without changes
|
|
File without changes
|
{leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/trust-boundaries.md
RENAMED
|
File without changes
|
{leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/video-recording.md
RENAMED
|
File without changes
|
|
File without changes
|
{leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/templates/authenticated-session.sh
RENAMED
|
File without changes
|
{leashd-2.1.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/templates/capture-workflow.sh
RENAMED
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|