kiro-telegram-bot 1.5.1 → 1.6.0

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 (43) hide show
  1. package/.env.example +30 -0
  2. package/CHANGELOG.md +310 -0
  3. package/README.md +8 -3
  4. package/package.json +2 -1
  5. package/src/acp/client.ts +24 -0
  6. package/src/app/settings-store.ts +7 -0
  7. package/src/app/types.ts +4 -2
  8. package/src/app/updater.ts +234 -0
  9. package/src/app/version.ts +41 -0
  10. package/src/bot/bot.ts +53 -1
  11. package/src/bot/chat-controller.ts +60 -7
  12. package/src/bot/commands.ts +3 -3
  13. package/src/bot/deps.ts +18 -0
  14. package/src/bot/handlers/control.ts +11 -3
  15. package/src/bot/handlers/history.ts +7 -2
  16. package/src/bot/handlers/kill.ts +4 -2
  17. package/src/bot/handlers/mcp.ts +2 -1
  18. package/src/bot/handlers/menu.ts +12 -7
  19. package/src/bot/handlers/message.ts +7 -2
  20. package/src/bot/handlers/photo.ts +13 -4
  21. package/src/bot/handlers/projects.ts +119 -19
  22. package/src/bot/handlers/running.ts +96 -21
  23. package/src/bot/handlers/sessions.ts +41 -25
  24. package/src/bot/handlers/tasks.ts +2 -1
  25. package/src/bot/handlers/usage.ts +2 -1
  26. package/src/bot/handlers/voice.ts +1 -1
  27. package/src/bot/menu/ephemeral.ts +117 -0
  28. package/src/bot/prompt-content.ts +1 -0
  29. package/src/bot/session-fork.ts +35 -0
  30. package/src/bot/session-runtime.ts +228 -66
  31. package/src/config.ts +21 -0
  32. package/src/index.ts +3 -1
  33. package/src/projects/manager.ts +16 -5
  34. package/src/render/file-summary.ts +111 -0
  35. package/src/render/hashtags.ts +34 -0
  36. package/src/render/markdown.ts +4 -0
  37. package/src/render/tool-call.ts +97 -3
  38. package/src/service/linux.ts +2 -0
  39. package/src/service/macos.ts +10 -0
  40. package/src/service/platform.ts +5 -0
  41. package/src/service/types.ts +2 -0
  42. package/src/sessions/history.ts +33 -0
  43. package/src/stream/streamer.ts +34 -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,310 @@
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.6.0] - 2026-06-23
11
+
12
+ The **"always-on & self-healing"** release — the bot keeps itself up to date,
13
+ recovers context-full sessions on its own, threads every reply to your prompt,
14
+ and keeps the chat tidy while you drive several sessions at once.
15
+
16
+ ### Added
17
+
18
+ - **🔄 Auto-update (`AUTO_UPDATE`, on by default).** Once an hour the bot makes
19
+ one tiny npm request for the latest version. When a newer one exists **and the
20
+ bot is fully idle** — no chat turn or scheduled task running, and no other
21
+ active Kiro session on the PC — it announces in chat, runs
22
+ `npm install -g kiro-telegram-bot@latest`, restarts, and posts the new
23
+ release's features/fixes **tagged `#update`** so every upgrade is easy to find.
24
+ It never interrupts work, and only acts on a global npm install (a source
25
+ checkout is left to `git`). Tunable via `UPDATE_CHECK_MS`.
26
+ - **🏷 Threaded replies + searchable hashtags.** **Every** message of a turn —
27
+ each response bubble, tool call, the retry/fork notices and the Done line — is
28
+ now sent as a **reply to your prompt** (not just the first one), so the whole
29
+ turn is visually threaded to what you asked (your prompt is left untouched).
30
+ **Every message bubble**, including the live thinking/streaming one, ends with
31
+ `#proj_… #sess_…`, so tapping a tag pulls up every message for that project or
32
+ session. (Model and reasoning tags were dropped — they were noisy and rarely
33
+ useful.) Works for text, voice and photo prompts.
34
+ - **🔁 Instant fork on a context-full session (`AUTO_FORK_CONTEXT_PCT`, default
35
+ 85).** Sending to a session whose context is exhausted used to fail with
36
+ `-32603 … The request was throttled by the service` and then burn the whole
37
+ retry backoff (6s → 12s → 24s → 48s → 60s ≈ 2½ min) before recovering — because
38
+ retrying the same oversized prompt can't succeed. Now, when a prompt fails
39
+ transiently **and** the session's last-known context usage is at/above
40
+ `AUTO_FORK_CONTEXT_PCT` (or the error explicitly names a context-window
41
+ overflow), the bot **skips the retries and forks immediately**: it compacts the
42
+ conversation into a fresh continuation primed with the recent transcript and
43
+ retries your message once. Requires `AUTO_FORK_ON_ERROR`; set the % to `0` to
44
+ disable the early trigger and keep the old retry-then-fork behavior.
45
+ - **🗂 Open any folder / safer project creation (`/projects`).** `/projects <path>`
46
+ now opens a session in **any existing folder** — `C:\work\app`, `/home/me/app`,
47
+ `~/app`, even outside your `PROJECT_ROOTS` — and **errors if the path doesn't
48
+ exist** (it's never created). `/projects new <name>` now **errors if the
49
+ project already exists** instead of silently reusing it; otherwise it creates
50
+ the folder and starts a session there. `/project` works as an alias.
51
+
52
+ ### Changed
53
+
54
+ - **📄 Paginated `/projects` and `/sessions` (10 per page).** Long lists no longer
55
+ flood the chat — the project picker pages in place with **◀ Prev / Next ▶** and
56
+ a `page x/y` indicator, and session cards are shown a page at a time with the
57
+ same nav. Selecting an item still works across pages (absolute indexing).
58
+
59
+ - **✅ "Done" summaries from other running sessions.** When you drive several
60
+ sessions at once and switch between them, a background session that finishes
61
+ now pings you — clearly marked **`📨 From other session [project · id]`** with
62
+ a **short** file count (`📝 +2 created · ~3 edited · −1 deleted`, or
63
+ `📄 No files modified`). The session you're actively viewing still gets the
64
+ full completion message with the list of changed paths. Toggle with the new
65
+ **`NOTIFY_OTHER_SESSIONS`** env var (default `true`); set it `false` to keep
66
+ background sessions silent (their output still shows when you switch back).
67
+ File operations are tracked for background turns too, so the count is accurate
68
+ regardless of which session you were viewing. **Switching (back) into a
69
+ session also replays its last Done + file summary** at the end of the catch-up
70
+ view (so you see how it ended), and the completion line is now more compact
71
+ and professional — no `end_turn`/`Files:` noise, with project-relative paths.
72
+ - **🏷 Clearer skill & MCP tool lines.** Loading a skill now shows
73
+ **`📚 Loaded skill: <name>`** instead of a cryptic `SKILL.md:1` read line, and
74
+ MCP/extension tool calls render as **`🧩 Call MCP <server>: <method>`** (or
75
+ `🧩 Call MCP: <tool>` when the call carries no server name). Built-in
76
+ file/shell tools are never mislabelled.
77
+ - **📁 Projects sorted by most-recently-used.** The `/projects` picker now lists
78
+ folders **freshest first** — ranked by the latest of the directory's modified
79
+ time and the newest Kiro session opened in it — so the project you were just
80
+ working in is at the top instead of a fixed alphabetical order.
81
+ - **🧭 Redesigned `/running` — one card per session.** Instead of a cramped
82
+ combined list, each controlled session is now its own **card** with
83
+ **🔀 Switch · 📜 History · ✖ Close** buttons, showing its project, status, how
84
+ long ago it was last active, unread count, and a short preview of its first
85
+ prompt (reasoning directive stripped) — so you can tell sessions apart and act
86
+ on each one directly. The foreground session shows ▶️ Current instead of Switch.
87
+ - **🧹 Self-cleaning navigation — a tidy history.** Menus, session/project
88
+ cards, pickers and submenus are now **transient**: opening a new surface (or
89
+ acting on one) removes the previous one, and your command / menu-button
90
+ messages are deleted after they're handled. Boundary markers you actually want
91
+ to keep — **🔀 Switched / ✨ New session / 📁 Now working in…**, agent output,
92
+ Done summaries and the pinned status panel — always remain, so the chat reads
93
+ as a clean timeline of what happened, not a pile of menus.
94
+
95
+ ### Fixed
96
+
97
+ - **👯 Duplicate session cards in `/running`.** Tapping a session twice (or in
98
+ quick succession) could create **two runtimes for the same session** — the
99
+ add-session paths checked "already controlled?" and then `await`ed before
100
+ reserving the runtime, so concurrent taps both passed the check. The runtime
101
+ is now reserved synchronously after the check; restores and persistence dedupe
102
+ by session id; and `/running` prunes any existing duplicate, so the list
103
+ self-heals.
104
+ - **🔣 Stray “`” in streamed messages.** An unbalanced/partial code fence in an
105
+ agent message could leave an orphan lone-backtick line that rendered as a
106
+ broken-looking single backtick. Such orphan ` / `` lines are now dropped (real
107
+ triple-backtick fences and inline `code` are untouched).
108
+ - **⚡ `/btw` now runs as soon as possible.** Previously `/btw <text>` only ever
109
+ parked the message in the queue — so when the bot was **idle** it sat there
110
+ doing nothing until `/flush` or another message. It now runs **immediately
111
+ when idle**, and when a turn is in flight it's queued and runs **automatically
112
+ the moment that turn finishes** (an in-flight agent turn can't be interrupted).
113
+
114
+ ## [1.5.1] - 2026-06-22
115
+
116
+ ### Added
117
+
118
+ - **📦 Install from npm** — the bot is now a published package with a global
119
+ CLI: `npm install -g kiro-telegram-bot` gives you the **`kiro-tg`** command
120
+ (alias `kiro-telegram-bot`). Multiple startup options: `kiro-tg setup`
121
+ (writes `.env` + auto-detects `kiro-cli`), `kiro-tg run` (foreground), and the
122
+ full 24/7 **service** controls — `install · status · logs · stop · restart ·
123
+ uninstall` — auto-detected per platform. Each instance keeps its
124
+ `.env`/`logs/`/`data/` in the **folder you run it from** (resolved from the
125
+ `--instance` the service passes, the launcher's working dir, or the cwd), so a
126
+ global install never writes into `node_modules`. Cloned/zip checkouts behave
127
+ exactly as before. `tsx` moved to runtime deps (still no build step). npm is
128
+ now the **primary** install option in [docs/INSTALL.md](docs/INSTALL.md).
129
+
130
+ ### Fixed
131
+
132
+ - **🧵 Long messages split by Telegram are now stitched back together** —
133
+ Telegram caps a message at 4096 characters, so a long paste arrives as several
134
+ back-to-back messages. The bot used to treat each part as its own prompt —
135
+ spamming **“Queued (position 1…4)”** and even replying **“Unknown command”**
136
+ when a split landed on a line starting with `/`. Rapid consecutive text
137
+ messages are now **coalesced within a short window into a single prompt** (one
138
+ submission, one confirmation, in order). Tunable via `MESSAGE_BATCH_MS`
139
+ (default `800`; `0` disables). A genuine lone `/typo` still gets the friendly
140
+ “Unknown command” hint, and a failed submit now reports an error instead of
141
+ silently vanishing.
142
+
143
+ ## [1.5.0] - 2026-06-22
144
+
145
+ The **"mission control"** release — manage the agent's MCP servers and watch
146
+ its subagents from Telegram, with quieter notifications and sturdier sessions.
147
+
148
+ ### Added
149
+
150
+ - **🧩 MCP control (`/mcp`)** — inspect and manage the agent's MCP servers from
151
+ Telegram. Lists every configured server with its **enabled/disabled** state,
152
+ transport (stdio/http) and scope (global/workspace); a **🧪 Health-check**
153
+ runs a real MCP `initialize` handshake against each enabled server and reports
154
+ which **connected** and which **failed (and why)** — connection refused,
155
+ timeout, HTTP status, bad transport, etc. **🔧 Enable/Disable** toggles a
156
+ server's `disabled` flag in its `mcp.json` (other fields preserved) and a
157
+ **🔄 Restart agent** button applies the change immediately. Tunable via
158
+ `MCP_PROBE_TIMEOUT_MS` / `MCP_PROBE_CONCURRENCY`.
159
+ - **👥 Subagent visibility** — when the main agent delegates to subagents
160
+ ("crew") and goes quiet while waiting on them, the chat now **shows each
161
+ subagent starting, working and finishing** (via Kiro's
162
+ `_kiro.dev/subagent/list_update`), and the pinned status panel + `/status`
163
+ show a live `🤖 N running · M pending` summary. No more wondering why the
164
+ agent "isn't responding" mid-delegation. Toggle with `SHOW_SUBAGENTS`.
165
+ - **🔐 Subagent permission routing** — when permission delegation is active
166
+ (non-trust-all mode), a permission request raised by a **subagent** is now
167
+ routed to its **parent chat** and clearly labelled (`Subagent "X" needs
168
+ approval…`), instead of being auto-decided as unattended.
169
+ - **🔕 Quiet notifications (on by default)** — the bot now sends messages
170
+ **silently** (no notification sound) so streaming output and tool/status
171
+ chatter no longer buzz your phone. Only messages that **finish a turn**
172
+ (✅ Done / ⏹ Stopped / ❌ Error), **scheduled-task results**, and **permission
173
+ prompts** ring. Toggle with `QUIET_NOTIFICATIONS` (default `true`).
174
+ - **🔐 Session-aware permission prompts** — when a permission request belongs to
175
+ a *background* session, the prompt names it ("Session X needs approval…") and
176
+ adds a **🔀 Switch to it** button next to Allow/Deny (which approve in place,
177
+ without switching). Permission prompts always ring, even in quiet mode.
178
+
179
+ ### Fixed
180
+
181
+ - **🧭 Session-switch project mismatch** — after switching between controlled
182
+ sessions in different projects, the pinned status panel could show one
183
+ session's **project** next to another's **session id**. The panel now reads
184
+ the project from the live foreground session, and the persisted restore fields
185
+ are kept in sync on every switch, so project and session always match.
186
+ - **🔁 Duplicated output after switching to a busy session** — following a busy
187
+ session's in-flight turn live and then sending a new message could echo output
188
+ twice (live stream + tail watcher). The follow-watch is now stopped when a new
189
+ turn starts streaming, and when the followed turn ends.
190
+ - **🧷 Lost session (and context) when the agent was waiting on a reply** — if
191
+ the agent ended a turn asking a clarifying question and the ACP process
192
+ restarted during the pause before you answered (it runs 24/7, so transient
193
+ restarts happen), your reply could land in a **brand-new empty session**,
194
+ discarding the whole conversation. Re-binding a session now **retries** the
195
+ flaky load (the agent is usually mid-restart on the first attempt), and if the
196
+ session truly can't be reopened the bot **forks a linked continuation primed
197
+ with the recent transcript** instead of silently starting fresh — and tells
198
+ you it did. Context (including the pending question) survives the restart.
199
+
200
+ ## [1.4.0] - 2026-06-21
201
+
202
+ The **"work on many sessions at once"** release — drive several Kiro sessions
203
+ from a single chat and switch between them, on a redesigned, compact menu.
204
+
205
+ ### Added
206
+
207
+ - **🧭 Multi-session control & switching (`/running`)** — one chat can now control
208
+ **several Kiro sessions at once**. Start them with 📁 Project / 🆕 New, then tap
209
+ **🧭 Running** (or `/running`) to jump between them. Only the foreground session
210
+ streams live; the rest keep running **quietly** in the background. **Switching
211
+ to a session shows its recent context + every message that arrived while you
212
+ were away** (its "unread", recovered from the session's event log). Each entry
213
+ shows busy/unread badges, and you can close one with ✖ (it isn't killed). The
214
+ controlled set and foreground survive restarts.
215
+
216
+ ### Changed
217
+
218
+ - **🎛 Redesigned menu — compact, organized, hideable.** The bulky multi-row
219
+ reply keyboard is replaced by a tiny persistent bar (**☰ Menu · 🧭 Running ·
220
+ ⏹ Stop**) plus a clean, grouped **inline menu** opened on demand. The inline
221
+ menu shows the **current agent, model and reasoning** right on their buttons and
222
+ reopens after a change. Hide it with 🙈 and restore with `/menu` or ⌨️ Show bar.
223
+ All live state (project / agent / model / reasoning / context % / controlled
224
+ count) lives in the pinned status panel, keeping the input area uncluttered.
225
+
226
+ ### Verified
227
+
228
+ - Re-reviewed the transient-error auto-retry path end-to-end (error
229
+ classification, the `6s → 12s → 24s → 48s → 60s` backoff, the "only retry while
230
+ nothing has streamed" guard, and cancellable waits) — confirmed logically
231
+ complete. (Shipped in 1.3.0; carried into this release.)
232
+
233
+ ## [1.3.0] - 2026-06-21
234
+
235
+ ### Added
236
+
237
+ - **🔁 Transient-error auto-retry with backoff** — when the agent returns a
238
+ transient error (e.g. "high volume of traffic" / `-32603` "Internal error")
239
+ before any output has streamed, the bot retries with an exponential backoff
240
+ (`6s → 12s → 24s → 48s → 60s`) instead of failing immediately. The **real**
241
+ error is shown on every attempt, and a clear summary is sent once retries are
242
+ exhausted. Configurable via `PROMPT_RETRY_ATTEMPTS` (`0` disables; default
243
+ `5`); waits are interruptible with `/cancel`.
244
+ - **🪪 Session cards** — `/sessions` and `/active` now render each session as a
245
+ rich card (status dot, project name + full path, created/updated times,
246
+ history size, context-usage %, short id) with **Resume/Continue · History ·
247
+ Watch** buttons, replacing the cramped button grid.
248
+ - **📖 Install guide** — new `docs/INSTALL.md`, linked from the README and from
249
+ every GitHub Release.
250
+
251
+ ### Changed
252
+
253
+ - ACP JSON-RPC errors now surface their **code and data** (and are logged), so
254
+ failures are diagnosable instead of an opaque "Internal error".
255
+ - The release workflow always attaches the clean source zip and appends a
256
+ **1-click install** footer (with a link to the install guide) to every
257
+ release's notes.
258
+
259
+ ## [1.2.0] - 2026-06-21
260
+
261
+ ### Added
262
+
263
+ - **👥 Contributors** — a contrib.rocks avatar wall plus "How to Contribute" and
264
+ "Releasing a New Version" guidance in the README.
265
+ - **⭐ Top Contributors** — a curated table highlighting the people who shape the
266
+ project.
267
+ - **📊 Stars** — a live star-history chart in the README.
268
+ - **🌍 StarMapper** — an interactive world map of the project's stargazers.
269
+ - **📦 Release automation** — `.github/workflows/release.yml` builds a clean,
270
+ downloadable source zip and publishes a GitHub Release on every `v*.*.*` tag,
271
+ using this CHANGELOG section as the release notes (auto-generated notes as a
272
+ fallback).
273
+ - **🤖 Agent instructions** — a new `AGENTS.md` documenting the architecture,
274
+ conventions, and the batched-PR → conflict-resolve → merge → release workflow.
275
+ - **📋 Release checklist** — `docs/ops/RELEASE_CHECKLIST.md` codifies the
276
+ pre-release validation steps.
277
+
278
+ ### Changed
279
+
280
+ - `CONTRIBUTING.md` now describes the feature-branch → pull-request → release
281
+ workflow and how versioned releases are cut.
282
+ - README roadmap updated to mark community/release tooling as shipped.
283
+
284
+ ## [1.1.0] - 2026-06-20
285
+
286
+ ### Added
287
+
288
+ - Inline approvals (`session/request_permission`): approve / approve-always /
289
+ deny risky tool calls from Telegram buttons.
290
+ - Account & context usage via `/usage`, plus a context-usage indicator in the
291
+ status panel.
292
+ - Voice messages transcribed to prompts (configurable STT endpoint).
293
+
294
+ ## [1.0.0] - 2026-06-20
295
+
296
+ ### Added
297
+
298
+ - Initial release: Telegram ⇄ Kiro CLI bridge over the Agent Client Protocol
299
+ (ACP) with projects, resumable and live sessions, queued follow-ups, edit
300
+ diffs, MarkdownV2 rendering, scheduled tasks, multi-image prompts, and a
301
+ cross-platform 24/7 background service.
302
+
303
+ [1.6.0]: https://github.com/artickc/kiro-telegram-bot/releases/tag/v1.6.0
304
+ [1.5.1]: https://github.com/artickc/kiro-telegram-bot/releases/tag/v1.5.1
305
+ [1.5.0]: https://github.com/artickc/kiro-telegram-bot/releases/tag/v1.5.0
306
+ [1.4.0]: https://github.com/artickc/kiro-telegram-bot/releases/tag/v1.4.0
307
+ [1.3.0]: https://github.com/artickc/kiro-telegram-bot/releases/tag/v1.3.0
308
+ [1.2.0]: https://github.com/artickc/kiro-telegram-bot/releases/tag/v1.2.0
309
+ [1.1.0]: https://github.com/artickc/kiro-telegram-bot/releases/tag/v1.1.0
310
+ [1.0.0]: https://github.com/artickc/kiro-telegram-bot/releases/tag/v1.0.0
package/README.md CHANGED
@@ -35,7 +35,7 @@ and extended into a full multi-session client.
35
35
  | 🧩 **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
36
  | 👥 **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. |
37
37
  | ⌨️ **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. |
38
+ | 📥 **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
39
  | ✏️ **Edit diffs** | File edits show as unified `diff` blocks with `+N -M` stats. |
40
40
  | 💬 **Quality markdown** | Converts agent markdown to Telegram **MarkdownV2** with safe escaping and code-fence-aware splitting. |
41
41
  | 🔁 **Self-healing** | Auto-restarts the Kiro agent with backoff and re-binds your session. |
@@ -162,7 +162,7 @@ Logs are written to `logs/kiro-telegram-bot.log` (rotated at 5 MB).
162
162
 
163
163
  ```
164
164
  /menu Show the persistent menu keyboard
165
- /projects List projects · /projects <q> search · /projects new <name>
165
+ /projects List · /projects <q> search · /projects <path> open any folder · /projects new <name>
166
166
  /sessions List & resume sessions (active first) · /sessions <q> to filter
167
167
  /active Sessions running now on the PC
168
168
  /running Sessions this chat controls — switch between them
@@ -174,7 +174,7 @@ Logs are written to `logs/kiro-telegram-bot.log` (rotated at 5 MB).
174
174
  /new Start a fresh session here
175
175
  /status Current session, project & queue
176
176
  /usage Account info & current context usage
177
- /btw <text> Queue a follow-up to run after the current task
177
+ /btw <text> Run it now if idle, else queue to run right after the current task
178
178
  /flush Send queued follow-ups now
179
179
  /queue Show queued follow-ups
180
180
  /clearqueue Clear the queue
@@ -283,10 +283,15 @@ Resuming an **idle** session loads it directly so you continue the exact thread.
283
283
  | `SHOW_EDIT_DIFFS` | no | `true` | Show unified diffs for edits. |
284
284
  | `DIFF_MAX_LINES` | no | `120` | Max diff lines shown inline. |
285
285
  | `SHOW_SUBAGENTS` | no | `true` | Stream subagent (crew) start/work/finish while the main agent waits. |
286
+ | `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
287
  | `MCP_PROBE_TIMEOUT_MS` | no | `8000` | Per-server timeout for the `/mcp` live health-check. |
287
288
  | `MCP_PROBE_CONCURRENCY` | no | `6` | How many MCP health probes run at once. |
288
289
  | `ACP_AUTO_RESTART` | no | `true` | Auto-restart the agent if it exits. |
290
+ | `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. |
291
+ | `UPDATE_CHECK_MS` | no | `3600000` | How often to check npm for updates (ms). |
289
292
  | `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. |
293
+ | `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. |
294
+ | `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
295
  | `LOG_LEVEL` | no | `info` | `debug` \| `info` \| `warn` \| `error`. |
291
296
  | `LOG_DIR` / `LOG_FILE` | no | `<project>/logs/…` | Log location. |
292
297
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kiro-telegram-bot",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
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": {
package/src/acp/client.ts CHANGED
@@ -50,6 +50,23 @@ export function isTransientAcpError(err: Error): boolean {
50
50
  return TRANSIENT_RE.test(err.message);
51
51
  }
52
52
 
53
+ /** Patterns that specifically indicate the request exceeded the model's context
54
+ * window (as opposed to a generic rate-limit/backend hiccup). */
55
+ const CONTEXT_EXHAUSTED_RE =
56
+ /context (?:length|window|limit|size|overflow)|maximum context|input (?:is )?too long|prompt (?:is )?too long|too many (?:input )?tokens|token limit|exceeds? (?:the )?(?:maximum|context|token)|reduce the (?:length|size)|context.{0,24}exhaust/i;
57
+
58
+ /**
59
+ * Heuristic: did this failure come from an exhausted context window? Unlike a
60
+ * generic transient error, this will NOT clear by retrying the same oversized
61
+ * prompt — the session must be compacted/forked into a fresh, smaller context.
62
+ * Note: throttling on a near-full session often surfaces as a plain "-32603 …
63
+ * throttled" with no context keywords, so callers should *also* consult the
64
+ * session's tracked context-usage % (see SessionRuntime.isContextRelatedFailure).
65
+ */
66
+ export function isContextExhaustedError(err: Error): boolean {
67
+ return CONTEXT_EXHAUSTED_RE.test(err.message);
68
+ }
69
+
53
70
  /** Compact, log/Telegram-safe stringification of an error's data payload. */
54
71
  function shortJson(v: unknown): string {
55
72
  try {
@@ -202,6 +219,13 @@ export class AcpClient extends EventEmitter {
202
219
  return Boolean(this.capabilities?.loadSession);
203
220
  }
204
221
 
222
+ /** True while any prompt (a chat turn or a scheduled task) awaits a response —
223
+ * i.e. the agent is actively working. Used to gate idle-only auto-updates. */
224
+ hasInflightPrompt(): boolean {
225
+ for (const p of this.pending.values()) if (p.method === "session/prompt") return true;
226
+ return false;
227
+ }
228
+
205
229
  /** PID of the bot's own kiro-cli acp process (to avoid killing ourselves). */
206
230
  get pid(): number | undefined {
207
231
  return this.proc?.pid;
@@ -28,4 +28,11 @@ export class SettingsStore {
28
28
  });
29
29
  return next;
30
30
  }
31
+
32
+ /** All chat ids that have interacted (for broadcast announcements). */
33
+ chatIds(): number[] {
34
+ return Object.keys(this.store.get())
35
+ .map(Number)
36
+ .filter((n) => Number.isFinite(n));
37
+ }
31
38
  }
package/src/app/types.ts CHANGED
@@ -41,8 +41,10 @@ export interface PromptImage {
41
41
  export interface PromptInput {
42
42
  text: string;
43
43
  images: PromptImage[];
44
+ /** Telegram message id of the prompt, so the reply threads to it. */
45
+ replyTo?: number;
44
46
  }
45
47
 
46
- export function textPrompt(text: string): PromptInput {
47
- return { text, images: [] };
48
+ export function textPrompt(text: string, replyTo?: number): PromptInput {
49
+ return { text, images: [], replyTo };
48
50
  }