telegram-exec-notifier 0.2.0__tar.gz → 0.2.1__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.
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/PKG-INFO +1 -1
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/pyproject.toml +23 -2
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/src/telegram_exec_notifier/cli.py +5 -3
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/src/telegram_exec_notifier/notifier.py +2 -6
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/src/telegram_exec_notifier/server.py +31 -20
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/src/telegram_exec_notifier.egg-info/PKG-INFO +1 -1
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/tests/test_credentials.py +1 -1
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/README.md +0 -0
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/setup.cfg +0 -0
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/src/telegram_exec_notifier/__init__.py +0 -0
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/src/telegram_exec_notifier/credentials.py +0 -0
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/src/telegram_exec_notifier/formatting.py +0 -0
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/src/telegram_exec_notifier/permission_mcp.py +0 -0
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/src/telegram_exec_notifier.egg-info/SOURCES.txt +0 -0
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/src/telegram_exec_notifier.egg-info/dependency_links.txt +0 -0
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/src/telegram_exec_notifier.egg-info/entry_points.txt +0 -0
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/src/telegram_exec_notifier.egg-info/top_level.txt +0 -0
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/tests/test_formatting.py +0 -0
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/tests/test_permission_mcp.py +0 -0
- {telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/tests/test_server.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: telegram-exec-notifier
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Run Claude, Codex and Kiro from Telegram and get execution notifications
|
|
5
5
|
Project-URL: Homepage, https://github.com/Sette/telegram-exec-notifier
|
|
6
6
|
Project-URL: Repository, https://github.com/Sette/telegram-exec-notifier
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "telegram-exec-notifier"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.1"
|
|
8
8
|
description = "Run Claude, Codex and Kiro from Telegram and get execution notifications"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -34,7 +34,7 @@ notify-telegram = "telegram_exec_notifier.cli:main"
|
|
|
34
34
|
telegram-exec-notifier = "telegram_exec_notifier.server:main"
|
|
35
35
|
|
|
36
36
|
[dependency-groups]
|
|
37
|
-
dev = ["pytest>=8", "ruff>=0.6"]
|
|
37
|
+
dev = ["pytest>=8", "pytest-cov>=5", "ruff>=0.6", "pylint>=3.3"]
|
|
38
38
|
|
|
39
39
|
[tool.setuptools.packages.find]
|
|
40
40
|
where = ["src"]
|
|
@@ -49,3 +49,24 @@ target-version = "py310"
|
|
|
49
49
|
|
|
50
50
|
[tool.ruff.lint]
|
|
51
51
|
select = ["E", "F", "I", "B", "UP"]
|
|
52
|
+
|
|
53
|
+
[tool.pylint.main]
|
|
54
|
+
init-hook = "import sys; sys.path.append('src')"
|
|
55
|
+
recursive = true
|
|
56
|
+
|
|
57
|
+
[tool.pylint.format]
|
|
58
|
+
max-line-length = 120
|
|
59
|
+
|
|
60
|
+
[tool.pylint.design]
|
|
61
|
+
max-args = 8
|
|
62
|
+
max-positional-arguments = 8
|
|
63
|
+
max-locals = 25
|
|
64
|
+
max-statements = 60
|
|
65
|
+
min-public-methods = 0
|
|
66
|
+
|
|
67
|
+
[tool.pylint."messages control"]
|
|
68
|
+
disable = [
|
|
69
|
+
"C0114", # missing-module-docstring: module docstrings are kept where useful
|
|
70
|
+
"C0116", # missing-function-docstring: small private helpers do not need one
|
|
71
|
+
"W0718", # broad-exception-caught: the service must survive Telegram/CLI failures
|
|
72
|
+
]
|
{telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/src/telegram_exec_notifier/cli.py
RENAMED
|
@@ -21,8 +21,10 @@ def main() -> None:
|
|
|
21
21
|
|
|
22
22
|
notifier = TelegramNotifier()
|
|
23
23
|
if args.tool:
|
|
24
|
-
asyncio.run(
|
|
25
|
-
notifier.execution_finished(args.tool, message, success=not args.failed)
|
|
26
|
-
)
|
|
24
|
+
asyncio.run(notifier.execution_finished(args.tool, message, success=not args.failed))
|
|
27
25
|
else:
|
|
28
26
|
asyncio.run(notifier.send(message))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if __name__ == "__main__":
|
|
30
|
+
main()
|
{telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/src/telegram_exec_notifier/notifier.py
RENAMED
|
@@ -13,9 +13,7 @@ class TelegramNotifier:
|
|
|
13
13
|
"""Send messages to the local notifier service."""
|
|
14
14
|
|
|
15
15
|
def __init__(self, service_url: str | None = None) -> None:
|
|
16
|
-
self.service_url = (
|
|
17
|
-
service_url or os.getenv("TELEGRAM_NOTIFIER_URL", "http://127.0.0.1:8765")
|
|
18
|
-
).rstrip("/")
|
|
16
|
+
self.service_url = (service_url or os.getenv("TELEGRAM_NOTIFIER_URL", "http://127.0.0.1:8765")).rstrip("/")
|
|
19
17
|
|
|
20
18
|
async def send(self, message: str) -> None:
|
|
21
19
|
"""Send a plain text notification via the local service."""
|
|
@@ -36,9 +34,7 @@ class TelegramNotifier:
|
|
|
36
34
|
except (HTTPError, URLError) as exc:
|
|
37
35
|
raise RuntimeError(f"Could not send notification: {exc}") from exc
|
|
38
36
|
|
|
39
|
-
async def execution_finished(
|
|
40
|
-
self, tool: str, summary: str, *, success: bool = True
|
|
41
|
-
) -> None:
|
|
37
|
+
async def execution_finished(self, tool: str, summary: str, *, success: bool = True) -> None:
|
|
42
38
|
"""Send a consistently formatted execution result."""
|
|
43
39
|
status = "✅ concluída" if success else "❌ falhou"
|
|
44
40
|
await self.send(f"{tool}: execução {status}\n\n{summary}")
|
{telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/src/telegram_exec_notifier/server.py
RENAMED
|
@@ -122,7 +122,7 @@ def _edit_message(message_id: int, text: str) -> None:
|
|
|
122
122
|
{"chat_id": os.environ["TELEGRAM_CHAT_ID"], "message_id": message_id, "text": text[:4096]},
|
|
123
123
|
)
|
|
124
124
|
except Exception:
|
|
125
|
-
|
|
125
|
+
log.warning("telegram edit failed")
|
|
126
126
|
|
|
127
127
|
|
|
128
128
|
def _handle_callback(callback: dict, allowed_chat: str) -> None:
|
|
@@ -183,7 +183,10 @@ def send_telegram(text: str, chat_id: str | int | None = None) -> None:
|
|
|
183
183
|
|
|
184
184
|
|
|
185
185
|
class Handler(BaseHTTPRequestHandler):
|
|
186
|
-
|
|
186
|
+
"""HTTP endpoints: /notify (plain text) and /permission (tool approval)."""
|
|
187
|
+
|
|
188
|
+
def do_POST(self) -> None: # pylint: disable=invalid-name
|
|
189
|
+
"""Route POST requests (method name is fixed by http.server)."""
|
|
187
190
|
if self.path == "/permission":
|
|
188
191
|
self._permission()
|
|
189
192
|
return
|
|
@@ -325,7 +328,6 @@ def _format_sessions(sessions: list[dict], active_id: str | None) -> str:
|
|
|
325
328
|
|
|
326
329
|
|
|
327
330
|
def _handle_use(arg: str, chat_id: int) -> None:
|
|
328
|
-
global _last_listing
|
|
329
331
|
arg = arg.strip().lower()
|
|
330
332
|
if arg in {"new", "nova", "0"}:
|
|
331
333
|
with _state_lock:
|
|
@@ -362,10 +364,18 @@ def _claude_command(prompt: str, state: dict) -> tuple[list[str], str | None]:
|
|
|
362
364
|
}
|
|
363
365
|
}
|
|
364
366
|
command = [
|
|
365
|
-
"claude",
|
|
366
|
-
"
|
|
367
|
-
|
|
368
|
-
"--
|
|
367
|
+
"claude",
|
|
368
|
+
"-p",
|
|
369
|
+
prompt,
|
|
370
|
+
"--add-dir",
|
|
371
|
+
str(Path.home()),
|
|
372
|
+
"--output-format",
|
|
373
|
+
"stream-json",
|
|
374
|
+
"--verbose",
|
|
375
|
+
"--mcp-config",
|
|
376
|
+
json.dumps(mcp_config),
|
|
377
|
+
"--permission-prompt-tool",
|
|
378
|
+
PERMISSION_TOOL,
|
|
369
379
|
]
|
|
370
380
|
if state.get("id"):
|
|
371
381
|
return command + ["--resume", state["id"]], state.get("cwd")
|
|
@@ -405,18 +415,21 @@ def _reader(stream, events: queue.Queue) -> None:
|
|
|
405
415
|
events.put(None)
|
|
406
416
|
|
|
407
417
|
|
|
408
|
-
def _stream_claude(
|
|
409
|
-
command: list[str], cwd: str | None, chat_id: int, state: dict, release
|
|
410
|
-
) -> None:
|
|
418
|
+
def _stream_claude(command: list[str], cwd: str | None, chat_id: int, state: dict, release) -> None: # pylint: disable=too-many-locals,too-many-branches,too-many-statements
|
|
411
419
|
"""Run `claude -p` and relay each assistant message as it appears, with heartbeats."""
|
|
412
420
|
label = f"claude [{state['title']}]" if state.get("id") else "claude"
|
|
413
421
|
started = time.monotonic()
|
|
414
422
|
log.info("start %s cwd=%s", label, cwd)
|
|
415
423
|
stderr_file = tempfile.TemporaryFile(mode="w+", errors="replace")
|
|
416
424
|
try:
|
|
417
|
-
proc = subprocess.Popen(
|
|
418
|
-
command,
|
|
419
|
-
|
|
425
|
+
proc = subprocess.Popen( # pylint: disable=consider-using-with
|
|
426
|
+
command,
|
|
427
|
+
stdout=subprocess.PIPE,
|
|
428
|
+
stderr=stderr_file,
|
|
429
|
+
stdin=subprocess.DEVNULL,
|
|
430
|
+
env=child_env(),
|
|
431
|
+
text=True,
|
|
432
|
+
cwd=cwd,
|
|
420
433
|
)
|
|
421
434
|
except Exception as exc:
|
|
422
435
|
send_telegram(f"❌ falha ao iniciar {label}: {exc}", chat_id)
|
|
@@ -518,13 +531,12 @@ def _execute_cli(
|
|
|
518
531
|
"--skip-git-repo-check",
|
|
519
532
|
prompt,
|
|
520
533
|
],
|
|
521
|
-
"kiro": [
|
|
522
|
-
"kiro-cli", "chat", "--no-interactive", "--trust-tools=fs_read,fs_write", prompt
|
|
523
|
-
],
|
|
534
|
+
"kiro": ["kiro-cli", "chat", "--no-interactive", "--trust-tools=fs_read,fs_write", prompt],
|
|
524
535
|
}
|
|
525
536
|
try:
|
|
526
537
|
proc = subprocess.run(
|
|
527
538
|
commands[tool],
|
|
539
|
+
check=False,
|
|
528
540
|
capture_output=True,
|
|
529
541
|
env=child_env(),
|
|
530
542
|
stdin=subprocess.DEVNULL,
|
|
@@ -554,7 +566,7 @@ def _execute_cli(
|
|
|
554
566
|
send_markdown(f"**{label}** {status}\n\n{output}", chat_id)
|
|
555
567
|
except Exception:
|
|
556
568
|
# Telegram outages must not terminate the polling service.
|
|
557
|
-
|
|
569
|
+
log.warning("telegram send failed")
|
|
558
570
|
|
|
559
571
|
|
|
560
572
|
HELP_TEXT = (
|
|
@@ -567,7 +579,7 @@ HELP_TEXT = (
|
|
|
567
579
|
)
|
|
568
580
|
|
|
569
581
|
|
|
570
|
-
def _poll_commands() -> None:
|
|
582
|
+
def _poll_commands() -> None: # pylint: disable=too-many-branches
|
|
571
583
|
allowed_chat = str(os.environ["TELEGRAM_CHAT_ID"])
|
|
572
584
|
offset = 0
|
|
573
585
|
while True:
|
|
@@ -599,8 +611,7 @@ def _poll_commands() -> None:
|
|
|
599
611
|
if tool in {"start", "help"}:
|
|
600
612
|
send_telegram(HELP_TEXT, chat["id"])
|
|
601
613
|
elif tool == "sessions":
|
|
602
|
-
|
|
603
|
-
_last_listing = _list_sessions()
|
|
614
|
+
_last_listing[:] = _list_sessions()
|
|
604
615
|
with _state_lock:
|
|
605
616
|
active = _load_state().get("id")
|
|
606
617
|
send_telegram(_format_sessions(_last_listing, active), chat["id"])
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: telegram-exec-notifier
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Run Claude, Codex and Kiro from Telegram and get execution notifications
|
|
5
5
|
Project-URL: Homepage, https://github.com/Sette/telegram-exec-notifier
|
|
6
6
|
Project-URL: Repository, https://github.com/Sette/telegram-exec-notifier
|
|
@@ -4,7 +4,7 @@ from telegram_exec_notifier import credentials
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
def test_parse_handles_comments_quotes_and_blank_lines():
|
|
7
|
-
text =
|
|
7
|
+
text = '# c\n\nTELEGRAM_BOT_TOKEN="tok"\nTELEGRAM_CHAT_ID=42\nBAD LINE\n'
|
|
8
8
|
assert credentials._parse(text) == {"TELEGRAM_BOT_TOKEN": "tok", "TELEGRAM_CHAT_ID": "42"}
|
|
9
9
|
|
|
10
10
|
|
|
File without changes
|
|
File without changes
|
{telegram_exec_notifier-0.2.0 → telegram_exec_notifier-0.2.1}/src/telegram_exec_notifier/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|