leashd 2.1.0__tar.gz → 2.3.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.
Files changed (126) hide show
  1. {leashd-2.1.0 → leashd-2.3.0}/CHANGELOG.md +14 -0
  2. {leashd-2.1.0 → leashd-2.3.0}/PKG-INFO +16 -4
  3. {leashd-2.1.0 → leashd-2.3.0}/README.md +15 -3
  4. {leashd-2.1.0 → leashd-2.3.0}/leashd/__init__.py +1 -1
  5. {leashd-2.1.0 → leashd-2.3.0}/leashd/agents/runtimes/_helpers.py +3 -1
  6. leashd-2.3.0/leashd/agents/runtimes/hook_relay.py +149 -0
  7. {leashd-2.1.0 → leashd-2.3.0}/leashd/agents/runtimes/tmux_session.py +218 -9
  8. {leashd-2.1.0 → leashd-2.3.0}/leashd/connectors/base.py +17 -0
  9. {leashd-2.1.0 → leashd-2.3.0}/leashd/connectors/multi.py +8 -0
  10. {leashd-2.1.0 → leashd-2.3.0}/leashd/connectors/telegram.py +44 -5
  11. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/chat_sessions.py +15 -4
  12. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/engine.py +146 -14
  13. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/events.py +2 -0
  14. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/safety/analyzer.py +4 -1
  15. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/safety/audit.py +20 -0
  16. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/session.py +12 -0
  17. leashd-2.3.0/leashd/core/session_title.py +27 -0
  18. {leashd-2.1.0 → leashd-2.3.0}/leashd/policies/autonomous.yaml +1 -1
  19. {leashd-2.1.0 → leashd-2.3.0}/leashd/policies/default.yaml +28 -1
  20. {leashd-2.1.0 → leashd-2.3.0}/leashd/policies/dev-tools.yaml +1 -0
  21. {leashd-2.1.0 → leashd-2.3.0}/leashd/storage/sqlite.py +6 -2
  22. {leashd-2.1.0 → leashd-2.3.0}/leashd/web/tmux_hooks.py +18 -5
  23. {leashd-2.1.0 → leashd-2.3.0}/pyproject.toml +1 -1
  24. {leashd-2.1.0 → leashd-2.3.0}/scripts/_harness/multisession_suite.py +126 -3
  25. {leashd-2.1.0 → leashd-2.3.0}/.claude/settings.json +0 -0
  26. {leashd-2.1.0 → leashd-2.3.0}/.gitignore +0 -0
  27. {leashd-2.1.0 → leashd-2.3.0}/LICENSE +0 -0
  28. {leashd-2.1.0 → leashd-2.3.0}/leashd/__main__.py +0 -0
  29. {leashd-2.1.0 → leashd-2.3.0}/leashd/agents/base.py +0 -0
  30. {leashd-2.1.0 → leashd-2.3.0}/leashd/agents/capabilities.py +0 -0
  31. {leashd-2.1.0 → leashd-2.3.0}/leashd/agents/registry.py +0 -0
  32. {leashd-2.1.0 → leashd-2.3.0}/leashd/agents/runtimes/tmux.py +0 -0
  33. {leashd-2.1.0 → leashd-2.3.0}/leashd/agents/runtimes/tmux_manifest.py +0 -0
  34. {leashd-2.1.0 → leashd-2.3.0}/leashd/agents/types.py +0 -0
  35. {leashd-2.1.0 → leashd-2.3.0}/leashd/app.py +0 -0
  36. {leashd-2.1.0 → leashd-2.3.0}/leashd/browser_profile.py +0 -0
  37. {leashd-2.1.0 → leashd-2.3.0}/leashd/cc_plugins.py +0 -0
  38. {leashd-2.1.0 → leashd-2.3.0}/leashd/cli.py +0 -0
  39. {leashd-2.1.0 → leashd-2.3.0}/leashd/cli_run.py +0 -0
  40. {leashd-2.1.0 → leashd-2.3.0}/leashd/config_store.py +0 -0
  41. {leashd-2.1.0 → leashd-2.3.0}/leashd/connectors/telegram_approval.py +0 -0
  42. {leashd-2.1.0 → leashd-2.3.0}/leashd/connectors/telegram_commands.py +0 -0
  43. {leashd-2.1.0 → leashd-2.3.0}/leashd/connectors/telegram_markdown.py +0 -0
  44. {leashd-2.1.0 → leashd-2.3.0}/leashd/connectors/telegram_sessions.py +0 -0
  45. {leashd-2.1.0 → leashd-2.3.0}/leashd/connectors/web.py +0 -0
  46. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/config.py +0 -0
  47. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/file_delivery.py +0 -0
  48. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/interactions.py +0 -0
  49. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/message_logger.py +0 -0
  50. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/plan_gate.py +0 -0
  51. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/queue.py +0 -0
  52. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/runtime_settings.py +0 -0
  53. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/safety/approval_card.py +0 -0
  54. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/safety/approvals.py +0 -0
  55. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/safety/gatekeeper.py +0 -0
  56. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/safety/policy.py +0 -0
  57. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/safety/sandbox.py +0 -0
  58. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/task.py +0 -0
  59. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/task_events.py +0 -0
  60. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/task_memory.py +0 -0
  61. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/task_profile.py +0 -0
  62. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/test_output.py +0 -0
  63. {leashd-2.1.0 → leashd-2.3.0}/leashd/core/workspace.py +0 -0
  64. {leashd-2.1.0 → leashd-2.3.0}/leashd/daemon.py +0 -0
  65. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/skills/agent-browser/SKILL.md +0 -0
  66. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/skills/agent-browser/references/authentication.md +0 -0
  67. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/skills/agent-browser/references/commands.md +0 -0
  68. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/skills/agent-browser/references/profiling.md +0 -0
  69. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/skills/agent-browser/references/proxy-support.md +0 -0
  70. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/skills/agent-browser/references/session-management.md +0 -0
  71. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/skills/agent-browser/references/snapshot-refs.md +0 -0
  72. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/skills/agent-browser/references/trust-boundaries.md +0 -0
  73. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/skills/agent-browser/references/video-recording.md +0 -0
  74. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/skills/agent-browser/references/webgpu.md +0 -0
  75. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/skills/agent-browser/templates/authenticated-session.sh +0 -0
  76. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/skills/agent-browser/templates/capture-workflow.sh +0 -0
  77. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/skills/agent-browser/templates/form-automation.sh +0 -0
  78. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/skills/search-batch.sh +0 -0
  79. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/webui/app.js +0 -0
  80. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/webui/icons/icon-192.png +0 -0
  81. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/webui/icons/icon-512.png +0 -0
  82. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/webui/index.html +0 -0
  83. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/webui/manifest.json +0 -0
  84. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/webui/service-worker.js +0 -0
  85. {leashd-2.1.0 → leashd-2.3.0}/leashd/data/webui/style.css +0 -0
  86. {leashd-2.1.0 → leashd-2.3.0}/leashd/exceptions.py +0 -0
  87. {leashd-2.1.0 → leashd-2.3.0}/leashd/git/formatter.py +0 -0
  88. {leashd-2.1.0 → leashd-2.3.0}/leashd/git/handler.py +0 -0
  89. {leashd-2.1.0 → leashd-2.3.0}/leashd/git/models.py +0 -0
  90. {leashd-2.1.0 → leashd-2.3.0}/leashd/git/service.py +0 -0
  91. {leashd-2.1.0 → leashd-2.3.0}/leashd/main.py +0 -0
  92. {leashd-2.1.0 → leashd-2.3.0}/leashd/middleware/auth.py +0 -0
  93. {leashd-2.1.0 → leashd-2.3.0}/leashd/middleware/base.py +0 -0
  94. {leashd-2.1.0 → leashd-2.3.0}/leashd/middleware/rate_limit.py +0 -0
  95. {leashd-2.1.0 → leashd-2.3.0}/leashd/plugins/base.py +0 -0
  96. {leashd-2.1.0 → leashd-2.3.0}/leashd/plugins/builtin/_task_prompts.py +0 -0
  97. {leashd-2.1.0 → leashd-2.3.0}/leashd/plugins/builtin/audit_plugin.py +0 -0
  98. {leashd-2.1.0 → leashd-2.3.0}/leashd/plugins/builtin/browser_tools.py +0 -0
  99. {leashd-2.1.0 → leashd-2.3.0}/leashd/plugins/builtin/merge_resolver.py +0 -0
  100. {leashd-2.1.0 → leashd-2.3.0}/leashd/plugins/builtin/playbooks/linkedin_comment.yaml +0 -0
  101. {leashd-2.1.0 → leashd-2.3.0}/leashd/plugins/builtin/task_orchestrator.py +0 -0
  102. {leashd-2.1.0 → leashd-2.3.0}/leashd/plugins/builtin/test_config_loader.py +0 -0
  103. {leashd-2.1.0 → leashd-2.3.0}/leashd/plugins/builtin/web_agent.py +0 -0
  104. {leashd-2.1.0 → leashd-2.3.0}/leashd/plugins/builtin/web_checkpoint.py +0 -0
  105. {leashd-2.1.0 → leashd-2.3.0}/leashd/plugins/builtin/web_interaction_logger.py +0 -0
  106. {leashd-2.1.0 → leashd-2.3.0}/leashd/plugins/builtin/workflow.py +0 -0
  107. {leashd-2.1.0 → leashd-2.3.0}/leashd/plugins/registry.py +0 -0
  108. {leashd-2.1.0 → leashd-2.3.0}/leashd/policies/.gitkeep +0 -0
  109. {leashd-2.1.0 → leashd-2.3.0}/leashd/policies/permissive.yaml +0 -0
  110. {leashd-2.1.0 → leashd-2.3.0}/leashd/policies/strict.yaml +0 -0
  111. {leashd-2.1.0 → leashd-2.3.0}/leashd/setup.py +0 -0
  112. {leashd-2.1.0 → leashd-2.3.0}/leashd/skills.py +0 -0
  113. {leashd-2.1.0 → leashd-2.3.0}/leashd/storage/base.py +0 -0
  114. {leashd-2.1.0 → leashd-2.3.0}/leashd/storage/memory.py +0 -0
  115. {leashd-2.1.0 → leashd-2.3.0}/leashd/tunnel.py +0 -0
  116. {leashd-2.1.0 → leashd-2.3.0}/leashd/web/app.py +0 -0
  117. {leashd-2.1.0 → leashd-2.3.0}/leashd/web/auth.py +0 -0
  118. {leashd-2.1.0 → leashd-2.3.0}/leashd/web/models.py +0 -0
  119. {leashd-2.1.0 → leashd-2.3.0}/leashd/web/push.py +0 -0
  120. {leashd-2.1.0 → leashd-2.3.0}/leashd/web/routes.py +0 -0
  121. {leashd-2.1.0 → leashd-2.3.0}/leashd/web/tmux_jsonl.py +0 -0
  122. {leashd-2.1.0 → leashd-2.3.0}/leashd/web/tmux_server.py +0 -0
  123. {leashd-2.1.0 → leashd-2.3.0}/leashd/web/ws_handler.py +0 -0
  124. {leashd-2.1.0 → leashd-2.3.0}/scripts/_harness/drive.py +0 -0
  125. {leashd-2.1.0 → leashd-2.3.0}/scripts/_harness/soak_model.py +0 -0
  126. {leashd-2.1.0 → leashd-2.3.0}/scripts/_harness/tmux_harness.py +0 -0
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.3.0] - 2026-10-10
4
+ - **added**: while background subagents are still working after Claude's turn has ended, the chat shows a line under the last reply naming them, until they report back.
5
+ - **added**: a `tool_ran_ungated` audit entry and `tmux_tool_ran_ungated` log line for any tool call that finishes without having gone through the gate.
6
+ - **fixed**: a tool call could run with no policy check and no audit entry (about 1 in 900) when its hook hit a connection the daemon had just closed, or arrived while the daemon was restarting. The gating hooks now retry until leashd answers and deny if it never does.
7
+ - **fixed**: a tool line left under a reply by a background subagent is cleared when the agent finishes, and its hand-back no longer shows as "Running: …".
8
+ - **fixed**: opening a running conversation in your own terminal (`claude` → `/resume`) no longer posts Claude Code's "No response requested." placeholder into the chat as the agent's reply.
9
+
10
+ ## [2.2.0] - 2026-10-03
11
+ - **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.
12
+ - **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`.
13
+ - **changed**: `git remote add`, `set-url`, `remove` and `rename` now ask instead of running as reads.
14
+ - **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".
15
+ - **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.
16
+
3
17
  ## [2.1.0] - 2026-10-03
4
18
  - **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
19
  - **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.1.0
3
+ Version: 2.3.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
@@ -152,11 +152,13 @@ Every tool call the agent makes passes through three layers before it can execut
152
152
 
153
153
  The pipeline is connector-agnostic: same sandbox, same rules, same buttons whether you're in the browser or on your phone. Every attempt and decision is appended to `.leashd/audit.jsonl`.
154
154
 
155
+ The gate fails closed. If a tool call cannot reach leashd, for example while the daemon restarts, it waits up to 60 seconds for an answer and is denied if none comes. A call that still finishes without a verdict is written to the audit log as `tool_ran_ungated`, so `grep tool_ran_ungated .leashd/audit.jsonl` should always print nothing.
156
+
155
157
  **Five policies ship in `policies/`:**
156
158
 
157
159
  | Policy | Auto-allows | Requires approval |
158
160
  |---|---|---|
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 |
161
+ | **`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
162
  | **`strict.yaml`** | `Read`, `Glob`, `Grep`, `LS` only | everything else (2-min timeout) |
161
163
  | **`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
164
  | **`dev-tools.yaml`** *(overlay)* | linters, test runners, package managers | — |
@@ -179,7 +181,13 @@ LEASHD_POLICY_FILES=policies/default.yaml,policies/my-overrides.yaml # merged,
179
181
 
180
182
  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
183
 
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).
184
+ **Background subagents stay visible.** Claude can start subagents in the background and end its turn while they work. The chat then shows one line under the last reply until they report back, and Claude's follow-up arrives as a normal reply:
185
+
186
+ ```
187
+ ⏳ 2 background agents are still working: Audit the API routes, Check test coverage. Claude replies here when they report back.
188
+ ```
189
+
190
+ **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
191
 
184
192
  **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
193
 
@@ -253,6 +261,8 @@ The Web UI has always had conversation tabs. `/session` gives a Telegram chat th
253
261
 
254
262
  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
263
 
264
+ 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.
265
+
256
266
  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
267
 
258
268
  ### CLI
@@ -274,7 +284,7 @@ Available in both the Web UI and Telegram.
274
284
 
275
285
  | Command | Description |
276
286
  |---|---|
277
- | `/task <description>` | Autonomous: implement → verify → PR |
287
+ | `/task <description>` | Autonomous: implement → verify, plus an opt-in review |
278
288
  | `/goal <condition>` | Set a completion condition the agent works toward across turns until a fast model confirms it's met |
279
289
  | `/web <instruction>` | Autonomous web automation with content-level human approval |
280
290
  | `/plan <text>` | Plan mode — agent proposes, you approve before execution |
@@ -364,6 +374,7 @@ leashd model show / set <opus|sonnet|claude-…> / clear
364
374
 
365
375
  # Task orchestrator
366
376
  leashd orchestrator enable / disable / show
377
+ leashd run "fix the flaky login test" # submit a /task and block until it finishes
367
378
 
368
379
  # Web UI
369
380
  leashd webui show / enable / disable / url
@@ -386,6 +397,7 @@ leashd ssh show
386
397
  # Agent tuning
387
398
  leashd effort show / set <low|medium|high|xhigh|max> # default: medium
388
399
  leashd turns show / set <N> # default: 120
400
+ leashd tool-calls show / set <N> # -1 for unlimited
389
401
 
390
402
  # Plugins and skills
391
403
  leashd plugin list / add <source> / remove <name> / enable <name> / disable <name>
@@ -104,11 +104,13 @@ Every tool call the agent makes passes through three layers before it can execut
104
104
 
105
105
  The pipeline is connector-agnostic: same sandbox, same rules, same buttons whether you're in the browser or on your phone. Every attempt and decision is appended to `.leashd/audit.jsonl`.
106
106
 
107
+ The gate fails closed. If a tool call cannot reach leashd, for example while the daemon restarts, it waits up to 60 seconds for an answer and is denied if none comes. A call that still finishes without a verdict is written to the audit log as `tool_ran_ungated`, so `grep tool_ran_ungated .leashd/audit.jsonl` should always print nothing.
108
+
107
109
  **Five policies ship in `policies/`:**
108
110
 
109
111
  | Policy | Auto-allows | Requires approval |
110
112
  |---|---|---|
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 |
113
+ | **`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
114
  | **`strict.yaml`** | `Read`, `Glob`, `Grep`, `LS` only | everything else (2-min timeout) |
113
115
  | **`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
116
  | **`dev-tools.yaml`** *(overlay)* | linters, test runners, package managers | — |
@@ -131,7 +133,13 @@ LEASHD_POLICY_FILES=policies/default.yaml,policies/my-overrides.yaml # merged,
131
133
 
132
134
  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
135
 
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).
136
+ **Background subagents stay visible.** Claude can start subagents in the background and end its turn while they work. The chat then shows one line under the last reply until they report back, and Claude's follow-up arrives as a normal reply:
137
+
138
+ ```
139
+ ⏳ 2 background agents are still working: Audit the API routes, Check test coverage. Claude replies here when they report back.
140
+ ```
141
+
142
+ **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
143
 
136
144
  **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
145
 
@@ -205,6 +213,8 @@ The Web UI has always had conversation tabs. `/session` gives a Telegram chat th
205
213
 
206
214
  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
215
 
216
+ 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.
217
+
208
218
  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
219
 
210
220
  ### CLI
@@ -226,7 +236,7 @@ Available in both the Web UI and Telegram.
226
236
 
227
237
  | Command | Description |
228
238
  |---|---|
229
- | `/task <description>` | Autonomous: implement → verify → PR |
239
+ | `/task <description>` | Autonomous: implement → verify, plus an opt-in review |
230
240
  | `/goal <condition>` | Set a completion condition the agent works toward across turns until a fast model confirms it's met |
231
241
  | `/web <instruction>` | Autonomous web automation with content-level human approval |
232
242
  | `/plan <text>` | Plan mode — agent proposes, you approve before execution |
@@ -316,6 +326,7 @@ leashd model show / set <opus|sonnet|claude-…> / clear
316
326
 
317
327
  # Task orchestrator
318
328
  leashd orchestrator enable / disable / show
329
+ leashd run "fix the flaky login test" # submit a /task and block until it finishes
319
330
 
320
331
  # Web UI
321
332
  leashd webui show / enable / disable / url
@@ -338,6 +349,7 @@ leashd ssh show
338
349
  # Agent tuning
339
350
  leashd effort show / set <low|medium|high|xhigh|max> # default: medium
340
351
  leashd turns show / set <N> # default: 120
352
+ leashd tool-calls show / set <N> # -1 for unlimited
341
353
 
342
354
  # Plugins and skills
343
355
  leashd plugin list / add <source> / remove <name> / enable <name> / disable <name>
@@ -1,3 +1,3 @@
1
1
  """leashd — Remote AI-assisted development with safety constraints."""
2
2
 
3
- __version__ = "2.1.0"
3
+ __version__ = "2.3.0"
@@ -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
- + _DIRECT_EDIT_RULES
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 = (
@@ -0,0 +1,149 @@
1
+ """Deliver one gating Claude Code hook to leashd, failing closed.
2
+
3
+ Claude Code runs a tool when its hook cannot be delivered. This command posts
4
+ the hook over a fresh connection, keeps trying while the daemon is away (a
5
+ restart), and answers ``deny`` itself when no verdict can be had. Standard
6
+ library only: it runs once per tool call, under ``python -I -S``.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import http.client
12
+ import json
13
+ import sys
14
+ import time
15
+ from typing import TYPE_CHECKING, Any
16
+ from urllib.parse import urlsplit
17
+
18
+ if TYPE_CHECKING:
19
+ from collections.abc import Callable
20
+ from typing import BinaryIO, TextIO
21
+
22
+ CONNECT_TIMEOUT_SECONDS = 2.0
23
+ RETRY_BUDGET_SECONDS = 60.0
24
+ FIRST_RETRY_DELAY_SECONDS = 0.1
25
+ LONGEST_RETRY_DELAY_SECONDS = 2.0
26
+ PERMISSION_REQUEST = "PermissionRequest"
27
+ PANE_TOKEN_HEADER = "X-Leashd-Pane" # noqa: S105
28
+ UNREACHABLE_REASON = (
29
+ "leashd could not be reached to check this tool call, so it did not run. "
30
+ "Nothing is wrong with the call itself; try again once leashd is back."
31
+ )
32
+ REFUSED_REASON = (
33
+ "leashd refused this pane's safety hook, so the tool call did not run. "
34
+ "This pane has to be restarted."
35
+ )
36
+ BROKEN_REASON = "leashd's safety hook failed, so the tool call did not run."
37
+
38
+
39
+ def deny(event: str, reason: str) -> dict[str, Any]:
40
+ if event == PERMISSION_REQUEST:
41
+ return {
42
+ "hookSpecificOutput": {
43
+ "hookEventName": PERMISSION_REQUEST,
44
+ "decision": {"behavior": "deny"},
45
+ }
46
+ }
47
+ return {
48
+ "hookSpecificOutput": {
49
+ "hookEventName": "PreToolUse",
50
+ "permissionDecision": "deny",
51
+ "permissionDecisionReason": reason,
52
+ }
53
+ }
54
+
55
+
56
+ def read_headers(header_file: str) -> dict[str, str]:
57
+ headers: dict[str, str] = {}
58
+ with open(header_file) as handle:
59
+ for line in handle:
60
+ name, separator, value = line.partition(":")
61
+ if separator:
62
+ headers[name.strip()] = value.strip()
63
+ return headers
64
+
65
+
66
+ def post(url: str, headers: dict[str, str], body: bytes) -> tuple[int, bytes]:
67
+ target = urlsplit(url)
68
+ connection = http.client.HTTPConnection(
69
+ target.hostname or "127.0.0.1", target.port, timeout=CONNECT_TIMEOUT_SECONDS
70
+ )
71
+ try:
72
+ connection.connect()
73
+ connection.sock.settimeout(None)
74
+ connection.request(
75
+ "POST",
76
+ target.path,
77
+ body=body,
78
+ headers={
79
+ **headers,
80
+ "Content-Type": "application/json",
81
+ "Connection": "close",
82
+ },
83
+ )
84
+ response = connection.getresponse()
85
+ return response.status, response.read()
86
+ finally:
87
+ connection.close()
88
+
89
+
90
+ def verdict_in(payload: bytes) -> dict[str, Any] | None:
91
+ try:
92
+ verdict = json.loads(payload)
93
+ except ValueError:
94
+ return None
95
+ if isinstance(verdict, dict) and isinstance(
96
+ verdict.get("hookSpecificOutput"), dict
97
+ ):
98
+ return verdict
99
+ return None
100
+
101
+
102
+ def relay(
103
+ event: str,
104
+ url: str,
105
+ headers: dict[str, str],
106
+ body: bytes,
107
+ *,
108
+ send: Callable[[str, dict[str, str], bytes], tuple[int, bytes]] = post,
109
+ clock: Callable[[], float] = time.monotonic,
110
+ sleep: Callable[[float], None] = time.sleep,
111
+ budget: float = RETRY_BUDGET_SECONDS,
112
+ ) -> dict[str, Any]:
113
+ give_up_at = clock() + budget
114
+ delay = FIRST_RETRY_DELAY_SECONDS
115
+ while True:
116
+ status: int | None
117
+ try:
118
+ status, payload = send(url, headers, body)
119
+ except (OSError, http.client.HTTPException):
120
+ status, payload = None, b""
121
+ if status == 200:
122
+ verdict = verdict_in(payload)
123
+ if verdict is not None:
124
+ return verdict
125
+ elif status is not None and 400 <= status < 500:
126
+ return deny(event, REFUSED_REASON)
127
+ if clock() + delay > give_up_at:
128
+ return deny(event, UNREACHABLE_REASON)
129
+ sleep(delay)
130
+ delay = min(delay * 2, LONGEST_RETRY_DELAY_SECONDS)
131
+
132
+
133
+ def main(argv: list[str], stdin: BinaryIO, stdout: TextIO) -> int:
134
+ event = argv[1] if len(argv) > 1 else "PreToolUse"
135
+ try:
136
+ _, _, url, header_file, pane_token = argv
137
+ headers = read_headers(header_file)
138
+ if pane_token:
139
+ headers[PANE_TOKEN_HEADER] = pane_token
140
+ verdict = relay(event, url, headers, stdin.read())
141
+ except Exception:
142
+ verdict = deny(event, BROKEN_REASON)
143
+ stdout.write(json.dumps(verdict))
144
+ stdout.flush()
145
+ return 0
146
+
147
+
148
+ if __name__ == "__main__":
149
+ sys.exit(main(sys.argv, sys.stdin.buffer, sys.stdout))