leashd 2.0.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.0.0 → leashd-2.2.0}/CHANGELOG.md +15 -0
- {leashd-2.0.0 → leashd-2.2.0}/PKG-INFO +11 -3
- {leashd-2.0.0 → leashd-2.2.0}/README.md +10 -2
- {leashd-2.0.0 → leashd-2.2.0}/leashd/__init__.py +1 -1
- {leashd-2.0.0 → leashd-2.2.0}/leashd/agents/runtimes/_helpers.py +3 -1
- {leashd-2.0.0 → leashd-2.2.0}/leashd/agents/runtimes/tmux.py +96 -11
- {leashd-2.0.0 → leashd-2.2.0}/leashd/agents/runtimes/tmux_session.py +303 -24
- {leashd-2.0.0 → leashd-2.2.0}/leashd/app.py +5 -1
- {leashd-2.0.0 → leashd-2.2.0}/leashd/cli.py +96 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/config_store.py +19 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/connectors/base.py +17 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/connectors/multi.py +8 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/connectors/telegram.py +58 -6
- leashd-2.2.0/leashd/connectors/telegram_commands.py +38 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/chat_sessions.py +15 -4
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/config.py +2 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/engine.py +121 -13
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/events.py +2 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/safety/analyzer.py +598 -8
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/safety/gatekeeper.py +34 -4
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/safety/policy.py +162 -17
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/safety/sandbox.py +62 -19
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/session.py +12 -0
- leashd-2.2.0/leashd/core/session_title.py +27 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/policies/autonomous.yaml +30 -4
- {leashd-2.0.0 → leashd-2.2.0}/leashd/policies/default.yaml +57 -4
- {leashd-2.0.0 → leashd-2.2.0}/leashd/policies/dev-tools.yaml +1 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/policies/permissive.yaml +9 -1
- {leashd-2.0.0 → leashd-2.2.0}/leashd/storage/sqlite.py +6 -2
- {leashd-2.0.0 → leashd-2.2.0}/pyproject.toml +1 -1
- {leashd-2.0.0 → leashd-2.2.0}/scripts/_harness/multisession_suite.py +434 -0
- {leashd-2.0.0 → leashd-2.2.0}/scripts/_harness/tmux_harness.py +23 -0
- {leashd-2.0.0 → leashd-2.2.0}/.claude/settings.json +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/.gitignore +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/LICENSE +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/__main__.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/agents/base.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/agents/capabilities.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/agents/registry.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/agents/runtimes/tmux_manifest.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/agents/types.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/browser_profile.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/cc_plugins.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/cli_run.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/connectors/telegram_approval.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/connectors/telegram_markdown.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/connectors/telegram_sessions.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/connectors/web.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/file_delivery.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/interactions.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/message_logger.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/plan_gate.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/queue.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/runtime_settings.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/safety/approval_card.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/safety/approvals.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/safety/audit.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/task.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/task_events.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/task_memory.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/task_profile.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/test_output.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/core/workspace.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/daemon.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/SKILL.md +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/authentication.md +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/commands.md +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/profiling.md +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/proxy-support.md +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/session-management.md +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/snapshot-refs.md +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/trust-boundaries.md +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/video-recording.md +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/references/webgpu.md +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/templates/authenticated-session.sh +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/templates/capture-workflow.sh +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/skills/agent-browser/templates/form-automation.sh +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/skills/search-batch.sh +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/webui/app.js +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/webui/icons/icon-192.png +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/webui/icons/icon-512.png +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/webui/index.html +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/webui/manifest.json +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/webui/service-worker.js +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/data/webui/style.css +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/exceptions.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/git/formatter.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/git/handler.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/git/models.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/git/service.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/main.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/middleware/auth.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/middleware/base.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/middleware/rate_limit.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/plugins/base.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/plugins/builtin/_task_prompts.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/plugins/builtin/audit_plugin.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/plugins/builtin/browser_tools.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/plugins/builtin/merge_resolver.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/plugins/builtin/playbooks/linkedin_comment.yaml +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/plugins/builtin/task_orchestrator.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/plugins/builtin/test_config_loader.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/plugins/builtin/web_agent.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/plugins/builtin/web_checkpoint.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/plugins/builtin/web_interaction_logger.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/plugins/builtin/workflow.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/plugins/registry.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/policies/.gitkeep +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/policies/strict.yaml +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/setup.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/skills.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/storage/base.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/storage/memory.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/tunnel.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/web/app.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/web/auth.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/web/models.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/web/push.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/web/routes.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/web/tmux_hooks.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/web/tmux_jsonl.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/web/tmux_server.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/leashd/web/ws_handler.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/scripts/_harness/drive.py +0 -0
- {leashd-2.0.0 → leashd-2.2.0}/scripts/_harness/soak_model.py +0 -0
|
@@ -1,5 +1,20 @@
|
|
|
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
|
+
|
|
10
|
+
## [2.1.0] - 2026-10-03
|
|
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.
|
|
12
|
+
- **added**: the Telegram bot fills its `/` command menu on startup, so leashd's commands and `/model`, `/effort`, `/compact`, `/context` show up with descriptions.
|
|
13
|
+
- **added**: fewer prompts: `rm -rf` under `/tmp` or a tool cache, `curl` writes with a literal body to a loopback dev server, and reads and writes in Claude Code's session scratchpad run without asking.
|
|
14
|
+
- **fixed**: a turn is no longer returned as finished while Claude is still thinking or writing, which cut long Linux runs short on a progress note.
|
|
15
|
+
- **fixed**: approved Bash commands no longer sit on Claude Code 2.1.286+'s permission prompt until leashd rejects it after 10 minutes. If a prompt does get stuck, `/screen` shows its answers as buttons.
|
|
16
|
+
- **fixed**: a message sent while Claude is working on its own no longer interrupts the running tool or gets answered twice, and a reply Claude writes on its own is sent once and saved.
|
|
17
|
+
|
|
3
18
|
## [2.0.0] - 2026-09-30
|
|
4
19
|
- **removed**: the `claude-cli`, `claude-code` (Agent SDK) and `codex` runtimes, `leashd runtime` and `/test`. tmux is the only runtime; an old `agent_runtime` setting falls back to it with a warning.
|
|
5
20
|
- **changed**: `/task` is one pipeline, implement → verify → opt-in review, and verify drives a real browser only when the change shows up in a running app. New defaults: `max_turns` 120, effort `medium`, and agent-browser browsing runs without asking.
|
|
@@ -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
|
|
@@ -377,6 +379,12 @@ leashd browser clear-profile
|
|
|
377
379
|
leashd browser headless
|
|
378
380
|
leashd browser auto-approve off # tap for each agent-browser step (on by default)
|
|
379
381
|
|
|
382
|
+
# Trusted SSH hosts
|
|
383
|
+
leashd ssh trust build-box # read-only commands on the host run without asking
|
|
384
|
+
leashd ssh trust build-box --full # every command on the host runs without asking
|
|
385
|
+
leashd ssh untrust build-box
|
|
386
|
+
leashd ssh show
|
|
387
|
+
|
|
380
388
|
# Agent tuning
|
|
381
389
|
leashd effort show / set <low|medium|high|xhigh|max> # default: medium
|
|
382
390
|
leashd turns show / set <N> # default: 120
|
|
@@ -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
|
|
@@ -329,6 +331,12 @@ leashd browser clear-profile
|
|
|
329
331
|
leashd browser headless
|
|
330
332
|
leashd browser auto-approve off # tap for each agent-browser step (on by default)
|
|
331
333
|
|
|
334
|
+
# Trusted SSH hosts
|
|
335
|
+
leashd ssh trust build-box # read-only commands on the host run without asking
|
|
336
|
+
leashd ssh trust build-box --full # every command on the host runs without asking
|
|
337
|
+
leashd ssh untrust build-box
|
|
338
|
+
leashd ssh show
|
|
339
|
+
|
|
332
340
|
# Agent tuning
|
|
333
341
|
leashd effort show / set <low|medium|high|xhigh|max> # default: medium
|
|
334
342
|
leashd turns show / set <N> # default: 120
|
|
@@ -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 = (
|
|
@@ -78,6 +78,23 @@ UNATTENDED_DIALOG_REJECT_S = 600.0
|
|
|
78
78
|
|
|
79
79
|
BLOCKED_ON_HUMAN_LOG_INTERVAL_S = 60.0
|
|
80
80
|
|
|
81
|
+
_BLINKING_BULLETS = str.maketrans({"⏺": " ", "●": " "})
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _without_blink(screen: str) -> str:
|
|
85
|
+
"""The screen with the bullet claude blinks beside a running tool blanked.
|
|
86
|
+
|
|
87
|
+
Everything else that changes between two reads is claude drawing: the
|
|
88
|
+
spinner's elapsed time, a tool's output, the answer as it is written. The
|
|
89
|
+
idle backstop waits for that to stop, because no single read can tell a
|
|
90
|
+
working pane from an idle one. Claude Code 2.1.288 draws no spinner and no
|
|
91
|
+
``esc to interrupt`` while it writes an answer, and on Linux one spinner
|
|
92
|
+
frame was a glyph leashd did not know, so a 103-second thinking stretch was
|
|
93
|
+
returned as a finished turn.
|
|
94
|
+
"""
|
|
95
|
+
return screen.translate(_BLINKING_BULLETS)
|
|
96
|
+
|
|
97
|
+
|
|
81
98
|
FINAL_TEXT_GRACE_SECONDS = 2.0
|
|
82
99
|
FINAL_TEXT_POLL_INTERVAL = 0.1
|
|
83
100
|
NATIVE_COST_SETTLE_SECONDS = 1.5
|
|
@@ -204,7 +221,7 @@ def _unattended_dialog_notice() -> str:
|
|
|
204
221
|
return (
|
|
205
222
|
"⏳ The agent is waiting on a permission prompt in its terminal that "
|
|
206
223
|
"leashd could not match to a tool call. Open /screen to see it and "
|
|
207
|
-
"
|
|
224
|
+
"answer it, or /stop to abort. leashd rejects it itself in "
|
|
208
225
|
f"{int(UNATTENDED_DIALOG_REJECT_S // 60)} minutes."
|
|
209
226
|
)
|
|
210
227
|
|
|
@@ -222,6 +239,35 @@ _INTERRUPTED_NOTE = (
|
|
|
222
239
|
)
|
|
223
240
|
|
|
224
241
|
|
|
242
|
+
async def _await_response_end(cs: TmuxClaudeSession, timeout: float) -> bool:
|
|
243
|
+
deadline = time.monotonic() + timeout
|
|
244
|
+
while time.monotonic() < deadline:
|
|
245
|
+
if cs.is_idle_at_composer():
|
|
246
|
+
return True
|
|
247
|
+
await asyncio.sleep(0.4)
|
|
248
|
+
return False
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
async def _send_interrupted_note(
|
|
252
|
+
cs: TmuxClaudeSession,
|
|
253
|
+
turn: TmuxTurn,
|
|
254
|
+
on_text_chunk: Callable[[str], Coroutine[Any, Any, None]] | None,
|
|
255
|
+
) -> None:
|
|
256
|
+
"""Say the turn stopped on an aborted tool call, once its last records
|
|
257
|
+
are in.
|
|
258
|
+
|
|
259
|
+
Sent the moment the turn ended, it went out ahead of a reply the tailer
|
|
260
|
+
had not read yet: the ``Stop`` hook beats the transcript, so an interrupt
|
|
261
|
+
claude had already answered past still read as the turn's last word.
|
|
262
|
+
"""
|
|
263
|
+
if turn.interrupted and on_text_chunk is not None and not cs.policy_block:
|
|
264
|
+
await safe_callback(
|
|
265
|
+
on_text_chunk,
|
|
266
|
+
f"\n\n{_INTERRUPTED_NOTE}\n",
|
|
267
|
+
log_event="tmux_interrupt_notice_failed",
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
|
|
225
271
|
async def _reply_content(
|
|
226
272
|
turn: TmuxTurn,
|
|
227
273
|
on_text_chunk: Callable[[str], Coroutine[Any, Any, None]] | None,
|
|
@@ -617,6 +663,16 @@ class TmuxAgent(BaseAgent):
|
|
|
617
663
|
turn = cs.begin_turn(
|
|
618
664
|
on_text_chunk=on_text_chunk, on_tool_activity=on_tool_activity
|
|
619
665
|
)
|
|
666
|
+
joined_text = " ".join(current_text.split())
|
|
667
|
+
joins_running_response = cs.response_running()
|
|
668
|
+
if joins_running_response:
|
|
669
|
+
turn.pending_followups += 1
|
|
670
|
+
turn.pending_followup_texts.append(joined_text)
|
|
671
|
+
logger.info(
|
|
672
|
+
"tmux_prompt_joins_running_response",
|
|
673
|
+
session_id=session.session_id,
|
|
674
|
+
chat_id=session.chat_id,
|
|
675
|
+
)
|
|
620
676
|
|
|
621
677
|
# Attachments belong to the original message only — never re-stage
|
|
622
678
|
# them on a plan-revision re-prompt.
|
|
@@ -629,7 +685,18 @@ class TmuxAgent(BaseAgent):
|
|
|
629
685
|
staged_attachments = True
|
|
630
686
|
# `cs.last_prompt` stays the raw user text (gatekeeper
|
|
631
687
|
# task_description) across revisions; only the keystrokes change.
|
|
632
|
-
await cs.submit(current_text)
|
|
688
|
+
delivered = await cs.submit(current_text, followup=joins_running_response)
|
|
689
|
+
if joins_running_response and not delivered:
|
|
690
|
+
turn.pending_followups = max(0, turn.pending_followups - 1)
|
|
691
|
+
turn.withdraw_followup(joined_text)
|
|
692
|
+
cs.clear_composer()
|
|
693
|
+
logger.warning(
|
|
694
|
+
"tmux_prompt_join_undelivered",
|
|
695
|
+
session_id=session.session_id,
|
|
696
|
+
chat_id=session.chat_id,
|
|
697
|
+
)
|
|
698
|
+
if await _await_response_end(cs, PANE_READY_TIMEOUT):
|
|
699
|
+
await cs.submit(current_text)
|
|
633
700
|
|
|
634
701
|
early = await self._await_turn(
|
|
635
702
|
cs,
|
|
@@ -700,6 +767,7 @@ class TmuxAgent(BaseAgent):
|
|
|
700
767
|
if turn.result_seen:
|
|
701
768
|
break
|
|
702
769
|
|
|
770
|
+
await _send_interrupted_note(cs, turn, on_text_chunk)
|
|
703
771
|
await cs.settle_native_cost(NATIVE_COST_SETTLE_SECONDS)
|
|
704
772
|
turn.settle_usage(cs.take_usage())
|
|
705
773
|
content = await _reply_content(turn, on_text_chunk)
|
|
@@ -759,6 +827,8 @@ class TmuxAgent(BaseAgent):
|
|
|
759
827
|
unattended_since: float | None = None
|
|
760
828
|
regate: asyncio.Task[bool] | None = None
|
|
761
829
|
regate_unmatched = False
|
|
830
|
+
drawn_screen: str | None = None
|
|
831
|
+
redrawn_at = started
|
|
762
832
|
|
|
763
833
|
async def _abort(event: str, content: str, **fields: Any) -> AgentResponse:
|
|
764
834
|
"""End a turn that can never legitimately complete: log, unblock
|
|
@@ -855,6 +925,11 @@ class TmuxAgent(BaseAgent):
|
|
|
855
925
|
if not cs.answer_drive_active:
|
|
856
926
|
with contextlib.suppress(Exception):
|
|
857
927
|
stalled_screen = cs.capture()
|
|
928
|
+
if stalled_screen:
|
|
929
|
+
drawn = _without_blink(stalled_screen)
|
|
930
|
+
if drawn_screen is not None and drawn != drawn_screen:
|
|
931
|
+
redrawn_at = time.monotonic()
|
|
932
|
+
drawn_screen = drawn
|
|
858
933
|
if (
|
|
859
934
|
stalled_screen
|
|
860
935
|
and cs.dedicated_selector_present(stalled_screen)
|
|
@@ -863,14 +938,14 @@ class TmuxAgent(BaseAgent):
|
|
|
863
938
|
and cs.was_interrupted(stalled_screen)
|
|
864
939
|
)
|
|
865
940
|
):
|
|
866
|
-
settled_screen = stalled_screen
|
|
941
|
+
settled_screen = _without_blink(stalled_screen)
|
|
867
942
|
if settled_screen != unattended_screen:
|
|
868
943
|
unattended_screen = settled_screen
|
|
869
944
|
unattended_since = time.monotonic()
|
|
870
945
|
regate_unmatched = False
|
|
871
946
|
elif not notified_unattended and unattended_since is not None:
|
|
872
947
|
stalled_s = time.monotonic() - unattended_since
|
|
873
|
-
if stalled_s > UNATTENDED_DIALOG_STALL_S:
|
|
948
|
+
if stalled_s > UNATTENDED_DIALOG_STALL_S and not cs.regate_active:
|
|
874
949
|
notified_unattended = True
|
|
875
950
|
logger.warning(
|
|
876
951
|
"tmux_native_dialog_unattended",
|
|
@@ -998,7 +1073,7 @@ class TmuxAgent(BaseAgent):
|
|
|
998
1073
|
and not cs.goal_active
|
|
999
1074
|
and not cs.followup_injecting
|
|
1000
1075
|
and turn.pending_followups == 0
|
|
1001
|
-
and now - turn.last_activity > completion_idle_grace
|
|
1076
|
+
and now - max(turn.last_activity, redrawn_at) > completion_idle_grace
|
|
1002
1077
|
and cs.is_idle_at_composer()
|
|
1003
1078
|
and (turn.assembled_text or cs.was_interrupted())
|
|
1004
1079
|
):
|
|
@@ -1048,12 +1123,6 @@ class TmuxAgent(BaseAgent):
|
|
|
1048
1123
|
is_error=True,
|
|
1049
1124
|
)
|
|
1050
1125
|
|
|
1051
|
-
if turn.interrupted and on_text_chunk is not None and not cs.policy_block:
|
|
1052
|
-
await safe_callback(
|
|
1053
|
-
on_text_chunk,
|
|
1054
|
-
f"\n\n{_INTERRUPTED_NOTE}\n",
|
|
1055
|
-
log_event="tmux_interrupt_notice_failed",
|
|
1056
|
-
)
|
|
1057
1126
|
return None
|
|
1058
1127
|
|
|
1059
1128
|
async def inject_followup(
|
|
@@ -1273,6 +1342,21 @@ class TmuxAgent(BaseAgent):
|
|
|
1273
1342
|
return None
|
|
1274
1343
|
return self._tsm.stuck_permission_id(cs)
|
|
1275
1344
|
|
|
1345
|
+
def stuck_prompt_options(self, session: Session) -> list[tuple[int, str]]:
|
|
1346
|
+
cs = self._tsm.get(session.session_id)
|
|
1347
|
+
if cs is None or cs.pane_is_dead():
|
|
1348
|
+
return []
|
|
1349
|
+
return [(o.number, o.label) for o in self._tsm.stuck_permission_options(cs)]
|
|
1350
|
+
|
|
1351
|
+
def answer_stuck_prompt(
|
|
1352
|
+
self, session: Session, prompt_id: str, number: int
|
|
1353
|
+
) -> str | None:
|
|
1354
|
+
cs = self._tsm.get(session.session_id)
|
|
1355
|
+
if cs is None or cs.pane_is_dead():
|
|
1356
|
+
return None
|
|
1357
|
+
option = self._tsm.answer_stuck_permission(cs, prompt_id, number, source="chat")
|
|
1358
|
+
return option.label if option is not None else None
|
|
1359
|
+
|
|
1276
1360
|
def reject_stuck_prompt(self, session: Session, prompt_id: str) -> bool:
|
|
1277
1361
|
cs = self._tsm.get(session.session_id)
|
|
1278
1362
|
if cs is None or cs.pane_is_dead():
|
|
@@ -1379,6 +1463,7 @@ class TmuxAgent(BaseAgent):
|
|
|
1379
1463
|
return early
|
|
1380
1464
|
if cs.claude_uuid:
|
|
1381
1465
|
session.agent_resume_token = cs.claude_uuid
|
|
1466
|
+
await _send_interrupted_note(cs, turn, on_text_chunk)
|
|
1382
1467
|
await cs.settle_native_cost(NATIVE_COST_SETTLE_SECONDS)
|
|
1383
1468
|
turn.settle_usage(cs.take_usage())
|
|
1384
1469
|
content = await _reply_content(turn, on_text_chunk)
|