clawmonitor 0.1.3__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 (34) hide show
  1. clawmonitor-0.1.3/LICENSE +22 -0
  2. clawmonitor-0.1.3/PKG-INFO +131 -0
  3. clawmonitor-0.1.3/README.md +105 -0
  4. clawmonitor-0.1.3/pyproject.toml +42 -0
  5. clawmonitor-0.1.3/setup.cfg +4 -0
  6. clawmonitor-0.1.3/src/clawmonitor/__init__.py +13 -0
  7. clawmonitor-0.1.3/src/clawmonitor/__main__.py +5 -0
  8. clawmonitor-0.1.3/src/clawmonitor/actions.py +43 -0
  9. clawmonitor-0.1.3/src/clawmonitor/channels_status.py +26 -0
  10. clawmonitor-0.1.3/src/clawmonitor/cli.py +359 -0
  11. clawmonitor-0.1.3/src/clawmonitor/config.py +95 -0
  12. clawmonitor-0.1.3/src/clawmonitor/delivery_queue.py +57 -0
  13. clawmonitor-0.1.3/src/clawmonitor/diagnostics.py +246 -0
  14. clawmonitor-0.1.3/src/clawmonitor/eventlog.py +45 -0
  15. clawmonitor-0.1.3/src/clawmonitor/gateway_logs.py +149 -0
  16. clawmonitor-0.1.3/src/clawmonitor/init_wizard.py +199 -0
  17. clawmonitor-0.1.3/src/clawmonitor/locks.py +49 -0
  18. clawmonitor-0.1.3/src/clawmonitor/openclaw_cli.py +58 -0
  19. clawmonitor-0.1.3/src/clawmonitor/openclaw_config.py +60 -0
  20. clawmonitor-0.1.3/src/clawmonitor/push_notify.py +61 -0
  21. clawmonitor-0.1.3/src/clawmonitor/redact.py +43 -0
  22. clawmonitor-0.1.3/src/clawmonitor/reports.py +171 -0
  23. clawmonitor-0.1.3/src/clawmonitor/session_store.py +95 -0
  24. clawmonitor-0.1.3/src/clawmonitor/state.py +111 -0
  25. clawmonitor-0.1.3/src/clawmonitor/status_cli.py +267 -0
  26. clawmonitor-0.1.3/src/clawmonitor/thread_bindings.py +68 -0
  27. clawmonitor-0.1.3/src/clawmonitor/transcript_tail.py +276 -0
  28. clawmonitor-0.1.3/src/clawmonitor/tui.py +1039 -0
  29. clawmonitor-0.1.3/src/clawmonitor.egg-info/PKG-INFO +131 -0
  30. clawmonitor-0.1.3/src/clawmonitor.egg-info/SOURCES.txt +32 -0
  31. clawmonitor-0.1.3/src/clawmonitor.egg-info/dependency_links.txt +1 -0
  32. clawmonitor-0.1.3/src/clawmonitor.egg-info/entry_points.txt +2 -0
  33. clawmonitor-0.1.3/src/clawmonitor.egg-info/requires.txt +3 -0
  34. clawmonitor-0.1.3/src/clawmonitor.egg-info/top_level.txt +1 -0
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
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.
22
+
@@ -0,0 +1,131 @@
1
+ Metadata-Version: 2.4
2
+ Name: clawmonitor
3
+ Version: 0.1.3
4
+ Summary: Real-time OpenClaw session monitor (TUI) with Gateway log correlation and manual progress nudges.
5
+ Author: OpenClaw community
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/openclawq/clawmonitor
8
+ Project-URL: Repository, https://github.com/openclawq/clawmonitor
9
+ Project-URL: Issues, https://github.com/openclawq/clawmonitor/issues
10
+ Keywords: openclaw,monitoring,tui,observability,feishu,telegram
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: System :: Monitoring
20
+ Classifier: Topic :: Utilities
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: tomli>=2.0.1; python_version < "3.11"
25
+ Dynamic: license-file
26
+
27
+ # ClawMonitor
28
+
29
+ English | [简体中文](README.zh-CN.md)
30
+
31
+ Real-time **OpenClaw** session monitor with:
32
+
33
+ - Per-session last inbound **user** message + last outbound **assistant** message (preview + timestamp)
34
+ - Work state: WORKING / FINISHED / INTERRUPTED / NO_MESSAGE (+ NO_FEEDBACK alert)
35
+ - Long-run visibility via `*.jsonl.lock` (works even if Gateway is down)
36
+ - Optional Gateway log tail + channel runtime snapshot correlation (Feishu/Telegram-focused rules)
37
+ - Full-screen TUI with manual “nudge” (send a progress request via `chat.send`)
38
+
39
+ ## Install (editable)
40
+
41
+ ```bash
42
+ cd ~/program/clawmonitor
43
+ python3 -m pip install -e .
44
+ ```
45
+
46
+ ## Install (PyPI)
47
+
48
+ Once published to PyPI, you’ll be able to install via:
49
+
50
+ ```bash
51
+ pip install clawmonitor
52
+ ```
53
+
54
+ ## Run
55
+
56
+ ```bash
57
+ clawmonitor init
58
+ clawmonitor tui
59
+ ```
60
+
61
+ Other commands:
62
+
63
+ ```bash
64
+ clawmonitor snapshot --format json
65
+ clawmonitor snapshot --format md
66
+ clawmonitor nudge --session-key 'agent:main:main' --template progress
67
+ clawmonitor nudge --session-key 'agent:main:main' --template continue
68
+ clawmonitor push --session-key 'agent:main:main' --dry-run
69
+ clawmonitor status
70
+ clawmonitor status --format json
71
+ clawmonitor status --format md
72
+ clawmonitor report --session-key 'agent:main:main' --format both
73
+ clawmonitor watch --interval 1
74
+ ```
75
+
76
+ ## Configuration
77
+
78
+ Default config path:
79
+
80
+ - `~/.config/clawmonitor/config.toml`
81
+
82
+ Example config is in `config.example.toml`.
83
+
84
+ Runtime data (NOT stored in this repo):
85
+
86
+ - Logs: `~/.local/state/clawmonitor/events.jsonl`
87
+ - Reports: `~/.local/state/clawmonitor/reports/`
88
+ - Cache: `~/.cache/clawmonitor/`
89
+
90
+ ## Keys (TUI)
91
+
92
+ - `↑/↓`: move selection
93
+ - `Enter`: nudge selected session (choose template)
94
+ - `?`: show help overlay
95
+ - `l`: toggle related logs panel
96
+ - `d`: re-run diagnosis for selected session
97
+ - `e`: export a redacted report for selected session
98
+ - `r`: force refresh
99
+ - `f`: cycle refresh interval
100
+ - `q`: quit
101
+
102
+ Rows are color-coded when your terminal supports colors (`OK` green, `RUN` cyan, `IDLE` yellow, `ALERT` red).
103
+
104
+ ## Telegram note: ACP “thread bindings”
105
+
106
+ OpenClaw can route a Telegram chat to a different session key via local *thread bindings*.
107
+ This may make it look like your “main” session stopped receiving messages.
108
+
109
+ ClawMonitor detects this and flags it:
110
+
111
+ - `BOUND_OTHER` in `clawmonitor status`
112
+ - `BIND` in the TUI list
113
+
114
+ Relevant files/settings:
115
+
116
+ - Thread bindings: `~/.openclaw/telegram/thread-bindings-default.json`
117
+ - Config toggle: `~/.openclaw/openclaw.json` → `channels.telegram.threadBindings.spawnAcpSessions`
118
+
119
+ ## First run
120
+
121
+ If no config file exists, most commands will offer to run the init wizard (interactive terminals only).
122
+
123
+ See `docs/launch-post.md` for a longer intro.
124
+
125
+ ## Notes
126
+
127
+ - ClawMonitor never prints or writes OpenClaw secrets. It avoids dumping `openclaw.json` and redacts suspicious token-like strings in logs/reports.
128
+ - If Gateway is unreachable, ClawMonitor still works in offline mode (sessions/transcripts/locks/delivery-queue) but disables log tail + nudge.
129
+ - If your terminal window is narrow, `clawmonitor tui` may hide the details panel; use `clawmonitor status` as a stable fallback.
130
+
131
+ See `CONTRIBUTORS.md` for acknowledgements.
@@ -0,0 +1,105 @@
1
+ # ClawMonitor
2
+
3
+ English | [简体中文](README.zh-CN.md)
4
+
5
+ Real-time **OpenClaw** session monitor with:
6
+
7
+ - Per-session last inbound **user** message + last outbound **assistant** message (preview + timestamp)
8
+ - Work state: WORKING / FINISHED / INTERRUPTED / NO_MESSAGE (+ NO_FEEDBACK alert)
9
+ - Long-run visibility via `*.jsonl.lock` (works even if Gateway is down)
10
+ - Optional Gateway log tail + channel runtime snapshot correlation (Feishu/Telegram-focused rules)
11
+ - Full-screen TUI with manual “nudge” (send a progress request via `chat.send`)
12
+
13
+ ## Install (editable)
14
+
15
+ ```bash
16
+ cd ~/program/clawmonitor
17
+ python3 -m pip install -e .
18
+ ```
19
+
20
+ ## Install (PyPI)
21
+
22
+ Once published to PyPI, you’ll be able to install via:
23
+
24
+ ```bash
25
+ pip install clawmonitor
26
+ ```
27
+
28
+ ## Run
29
+
30
+ ```bash
31
+ clawmonitor init
32
+ clawmonitor tui
33
+ ```
34
+
35
+ Other commands:
36
+
37
+ ```bash
38
+ clawmonitor snapshot --format json
39
+ clawmonitor snapshot --format md
40
+ clawmonitor nudge --session-key 'agent:main:main' --template progress
41
+ clawmonitor nudge --session-key 'agent:main:main' --template continue
42
+ clawmonitor push --session-key 'agent:main:main' --dry-run
43
+ clawmonitor status
44
+ clawmonitor status --format json
45
+ clawmonitor status --format md
46
+ clawmonitor report --session-key 'agent:main:main' --format both
47
+ clawmonitor watch --interval 1
48
+ ```
49
+
50
+ ## Configuration
51
+
52
+ Default config path:
53
+
54
+ - `~/.config/clawmonitor/config.toml`
55
+
56
+ Example config is in `config.example.toml`.
57
+
58
+ Runtime data (NOT stored in this repo):
59
+
60
+ - Logs: `~/.local/state/clawmonitor/events.jsonl`
61
+ - Reports: `~/.local/state/clawmonitor/reports/`
62
+ - Cache: `~/.cache/clawmonitor/`
63
+
64
+ ## Keys (TUI)
65
+
66
+ - `↑/↓`: move selection
67
+ - `Enter`: nudge selected session (choose template)
68
+ - `?`: show help overlay
69
+ - `l`: toggle related logs panel
70
+ - `d`: re-run diagnosis for selected session
71
+ - `e`: export a redacted report for selected session
72
+ - `r`: force refresh
73
+ - `f`: cycle refresh interval
74
+ - `q`: quit
75
+
76
+ Rows are color-coded when your terminal supports colors (`OK` green, `RUN` cyan, `IDLE` yellow, `ALERT` red).
77
+
78
+ ## Telegram note: ACP “thread bindings”
79
+
80
+ OpenClaw can route a Telegram chat to a different session key via local *thread bindings*.
81
+ This may make it look like your “main” session stopped receiving messages.
82
+
83
+ ClawMonitor detects this and flags it:
84
+
85
+ - `BOUND_OTHER` in `clawmonitor status`
86
+ - `BIND` in the TUI list
87
+
88
+ Relevant files/settings:
89
+
90
+ - Thread bindings: `~/.openclaw/telegram/thread-bindings-default.json`
91
+ - Config toggle: `~/.openclaw/openclaw.json` → `channels.telegram.threadBindings.spawnAcpSessions`
92
+
93
+ ## First run
94
+
95
+ If no config file exists, most commands will offer to run the init wizard (interactive terminals only).
96
+
97
+ See `docs/launch-post.md` for a longer intro.
98
+
99
+ ## Notes
100
+
101
+ - ClawMonitor never prints or writes OpenClaw secrets. It avoids dumping `openclaw.json` and redacts suspicious token-like strings in logs/reports.
102
+ - If Gateway is unreachable, ClawMonitor still works in offline mode (sessions/transcripts/locks/delivery-queue) but disables log tail + nudge.
103
+ - If your terminal window is narrow, `clawmonitor tui` may hide the details panel; use `clawmonitor status` as a stable fallback.
104
+
105
+ See `CONTRIBUTORS.md` for acknowledgements.
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "clawmonitor"
7
+ version = "0.1.3"
8
+ description = "Real-time OpenClaw session monitor (TUI) with Gateway log correlation and manual progress nudges."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ authors = [{ name = "OpenClaw community" }]
13
+ keywords = ["openclaw", "monitoring", "tui", "observability", "feishu", "telegram"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Environment :: Console",
17
+ "Intended Audience :: Developers",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3 :: Only",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Topic :: System :: Monitoring",
24
+ "Topic :: Utilities",
25
+ ]
26
+ dependencies = [
27
+ "tomli>=2.0.1; python_version < '3.11'",
28
+ ]
29
+
30
+ [project.urls]
31
+ Homepage = "https://github.com/openclawq/clawmonitor"
32
+ Repository = "https://github.com/openclawq/clawmonitor"
33
+ Issues = "https://github.com/openclawq/clawmonitor/issues"
34
+
35
+ [project.scripts]
36
+ clawmonitor = "clawmonitor.cli:main"
37
+
38
+ [tool.setuptools]
39
+ package-dir = {"" = "src"}
40
+
41
+ [tool.setuptools.packages.find]
42
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,13 @@
1
+ from __future__ import annotations
2
+
3
+ __all__ = ["__version__"]
4
+
5
+ try:
6
+ from importlib.metadata import PackageNotFoundError, version
7
+ except ImportError: # pragma: no cover
8
+ from importlib_metadata import PackageNotFoundError, version # type: ignore
9
+
10
+ try:
11
+ __version__ = version("clawmonitor")
12
+ except PackageNotFoundError: # pragma: no cover
13
+ __version__ = "0.0.0+unknown"
@@ -0,0 +1,5 @@
1
+ from .cli import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
5
+
@@ -0,0 +1,43 @@
1
+ from __future__ import annotations
2
+
3
+ import uuid
4
+ from dataclasses import dataclass
5
+ from typing import Any, Dict, Optional
6
+
7
+ from .openclaw_cli import gateway_call
8
+
9
+
10
+ TEMPLATES: Dict[str, str] = {
11
+ "progress": "请用不超过8行汇报:当前进度、下一步、预估完成时间;已完成请写 DONE;受阻请写 BLOCKED: 原因。",
12
+ "status": "只回复一个词:WORKING / DONE / BLOCKED,并补充1行原因或下一步。",
13
+ "last_action": "请列出你最近一次工具/命令执行的名称与结果摘要(最多5行)。",
14
+ "continue": "继续完成你正在做/上次未完成的任务;如果正在运行长任务也不要中断,完成后汇报 DONE,并在过程中每隔10分钟用不超过6行汇报一次进度。",
15
+ "finalize": "如果你已经完成了用户交代的任务:请输出最终总结(<=10行)+ 交付物/结果位置(路径/链接)+ 用一行写 DONE。若尚未完成:用 <=6 行汇报当前进度、下一步、预估完成时间,并用 WORKING 结尾。",
16
+ }
17
+
18
+
19
+ @dataclass(frozen=True)
20
+ class NudgeResult:
21
+ ok: bool
22
+ run_id: Optional[str]
23
+ status: Optional[str]
24
+ error: Optional[str]
25
+
26
+
27
+ def send_nudge(openclaw_bin: str, session_key: str, template_id: str, deliver: bool = True) -> NudgeResult:
28
+ msg = TEMPLATES.get(template_id)
29
+ if not msg:
30
+ return NudgeResult(ok=False, run_id=None, status=None, error=f"unknown template: {template_id}")
31
+ params: Dict[str, Any] = {
32
+ "sessionKey": session_key,
33
+ "message": msg,
34
+ "deliver": bool(deliver),
35
+ "timeoutMs": 0,
36
+ "idempotencyKey": str(uuid.uuid4()),
37
+ }
38
+ res = gateway_call(openclaw_bin, "chat.send", params=params, timeout_ms=10000)
39
+ if not res.ok or not res.data:
40
+ return NudgeResult(ok=False, run_id=None, status=None, error=f"chat.send failed (rc={res.returncode})")
41
+ run_id = res.data.get("runId") if isinstance(res.data.get("runId"), str) else None
42
+ status = res.data.get("status") if isinstance(res.data.get("status"), str) else None
43
+ return NudgeResult(ok=True, run_id=run_id, status=status, error=None)
@@ -0,0 +1,26 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Any, Dict, Optional
5
+
6
+ from .openclaw_cli import gateway_call
7
+
8
+
9
+ @dataclass(frozen=True)
10
+ class ChannelsSnapshot:
11
+ ts: Optional[int]
12
+ raw: Dict[str, Any]
13
+
14
+
15
+ def fetch_channels_status(openclaw_bin: str, probe: bool = False, timeout_ms: int = 10000) -> Optional[ChannelsSnapshot]:
16
+ params: Dict[str, Any] = {}
17
+ if probe:
18
+ params["probe"] = True
19
+ params["timeoutMs"] = timeout_ms
20
+ res = gateway_call(openclaw_bin, "channels.status", params=params, timeout_ms=timeout_ms)
21
+ if not res.ok or not res.data:
22
+ return None
23
+ data = res.data
24
+ ts = data.get("ts")
25
+ return ChannelsSnapshot(ts=int(ts) if isinstance(ts, int) else None, raw=data)
26
+