clawtop 0.4.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.
clawtop-0.4.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Gishant Singh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
clawtop-0.4.0/PKG-INFO ADDED
@@ -0,0 +1,153 @@
1
+ Metadata-Version: 2.4
2
+ Name: clawtop
3
+ Version: 0.4.0
4
+ Summary: htop for OpenClaw: see gateway memory per agent run, kill runaway runs, and manage open sessions.
5
+ Keywords: openclaw,monitoring,memory,wsl,cli,typer
6
+ Author: Gishant Singh
7
+ Author-email: Gishant Singh <khiladisngh@hotmail.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Operating System :: Microsoft :: Windows
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: System :: Monitoring
20
+ Requires-Dist: typer>=0.15
21
+ Requires-Dist: rich>=13
22
+ Requires-Dist: textual>=8.2.8
23
+ Requires-Python: >=3.11
24
+ Project-URL: Homepage, https://github.com/khiladisngh/clawtop
25
+ Project-URL: Issues, https://github.com/khiladisngh/clawtop/issues
26
+ Project-URL: Documentation, https://khiladisngh.github.io/clawtop/
27
+ Project-URL: Changelog, https://github.com/khiladisngh/clawtop/blob/main/CHANGELOG.md
28
+ Description-Content-Type: text/markdown
29
+
30
+ # clawtop
31
+
32
+ [![ci](https://github.com/khiladisngh/clawtop/actions/workflows/ci.yml/badge.svg)](https://github.com/khiladisngh/clawtop/actions/workflows/ci.yml)
33
+ [![docs](https://github.com/khiladisngh/clawtop/actions/workflows/docs.yml/badge.svg)](https://khiladisngh.github.io/clawtop/)
34
+ [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/khiladisngh/clawtop/blob/main/LICENSE)
35
+ ![python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue)
36
+
37
+ **htop for [OpenClaw](https://openclaw.ai).** See where your gateway's memory goes, per agent run; stop
38
+ the runaway ones safely; keep your sessions tidy.
39
+
40
+ <p align="center">
41
+ <a href="https://khiladisngh.github.io/clawtop/guides/interactive-top/">
42
+ <img src="https://raw.githubusercontent.com/khiladisngh/clawtop/main/docs/assets/tui/top.gif"
43
+ alt="Animated tour of clawtop top: live memory graph, sortable runs, kill confirmation, session tree and history"
44
+ width="860">
45
+ </a>
46
+ <br>
47
+ <sub><code>clawtop top</code> on sample data (kills simulated). Also:
48
+ <a href="https://khiladisngh.github.io/clawtop/getting-started/walkthrough/">a 1:43 video walkthrough</a>
49
+ of the command-line tools.</sub>
50
+ </p>
51
+
52
+ **Documentation: <https://khiladisngh.github.io/clawtop/>**
53
+
54
+ ## Why
55
+
56
+ Many OpenClaw runtimes (CLI backends such as Claude CLI or Gemini CLI, and ACP harnesses) start a
57
+ separate process for every agent run, plus the MCP servers and helpers that run uses. In the author's
58
+ setup each such stack is roughly 0.5 to 0.7 GB. A burst of runs, or a few that hang on a tool call, can
59
+ push the gateway past the VM's RAM; the event loop then stalls in swap and restarts fail. clawtop makes
60
+ that visible and fixable in one command. It is not tied to one runtime: runs are recognised by structure,
61
+ not by program name.
62
+
63
+ - **Memory per run**, measured so the numbers add up to the gateway's cgroup total.
64
+ - **Real idleness** where the runtime exposes it (Claude Code's transcript today), so a busy long-lived
65
+ run is not flagged and a stuck one is. Where it doesn't, idle time is shown as `-`, never guessed.
66
+ - **Safe kills.** Only processes the gateway spawned can be selected, whole stacks die together (SIGTERM,
67
+ then SIGKILL), and PID reuse is guarded.
68
+ - **Sessions** through the supported `openclaw sessions` CLI: list, tree (subagents under their parent,
69
+ with titles), archive, prune.
70
+ - **History**: a per-minute sampler and `clawtop history` to see what a spike looked like.
71
+ - **Works from Windows**: it forwards into your WSL distro.
72
+
73
+ ## Install
74
+
75
+ On the Linux or WSL machine that runs the gateway (needs `uv` and Python 3.11+):
76
+
77
+ ```sh
78
+ uv tool install git+https://github.com/khiladisngh/clawtop
79
+ clawtop
80
+ clawtop sampler install # optional: per-minute memory history via a systemd user timer
81
+ ```
82
+
83
+ On a Windows host, install it there too; every command is forwarded into WSL
84
+ (your default WSL distro and user; override with `CLAWTOP_WSL_DISTRO` and `CLAWTOP_WSL_USER`).
85
+ See [Install](https://khiladisngh.github.io/clawtop/getting-started/install/).
86
+
87
+ ## Usage
88
+
89
+ | Command | What it does |
90
+ |---|---|
91
+ | `clawtop` / `status` | VM and gateway memory plus every agent run stack. `--json` for scripts. |
92
+ | `clawtop top` | Interactive htop-style screen: live memory graph, sortable runs, kill, session tree, history. |
93
+ | `clawtop kill` | Interactive picker: choose rows by number, `stale` or `all`. |
94
+ | `clawtop kill PID...` | Kill specific stacks by leader PID. |
95
+ | `clawtop kill --idle 30` | Kill runs with no transcript activity for 30 minutes. |
96
+ | `clawtop kill --older-than 120` | Kill runs older than 2 hours. |
97
+ | `clawtop kill --orphans` | Kill gateway-spawned stacks whose parent is gone. |
98
+ | `clawtop history --last 6h` | Memory sparkline, the peak, and the stacks alive at the peak. |
99
+ | `clawtop sessions list [--titles]` | Open sessions, longest idle first. |
100
+ | `clawtop sessions tree` | Sessions per agent, subagents nested under their parent. |
101
+ | `clawtop sessions archive KEY...` | Archive specific sessions. |
102
+ | `clawtop sessions prune` | Archive open **subagent** sessions idle for 6h (`--idle-hours`, `--kind`, `--agent`). |
103
+ | `clawtop sampler install\|uninstall` | Manage the per-minute sampler timer. |
104
+
105
+ `kill` and `sessions archive|prune` ask for confirmation; `--yes` skips it and `--dry-run` previews.
106
+ `prune` only touches subagent sessions unless you pass `--kind`, because channel and main sessions hold
107
+ conversation context. Full options: [CLI reference](https://khiladisngh.github.io/clawtop/reference/cli/).
108
+
109
+ ## Try it without a gateway
110
+
111
+ `scripts/demo.py` runs the real CLI against made-up sample data (the video above uses it); `kill` and
112
+ `archive` are simulated:
113
+
114
+ ```sh
115
+ git clone https://github.com/khiladisngh/clawtop && cd clawtop && uv sync
116
+ uv run python scripts/demo.py sessions tree
117
+ CLAWTOP_DEMO_ANSWERS="stale;y" uv run python scripts/demo.py kill
118
+ ```
119
+
120
+ ## Keep the gateway from running out of memory
121
+
122
+ clawtop shows problems; systemd limits and a concurrency cap stop them taking the VM down. See
123
+ [Harden the gateway](https://khiladisngh.github.io/clawtop/guides/harden-the-gateway/).
124
+
125
+ ## Limits
126
+
127
+ - Linux only (reads `/proc` and cgroup v2); on Windows it needs WSL.
128
+ - It looks for the systemd **user** unit `openclaw-gateway`.
129
+ - **Runtimes that run inside the gateway** (`openclaw`, `codex`, `copilot`, `muse`) have no process per
130
+ run, so there is no stack to list; their memory is part of the gateway's "main".
131
+ - **Verified on Claude CLI only.** Other process-per-run runtimes (Gemini CLI, ACP harnesses) are
132
+ recognised by the same structural rules, but I have not seen them on a real gateway. Please report
133
+ what you see. See [Concepts](https://khiladisngh.github.io/clawtop/concepts/).
134
+ - A run stack cannot be mapped to an OpenClaw session key (the gateway does not expose it), so clawtop
135
+ shows the runtime and agent instead of guessing.
136
+ - Runs are found by agent workspace (from your OpenClaw config), so the config must declare them.
137
+
138
+ ## Development
139
+
140
+ ```sh
141
+ uv sync
142
+ uv run ruff check . && uv run ruff format --check .
143
+ uv run pyright
144
+ uv run pytest --cov
145
+ uv run zensical serve # docs at http://localhost:8000
146
+ ```
147
+
148
+ The `/proc` parser tests build a fake `/proc` tree and need Linux; they are skipped on Windows and run in
149
+ CI. See [CONTRIBUTING.md](https://github.com/khiladisngh/clawtop/blob/main/CONTRIBUTING.md).
150
+
151
+ ## License
152
+
153
+ MIT
@@ -0,0 +1,124 @@
1
+ # clawtop
2
+
3
+ [![ci](https://github.com/khiladisngh/clawtop/actions/workflows/ci.yml/badge.svg)](https://github.com/khiladisngh/clawtop/actions/workflows/ci.yml)
4
+ [![docs](https://github.com/khiladisngh/clawtop/actions/workflows/docs.yml/badge.svg)](https://khiladisngh.github.io/clawtop/)
5
+ [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/khiladisngh/clawtop/blob/main/LICENSE)
6
+ ![python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue)
7
+
8
+ **htop for [OpenClaw](https://openclaw.ai).** See where your gateway's memory goes, per agent run; stop
9
+ the runaway ones safely; keep your sessions tidy.
10
+
11
+ <p align="center">
12
+ <a href="https://khiladisngh.github.io/clawtop/guides/interactive-top/">
13
+ <img src="https://raw.githubusercontent.com/khiladisngh/clawtop/main/docs/assets/tui/top.gif"
14
+ alt="Animated tour of clawtop top: live memory graph, sortable runs, kill confirmation, session tree and history"
15
+ width="860">
16
+ </a>
17
+ <br>
18
+ <sub><code>clawtop top</code> on sample data (kills simulated). Also:
19
+ <a href="https://khiladisngh.github.io/clawtop/getting-started/walkthrough/">a 1:43 video walkthrough</a>
20
+ of the command-line tools.</sub>
21
+ </p>
22
+
23
+ **Documentation: <https://khiladisngh.github.io/clawtop/>**
24
+
25
+ ## Why
26
+
27
+ Many OpenClaw runtimes (CLI backends such as Claude CLI or Gemini CLI, and ACP harnesses) start a
28
+ separate process for every agent run, plus the MCP servers and helpers that run uses. In the author's
29
+ setup each such stack is roughly 0.5 to 0.7 GB. A burst of runs, or a few that hang on a tool call, can
30
+ push the gateway past the VM's RAM; the event loop then stalls in swap and restarts fail. clawtop makes
31
+ that visible and fixable in one command. It is not tied to one runtime: runs are recognised by structure,
32
+ not by program name.
33
+
34
+ - **Memory per run**, measured so the numbers add up to the gateway's cgroup total.
35
+ - **Real idleness** where the runtime exposes it (Claude Code's transcript today), so a busy long-lived
36
+ run is not flagged and a stuck one is. Where it doesn't, idle time is shown as `-`, never guessed.
37
+ - **Safe kills.** Only processes the gateway spawned can be selected, whole stacks die together (SIGTERM,
38
+ then SIGKILL), and PID reuse is guarded.
39
+ - **Sessions** through the supported `openclaw sessions` CLI: list, tree (subagents under their parent,
40
+ with titles), archive, prune.
41
+ - **History**: a per-minute sampler and `clawtop history` to see what a spike looked like.
42
+ - **Works from Windows**: it forwards into your WSL distro.
43
+
44
+ ## Install
45
+
46
+ On the Linux or WSL machine that runs the gateway (needs `uv` and Python 3.11+):
47
+
48
+ ```sh
49
+ uv tool install git+https://github.com/khiladisngh/clawtop
50
+ clawtop
51
+ clawtop sampler install # optional: per-minute memory history via a systemd user timer
52
+ ```
53
+
54
+ On a Windows host, install it there too; every command is forwarded into WSL
55
+ (your default WSL distro and user; override with `CLAWTOP_WSL_DISTRO` and `CLAWTOP_WSL_USER`).
56
+ See [Install](https://khiladisngh.github.io/clawtop/getting-started/install/).
57
+
58
+ ## Usage
59
+
60
+ | Command | What it does |
61
+ |---|---|
62
+ | `clawtop` / `status` | VM and gateway memory plus every agent run stack. `--json` for scripts. |
63
+ | `clawtop top` | Interactive htop-style screen: live memory graph, sortable runs, kill, session tree, history. |
64
+ | `clawtop kill` | Interactive picker: choose rows by number, `stale` or `all`. |
65
+ | `clawtop kill PID...` | Kill specific stacks by leader PID. |
66
+ | `clawtop kill --idle 30` | Kill runs with no transcript activity for 30 minutes. |
67
+ | `clawtop kill --older-than 120` | Kill runs older than 2 hours. |
68
+ | `clawtop kill --orphans` | Kill gateway-spawned stacks whose parent is gone. |
69
+ | `clawtop history --last 6h` | Memory sparkline, the peak, and the stacks alive at the peak. |
70
+ | `clawtop sessions list [--titles]` | Open sessions, longest idle first. |
71
+ | `clawtop sessions tree` | Sessions per agent, subagents nested under their parent. |
72
+ | `clawtop sessions archive KEY...` | Archive specific sessions. |
73
+ | `clawtop sessions prune` | Archive open **subagent** sessions idle for 6h (`--idle-hours`, `--kind`, `--agent`). |
74
+ | `clawtop sampler install\|uninstall` | Manage the per-minute sampler timer. |
75
+
76
+ `kill` and `sessions archive|prune` ask for confirmation; `--yes` skips it and `--dry-run` previews.
77
+ `prune` only touches subagent sessions unless you pass `--kind`, because channel and main sessions hold
78
+ conversation context. Full options: [CLI reference](https://khiladisngh.github.io/clawtop/reference/cli/).
79
+
80
+ ## Try it without a gateway
81
+
82
+ `scripts/demo.py` runs the real CLI against made-up sample data (the video above uses it); `kill` and
83
+ `archive` are simulated:
84
+
85
+ ```sh
86
+ git clone https://github.com/khiladisngh/clawtop && cd clawtop && uv sync
87
+ uv run python scripts/demo.py sessions tree
88
+ CLAWTOP_DEMO_ANSWERS="stale;y" uv run python scripts/demo.py kill
89
+ ```
90
+
91
+ ## Keep the gateway from running out of memory
92
+
93
+ clawtop shows problems; systemd limits and a concurrency cap stop them taking the VM down. See
94
+ [Harden the gateway](https://khiladisngh.github.io/clawtop/guides/harden-the-gateway/).
95
+
96
+ ## Limits
97
+
98
+ - Linux only (reads `/proc` and cgroup v2); on Windows it needs WSL.
99
+ - It looks for the systemd **user** unit `openclaw-gateway`.
100
+ - **Runtimes that run inside the gateway** (`openclaw`, `codex`, `copilot`, `muse`) have no process per
101
+ run, so there is no stack to list; their memory is part of the gateway's "main".
102
+ - **Verified on Claude CLI only.** Other process-per-run runtimes (Gemini CLI, ACP harnesses) are
103
+ recognised by the same structural rules, but I have not seen them on a real gateway. Please report
104
+ what you see. See [Concepts](https://khiladisngh.github.io/clawtop/concepts/).
105
+ - A run stack cannot be mapped to an OpenClaw session key (the gateway does not expose it), so clawtop
106
+ shows the runtime and agent instead of guessing.
107
+ - Runs are found by agent workspace (from your OpenClaw config), so the config must declare them.
108
+
109
+ ## Development
110
+
111
+ ```sh
112
+ uv sync
113
+ uv run ruff check . && uv run ruff format --check .
114
+ uv run pyright
115
+ uv run pytest --cov
116
+ uv run zensical serve # docs at http://localhost:8000
117
+ ```
118
+
119
+ The `/proc` parser tests build a fake `/proc` tree and need Linux; they are skipped on Windows and run in
120
+ CI. See [CONTRIBUTING.md](https://github.com/khiladisngh/clawtop/blob/main/CONTRIBUTING.md).
121
+
122
+ ## License
123
+
124
+ MIT
@@ -0,0 +1,88 @@
1
+ [project]
2
+ name = "clawtop"
3
+ version = "0.4.0"
4
+ description = "htop for OpenClaw: see gateway memory per agent run, kill runaway runs, and manage open sessions."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ keywords = [
9
+ "openclaw",
10
+ "monitoring",
11
+ "memory",
12
+ "wsl",
13
+ "cli",
14
+ "typer",
15
+ ]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Environment :: Console",
19
+ "Intended Audience :: Developers",
20
+ "Operating System :: POSIX :: Linux",
21
+ "Operating System :: Microsoft :: Windows",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Topic :: System :: Monitoring",
27
+ ]
28
+ requires-python = ">=3.11"
29
+ dependencies = [
30
+ "typer>=0.15",
31
+ "rich>=13",
32
+ "textual>=8.2.8",
33
+ ]
34
+
35
+ [[project.authors]]
36
+ name = "Gishant Singh"
37
+ email = "khiladisngh@hotmail.com"
38
+
39
+ [project.urls]
40
+ Homepage = "https://github.com/khiladisngh/clawtop"
41
+ Issues = "https://github.com/khiladisngh/clawtop/issues"
42
+ Documentation = "https://khiladisngh.github.io/clawtop/"
43
+ Changelog = "https://github.com/khiladisngh/clawtop/blob/main/CHANGELOG.md"
44
+
45
+ [project.scripts]
46
+ clawtop = "clawtop.cli:main"
47
+
48
+ [build-system]
49
+ requires = ["uv_build>=0.13.0,<0.14.0"]
50
+ build-backend = "uv_build"
51
+
52
+ [dependency-groups]
53
+ dev = [
54
+ "pytest>=8",
55
+ "pytest-cov>=5",
56
+ "ruff>=0.8",
57
+ "pyright>=1.1.390",
58
+ "zensical>=0.0.71",
59
+ ]
60
+
61
+ [tool.ruff]
62
+ line-length = 120
63
+ target-version = "py311"
64
+
65
+ [tool.ruff.lint]
66
+ select = [
67
+ "E",
68
+ "F",
69
+ "I",
70
+ "UP",
71
+ "B",
72
+ "SIM",
73
+ "RUF",
74
+ ]
75
+
76
+ [tool.pyright]
77
+ include = ["src"]
78
+ typeCheckingMode = "strict"
79
+ pythonVersion = "3.11"
80
+ pythonPlatform = "Linux"
81
+
82
+ [tool.pytest.ini_options]
83
+ testpaths = ["tests"]
84
+ addopts = "-q"
85
+
86
+ [tool.coverage.run]
87
+ source = ["clawtop"]
88
+ omit = ["*/__main__.py"]
@@ -0,0 +1,70 @@
1
+ [project]
2
+ name = "clawtop"
3
+ version = "0.4.0"
4
+ description = "htop for OpenClaw: see gateway memory per agent run, kill runaway runs, and manage open sessions."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ authors = [{ name = "Gishant Singh", email = "khiladisngh@hotmail.com" }]
9
+ keywords = ["openclaw", "monitoring", "memory", "wsl", "cli", "typer"]
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Environment :: Console",
13
+ "Intended Audience :: Developers",
14
+ "Operating System :: POSIX :: Linux",
15
+ "Operating System :: Microsoft :: Windows",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Topic :: System :: Monitoring",
21
+ ]
22
+ requires-python = ">=3.11"
23
+ dependencies = [
24
+ "typer>=0.15",
25
+ "rich>=13",
26
+ "textual>=8.2.8",
27
+ ]
28
+
29
+ [project.urls]
30
+ Homepage = "https://github.com/khiladisngh/clawtop"
31
+ Issues = "https://github.com/khiladisngh/clawtop/issues"
32
+ Documentation = "https://khiladisngh.github.io/clawtop/"
33
+ Changelog = "https://github.com/khiladisngh/clawtop/blob/main/CHANGELOG.md"
34
+
35
+ [project.scripts]
36
+ clawtop = "clawtop.cli:main"
37
+
38
+ [build-system]
39
+ requires = ["uv_build>=0.13.0,<0.14.0"]
40
+ build-backend = "uv_build"
41
+
42
+ [dependency-groups]
43
+ dev = [
44
+ "pytest>=8",
45
+ "pytest-cov>=5",
46
+ "ruff>=0.8",
47
+ "pyright>=1.1.390",
48
+ "zensical>=0.0.71",
49
+ ]
50
+
51
+ [tool.ruff]
52
+ line-length = 120
53
+ target-version = "py311"
54
+
55
+ [tool.ruff.lint]
56
+ select = ["E", "F", "I", "UP", "B", "SIM", "RUF"]
57
+
58
+ [tool.pyright]
59
+ include = ["src"]
60
+ typeCheckingMode = "strict"
61
+ pythonVersion = "3.11"
62
+ pythonPlatform = "Linux"
63
+
64
+ [tool.pytest.ini_options]
65
+ testpaths = ["tests"]
66
+ addopts = "-q"
67
+
68
+ [tool.coverage.run]
69
+ source = ["clawtop"]
70
+ omit = ["*/__main__.py"]
@@ -0,0 +1 @@
1
+ """clawtop: htop for OpenClaw."""
@@ -0,0 +1,3 @@
1
+ from clawtop.cli import main
2
+
3
+ main()