kiro-telegram-bot 1.5.1 → 1.7.1

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 (53) hide show
  1. package/.env.example +30 -0
  2. package/CHANGELOG.md +409 -0
  3. package/README.md +48 -9
  4. package/package.json +5 -1
  5. package/src/acp/client.ts +109 -13
  6. package/src/app/auth-service.ts +325 -0
  7. package/src/app/settings-store.ts +7 -0
  8. package/src/app/types.ts +4 -2
  9. package/src/app/updater.ts +234 -0
  10. package/src/app/version.ts +41 -0
  11. package/src/bot/bot.ts +57 -1
  12. package/src/bot/chat-controller.ts +70 -7
  13. package/src/bot/commands.ts +4 -3
  14. package/src/bot/deps.ts +18 -0
  15. package/src/bot/handlers/auth.ts +89 -0
  16. package/src/bot/handlers/control.ts +11 -3
  17. package/src/bot/handlers/history.ts +7 -2
  18. package/src/bot/handlers/kill.ts +5 -20
  19. package/src/bot/handlers/mcp.ts +2 -1
  20. package/src/bot/handlers/menu.ts +12 -7
  21. package/src/bot/handlers/message.ts +7 -2
  22. package/src/bot/handlers/photo.ts +13 -4
  23. package/src/bot/handlers/projects.ts +119 -19
  24. package/src/bot/handlers/running.ts +98 -21
  25. package/src/bot/handlers/session-card.ts +16 -0
  26. package/src/bot/handlers/session-kill.ts +95 -0
  27. package/src/bot/handlers/sessions.ts +43 -26
  28. package/src/bot/handlers/tasks.ts +2 -1
  29. package/src/bot/handlers/usage.ts +2 -1
  30. package/src/bot/handlers/voice.ts +1 -1
  31. package/src/bot/menu/ephemeral.ts +117 -0
  32. package/src/bot/menu/status-panel.ts +3 -0
  33. package/src/bot/prompt-content.ts +6 -0
  34. package/src/bot/reauth-controller.ts +462 -0
  35. package/src/bot/session-fork.ts +35 -0
  36. package/src/bot/session-runtime.ts +265 -67
  37. package/src/config.ts +24 -0
  38. package/src/index.ts +3 -1
  39. package/src/projects/manager.ts +16 -5
  40. package/src/render/device-flow.ts +76 -0
  41. package/src/render/file-summary.ts +111 -0
  42. package/src/render/hashtags.ts +34 -0
  43. package/src/render/markdown.ts +4 -0
  44. package/src/render/progress.ts +80 -0
  45. package/src/render/tool-call.ts +97 -3
  46. package/src/service/linux.ts +2 -0
  47. package/src/service/macos.ts +10 -0
  48. package/src/service/platform.ts +5 -0
  49. package/src/service/types.ts +2 -0
  50. package/src/service/windows.ts +116 -21
  51. package/src/sessions/history.ts +45 -1
  52. package/src/sessions/process.ts +30 -0
  53. package/src/stream/streamer.ts +57 -8
package/.env.example CHANGED
@@ -61,6 +61,13 @@ AGENT_IMAGES_MAX=8
61
61
  # so the chat isn't silent during delegated/parallel work. true/false
62
62
  SHOW_SUBAGENTS=true
63
63
 
64
+ # When you control several sessions at once and switch between them, deliver a
65
+ # session's "Done" summary even while that session is in the background (you're
66
+ # viewing another one) — clearly marked "From other session" with a short
67
+ # created/edited/deleted file count. Set false to keep background sessions
68
+ # silent (their output still shows when you switch back). true/false
69
+ NOTIFY_OTHER_SESSIONS=true
70
+
64
71
  # ── MCP servers (/mcp) ───────────────────────────────────────────────────────
65
72
  # /mcp lists configured MCP servers, toggles them on/off, and runs a live
66
73
  # health-check (a real MCP `initialize` handshake) against each enabled server.
@@ -69,6 +76,15 @@ SHOW_SUBAGENTS=true
69
76
  # MCP_PROBE_TIMEOUT_MS=8000
70
77
  # MCP_PROBE_CONCURRENCY=6
71
78
 
79
+ # Auto-update (default on): once an hour, check npm for a newer version with one
80
+ # tiny request. When a newer version exists AND the bot is fully idle (no turn or
81
+ # task running, no other active Kiro session on this PC), it announces in chat,
82
+ # runs `npm install -g kiro-telegram-bot@latest`, restarts, and posts the new
83
+ # release notes (tagged #update). Only applies to a global npm install. true/false
84
+ AUTO_UPDATE=true
85
+ # How often to check for updates, in ms (default 3600000 = 1h).
86
+ # UPDATE_CHECK_MS=3600000
87
+
72
88
  # Log level: debug | info | warn | error
73
89
  LOG_LEVEL=info
74
90
 
@@ -90,6 +106,20 @@ QUIET_NOTIFICATIONS=true
90
106
  # real error is shown on every attempt; a summary is shown after the last. 0 = off.
91
107
  # PROMPT_RETRY_ATTEMPTS=5
92
108
 
109
+ # When the retries above are exhausted on a transient error (and nothing was
110
+ # streamed yet), automatically "logically fork" the session: open a fresh
111
+ # continuation in the same project primed with the recent transcript, drop the
112
+ # stuck/throttled/exhausted session, and retry the same message once. true = on.
113
+ # AUTO_FORK_ON_ERROR=true
114
+
115
+ # When a prompt fails transiently AND this session's last-known context usage is
116
+ # at/above this percentage, skip the retry backoff and fork immediately — a
117
+ # context-exhausted session won't recover by retrying the same oversized prompt
118
+ # (throttling on a near-full session shows up as "-32603 … throttled"). Forking
119
+ # compacts it into a fresh continuation primed with the recent transcript.
120
+ # Requires AUTO_FORK_ON_ERROR. 0 disables this %-trigger. Default 85.
121
+ # AUTO_FORK_CONTEXT_PCT=85
122
+
93
123
  # Where to write the log file. Defaults to <project>/logs/kiro-telegram-bot.log
94
124
  # LOG_DIR=
95
125
  # LOG_FILE=
package/CHANGELOG.md ADDED
@@ -0,0 +1,409 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format is based on
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
5
+ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ The latest section is published verbatim as the GitHub Release notes by
8
+ `.github/workflows/release.yml` when a `vX.Y.Z` tag is pushed.
9
+
10
+ ## [1.7.1] - 2026-06-24
11
+
12
+ The **"sign in your way"** release — `/reauth` now lets you pick how you log in
13
+ (Builder ID, Google, GitHub or IAM Identity Center) on one tidy status card, and
14
+ the live task-progress bar climbs steadily instead of appearing only at the end.
15
+
16
+ ### Added
17
+
18
+ - **🔐 `/reauth` login-method picker.** Re-authentication now opens with a
19
+ **picker** — **Builder ID** (free), **Google**, **GitHub**, or **IAM Identity
20
+ Center** (Pro) — driven on a **single, self-animated status message** with
21
+ inline **Cancel · Retry · Change method · Restart agent** controls, so the chat
22
+ no longer fills with raw spinner frames. **IAM Identity Center** sign-in is now
23
+ fully supported: the bot asks for your **start URL + region** and drives the
24
+ CLI's interactive prompts inside a pseudo-terminal (optional
25
+ `@homebridge/node-pty-prebuilt-multiarch` dependency; a clear message tells you
26
+ to run `npm install` if it's missing). The device-verification URL + code still
27
+ stream to the chat for every method. Power users can skip the picker by passing
28
+ flags directly, e.g. `/reauth --license pro --identity-provider <url> --region <region>`.
29
+
30
+ ### Changed
31
+
32
+ - **📈 Stricter, steadier task-progress reporting.** The agent instruction behind
33
+ the `{progress: N%}` marker is now far more rigorous: a marker is required on
34
+ **every** message (not only the last), the number must be **computed from real
35
+ step completion** and is **monotonic** (never decreases within a task), and
36
+ **100 %** is reserved for work that is fully complete *and verified*. The bar
37
+ now advances in realistic increments instead of jumping to a value at the very
38
+ end.
39
+
40
+ ### Fixed
41
+
42
+ - **🔁 `/reauth` agent-restart race** (`agent restart failed: kiro-cli acp exited
43
+ (code null)`). Logging out and restarting could let the **old** agent process's
44
+ exit fail the **new** connection's `initialize` and even trigger a competing
45
+ auto-restart. The ACP client now **fully tears down** the previous process
46
+ (ignoring the exit of a process it has already replaced) **before** spawning a
47
+ fresh one, and `/reauth` takes the agent down and **waits** before logging out —
48
+ so a deliberate restart is clean and the new identity sticks.
49
+ - **🪪 Stale identity after re-login.** On logout the bot now also **clears Kiro's
50
+ cached auth token** (`~/.aws/sso/cache/kiro-auth-token.json`), so the next login
51
+ performs a genuine device-flow authentication instead of silently reusing the
52
+ previous account's refreshable token.
53
+
54
+ ## [1.7.0] - 2026-06-23
55
+
56
+ The **"take control"** release — stop a runaway session by PID, re-authenticate
57
+ Kiro from your phone, watch a live task-progress bar, and install on Windows
58
+ without admin.
59
+
60
+ ### Added
61
+
62
+ - **🛑 Kill a session / PID from its card (`/sessions`, `/active`).** Every
63
+ **live** session card now has a **`🛑 Kill · pid N`** button that terminates
64
+ that session's process — and its whole child tree on Windows (`taskkill /T`).
65
+ It's guarded by an inline **confirm** (Kill / Cancel) since it's destructive,
66
+ the bot's **own** agent process is never offered (killing it would take the
67
+ bot down), and the session state is re-read at every step so a session that
68
+ already stopped reports "no longer running" instead of a phantom kill. The
69
+ existing `/killall` (stop every active session at once) is unchanged and now
70
+ shares the same kill logic.
71
+ - **🔐 Re-authenticate Kiro from Telegram (`/reauth`).** Logs out
72
+ (`kiro-cli logout`) and starts a fresh **device-flow** login
73
+ (`kiro-cli login --use-device-flow`) — the verification URL + code are
74
+ **streamed into the chat** so you complete it on your own device — then
75
+ **restarts the agent** so it picks up the new credentials. Refused while a
76
+ turn is in flight (logging out would break it) and serialised so two runs
77
+ can't overlap. Pass-through flags are supported, e.g.
78
+ `/reauth --license free` or `/reauth --license pro --region <r> --identity-provider <url>`.
79
+ - **📈 Live task-progress bar (`SHOW_PROGRESS`, on by default).** The agent is
80
+ asked to end each message with a `{progress: N%}` marker; the bot **parses and
81
+ hides** it and renders a **green 0–100 % loading bar** (`🟩🟩🟩⬜⬜⬜ 50%`,
82
+ all-green ✅ at 100 %) at the bottom of the **live message**, in the pinned
83
+ **status panel**, and on **`/running` and `/sessions` cards** — so you can see
84
+ how far along the current task is. Markers (and the instruction) are also
85
+ stripped from history, unread replays, previews and fork-priming, so the raw
86
+ plumbing never shows. Disable with `SHOW_PROGRESS=false`.
87
+ - **🔀 "Switch to this session" on background pings.** A **`📨 From other
88
+ session`** Done/error notification now carries a **🔀 Switch to this session**
89
+ button that brings that session to the foreground in one tap.
90
+
91
+ ### Changed
92
+
93
+ - **🪟 Windows install no longer needs admin.** `kiro-tg install` used to fail
94
+ with **`schtasks create failed: ERROR: Access is denied`** for a normal user,
95
+ because registering a **logon-triggered** Scheduled Task is a privileged
96
+ operation. The installer now falls back to a hidden per-user **Startup-folder**
97
+ launcher (runs at logon, **no elevation**) when the task can't be created; an
98
+ **elevated** run still uses the nicer hidden Scheduled Task. `install`,
99
+ `start`, `stop`, `status` and `uninstall` understand both mechanisms, and a
100
+ pre-launch running-check prevents a **double-launch** (two pollers on one bot
101
+ token would otherwise trigger Telegram 409 Conflict).
102
+ - **🔕 No interim "Done" ping from a busy background session.** A background
103
+ ("other session") turn that still has **queued follow-ups** no longer pings an
104
+ intermediate "Done" — only the final, queue-empty turn announces completion,
105
+ so a session working through a queue doesn't spam you between steps.
106
+
107
+ ## [1.6.0] - 2026-06-23
108
+
109
+ The **"always-on & self-healing"** release — the bot keeps itself up to date,
110
+ recovers context-full sessions on its own, threads every reply to your prompt,
111
+ and keeps the chat tidy while you drive several sessions at once.
112
+
113
+ ### Added
114
+
115
+ - **🔄 Auto-update (`AUTO_UPDATE`, on by default).** Once an hour the bot makes
116
+ one tiny npm request for the latest version. When a newer one exists **and the
117
+ bot is fully idle** — no chat turn or scheduled task running, and no other
118
+ active Kiro session on the PC — it announces in chat, runs
119
+ `npm install -g kiro-telegram-bot@latest`, restarts, and posts the new
120
+ release's features/fixes **tagged `#update`** so every upgrade is easy to find.
121
+ It never interrupts work, and only acts on a global npm install (a source
122
+ checkout is left to `git`). Tunable via `UPDATE_CHECK_MS`.
123
+ - **🏷 Threaded replies + searchable hashtags.** **Every** message of a turn —
124
+ each response bubble, tool call, the retry/fork notices and the Done line — is
125
+ now sent as a **reply to your prompt** (not just the first one), so the whole
126
+ turn is visually threaded to what you asked (your prompt is left untouched).
127
+ **Every message bubble**, including the live thinking/streaming one, ends with
128
+ `#proj_… #sess_…`, so tapping a tag pulls up every message for that project or
129
+ session. (Model and reasoning tags were dropped — they were noisy and rarely
130
+ useful.) Works for text, voice and photo prompts.
131
+ - **🔁 Instant fork on a context-full session (`AUTO_FORK_CONTEXT_PCT`, default
132
+ 85).** Sending to a session whose context is exhausted used to fail with
133
+ `-32603 … The request was throttled by the service` and then burn the whole
134
+ retry backoff (6s → 12s → 24s → 48s → 60s ≈ 2½ min) before recovering — because
135
+ retrying the same oversized prompt can't succeed. Now, when a prompt fails
136
+ transiently **and** the session's last-known context usage is at/above
137
+ `AUTO_FORK_CONTEXT_PCT` (or the error explicitly names a context-window
138
+ overflow), the bot **skips the retries and forks immediately**: it compacts the
139
+ conversation into a fresh continuation primed with the recent transcript and
140
+ retries your message once. Requires `AUTO_FORK_ON_ERROR`; set the % to `0` to
141
+ disable the early trigger and keep the old retry-then-fork behavior.
142
+ - **🗂 Open any folder / safer project creation (`/projects`).** `/projects <path>`
143
+ now opens a session in **any existing folder** — `C:\work\app`, `/home/me/app`,
144
+ `~/app`, even outside your `PROJECT_ROOTS` — and **errors if the path doesn't
145
+ exist** (it's never created). `/projects new <name>` now **errors if the
146
+ project already exists** instead of silently reusing it; otherwise it creates
147
+ the folder and starts a session there. `/project` works as an alias.
148
+
149
+ ### Changed
150
+
151
+ - **📄 Paginated `/projects` and `/sessions` (10 per page).** Long lists no longer
152
+ flood the chat — the project picker pages in place with **◀ Prev / Next ▶** and
153
+ a `page x/y` indicator, and session cards are shown a page at a time with the
154
+ same nav. Selecting an item still works across pages (absolute indexing).
155
+
156
+ - **✅ "Done" summaries from other running sessions.** When you drive several
157
+ sessions at once and switch between them, a background session that finishes
158
+ now pings you — clearly marked **`📨 From other session [project · id]`** with
159
+ a **short** file count (`📝 +2 created · ~3 edited · −1 deleted`, or
160
+ `📄 No files modified`). The session you're actively viewing still gets the
161
+ full completion message with the list of changed paths. Toggle with the new
162
+ **`NOTIFY_OTHER_SESSIONS`** env var (default `true`); set it `false` to keep
163
+ background sessions silent (their output still shows when you switch back).
164
+ File operations are tracked for background turns too, so the count is accurate
165
+ regardless of which session you were viewing. **Switching (back) into a
166
+ session also replays its last Done + file summary** at the end of the catch-up
167
+ view (so you see how it ended), and the completion line is now more compact
168
+ and professional — no `end_turn`/`Files:` noise, with project-relative paths.
169
+ - **🏷 Clearer skill & MCP tool lines.** Loading a skill now shows
170
+ **`📚 Loaded skill: <name>`** instead of a cryptic `SKILL.md:1` read line, and
171
+ MCP/extension tool calls render as **`🧩 Call MCP <server>: <method>`** (or
172
+ `🧩 Call MCP: <tool>` when the call carries no server name). Built-in
173
+ file/shell tools are never mislabelled.
174
+ - **📁 Projects sorted by most-recently-used.** The `/projects` picker now lists
175
+ folders **freshest first** — ranked by the latest of the directory's modified
176
+ time and the newest Kiro session opened in it — so the project you were just
177
+ working in is at the top instead of a fixed alphabetical order.
178
+ - **🧭 Redesigned `/running` — one card per session.** Instead of a cramped
179
+ combined list, each controlled session is now its own **card** with
180
+ **🔀 Switch · 📜 History · ✖ Close** buttons, showing its project, status, how
181
+ long ago it was last active, unread count, and a short preview of its first
182
+ prompt (reasoning directive stripped) — so you can tell sessions apart and act
183
+ on each one directly. The foreground session shows ▶️ Current instead of Switch.
184
+ - **🧹 Self-cleaning navigation — a tidy history.** Menus, session/project
185
+ cards, pickers and submenus are now **transient**: opening a new surface (or
186
+ acting on one) removes the previous one, and your command / menu-button
187
+ messages are deleted after they're handled. Boundary markers you actually want
188
+ to keep — **🔀 Switched / ✨ New session / 📁 Now working in…**, agent output,
189
+ Done summaries and the pinned status panel — always remain, so the chat reads
190
+ as a clean timeline of what happened, not a pile of menus.
191
+
192
+ ### Fixed
193
+
194
+ - **👯 Duplicate session cards in `/running`.** Tapping a session twice (or in
195
+ quick succession) could create **two runtimes for the same session** — the
196
+ add-session paths checked "already controlled?" and then `await`ed before
197
+ reserving the runtime, so concurrent taps both passed the check. The runtime
198
+ is now reserved synchronously after the check; restores and persistence dedupe
199
+ by session id; and `/running` prunes any existing duplicate, so the list
200
+ self-heals.
201
+ - **🔣 Stray “`” in streamed messages.** An unbalanced/partial code fence in an
202
+ agent message could leave an orphan lone-backtick line that rendered as a
203
+ broken-looking single backtick. Such orphan ` / `` lines are now dropped (real
204
+ triple-backtick fences and inline `code` are untouched).
205
+ - **⚡ `/btw` now runs as soon as possible.** Previously `/btw <text>` only ever
206
+ parked the message in the queue — so when the bot was **idle** it sat there
207
+ doing nothing until `/flush` or another message. It now runs **immediately
208
+ when idle**, and when a turn is in flight it's queued and runs **automatically
209
+ the moment that turn finishes** (an in-flight agent turn can't be interrupted).
210
+
211
+ ## [1.5.1] - 2026-06-22
212
+
213
+ ### Added
214
+
215
+ - **📦 Install from npm** — the bot is now a published package with a global
216
+ CLI: `npm install -g kiro-telegram-bot` gives you the **`kiro-tg`** command
217
+ (alias `kiro-telegram-bot`). Multiple startup options: `kiro-tg setup`
218
+ (writes `.env` + auto-detects `kiro-cli`), `kiro-tg run` (foreground), and the
219
+ full 24/7 **service** controls — `install · status · logs · stop · restart ·
220
+ uninstall` — auto-detected per platform. Each instance keeps its
221
+ `.env`/`logs/`/`data/` in the **folder you run it from** (resolved from the
222
+ `--instance` the service passes, the launcher's working dir, or the cwd), so a
223
+ global install never writes into `node_modules`. Cloned/zip checkouts behave
224
+ exactly as before. `tsx` moved to runtime deps (still no build step). npm is
225
+ now the **primary** install option in [docs/INSTALL.md](docs/INSTALL.md).
226
+
227
+ ### Fixed
228
+
229
+ - **🧵 Long messages split by Telegram are now stitched back together** —
230
+ Telegram caps a message at 4096 characters, so a long paste arrives as several
231
+ back-to-back messages. The bot used to treat each part as its own prompt —
232
+ spamming **“Queued (position 1…4)”** and even replying **“Unknown command”**
233
+ when a split landed on a line starting with `/`. Rapid consecutive text
234
+ messages are now **coalesced within a short window into a single prompt** (one
235
+ submission, one confirmation, in order). Tunable via `MESSAGE_BATCH_MS`
236
+ (default `800`; `0` disables). A genuine lone `/typo` still gets the friendly
237
+ “Unknown command” hint, and a failed submit now reports an error instead of
238
+ silently vanishing.
239
+
240
+ ## [1.5.0] - 2026-06-22
241
+
242
+ The **"mission control"** release — manage the agent's MCP servers and watch
243
+ its subagents from Telegram, with quieter notifications and sturdier sessions.
244
+
245
+ ### Added
246
+
247
+ - **🧩 MCP control (`/mcp`)** — inspect and manage the agent's MCP servers from
248
+ Telegram. Lists every configured server with its **enabled/disabled** state,
249
+ transport (stdio/http) and scope (global/workspace); a **🧪 Health-check**
250
+ runs a real MCP `initialize` handshake against each enabled server and reports
251
+ which **connected** and which **failed (and why)** — connection refused,
252
+ timeout, HTTP status, bad transport, etc. **🔧 Enable/Disable** toggles a
253
+ server's `disabled` flag in its `mcp.json` (other fields preserved) and a
254
+ **🔄 Restart agent** button applies the change immediately. Tunable via
255
+ `MCP_PROBE_TIMEOUT_MS` / `MCP_PROBE_CONCURRENCY`.
256
+ - **👥 Subagent visibility** — when the main agent delegates to subagents
257
+ ("crew") and goes quiet while waiting on them, the chat now **shows each
258
+ subagent starting, working and finishing** (via Kiro's
259
+ `_kiro.dev/subagent/list_update`), and the pinned status panel + `/status`
260
+ show a live `🤖 N running · M pending` summary. No more wondering why the
261
+ agent "isn't responding" mid-delegation. Toggle with `SHOW_SUBAGENTS`.
262
+ - **🔐 Subagent permission routing** — when permission delegation is active
263
+ (non-trust-all mode), a permission request raised by a **subagent** is now
264
+ routed to its **parent chat** and clearly labelled (`Subagent "X" needs
265
+ approval…`), instead of being auto-decided as unattended.
266
+ - **🔕 Quiet notifications (on by default)** — the bot now sends messages
267
+ **silently** (no notification sound) so streaming output and tool/status
268
+ chatter no longer buzz your phone. Only messages that **finish a turn**
269
+ (✅ Done / ⏹ Stopped / ❌ Error), **scheduled-task results**, and **permission
270
+ prompts** ring. Toggle with `QUIET_NOTIFICATIONS` (default `true`).
271
+ - **🔐 Session-aware permission prompts** — when a permission request belongs to
272
+ a *background* session, the prompt names it ("Session X needs approval…") and
273
+ adds a **🔀 Switch to it** button next to Allow/Deny (which approve in place,
274
+ without switching). Permission prompts always ring, even in quiet mode.
275
+
276
+ ### Fixed
277
+
278
+ - **🧭 Session-switch project mismatch** — after switching between controlled
279
+ sessions in different projects, the pinned status panel could show one
280
+ session's **project** next to another's **session id**. The panel now reads
281
+ the project from the live foreground session, and the persisted restore fields
282
+ are kept in sync on every switch, so project and session always match.
283
+ - **🔁 Duplicated output after switching to a busy session** — following a busy
284
+ session's in-flight turn live and then sending a new message could echo output
285
+ twice (live stream + tail watcher). The follow-watch is now stopped when a new
286
+ turn starts streaming, and when the followed turn ends.
287
+ - **🧷 Lost session (and context) when the agent was waiting on a reply** — if
288
+ the agent ended a turn asking a clarifying question and the ACP process
289
+ restarted during the pause before you answered (it runs 24/7, so transient
290
+ restarts happen), your reply could land in a **brand-new empty session**,
291
+ discarding the whole conversation. Re-binding a session now **retries** the
292
+ flaky load (the agent is usually mid-restart on the first attempt), and if the
293
+ session truly can't be reopened the bot **forks a linked continuation primed
294
+ with the recent transcript** instead of silently starting fresh — and tells
295
+ you it did. Context (including the pending question) survives the restart.
296
+
297
+ ## [1.4.0] - 2026-06-21
298
+
299
+ The **"work on many sessions at once"** release — drive several Kiro sessions
300
+ from a single chat and switch between them, on a redesigned, compact menu.
301
+
302
+ ### Added
303
+
304
+ - **🧭 Multi-session control & switching (`/running`)** — one chat can now control
305
+ **several Kiro sessions at once**. Start them with 📁 Project / 🆕 New, then tap
306
+ **🧭 Running** (or `/running`) to jump between them. Only the foreground session
307
+ streams live; the rest keep running **quietly** in the background. **Switching
308
+ to a session shows its recent context + every message that arrived while you
309
+ were away** (its "unread", recovered from the session's event log). Each entry
310
+ shows busy/unread badges, and you can close one with ✖ (it isn't killed). The
311
+ controlled set and foreground survive restarts.
312
+
313
+ ### Changed
314
+
315
+ - **🎛 Redesigned menu — compact, organized, hideable.** The bulky multi-row
316
+ reply keyboard is replaced by a tiny persistent bar (**☰ Menu · 🧭 Running ·
317
+ ⏹ Stop**) plus a clean, grouped **inline menu** opened on demand. The inline
318
+ menu shows the **current agent, model and reasoning** right on their buttons and
319
+ reopens after a change. Hide it with 🙈 and restore with `/menu` or ⌨️ Show bar.
320
+ All live state (project / agent / model / reasoning / context % / controlled
321
+ count) lives in the pinned status panel, keeping the input area uncluttered.
322
+
323
+ ### Verified
324
+
325
+ - Re-reviewed the transient-error auto-retry path end-to-end (error
326
+ classification, the `6s → 12s → 24s → 48s → 60s` backoff, the "only retry while
327
+ nothing has streamed" guard, and cancellable waits) — confirmed logically
328
+ complete. (Shipped in 1.3.0; carried into this release.)
329
+
330
+ ## [1.3.0] - 2026-06-21
331
+
332
+ ### Added
333
+
334
+ - **🔁 Transient-error auto-retry with backoff** — when the agent returns a
335
+ transient error (e.g. "high volume of traffic" / `-32603` "Internal error")
336
+ before any output has streamed, the bot retries with an exponential backoff
337
+ (`6s → 12s → 24s → 48s → 60s`) instead of failing immediately. The **real**
338
+ error is shown on every attempt, and a clear summary is sent once retries are
339
+ exhausted. Configurable via `PROMPT_RETRY_ATTEMPTS` (`0` disables; default
340
+ `5`); waits are interruptible with `/cancel`.
341
+ - **🪪 Session cards** — `/sessions` and `/active` now render each session as a
342
+ rich card (status dot, project name + full path, created/updated times,
343
+ history size, context-usage %, short id) with **Resume/Continue · History ·
344
+ Watch** buttons, replacing the cramped button grid.
345
+ - **📖 Install guide** — new `docs/INSTALL.md`, linked from the README and from
346
+ every GitHub Release.
347
+
348
+ ### Changed
349
+
350
+ - ACP JSON-RPC errors now surface their **code and data** (and are logged), so
351
+ failures are diagnosable instead of an opaque "Internal error".
352
+ - The release workflow always attaches the clean source zip and appends a
353
+ **1-click install** footer (with a link to the install guide) to every
354
+ release's notes.
355
+
356
+ ## [1.2.0] - 2026-06-21
357
+
358
+ ### Added
359
+
360
+ - **👥 Contributors** — a contrib.rocks avatar wall plus "How to Contribute" and
361
+ "Releasing a New Version" guidance in the README.
362
+ - **⭐ Top Contributors** — a curated table highlighting the people who shape the
363
+ project.
364
+ - **📊 Stars** — a live star-history chart in the README.
365
+ - **🌍 StarMapper** — an interactive world map of the project's stargazers.
366
+ - **📦 Release automation** — `.github/workflows/release.yml` builds a clean,
367
+ downloadable source zip and publishes a GitHub Release on every `v*.*.*` tag,
368
+ using this CHANGELOG section as the release notes (auto-generated notes as a
369
+ fallback).
370
+ - **🤖 Agent instructions** — a new `AGENTS.md` documenting the architecture,
371
+ conventions, and the batched-PR → conflict-resolve → merge → release workflow.
372
+ - **📋 Release checklist** — `docs/ops/RELEASE_CHECKLIST.md` codifies the
373
+ pre-release validation steps.
374
+
375
+ ### Changed
376
+
377
+ - `CONTRIBUTING.md` now describes the feature-branch → pull-request → release
378
+ workflow and how versioned releases are cut.
379
+ - README roadmap updated to mark community/release tooling as shipped.
380
+
381
+ ## [1.1.0] - 2026-06-20
382
+
383
+ ### Added
384
+
385
+ - Inline approvals (`session/request_permission`): approve / approve-always /
386
+ deny risky tool calls from Telegram buttons.
387
+ - Account & context usage via `/usage`, plus a context-usage indicator in the
388
+ status panel.
389
+ - Voice messages transcribed to prompts (configurable STT endpoint).
390
+
391
+ ## [1.0.0] - 2026-06-20
392
+
393
+ ### Added
394
+
395
+ - Initial release: Telegram ⇄ Kiro CLI bridge over the Agent Client Protocol
396
+ (ACP) with projects, resumable and live sessions, queued follow-ups, edit
397
+ diffs, MarkdownV2 rendering, scheduled tasks, multi-image prompts, and a
398
+ cross-platform 24/7 background service.
399
+
400
+ [1.7.1]: https://github.com/artickc/kiro-telegram-bot/releases/tag/v1.7.1
401
+ [1.7.0]: https://github.com/artickc/kiro-telegram-bot/releases/tag/v1.7.0
402
+ [1.6.0]: https://github.com/artickc/kiro-telegram-bot/releases/tag/v1.6.0
403
+ [1.5.1]: https://github.com/artickc/kiro-telegram-bot/releases/tag/v1.5.1
404
+ [1.5.0]: https://github.com/artickc/kiro-telegram-bot/releases/tag/v1.5.0
405
+ [1.4.0]: https://github.com/artickc/kiro-telegram-bot/releases/tag/v1.4.0
406
+ [1.3.0]: https://github.com/artickc/kiro-telegram-bot/releases/tag/v1.3.0
407
+ [1.2.0]: https://github.com/artickc/kiro-telegram-bot/releases/tag/v1.2.0
408
+ [1.1.0]: https://github.com/artickc/kiro-telegram-bot/releases/tag/v1.1.0
409
+ [1.0.0]: https://github.com/artickc/kiro-telegram-bot/releases/tag/v1.0.0
package/README.md CHANGED
@@ -27,6 +27,7 @@ and extended into a full multi-session client.
27
27
  | 🗂 **Projects** | `/projects` browses your folders and runs Kiro in the one you pick. |
28
28
  | ♻️ **Resume sessions** | `/sessions` lists recent Kiro sessions; tap to resume via ACP `session/load`. |
29
29
  | 🟢 **Connect to live sessions** | `/active` shows sessions running **right now** on your PC. Watch them live, or continue them — see below. |
30
+ | 🛑 **Kill a session / PID** | Each live `/sessions` · `/active` card has a **🛑 Kill · pid N** button (confirm-guarded) that stops that session's process and its child tree; `/killall` stops them all. The bot's own agent is never killable. |
30
31
  | 📡 **Live watch** | Follow a running session read-only in real time (tails its event log). |
31
32
  | 🧭 **Always-visible menu** | A persistent keyboard plus a pinned status panel that always shows your current **project, agent, reasoning effort, model, session and queue**. |
32
33
  | ⏰ **Scheduled tasks** | Create prompts that run on a schedule (once / daily / weekly / monthly / every-N-minutes) in a chosen project, delivered back to your chat. |
@@ -34,8 +35,10 @@ and extended into a full multi-session client.
34
35
  | 📜 **History** | `/history` shows the latest messages of any session. |
35
36
  | 🧩 **MCP control** | `/mcp` lists MCP servers, **health-checks** them (which connected / failed and why), and **enables/disables** them — then restarts the agent to apply. |
36
37
  | 👥 **Subagent visibility** | When Kiro delegates to subagents and waits on them, you see each one **start / work / finish** plus a live `🤖 N running` summary — and subagent permission prompts route to your chat. |
38
+ | 📈 **Task progress bar** | The agent appends a `{progress: N%}` marker; the bot hides it and shows a **green 0–100% loading bar** on the live message, in the status panel, and on session cards (`SHOW_PROGRESS`). |
39
+ | 🔐 **Re-auth from chat** | `/reauth` logs out and runs a device-flow login (URL + code streamed to your chat), then restarts the agent — no terminal needed. |
37
40
  | ⌨️ **Typing indicator** | Stays on for the whole turn, even through long tool chains. |
38
- | 📥 **Queued follow-ups** | Message while Kiro is busy — it's queued and runs next. `/btw` queues explicitly; `/flush` runs now. |
41
+ | 📥 **Queued follow-ups** | Message while Kiro is busy — it's queued and runs next. `/btw` runs it ASAP (now if idle, else right after the current task); `/flush` runs the queue now. |
39
42
  | ✏️ **Edit diffs** | File edits show as unified `diff` blocks with `+N -M` stats. |
40
43
  | 💬 **Quality markdown** | Converts agent markdown to Telegram **MarkdownV2** with safe escaping and code-fence-aware splitting. |
41
44
  | 🔁 **Self-healing** | Auto-restarts the Kiro agent with backoff and re-binds your session. |
@@ -52,6 +55,9 @@ and extended into a full multi-session client.
52
55
  | Switch between projects | ✅ | ❌ |
53
56
  | Resume saved sessions | ✅ | ❌ |
54
57
  | Attach to **live** PC sessions (watch / fork) | ✅ | ❌ |
58
+ | **Kill a session by PID** (or all at once) | ✅ | ❌ |
59
+ | **Live task-progress bars** (`{progress: N%}`) | ✅ | ❌ |
60
+ | **Re-authenticate from chat** (`/reauth`, device flow) | ✅ | ❌ |
55
61
  | Multiple isolated sessions | ✅ | ❌ (single shared) |
56
62
  | Queued follow-ups while busy | ✅ | ❌ |
57
63
  | **Scheduled tasks** (cron-like) | ✅ | ❌ |
@@ -139,10 +145,16 @@ The platform is auto-detected:
139
145
 
140
146
  | OS | Mechanism | Starts on |
141
147
  |---|---|---|
142
- | Windows | Hidden Scheduled Task | logon |
148
+ | Windows | Hidden Scheduled Task (elevated) · per-user **Startup folder** (no admin) | logon |
143
149
  | Linux | systemd **user** service (+ linger) | boot |
144
150
  | macOS | launchd LaunchAgent | login |
145
151
 
152
+ On Windows, registering a logon-triggered Scheduled Task needs admin, so from a
153
+ normal terminal `kiro-tg install` falls back to a hidden launcher in your
154
+ per-user **Startup folder** (starts at logon, no elevation). Run it from an
155
+ **elevated** terminal to use the Scheduled Task instead; either way `status`,
156
+ `stop`, `restart` and `uninstall` work the same.
157
+
146
158
  ```bash
147
159
  npm run install:service # install + start, enable autostart
148
160
  npm run service -- status # show install + running state
@@ -162,7 +174,7 @@ Logs are written to `logs/kiro-telegram-bot.log` (rotated at 5 MB).
162
174
 
163
175
  ```
164
176
  /menu Show the persistent menu keyboard
165
- /projects List projects · /projects <q> search · /projects new <name>
177
+ /projects List · /projects <q> search · /projects <path> open any folder · /projects new <name>
166
178
  /sessions List & resume sessions (active first) · /sessions <q> to filter
167
179
  /active Sessions running now on the PC
168
180
  /running Sessions this chat controls — switch between them
@@ -174,7 +186,7 @@ Logs are written to `logs/kiro-telegram-bot.log` (rotated at 5 MB).
174
186
  /new Start a fresh session here
175
187
  /status Current session, project & queue
176
188
  /usage Account info & current context usage
177
- /btw <text> Queue a follow-up to run after the current task
189
+ /btw <text> Run it now if idle, else queue to run right after the current task
178
190
  /flush Send queued follow-ups now
179
191
  /queue Show queued follow-ups
180
192
  /clearqueue Clear the queue
@@ -182,6 +194,7 @@ Logs are written to `logs/kiro-telegram-bot.log` (rotated at 5 MB).
182
194
  /unwatch Stop following a live session
183
195
  /model <id> Switch the model for this session
184
196
  /restart Restart the Kiro agent
197
+ /reauth Log out & log in to Kiro (device flow) · /reauth --license free|pro …
185
198
  /help Show help
186
199
  ```
187
200
 
@@ -199,10 +212,10 @@ Sessions · Agent · Model · Reasoning · Tasks · Status · Usage · Stop · K
199
212
  The bar can be hidden (🙈) and restored (⌨️ Show bar or `/menu`).
200
213
 
201
214
  A **pinned status panel** at the top of the chat always shows your current
202
- **project, agent, reasoning effort, model, session id, context %, activity and
203
- queue** (and how many sessions the chat controls), updating live. Pick **Agent**,
204
- **Reasoning** or **Model** from the inline menu (reasoning steers how thoroughly
205
- the agent works: Minimal → Max).
215
+ **project, agent, reasoning effort, model, session id, context %, task progress,
216
+ activity and queue** (and how many sessions the chat controls), updating live.
217
+ Pick **Agent**, **Reasoning** or **Model** from the inline menu (reasoning steers
218
+ how thoroughly the agent works: Minimal → Max).
206
219
 
207
220
  ## ⏰ Scheduled tasks
208
221
 
@@ -237,6 +250,25 @@ prompt. Configure any OpenAI/Whisper-compatible endpoint via `STT_API_URL` in
237
250
  `.env`; leave `STT_LANGUAGE` blank for automatic detection (English, Russian,
238
251
  Romanian/Moldovan, and ~100 more).
239
252
 
253
+ ## 📈 Task progress
254
+
255
+ The bot asks the agent to end each message with a `{progress: N%}` marker, then
256
+ **hides the marker** and renders a **green loading bar** from 0–100 %
257
+ (`🟩🟩🟩🟩🟩⬜⬜⬜⬜⬜ 50%`, all-green ✅ at 100 %) so you can see how far along the
258
+ current task is. The bar appears at the bottom of the **live message**, in the
259
+ pinned **status panel**, and on **`/running` and `/sessions` cards**. Markers are
260
+ also stripped from history, replays and previews, so the raw plumbing never
261
+ shows. Turn it off with `SHOW_PROGRESS=false`.
262
+
263
+ ## 🔐 Re-authenticating Kiro
264
+
265
+ Run **`/reauth`** to log out and start a fresh **device-flow** login without
266
+ touching a terminal: the verification URL + code are streamed into the chat
267
+ (open them on any device), and once you're logged in the agent is restarted to
268
+ pick up the new credentials. It's refused while a turn is running, and you can
269
+ pass login flags through, e.g. `/reauth --license free` or
270
+ `/reauth --license pro --region <r> --identity-provider <url>`.
271
+
240
272
  ---
241
273
 
242
274
  ## 🧭 Working on several sessions at once
@@ -248,7 +280,8 @@ while the others keep working quietly. When you switch to a session you see its
248
280
  recent context and **every message that arrived while you were away** (its
249
281
  unread, recovered from the session log). Leave a task running in A, hop to B,
250
282
  reply, and come back to A to read what it did. Close a session with ✖ (it isn't
251
- killed — see `/killall` for that).
283
+ killed)or tap **🛑 Kill · pid N** on its `/sessions` · `/active` card to stop
284
+ its process (and `/killall` to stop them all).
252
285
 
253
286
  ## 🔗 Connecting to live sessions
254
287
 
@@ -283,10 +316,16 @@ Resuming an **idle** session loads it directly so you continue the exact thread.
283
316
  | `SHOW_EDIT_DIFFS` | no | `true` | Show unified diffs for edits. |
284
317
  | `DIFF_MAX_LINES` | no | `120` | Max diff lines shown inline. |
285
318
  | `SHOW_SUBAGENTS` | no | `true` | Stream subagent (crew) start/work/finish while the main agent waits. |
319
+ | `SHOW_PROGRESS` | no | `true` | Ask the agent to append a `{progress: N%}` marker to each message; the bot parses it, hides the marker, and renders a green 0–100% bar on the live message, in session cards, and in the status panel. |
320
+ | `NOTIFY_OTHER_SESSIONS` | no | `true` | Deliver a session's "Done" summary (with a short created/edited/deleted count) even when it's a background session, marked "From other session". `false` keeps background sessions silent. |
286
321
  | `MCP_PROBE_TIMEOUT_MS` | no | `8000` | Per-server timeout for the `/mcp` live health-check. |
287
322
  | `MCP_PROBE_CONCURRENCY` | no | `6` | How many MCP health probes run at once. |
288
323
  | `ACP_AUTO_RESTART` | no | `true` | Auto-restart the agent if it exits. |
324
+ | `AUTO_UPDATE` | no | `true` | Hourly check npm and, when a newer version exists **and the bot is idle** (no turn/task running, no other active Kiro session), auto-update + restart + post the release notes (tagged `#update`). Global npm installs only. |
325
+ | `UPDATE_CHECK_MS` | no | `3600000` | How often to check npm for updates (ms). |
289
326
  | `PROMPT_RETRY_ATTEMPTS` | no | `5` | Max retries for a transient agent error (e.g. high-traffic / `Internal error`) before any output streamed, with `6s → 12s → 24s → 48s → 60s` backoff. The real error shows each attempt; a summary after the last. `0` disables. |
327
+ | `AUTO_FORK_ON_ERROR` | no | `true` | When the retries above are exhausted on a transient error (throttle / `Internal error` / exhausted context) and nothing streamed, **logically fork** the session — open a fresh continuation primed with the recent transcript, drop the stuck session, and retry the message once. |
328
+ | `AUTO_FORK_CONTEXT_PCT` | no | `85` | When a prompt fails transiently **and** the session's last-known context usage is at/above this %, **skip the retry backoff and fork immediately** — a context-exhausted session won't recover by retrying the same oversized prompt (throttling on a near-full session shows up as `-32603 … throttled`). Forking compacts it into a fresh continuation primed with the recent transcript. Requires `AUTO_FORK_ON_ERROR`; `0` disables this trigger. |
290
329
  | `LOG_LEVEL` | no | `info` | `debug` \| `info` \| `warn` \| `error`. |
291
330
  | `LOG_DIR` / `LOG_FILE` | no | `<project>/logs/…` | Log location. |
292
331
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kiro-telegram-bot",
3
- "version": "1.5.1",
3
+ "version": "1.7.1",
4
4
  "description": "Control Kiro CLI from Telegram over the Agent Client Protocol (ACP). Switch projects, resume and attach to live coding sessions, stream responses with diffs, queue follow-ups, and run 24/7 as a cross-platform background service.",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -14,6 +14,7 @@
14
14
  "scripts",
15
15
  "tsconfig.json",
16
16
  ".env.example",
17
+ "CHANGELOG.md",
17
18
  "docs"
18
19
  ],
19
20
  "engines": {
@@ -62,6 +63,9 @@
62
63
  "grammy": "^1.30.0",
63
64
  "tsx": "^4.19.2"
64
65
  },
66
+ "optionalDependencies": {
67
+ "@homebridge/node-pty-prebuilt-multiarch": "0.13.1"
68
+ },
65
69
  "devDependencies": {
66
70
  "@types/diff": "^7.0.0",
67
71
  "@types/node": "^22.10.0",