charness 3.0.0 → 3.2.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 (293) hide show
  1. package/.env.example +8 -7
  2. package/DEVELOPMENT.md +12 -6
  3. package/MIGRATION_1_TO_2.md +1 -1
  4. package/MIGRATION_RENAME_TO_CHARNESS.md +133 -0
  5. package/README.md +221 -555
  6. package/SETUP.md +539 -0
  7. package/dist/adapters/claudeCliAdapter.d.ts +16 -1
  8. package/dist/adapters/claudeCliAdapter.d.ts.map +1 -1
  9. package/dist/adapters/claudeCliAdapter.js +37 -2
  10. package/dist/adapters/claudeCliAdapter.js.map +1 -1
  11. package/dist/adapters/claudeConfigDir.d.ts +40 -0
  12. package/dist/adapters/claudeConfigDir.d.ts.map +1 -0
  13. package/dist/adapters/claudeConfigDir.js +3 -0
  14. package/dist/adapters/claudeConfigDir.js.map +1 -0
  15. package/dist/adapters/claudeJsonStreamAdapter.d.ts +32 -0
  16. package/dist/adapters/claudeJsonStreamAdapter.d.ts.map +1 -1
  17. package/dist/adapters/claudeJsonStreamAdapter.js +90 -8
  18. package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -1
  19. package/dist/adapters/claudePlatformFlags.d.ts +4 -4
  20. package/dist/adapters/claudePlatformFlags.js +4 -4
  21. package/dist/adapters/createAdapter.d.ts +8 -0
  22. package/dist/adapters/createAdapter.d.ts.map +1 -1
  23. package/dist/adapters/createAdapter.js +37 -0
  24. package/dist/adapters/createAdapter.js.map +1 -1
  25. package/dist/adapters/openCodeAdapter.d.ts +23 -0
  26. package/dist/adapters/openCodeAdapter.d.ts.map +1 -1
  27. package/dist/adapters/openCodeAdapter.js +85 -2
  28. package/dist/adapters/openCodeAdapter.js.map +1 -1
  29. package/dist/agentLogin/agentLogin.d.ts +15 -2
  30. package/dist/agentLogin/agentLogin.d.ts.map +1 -1
  31. package/dist/agentLogin/agentLogin.js +53 -16
  32. package/dist/agentLogin/agentLogin.js.map +1 -1
  33. package/dist/apiErrorRetry.d.ts +8 -3
  34. package/dist/apiErrorRetry.d.ts.map +1 -1
  35. package/dist/apiErrorRetry.js +36 -5
  36. package/dist/apiErrorRetry.js.map +1 -1
  37. package/dist/apiRetryKick.d.ts +9 -0
  38. package/dist/apiRetryKick.d.ts.map +1 -1
  39. package/dist/apiRetryKick.js +16 -0
  40. package/dist/apiRetryKick.js.map +1 -1
  41. package/dist/bot.d.ts.map +1 -1
  42. package/dist/bot.js +642 -26
  43. package/dist/bot.js.map +1 -1
  44. package/dist/cli/bot.d.ts +4 -2
  45. package/dist/cli/bot.d.ts.map +1 -1
  46. package/dist/cli/bot.js +11 -3
  47. package/dist/cli/bot.js.map +1 -1
  48. package/dist/cli/botEntry.js +3 -1
  49. package/dist/cli/botEntry.js.map +1 -1
  50. package/dist/cli/claudeProfiles.d.ts +42 -0
  51. package/dist/cli/claudeProfiles.d.ts.map +1 -0
  52. package/dist/cli/claudeProfiles.js +106 -0
  53. package/dist/cli/claudeProfiles.js.map +1 -0
  54. package/dist/cli/envLoader.d.ts +6 -5
  55. package/dist/cli/envLoader.d.ts.map +1 -1
  56. package/dist/cli/envLoader.js +8 -27
  57. package/dist/cli/envLoader.js.map +1 -1
  58. package/dist/cli/hot.d.ts +2 -2
  59. package/dist/cli/hot.d.ts.map +1 -1
  60. package/dist/cli/hot.js +26 -16
  61. package/dist/cli/hot.js.map +1 -1
  62. package/dist/cli.js +19 -9
  63. package/dist/cli.js.map +1 -1
  64. package/dist/connectors/jira/adf.d.ts +23 -0
  65. package/dist/connectors/jira/adf.d.ts.map +1 -1
  66. package/dist/connectors/jira/adf.js +44 -0
  67. package/dist/connectors/jira/adf.js.map +1 -1
  68. package/dist/connectors/jira/answerSink.d.ts +27 -3
  69. package/dist/connectors/jira/answerSink.d.ts.map +1 -1
  70. package/dist/connectors/jira/answerSink.js +145 -18
  71. package/dist/connectors/jira/answerSink.js.map +1 -1
  72. package/dist/connectors/jira/attachmentTool.d.ts +7 -0
  73. package/dist/connectors/jira/attachmentTool.d.ts.map +1 -1
  74. package/dist/connectors/jira/attachmentTool.js +16 -0
  75. package/dist/connectors/jira/attachmentTool.js.map +1 -1
  76. package/dist/connectors/jira/client.d.ts +36 -0
  77. package/dist/connectors/jira/client.d.ts.map +1 -1
  78. package/dist/connectors/jira/client.js +46 -5
  79. package/dist/connectors/jira/client.js.map +1 -1
  80. package/dist/connectors/jira/config.d.ts +13 -17
  81. package/dist/connectors/jira/config.d.ts.map +1 -1
  82. package/dist/connectors/jira/config.js +15 -33
  83. package/dist/connectors/jira/config.js.map +1 -1
  84. package/dist/connectors/jira/connector.d.ts +10 -1
  85. package/dist/connectors/jira/connector.d.ts.map +1 -1
  86. package/dist/connectors/jira/connector.js +90 -16
  87. package/dist/connectors/jira/connector.js.map +1 -1
  88. package/dist/connectors/jira/contextLedger.d.ts +7 -0
  89. package/dist/connectors/jira/contextLedger.d.ts.map +1 -1
  90. package/dist/connectors/jira/contextLedger.js +18 -0
  91. package/dist/connectors/jira/contextLedger.js.map +1 -1
  92. package/dist/connectors/jira/contextPreamble.d.ts.map +1 -1
  93. package/dist/connectors/jira/contextPreamble.js +6 -3
  94. package/dist/connectors/jira/contextPreamble.js.map +1 -1
  95. package/dist/connectors/jira/inbound.d.ts +72 -10
  96. package/dist/connectors/jira/inbound.d.ts.map +1 -1
  97. package/dist/connectors/jira/inbound.js +204 -36
  98. package/dist/connectors/jira/inbound.js.map +1 -1
  99. package/dist/connectors/jira/issueBlocks.d.ts +31 -3
  100. package/dist/connectors/jira/issueBlocks.d.ts.map +1 -1
  101. package/dist/connectors/jira/issueBlocks.js +108 -29
  102. package/dist/connectors/jira/issueBlocks.js.map +1 -1
  103. package/dist/connectors/jira/issueContext.d.ts +11 -5
  104. package/dist/connectors/jira/issueContext.d.ts.map +1 -1
  105. package/dist/connectors/jira/issueContext.js +23 -6
  106. package/dist/connectors/jira/issueContext.js.map +1 -1
  107. package/dist/connectors/jira/issueDelta.d.ts +3 -0
  108. package/dist/connectors/jira/issueDelta.d.ts.map +1 -1
  109. package/dist/connectors/jira/issueDelta.js +15 -6
  110. package/dist/connectors/jira/issueDelta.js.map +1 -1
  111. package/dist/connectors/jira/mediaPlaceholders.d.ts +2 -0
  112. package/dist/connectors/jira/mediaPlaceholders.d.ts.map +1 -1
  113. package/dist/connectors/jira/mediaPlaceholders.js +16 -3
  114. package/dist/connectors/jira/mediaPlaceholders.js.map +1 -1
  115. package/dist/connectors/jira/prompt.d.ts +4 -0
  116. package/dist/connectors/jira/prompt.d.ts.map +1 -1
  117. package/dist/connectors/jira/prompt.js +20 -1
  118. package/dist/connectors/jira/prompt.js.map +1 -1
  119. package/dist/connectors/jira/sessionKeyCodec.d.ts +2 -0
  120. package/dist/connectors/jira/sessionKeyCodec.d.ts.map +1 -1
  121. package/dist/connectors/jira/sessionKeyCodec.js +5 -0
  122. package/dist/connectors/jira/sessionKeyCodec.js.map +1 -1
  123. package/dist/connectors/jira/trigger.d.ts +16 -3
  124. package/dist/connectors/jira/trigger.d.ts.map +1 -1
  125. package/dist/connectors/jira/trigger.js +17 -2
  126. package/dist/connectors/jira/trigger.js.map +1 -1
  127. package/dist/connectors/jira/triggerLog.d.ts +12 -3
  128. package/dist/connectors/jira/triggerLog.d.ts.map +1 -1
  129. package/dist/connectors/jira/triggerLog.js +18 -2
  130. package/dist/connectors/jira/triggerLog.js.map +1 -1
  131. package/dist/connectors/jira/trustedGroup.d.ts +54 -0
  132. package/dist/connectors/jira/trustedGroup.d.ts.map +1 -0
  133. package/dist/connectors/jira/trustedGroup.js +98 -0
  134. package/dist/connectors/jira/trustedGroup.js.map +1 -0
  135. package/dist/connectors/telegram/commands/autoContinueLimits.d.ts +3 -0
  136. package/dist/connectors/telegram/commands/autoContinueLimits.d.ts.map +1 -1
  137. package/dist/connectors/telegram/commands/autoContinueLimits.js +15 -45
  138. package/dist/connectors/telegram/commands/autoContinueLimits.js.map +1 -1
  139. package/dist/connectors/telegram/commands/claudeAccounts.d.ts +58 -0
  140. package/dist/connectors/telegram/commands/claudeAccounts.d.ts.map +1 -0
  141. package/dist/connectors/telegram/commands/claudeAccounts.js +591 -0
  142. package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -0
  143. package/dist/connectors/telegram/commands/fallbackChain.d.ts +49 -0
  144. package/dist/connectors/telegram/commands/fallbackChain.d.ts.map +1 -0
  145. package/dist/connectors/telegram/commands/fallbackChain.js +624 -0
  146. package/dist/connectors/telegram/commands/fallbackChain.js.map +1 -0
  147. package/dist/connectors/telegram/commands/modelProviders.d.ts +23 -1
  148. package/dist/connectors/telegram/commands/modelProviders.d.ts.map +1 -1
  149. package/dist/connectors/telegram/commands/modelProviders.js +131 -6
  150. package/dist/connectors/telegram/commands/modelProviders.js.map +1 -1
  151. package/dist/i18n/de.d.ts.map +1 -1
  152. package/dist/i18n/de.js +137 -9
  153. package/dist/i18n/de.js.map +1 -1
  154. package/dist/i18n/en.d.ts.map +1 -1
  155. package/dist/i18n/en.js +137 -9
  156. package/dist/i18n/en.js.map +1 -1
  157. package/dist/i18n/es.d.ts.map +1 -1
  158. package/dist/i18n/es.js +137 -9
  159. package/dist/i18n/es.js.map +1 -1
  160. package/dist/i18n/fr.d.ts.map +1 -1
  161. package/dist/i18n/fr.js +137 -9
  162. package/dist/i18n/fr.js.map +1 -1
  163. package/dist/i18n/hi.d.ts.map +1 -1
  164. package/dist/i18n/hi.js +137 -9
  165. package/dist/i18n/hi.js.map +1 -1
  166. package/dist/i18n/ja.d.ts.map +1 -1
  167. package/dist/i18n/ja.js +137 -9
  168. package/dist/i18n/ja.js.map +1 -1
  169. package/dist/i18n/ka.d.ts.map +1 -1
  170. package/dist/i18n/ka.js +137 -9
  171. package/dist/i18n/ka.js.map +1 -1
  172. package/dist/i18n/pt.d.ts.map +1 -1
  173. package/dist/i18n/pt.js +137 -9
  174. package/dist/i18n/pt.js.map +1 -1
  175. package/dist/i18n/ru.d.ts.map +1 -1
  176. package/dist/i18n/ru.js +137 -9
  177. package/dist/i18n/ru.js.map +1 -1
  178. package/dist/i18n/uk.d.ts.map +1 -1
  179. package/dist/i18n/uk.js +137 -9
  180. package/dist/i18n/uk.js.map +1 -1
  181. package/dist/i18n/uz.d.ts.map +1 -1
  182. package/dist/i18n/uz.js +137 -9
  183. package/dist/i18n/uz.js.map +1 -1
  184. package/dist/i18n/zh.d.ts.map +1 -1
  185. package/dist/i18n/zh.js +137 -9
  186. package/dist/i18n/zh.js.map +1 -1
  187. package/dist/index.js +1 -1
  188. package/dist/index.js.map +1 -1
  189. package/dist/installManager.d.ts +16 -2
  190. package/dist/installManager.d.ts.map +1 -1
  191. package/dist/installManager.js +42 -12
  192. package/dist/installManager.js.map +1 -1
  193. package/dist/instanceLock.d.ts.map +1 -1
  194. package/dist/instanceLock.js +10 -8
  195. package/dist/instanceLock.js.map +1 -1
  196. package/dist/legacyMigration.d.ts +69 -0
  197. package/dist/legacyMigration.d.ts.map +1 -0
  198. package/dist/legacyMigration.js +338 -0
  199. package/dist/legacyMigration.js.map +1 -0
  200. package/dist/legacyNames.d.ts +107 -0
  201. package/dist/legacyNames.d.ts.map +1 -0
  202. package/dist/legacyNames.js +230 -0
  203. package/dist/legacyNames.js.map +1 -0
  204. package/dist/platform/answerSink.d.ts +5 -0
  205. package/dist/platform/answerSink.d.ts.map +1 -1
  206. package/dist/platform/answerSink.js.map +1 -1
  207. package/dist/requests/answerRequest.d.ts +2 -0
  208. package/dist/requests/answerRequest.d.ts.map +1 -1
  209. package/dist/requests/answerRequest.js +3 -1
  210. package/dist/requests/answerRequest.js.map +1 -1
  211. package/dist/requests/answerStyle.d.ts +11 -0
  212. package/dist/requests/answerStyle.d.ts.map +1 -0
  213. package/dist/requests/answerStyle.js +14 -0
  214. package/dist/requests/answerStyle.js.map +1 -0
  215. package/dist/requests/answerTail.d.ts.map +1 -1
  216. package/dist/requests/answerTail.js +2 -0
  217. package/dist/requests/answerTail.js.map +1 -1
  218. package/dist/requests/requestHeader.d.ts.map +1 -1
  219. package/dist/requests/requestHeader.js +3 -0
  220. package/dist/requests/requestHeader.js.map +1 -1
  221. package/dist/requests/requestLedger.js +1 -1
  222. package/dist/requests/requestLedger.js.map +1 -1
  223. package/dist/requests/types.d.ts +3 -1
  224. package/dist/requests/types.d.ts.map +1 -1
  225. package/dist/scheduler/mcpSurface.d.ts +17 -1
  226. package/dist/scheduler/mcpSurface.d.ts.map +1 -1
  227. package/dist/scheduler/mcpSurface.js +86 -13
  228. package/dist/scheduler/mcpSurface.js.map +1 -1
  229. package/dist/state.d.ts +175 -2
  230. package/dist/state.d.ts.map +1 -1
  231. package/dist/state.js +303 -2
  232. package/dist/state.js.map +1 -1
  233. package/dist/types.d.ts +7 -0
  234. package/dist/types.d.ts.map +1 -1
  235. package/dist/utils/autoContinueOnLimit.d.ts +7 -0
  236. package/dist/utils/autoContinueOnLimit.d.ts.map +1 -1
  237. package/dist/utils/autoContinueOnLimit.js +10 -0
  238. package/dist/utils/autoContinueOnLimit.js.map +1 -1
  239. package/dist/utils/claudeAccountPickerPlan.d.ts +85 -0
  240. package/dist/utils/claudeAccountPickerPlan.d.ts.map +1 -0
  241. package/dist/utils/claudeAccountPickerPlan.js +123 -0
  242. package/dist/utils/claudeAccountPickerPlan.js.map +1 -0
  243. package/dist/utils/claudeLimitSwitch.d.ts +40 -0
  244. package/dist/utils/claudeLimitSwitch.d.ts.map +1 -0
  245. package/dist/utils/claudeLimitSwitch.js +54 -0
  246. package/dist/utils/claudeLimitSwitch.js.map +1 -0
  247. package/dist/utils/claudeProfileUsageLines.d.ts +15 -0
  248. package/dist/utils/claudeProfileUsageLines.d.ts.map +1 -0
  249. package/dist/utils/claudeProfileUsageLines.js +42 -0
  250. package/dist/utils/claudeProfileUsageLines.js.map +1 -0
  251. package/dist/utils/claudeProfiles.d.ts +124 -0
  252. package/dist/utils/claudeProfiles.d.ts.map +1 -0
  253. package/dist/utils/claudeProfiles.js +304 -0
  254. package/dist/utils/claudeProfiles.js.map +1 -0
  255. package/dist/utils/claudeStreamJson.d.ts +13 -1
  256. package/dist/utils/claudeStreamJson.d.ts.map +1 -1
  257. package/dist/utils/claudeStreamJson.js +13 -0
  258. package/dist/utils/claudeStreamJson.js.map +1 -1
  259. package/dist/utils/claudeUsage.d.ts +209 -0
  260. package/dist/utils/claudeUsage.d.ts.map +1 -0
  261. package/dist/utils/claudeUsage.js +413 -0
  262. package/dist/utils/claudeUsage.js.map +1 -0
  263. package/dist/utils/claudeUsageRefresher.d.ts +44 -0
  264. package/dist/utils/claudeUsageRefresher.d.ts.map +1 -0
  265. package/dist/utils/claudeUsageRefresher.js +95 -0
  266. package/dist/utils/claudeUsageRefresher.js.map +1 -0
  267. package/dist/utils/fallbackBridge.d.ts +32 -0
  268. package/dist/utils/fallbackBridge.d.ts.map +1 -0
  269. package/dist/utils/fallbackBridge.js +62 -0
  270. package/dist/utils/fallbackBridge.js.map +1 -0
  271. package/dist/utils/fallbackChain.d.ts +299 -0
  272. package/dist/utils/fallbackChain.d.ts.map +1 -0
  273. package/dist/utils/fallbackChain.js +542 -0
  274. package/dist/utils/fallbackChain.js.map +1 -0
  275. package/dist/utils/jsonStreamHost.d.ts +14 -3
  276. package/dist/utils/jsonStreamHost.d.ts.map +1 -1
  277. package/dist/utils/jsonStreamHost.js +26 -5
  278. package/dist/utils/jsonStreamHost.js.map +1 -1
  279. package/dist/utils/modelRecentPlan.d.ts +56 -0
  280. package/dist/utils/modelRecentPlan.d.ts.map +1 -0
  281. package/dist/utils/modelRecentPlan.js +107 -0
  282. package/dist/utils/modelRecentPlan.js.map +1 -0
  283. package/dist/utils/openCodeCompactPlugin.d.ts +11 -3
  284. package/dist/utils/openCodeCompactPlugin.d.ts.map +1 -1
  285. package/dist/utils/openCodeCompactPlugin.js +37 -5
  286. package/dist/utils/openCodeCompactPlugin.js.map +1 -1
  287. package/dist/utils/threadStatusReport.d.ts +25 -1
  288. package/dist/utils/threadStatusReport.d.ts.map +1 -1
  289. package/dist/utils/threadStatusReport.js +24 -1
  290. package/dist/utils/threadStatusReport.js.map +1 -1
  291. package/examples/.env.example +7 -7
  292. package/examples/docker-compose.yml +15 -14
  293. package/package.json +3 -1
package/README.md CHANGED
@@ -1,13 +1,36 @@
1
1
  <h1 align="center">Charness</h1>
2
2
 
3
- <p align="center"><em>formerly TelegramCode</em></p>
3
+ <p align="center">
4
+ <a href="https://www.npmjs.com/package/charness"><img src="https://img.shields.io/npm/v/charness?logo=npm" alt="npm version"></a>
5
+ <a href="https://www.npmjs.com/package/charness"><img src="https://img.shields.io/node/v/charness?logo=node.js" alt="Node.js version"></a>
6
+ <a href="https://github.com/olosegres/charness/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/charness" alt="license"></a>
7
+ </p>
8
+
9
+ <h2 align="center">Run multiple Claude Code / OpenCode agents and connect them to your Telegram or Jira.</h2>
4
10
 
5
- <h2 align="center">Telegram bot/group as a terminal for OpenCode, Claude Code — every thread like a terminal tab + scheduling, voice control</h2>
11
+ - **In Telegram** you control your agents through a bot or a group, so it becomes a terminal for OpenCode and Claude Code — every thread is like a terminal tab, plus scheduling and voice control.
12
+ - **In Jira** it starts an agent when you assign a ticket to a special user: the agent reads the description, comments and attachments and does the work according to the ticket's status — like a real employee.
13
+
14
+ <p align="center">It runs fine on your laptop. But it is called a <b>c</b>loud <b>harness</b> for a reason — put it on a server and your agents keep working while the laptop sleeps.</p>
6
15
 
7
16
  <p align="center">
8
17
  <img src="docs/images/hero-v2.png" alt="Charness — all your agents in Telegram; chat, code, ship; powerful slash commands" width="900" />
9
18
  </p>
10
19
 
20
+ ## What it does
21
+
22
+ ### Common (any surface)
23
+
24
+ These hold whichever surface you drive it from — the same core serves all of them:
25
+
26
+ - **Agent backends** — OpenCode (native server API over HTTP+SSE) and Claude Code (three backends — json-stream, per-turn and tmux)
27
+ - **Sleeping agents** — a Claude json-stream topic's process is stopped when idle (or after every turn in per-turn mode) and the next message resumes the same conversation by itself, prompt cache still warm
28
+ - **Several Claude accounts** — keep more than one Claude subscription signed in side by side and choose per topic which one a session runs on (`/accounts`); every account's usage windows are shown next to it. See [Several accounts](#several-accounts-accounts)
29
+ - **Waits out usage limits** — when the agent hits a usage / session limit the bot reads the reset time out of the error (honouring the timezone the provider quotes), waits, then tells the agent to continue by itself and pins the "work resumed" message so a muted topic still notifies you; `/limits` turns waiting off per topic or skips a single resume. With a **fallback chain** (`/limits`: other Claude accounts, OpenCode providers and models, in your order of preference) the limit notice offers «🔁 Switch to …» buttons to move the topic to the next entry with room and continue at once — or the bot does it by itself when you turn switching on; across backends the new agent gets a context bridge with the previous one's last turns
30
+ - **Restart-safe** — agents run as external processes (tmux, `opencode serve`) that the bot re-adopts after a restart instead of killing them; a prompt sent while a session boots is buffered and replayed. See [Restart behaviour](#restart-behaviour)
31
+
32
+ ### Telegram
33
+
11
34
  Charness turns Telegram into a terminal for running agentic CLIs. Open as
12
35
  many tabs as you need — even two on the same project for parallel work — and
13
36
  drive the agents from your phone or tablet, voice messages included.
@@ -16,13 +39,9 @@ Think **OpenClaw for vibe coding**, driven entirely from Telegram: no complex
16
39
  setup, no extra dashboards — direct access to your own **OpenCode** /
17
40
  **Claude Code** running on your machine or server.
18
41
 
19
- ### Features
20
-
21
42
  - **Simple setup & management** — install the CLI, put your bot token in one `.env`, bind a topic to a folder, and run; everything after is managed from Telegram — no dashboards
22
43
  - **Multi-thread / topic** — one topic per directory with your agent; two topics can share one folder for parallel work — run almost unlimited agents in parallel
23
44
  - **Two chat surfaces** — forum-group topics and the owner's bot DM, both served at once by default, with tabs on either
24
- - **Agent backends** — OpenCode (native server API over HTTP+SSE) and Claude Code (three backends — json-stream, per-turn and tmux)
25
- - **Sleeping agents** — a Claude json-stream topic's process is stopped when idle (or after every turn in per-turn mode) and the next message resumes the same conversation by itself, prompt cache still warm
26
45
  - **Raw terminal** — `/terminal` binds a topic to a real `$SHELL` in the project folder
27
46
  - **Notifications** — when the agent asks a question, the bot pins that message so even a muted topic notifies you: the pin pierces mute, giving exactly one notification per question (unpinned once you answer)
28
47
  - **Scheduled & self-driving runs** — `/schedule` arms cron / one-shot / N-times jobs per topic, and the agent can schedule *itself* via injected MCP tools: nightly reviews, recurring reports, a "finish this tomorrow at 9" hand-off. Each job fires as a fresh session with your prompt; restart-safe, with one catch-up for a run missed while the bot was down
@@ -34,9 +53,8 @@ setup, no extra dashboards — direct access to your own **OpenCode** /
34
53
  - **Time-aware prompts** — `/timestamps on` prepends each forwarded prompt's send time (local-offset ISO), so a days-long session knows what "yesterday" or "2 days ago" means; agent-facing only, per topic
35
54
  - **Reply context** — reply to a message in a topic and the quoted text is folded into the prompt the agent receives, so it sees what you point at without re-pasting; works for text, voice and files (a photo, a document, an album…), both agents; a reply TO a photo, file or voice note names it, with the path of the bot's saved copy when it has one
36
55
  - **Your timezone** — `/timezone Europe/Moscow` once, and schedules fire at your wall-clock time while the agent is told what time it actually is; no server-clock guessing
37
- - **Waits out usage limits** — when the agent hits a usage / session limit the bot reads the reset time out of the error (honouring the timezone the provider quotes), waits, then tells the agent to continue by itself and pins the "work resumed" message so a muted topic still notifies you; `/auto_continue_limits` turns it off per topic or skips a single resume
38
56
 
39
- ## Two surfaces: group topics, bot DM, or both
57
+ #### Two surfaces: group topics, bot DM, or both
40
58
 
41
59
  The bot serves two Telegram surfaces:
42
60
 
@@ -50,289 +68,22 @@ The bot serves two Telegram surfaces:
50
68
  the reply grows in place in one message instead of arriving as a flood of
51
69
  separate messages.
52
70
 
53
- ## Where to run the bot server
54
-
55
- The bot runs anywhere the agent CLIs run:
71
+ ## Quick start
56
72
 
57
- - **Your own working machine** — the simplest start: launch `telegramcode`
58
- from your projects parent folder and your laptop/desktop becomes the
59
- backend. The catch: agents are only reachable while the machine is on and
60
- awake.
61
- - **A remote server (cloud VPS/VDS or bare metal)** — the more convenient
62
- setup: organize your working environment there once (git + your repos,
63
- Claude Code / OpenCode, `telegramcode`) and you get an always-on dev box you
64
- drive from any device through Telegram — phone, tablet, voice. When picking
65
- one, a bare-metal server without virtualization beats a virtualized VPS/VDS:
66
- its NVMe drives are usually much faster, which matters once you also build
67
- and run a dev server there, not just the agents. Classic terminal access to
68
- the very same Claude sessions stays available over SSH — run plain `claude`
69
- in the project folder: it reads the same `~/.claude/projects/<cwd-slug>/`
70
- session store the bot uses, so a session started in a Telegram thread can
71
- be picked up in the terminal and vice versa.
73
+ 1. `npm install -g charness` (needs Node ≥ 22.12).
74
+ 2. Put your bot token (from [@BotFather](https://t.me/BotFather)) into `~/.config/charness/.env` as
75
+ `TELEGRAM_BOT_TOKEN=…`.
76
+ 3. Run `charness` from the folder that holds your projects: `cd ~/projects && charness`.
77
+ 4. In your Telegram group (or the bot's DM): `/bind <subfolder>` in a topic, then `/claude` or `/opencode` and
78
+ talk to the agent — text or voice.
72
79
 
73
- ## Quick Start
74
-
75
- Five steps: install the CLI, create a bot, (optionally) set up a group, launch
76
- from your projects folder, bind a topic to an agent.
77
-
78
- > **[manual]** tags a step you must do by hand in the Telegram app — an agent
79
- > running on the host can't do it for you. Everything unmarked is a host-side
80
- > command (or file edit) that can be automated.
81
-
82
- ### 1. Install the CLI
83
-
84
- ```bash
85
- npm install -g charness # needs Node ≥ 22.12
86
- ```
80
+ Full setup — Telegram, Jira, environment, updating: [SETUP.md](SETUP.md)
87
81
 
88
- This registers the `telegramcode` command (it keeps the project's former name;
89
- `charness` works too). Coming from the old `telegramcode` npm package (2.x)?
90
- Run `npm uninstall -g telegramcode` first: both install the same commands. The
91
- config, `DATA_DIR` and sessions carry over as they are.
82
+ ## Reference
92
83
 
93
- Prefer the whole bot in a container, isolated from the host? Use
94
- [Run with Docker](#run-with-docker) instead — the bot and group steps are the
95
- same. To hack on the bot itself, see [Run from source](#run-from-source).
96
-
97
- ### 2. Create the bot
98
-
99
- **[manual]** In Telegram, with @BotFather:
100
-
101
- 1. Message [@BotFather](https://t.me/BotFather), send `/newbot`, follow prompts.
102
- 2. Save the token (`123456789:ABCdef...`).
103
- 3. **Disable privacy mode** — same chat: `/setprivacy` → pick this bot →
104
- `Disable`. Without this the bot only sees `/commands`, not free-form text.
105
-
106
- <p><img src="docs/images/01-botfather.png" width="360" alt="@BotFather: /newbot to get the token, then /setprivacy → this bot → Disable" /></p>
107
-
108
- Put the token where the bot reads it — the global config `.env`:
109
-
110
- ```bash
111
- mkdir -p ~/.config/telegramcode
112
- $EDITOR ~/.config/telegramcode/.env
113
- ```
114
-
115
- ```dotenv
116
- # ~/.config/telegramcode/.env — the one place your keys live
117
- TELEGRAM_BOT_TOKEN=123456789:ABCdef...
118
- # GROQ_API_KEY=... # optional: free voice transcription
119
- # OWNER_USER_ID=... # set to drive the bot from its DM (step 3)
120
- ```
121
-
122
- All keys the bot needs live in this one file — the bot token and the optional
123
- `GROQ_API_KEY` for voice sit side by side, no separate stores. (Agent
124
- provider auth is the exception, and lives inside the agents themselves:
125
- `claude login` for Claude, `/connect` or OpenCode's own config for OpenCode —
126
- see [Environment Variables](#environment-variables).) The wrapper loads env
127
- from two locations, in order — a global base and an optional per-project
128
- override:
129
-
130
- 1. `~/.config/telegramcode/.env` — base, set once, used everywhere.
131
- 2. `$PWD/.env` — per-project tweaks (last write wins).
132
-
133
- The full annotated template is `.env.example` (shipped with the package and in
134
- the repo).
135
-
136
- ### 3. Set up a group (optional) or DM
137
-
138
- The bot serves a **forum supergroup**, the **owner's private chat (DM)**, or
139
- both at once (`CHAT_MODE`, default `both`). The group is the nicest UX — a
140
- visible topic list, per-topic names/icons, quick agent switching — but it is
141
- **optional**: with `OWNER_USER_ID` set you can run entirely from the bot's DM.
142
-
143
- **To use a group (recommended)** — **[manual]**, all in the Telegram client:
144
-
145
- 1. In a Telegram client: `New Group` → name it → add the bot.
146
- 2. Open group settings → enable **Topics** (Forum mode).
147
- 3. Promote the bot to admin with these rights:
148
- - `Manage Topics` (required — bind/create threads)
149
- - `Delete Messages` (for `/clear_messages`)
150
- - `Pin Messages` (per-thread status banner + question alerts; `/doctor`
151
- warns if missing, but the bot still runs without it)
152
- 4. **Remove the bot from the group and add it again.** Telegram caches the
153
- privacy-mode flag on join; without re-adding, the bot keeps private-mode and
154
- ignores free-form messages (see
155
- [Troubleshooting → Bot doesn't see text](#bot-doesnt-see-text)).
156
-
157
- <p>
158
- <img src="docs/images/02-enable-topics.png" width="360" alt="Group settings → Topics toggle enabled (Forum mode)" />
159
- <img src="docs/images/03-promote-admin.png" width="360" alt="Bot admin rights: Manage Topics, Delete Messages, Pin Messages ticked" />
160
- </p>
161
-
162
- The group **id is automatic** — leave `ALLOWED_GROUP_ID` empty and the bot
163
- auto-pairs with the first forum supergroup an admin talks to it from (the
164
- `-100…` id is saved to `state.json`; re-point later with `/pair`). To pin a
165
- specific id by hand, set `ALLOWED_GROUP_ID` to the numeric value (a group
166
- **name** is not accepted) — that also disables auto-pairing. **Access control:**
167
- whoever is a creator/administrator of that group may drive the bot — there is no
168
- separate allow-list.
169
-
170
- **To use the DM instead (or as well):** **[manual]** send `/start` to
171
- [@userinfobot](https://t.me/userinfobot) for your numeric user id, then add it
172
- (host-side) to the same `.env`:
173
-
174
- ```dotenv
175
- OWNER_USER_ID=987654321
176
- ```
177
-
178
- With the default `CHAT_MODE=both`, an unset `OWNER_USER_ID` just leaves the DM
179
- surface inert (group-only); set it and the DM lights up alongside the group. Use
180
- `CHAT_MODE=dm` to skip the group entirely.
181
-
182
- ### 4. Launch from your projects folder
183
-
184
- ```bash
185
- cd ~/projects && telegramcode
186
- ```
84
+ ### Commands (Telegram)
187
85
 
188
- That `$PWD` — the parent folder holding your repositories — is the folder the
189
- bot works in; each topic binds to a subfolder under it. There's nothing else to
190
- configure for it. A single-instance lockfile (`$DATA_DIR/instance.lock`) stops a
191
- second bot starting under the same user; stale locks (after `kill -9`) are
192
- reclaimed automatically.
193
-
194
- ### 5. Bind a topic and talk to an agent
195
-
196
- This step is **[manual]** — it all happens inside the Telegram app.
197
-
198
- **In the group:**
199
-
200
- 1. Open the group; in the General topic send `/ls` — the bot lists subfolders
201
- under the work root.
202
- 2. Create a topic (the `+` button).
203
- 3. In the new topic: `/bind <subdir>` (auto-bound if the topic name matches a
204
- subdir).
205
- 4. `/claude` or `/opencode` → talk to the agent (text or voice).
206
-
207
- <p><img src="docs/images/04-bind-and-run.png" width="360" alt="A topic bound with /bind, /claude started, and the agent replying" /></p>
208
-
209
- **In the DM:** the same commands, one thread per agent — `/ls`,
210
- `/bind <subdir>`, then `/claude` or `/opencode`.
211
-
212
- Then: `/quit` ends the session; bare `/bind` inspects/reconfigures the binding;
213
- `/clear_messages` deletes the topic's bot messages.
214
-
215
- > **Continue the same session from a terminal.** No wrapper needed: run
216
- > `claude --dangerously-skip-permissions` in the project folder. It is the same
217
- > binary and the same `~/.claude/projects/<cwd-slug>/` session store the bot
218
- > uses, so a thread started in Telegram can be picked up with `claude --resume`
219
- > and vice versa.
220
-
221
- ### Run with Docker
222
-
223
- The whole bot runs in one container: the bot itself, tmux, every agent it starts (Claude Code in any backend,
224
- `/terminal`, OpenCode and its server) and the bot's MCP server. Everything works as on a host; the host only
225
- lends the container the folders it mounts, so the bot and its agents see nothing else of the machine.
226
-
227
- ```
228
- host container telegramcode-<instance>
229
- your instance env file (tokens) ── ro ──▶ the bot (hot mode) + a restart loop
230
- DATA_DIR, WORK_ROOT ──────▶ tmux, the agents, OpenCode, the bot MCP
231
- a clone of this repository ──────▶ /opt/telegramcode
232
- the agents' home folder ──────▶ /home/telegramcode: their Claude / OpenCode
233
- login, sessions and CLI installs
234
- ```
235
-
236
- 1. **Image and checkout.** Clone the repository for the container (a full clone of its own, not a worktree and
237
- not the checkout a host instance runs from) and build the image from it:
238
-
239
- ```bash
240
- git clone https://github.com/olosegres/charness /srv/telegramcode/checkout
241
- cd /srv/telegramcode/checkout && docker build -t telegramcode -f docker/Dockerfile .
242
- ```
243
-
244
- The image holds only system tools (tmux, git, ffmpeg, ripgrep, …) and the yarn the checkout's `package.json`
245
- names (build from the checkout's root, which is how the build reads it; rebuild after a yarn bump so no
246
- container has to download it). On first start the container installs the checkout's dependencies for the
247
- image and builds it; the bot installs Claude Code and OpenCode into the agents' home.
248
- 2. **Instance env file**, as for a host install (`TELEGRAM_BOT_TOKEN`, `DATA_DIR`, `WORK_ROOT`, …). It stays on
249
- the host and is mounted read-only. Every host path it names (`DATA_DIR`, `WORK_ROOT`, `TMUX_TMPDIR`, …) is
250
- mounted at the SAME path, so `state.json`, sessions and file paths stay valid inside and an instance can move
251
- between host and container unchanged.
252
- 3. **Run** (or use `examples/docker-compose.yml`):
253
-
254
- ```bash
255
- docker run -d --name telegramcode-main --hostname telegramcode-main \
256
- --restart unless-stopped --stop-timeout 60 \
257
- -v /srv/telegramcode/checkout:/opt/telegramcode \
258
- -v /srv/telegramcode/home:/home/telegramcode \
259
- -v /srv/telegramcode/data:/srv/telegramcode/data \
260
- -v /srv/projects:/srv/projects \
261
- -v /srv/telegramcode/instance.env:/srv/telegramcode/instance.env:ro \
262
- -e ENV_FILE=/srv/telegramcode/instance.env \
263
- telegramcode
264
- ```
265
-
266
- No port is published: Telegram is long polling, and the bot's MCP server and the OpenCode server listen on the
267
- container's own loopback. Keep the `--hostname` fixed and unique per instance: the instance lock tells its own
268
- restarted container from another machine by it.
269
- 4. **Log the agents in once**, with the account the agents should use (a separate one is best):
270
- `docker exec -it telegramcode-main claude`, then `/login` (or `/login` in a topic). OpenCode: `/connect` in a
271
- topic, or `docker exec -it telegramcode-main opencode auth login`. Never copy your own `~/.claude` login in:
272
- a second holder of its refresh token can log the first one out. For git, put a `.gitconfig` and an SSH key of
273
- their own into the agents' home.
274
-
275
- Running it:
276
-
277
- - **Restart the bot only** (agents keep running and are adopted): `docker exec telegramcode-main
278
- telegramcode-restart-bot`. A crashed bot is restarted by the container after 20 s.
279
- - **Update the bot**: `docker exec telegramcode-main /opt/telegramcode/scripts/self-update.sh` (by hand or from
280
- a timer on the host); hot mode picks the change up. A change to `src/cli.ts`, `src/cli/hot.ts` or `nodemon.json`
281
- needs the bot restart above. **Update Claude Code / OpenCode**: they update themselves in the agents' home, or
282
- `docker exec telegramcode-main npm install -g @anthropic-ai/claude-code` / `… opencode-ai`.
283
- - **A container restart is a reboot**: every agent process ends; each conversation resumes with its next message.
284
- - **Rootless Docker** (recommended): the container's root is your user, so everything written on the mounts is
285
- yours. **Rootful Docker**: add `--user "$(id -u):$(id -g)"` and give that user the agents' home.
286
- - **Moving a host instance in**: stop it first (the lock refuses a lock written on another host), mount its
287
- folders at their paths, and copy its conversations' folders from `~/.claude/projects/` into the agents' home
288
- `.claude/projects/` — without them each conversation starts a fresh session on its next message.
289
- - **What the agents can read**: everything mounted, the instance env file with its tokens, `DATA_DIR` and the
290
- checkout included. The container keeps the rest of the host out of reach; running the agents as a second user
291
- inside the container would close that gap later.
292
-
293
- ### Run from source
294
-
295
- To hack on the bot itself:
296
-
297
- ```bash
298
- git clone https://github.com/olosegres/charness && cd charness
299
- yarn install && yarn build
300
- npm install -g . # registers the `telegramcode` (and `charness`) command
301
- ```
302
-
303
- Shortcut: `yarn install-link` runs `yarn install && yarn build && npm link` in
304
- one shot — `npm link` symlinks the global `telegramcode` to this folder, so
305
- later rebuilds (`yarn build`) are picked up without re-installing. Config and
306
- launch are identical to steps 2–5 above.
307
-
308
- ## Required files structure
309
-
310
- Launch `telegramcode` from the parent folder that holds your project repos —
311
- that `$PWD` is the work root, and every topic binds to a subfolder under it:
312
-
313
- ```
314
- $PWD=/home/user/src ← run the bot here ($PWD = work root)
315
- ├── projectA/ ← Topic "projectA" (claude)
316
- ├── projectB/ ← Topic "projB-frontend" (claude)
317
- │ ← Topic "projB-backend" (opencode) ← one folder, two topics
318
- │ ← Topic "projB-refactor" (claude)
319
- └── projectC/ ← Topic "projectC" (opencode)
320
-
321
- Telegram forum supergroup
322
- ├── Bot is admin with can_manage_topics + can_delete_messages + can_pin_messages
323
- └── Routes each topic by (chatId, threadId) → remembered in state.json
324
- ```
325
-
326
- **What the bot remembers (`state.json`).** So a restart is seamless, the bot
327
- saves which topic is bound to which folder, each topic's live agent session (to
328
- re-attach it after a reboot), your per-topic preferences (agent, model,
329
- reasoning effort, language, display verbosity), scheduled prompts, and the
330
- paired group id. This file lives in `DATA_DIR` (default `~/.telegramCode`) and
331
- is written safely, so a crash can't corrupt it.
332
-
333
- ## Commands
334
-
335
- ### In any topic
86
+ #### In any topic
336
87
 
337
88
  Most commands work in any topic; a binding (`/bind`) is required only to
338
89
  actually start an agent or terminal in the folder.
@@ -340,13 +91,12 @@ actually start an agent or terminal in the folder.
340
91
  | Command | Description |
341
92
  |---|---|
342
93
  | `/claude`, `/opencode`, `/oc` | Start agent in this topic's bound folder |
343
- | `/terminal` | Open a raw `$SHELL` in the bound folder — see [Raw terminal](#raw-terminal-terminal) |
94
+ | `/terminal` | Open a raw `$SHELL` in the bound folder — see [Raw terminal](#raw-terminal-terminal-telegram) |
344
95
  | `/claude_mode` | Switch this topic's Claude backend (json-stream ⇄ per-turn ⇄ tmux-scrape); bare shows a picker — see [Claude Code backends](#claude-code-backends-claude_mode) |
345
- | `/model` | Switch model through a two-level picker: providers, then that provider's models (10 per page). Each provider row has a 🙈 to hide it from the picker (bot-wide, persisted; 👁 brings it back) — `/model <provider/model>` still reaches a hidden provider. If OpenCode is waiting on an old provider's retry, the next prompt interrupts that wait and starts with the selected model instead of sitting queued behind it |
346
- | `/connect [provider]` | Connect an OpenCode provider (OpenAI by default; for example `/connect openrouter`). Special OAuth methods are shown when available; ordinary catalog providers ask for an API key and delete the key message from Telegram |
347
- | `/disconnect [provider]` | Remove an OpenCode provider's stored credentials; bare shows a picker of active providers. A provider OpenCode enables from an environment variable (e.g. `OPENROUTER_API_KEY`) stays active after this — the reply says so and points at hiding it in `/model` |
96
+ | `/model` | Switch model through a two-level picker: providers, then that provider's models (10 per page). On OpenCode the first row is 🕘 Recently used — a flat list of the models picked before, across providers (bot-wide, most recent first, up to 10), one tap to switch; it appears once something has been picked. Each provider row has a 🙈 to hide it from the picker (bot-wide, persisted; 👁 brings it back) — `/model <provider/model>` still reaches a hidden provider. If OpenCode is waiting on an old provider's retry, the next prompt interrupts that wait and starts with the selected model instead of sitting queued behind it |
97
+ | `/accounts` | Every account the bot works with, on one screen. **Claude accounts** (when you keep several subscriptions signed in): each profile with its email, plan (personal Pro/Max or corporate Team/Enterprise), how many topics use it and its usage windows, ✓ on the active one; tap a profile to switch this topic (a running session is restarted under it, same conversation — at the end of its turn if it is working); in **General** the pick becomes the default for all topics. Per profile: 🔑 signs it in again, 🗑 removes it (after a confirmation; for `default`, which IS `~/.claude`, «remove» signs it out — see below). The usage lines give each window's percentage USED and when it resets as a time from now (`5h 5% 🔄 in 4h · week 20% 🔄 in 5d 8h · Fable 4% 🔄 in 5d 8h`; «🔄 in 2h», «🔄 in 2d 1h», «🔄 in 30m»; Fable only on a plan that has its own weekly window); when the 5h window's reset is unknown the weekly one is shown in its place, and with no reset at all only the percentage. The hint paragraph under the account list says the percentages are used. «➕ Claude account» asks for a name and runs the sign-in. **OpenCode providers**: the connected ones are listed with a «🔌 Disconnect <provider>» button and a 🔑 (connect again) each (the disconnect asks, then removes the stored credentials; a provider OpenCode enables from an environment variable, e.g. `OPENROUTER_API_KEY`, stays active — the reply says so and points at hiding it in `/model`); «➕ OpenCode provider» asks for the provider id and continues with the connect flow (OAuth methods when available, otherwise an API key whose message is deleted from Telegram). What happens when an account hits a usage limit is set in `/limits`. Text forms: `/accounts add <name>`, `/accounts use <name>`, `/accounts login <name>`, `/accounts remove <name>`, `/accounts autoswitch on\|off`. `/account`, `/connect [provider [key]]` and `/disconnect [provider]` still work as hidden aliases (the menu lists only `/accounts`). See [Several accounts](#several-accounts-accounts) |
348
98
  | `/effort` | Set reasoning effort (per-thread) via inline buttons. Claude: native `/effort` levels (`low…ultracode`). OpenCode: the current model's variants, applied per-prompt. No env configuration |
349
- | `/verbosity` | Output-verbosity macro (`minimal\|short\|full`): sets the thinking, tool-results and sub-agent display prefs at once; `/thinking`, `/tool_results`, `/subagent` point-override afterwards. Mixed prefs show as "custom" in the picker. The picker's second row (or `/verbosity stream\|stream_answers\|answers`) sets what the topic SHOWS — "Stream only" (default), "Stream + answers" (the stream plus the agent's pinned answers) or "Answers only" (the pinned answers, no stream; an agent that keeps writing after its final answer is reminded once to send what matters); a switch applies from the next message, and `/status` names the view |
99
+ | `/verbosity` | Output-verbosity macro (`minimal\|short\|full`): sets the thinking, tool-results and sub-agent display prefs at once; `/thinking`, `/tool_results`, `/subagent` point-override afterwards. Mixed prefs show as "custom" in the picker. The picker's second row (or `/verbosity stream\|stream_answers\|answers`) sets what the topic SHOWS — "Stream only" (default), "Stream + answers" (the stream plus the agent's pinned answers) or "Answers only" (the pinned answers, no stream; an agent that keeps writing after its final answer is reminded once to send what matters); the answers are written like for a manager or QA — brief and to the point; a switch applies from the next message, and `/status` names the view |
350
100
  | `/thinking` | Chain-of-thought display: `full` keeps the reasoning, `short` collapses to "💭 thought for Ns", `minimal` keeps only the live working cue |
351
101
  | `/tool_results` | Completed tool-call output: `full` whole body, `short` capped (15 lines / 1200 chars), `minimal` transient 🔧 status only |
352
102
  | `/subagent` | Sub-agent transcript: status-only with a ticking elapsed counter (`minimal`/`short`), or streamed "🤖 ⤷" chunks (`full`) |
@@ -354,23 +104,23 @@ actually start an agent or terminal in the folder.
354
104
  | `/rename_session` | Rename the current live session (OpenCode; Claude transcripts have no title) |
355
105
  | `/quit`, `/q` | End the session — Claude: graceful double Ctrl+C; OpenCode/terminal: `stopSession`. Releases the persisted session id, so a bot restart won't auto-reattach it (resume later via `/sessions`). A topic whose agent process is gone but whose session is kept (it "sleeps": the next message, file, voice note, `/compact`, `/model` or `/effort` resumes it by itself) is released the same way |
356
106
  | `/new`, `/clear_session` | End the current session and start a fresh one (same adapter) |
357
- | `/status` | This thread's status: agent, bound folder and resolved workdir; a live session also shows the model it is actually running, effort, start time, runtime version and context use (anything the backend cannot report renders as unknown) |
107
+ | `/status` | This thread's status: agent, bound folder, the Claude account it runs on and the resolved workdir; a live session also shows the model it is actually running, effort, start time, runtime version and context use (anything the backend cannot report renders as unknown). On a Claude topic the account is its profile (name · email as in `/accounts`, marked ⛔ while it is at its limit, with a second row for a switch still pending); an OpenCode topic's model already names its provider |
358
108
  | `/output` | Last 500 lines of agent output (sent as at most 5 chunks; the overflow is reported as omitted) |
359
109
  | `/c`, `/y`, `/n` | Ctrl+C / "y" / "n" |
360
110
  | `/enter`, `/up`, `/down`, `/tab` | tmux key passthrough |
361
111
  | `/esc`, `/escape` | Send a raw Escape — interrupt the current turn / dismiss a selector |
362
- | `/schedule` | Schedule a prompt in free text — the agent parses the time and owns the job; see [Scheduler](#scheduler-schedule) |
363
- | `/reminders` | Reminders set with buttons only — the bot posts and pins them itself, with no agent involved; works in any topic, bound or not. See [Reminders](#reminders-reminders) |
112
+ | `/schedule` | Schedule a prompt in free text — the agent parses the time and owns the job; see [Scheduler](#scheduler-schedule-telegram) |
113
+ | `/reminders` | Reminders set with buttons only — the bot posts and pins them itself, with no agent involved; works in any topic, bound or not. See [Reminders](#reminders-reminders-telegram) |
364
114
  | `/clear_messages` | Delete bot messages in this topic (up to 48h, Telegram limit) |
365
115
  | `/clear` | Forwarded to the agent (Claude wipes context; OpenCode plain text) — not a bot command anymore. Also purges the topic's file-intake dir |
366
116
  | `/compact` | Compact the agent's context — a real, confirmed compaction on OpenCode and on the default (stream) Claude backend; the tmux Claude backend has the literal command forwarded (its TUI compacts); terminal: not supported |
367
117
  | `/compact_on_idle` | Toggle auto-compaction after ~55 min idle (Enable/Disable picker; `AGENT_IDLE_MINUTES` sets the window). Per topic; run it in **General** to set the default for all topics. On by default. Each idle compaction posts one short notice; the picker's «Show summary» / «Hide summary» row (the `/compact_summary` switch) adds the agent's full summary after it. Fires at most once per active period (until you write again); if a question was pending it is re-asked with tappable buttons after the compaction. On the json-stream backends the idle mark also STOPS the agent process, compaction or not — the topic sleeps and your next message resumes it (`/status` says so) |
368
118
  | `/compact_summary` | Toggle posting the agent's full summary after a compaction — `/compact`, the idle compaction and the agent's own `compact_conversation` (Enable/Disable picker). Per topic; run it in **General** to set the default for all topics. Off by default: a compaction ends in a short line. On OpenCode it also hides the summary OpenCode streams itself |
369
- | `/auto_continue_limits` | Toggle waiting out a usage / session limit and resuming this topic by itself (Enable/Disable picker). Per topic; run it in **General** to set the default for all topics. On by default. While a resume is waiting the picker also offers «⏭ Skip once» — drop that one resume without turning the mode off |
119
+ | `/limits` | Everything about a usage limit on one screen, with a short text: at the top each Claude account's **usage windows** exactly as `/accounts` shows them, under a «Usage (% used)» heading (`default — ⏱ 5h 5% 🔄 in 4h · week 20% 🔄 in 5d 8h · Fable 4% 🔄 in 5d 8h`; a signed-out account is named, one never polled is left out), then what the topic runs on and where its two settings come from. **Fallback models** — an ordered list of Claude accounts (with an optional model) and OpenCode providers with a model, top = preferred, where a topic continues when its agent hits a limit. One full-width button per entry (`1. Claude · work · opus ⛔ 14:00` — limited until, 🔒 not signed in, ❓ no longer offered, 🚫 left out of automatic switching, ✓ where the topic runs); a tap opens that entry in the same message with ⬆️ Up / ⬇️ Down, 🚫 Don't use / ✅ Use (a left-out entry stays usable by hand through `/model` and `/accounts`), 🗑 Remove and ⬅️ Back. Below the list: «➕ Add» (account or provider, then the model), «🔄 Fill from connected» (a draft from what is connected; entries you left out stay left out; asks first when a list exists), «🗑 Clear». The list is ONE instance-wide list and is editable from every topic. **Two settings** decide what a limit does: «🔁 Auto switch» — auto switch to a fallback model (OFF by default: the limit notice carries «🔁 Switch to …» buttons instead) and «⏳ Wait for reset» — wait for the reset and continue (ON by default; while a wait is armed the topic screen also offers «⏭ Skip once»). In General they are the defaults for all topics and each is one button that flips the value. In a regular topic each is one short full-width button showing the effective value (`🔁 Auto switch: ON`; one line of text above the list says where each value comes from — `🔁 as in General · ⏳ set for this topic`); a tap opens the setting in the same message with ON / OFF / «As in General (<the General value>)» — the topic's own choice marked ✓ — and ⬅️ Back, and a choice applies and returns to the screen. Switch ON: the topic moves to the first available entry at once. OFF: buttons on the notice, and if none is pressed the bot waits for the reset (waiting ON); both OFF: it only reports the limit. When every enabled entry, the current one included, is limited, the wait ends at the EARLIEST reset and the topic continues on that entry (the notice names it and the time). Text forms: `/limits rebuild`, `/limits clear`, `/limits switch on\|off\|same`, `/limits wait on\|off\|same`. `/fallback` and `/auto_continue_limits [on\|off]` still work as hidden aliases. See [Usage limits and the fallback models](#usage-limits-and-the-fallback-models-limits) |
370
120
  | `/bind` | Bare: current binding + folder picker, with «leave current dir» (the old `/unbind`) and «create new folder» buttons |
371
121
  | `/mcp` | List MCP servers active for this thread |
372
122
 
373
- ### Info / ops (work anywhere)
123
+ #### Info / ops (work anywhere)
374
124
 
375
125
  | Command | Description |
376
126
  |---|---|
@@ -378,7 +128,7 @@ actually start an agent or terminal in the folder.
378
128
  | `/help` | Context-aware help |
379
129
  | `/ls` | List the project subfolders of the folder the bot was launched from |
380
130
  | `/list` | List existing topics and their bindings |
381
- | `/status` | This topic's status; in General — a global view of all topics + active agents. A live non-General topic also reports the resolved workdir, the model actually running, runtime version and context use (unknown when the backend cannot report it) |
131
+ | `/status` | This topic's status; in General — a global view of all topics + active agents. A non-General topic also reports the account it runs on (Claude profile · email, ⛔ at its limit) and the resolved workdir; a live one the model actually running, runtime version and context use (unknown when the backend cannot report it) |
382
132
  | `/doctor` | Self-diagnose: admin rights, privacy mode, paths, CLIs |
383
133
  | `/version` | Versions: bot, claude, opencode, node, tmux |
384
134
  | `/whoami` | Show userId, chatId, threadId, isAllowed, binding |
@@ -388,13 +138,13 @@ actually start an agent or terminal in the folder.
388
138
  | `/timezone` | Set the timezone every clock the bot touches speaks in — schedules, agent time context, time renders. `/timezone Europe/Moscow`, `/timezone +04:00`, `/timezone auto` (host zone); bare opens a region → zone picker. Instance-wide, not per chat |
389
139
  | `/pair` | Bind this forum supergroup to the bot (re-point auto-pairing) — works from any topic of the target group; a numeric `ALLOWED_GROUP_ID` env locks pairing |
390
140
 
391
- ### General-only
141
+ #### General-only
392
142
 
393
143
  | Command | Description |
394
144
  |---|---|
395
145
  | `/quit-all`, `/quitall` | End every active agent in every bound topic (also releases their session ids) |
396
146
 
397
- ### Natural language
147
+ #### Natural language
398
148
 
399
149
  In a bound topic you can also type:
400
150
  - `claude fix the bug` / `opencode add tests`
@@ -408,7 +158,7 @@ then 15 s) — no need to re-record the voice note.
408
158
  `/terminal` is never started from a natural-language phrase — only the
409
159
  explicit command opens a shell.
410
160
 
411
- ## Claude Code backends (`/claude_mode`)
161
+ ### Claude Code backends (`/claude_mode`)
412
162
 
413
163
  "Claude Code" in a topic is one user-facing choice with three interchangeable
414
164
  backends:
@@ -449,7 +199,151 @@ conversation resumes on the other backend. The pick persists per topic
449
199
  Billing note: the json-stream backends strip `ANTHROPIC_API_KEY` from the
450
200
  agent's env, so usage bills to your Claude subscription rather than an API key.
451
201
 
452
- ## Scheduler (`/schedule`)
202
+ ### Several accounts (`/accounts`)
203
+
204
+ If you hold more than one Claude subscription (a personal Pro/Max and a
205
+ corporate Team/Enterprise seat, say), the bot keeps each signed in as its own
206
+ **profile** and lets you choose, per topic, which one a Claude session runs on —
207
+ so one account's usage limit does not stop every topic.
208
+
209
+ - The profile `default` is your existing `~/.claude` login; nothing is migrated.
210
+ An added profile is a Claude config directory of its own under
211
+ `DATA_DIR/claude-profiles/<name>/` (the CLI gets it through
212
+ `CLAUDE_CONFIG_DIR`): it holds that account's login, while the transcripts,
213
+ settings, skills, plugins and your user memory are symlinks back into
214
+ `~/.claude` — every account sees the same hooks and skills, and a conversation
215
+ started under one account resumes under another.
216
+ - **Adding an account:** `/accounts` → «➕ Claude account» (or `/accounts add work`) — give it
217
+ a short name, then open the sign-in link the bot posts **in a browser that is
218
+ signed in as that other account** (an incognito window or another browser
219
+ profile keeps your current login out of the way), finish the sign-in and paste
220
+ the code back into the topic. The code message is deleted; the bot confirms
221
+ with the account's email and plan.
222
+ - **Switching:** tap a profile in `/accounts` (or `/accounts use <name>`). A
223
+ running session on the default (stream) backend is restarted under the new
224
+ account with the same conversation — right away when idle, at the end of its
225
+ turn when it is working; a sleeping topic simply resumes under it. The
226
+ tmux-scrape backend is reopened the same way when idle and waits for the next
227
+ start when busy. In the **General** topic the pick is the default for all
228
+ topics; a topic with its own pick keeps it («↩ Follow the default» drops it).
229
+ A profile that is not signed in cannot be picked.
230
+ - **Removing:** «🗑 Remove» deletes the profile's login directory. The profile
231
+ that is currently the instance default cannot be removed (pick another one in
232
+ General first); topics that had picked the removed profile return to the
233
+ default and the confirmation says how many. For `default` (`~/.claude`
234
+ itself) «remove» means **sign out**: after a confirmation that says running
235
+ sessions on it will stop working, only the stored subscription login
236
+ (`claudeAiOauth` in `~/.claude/.credentials.json`; MCP tokens beside it stay)
237
+ is deleted — `projects/`, settings, skills, plugins and memory are never
238
+ touched — and the account is hidden from the list, the recommendation and the
239
+ fallback ranking until it is signed in again (`/accounts login default`).
240
+ - A child `claude` the agent starts inherits the same `CLAUDE_CONFIG_DIR`, so
241
+ it runs on the topic's account too.
242
+ - **Usage per account.** Under each profile `/accounts` shows how much of each
243
+ subscription window is used and when it resets:
244
+ the 5-hour session window, the weekly window (all models) and Fable's own
245
+ weekly window (left out entirely on a plan without one). A line reads
246
+ `5h 5% 🔄 in 4h · week 20% 🔄 in 5d 8h · Fable 4% 🔄 in 5d 8h` — the
247
+ percentage is USED. A reset is shown as a time from
248
+ now (`🔄 in 2d 1h`; the two largest units, minutes only under an hour); an
249
+ unknown 5h reset shows the weekly one, and with no reset at all only the
250
+ percentage is shown. `charness claude-profiles` prints
251
+ the same relative form; its `--json` and the MCP tool keep ISO instants. The bot reads the figures with
252
+ each profile's own login every 10 minutes, when `/accounts` or `/limits` opens and when an
253
+ agent asks; a json-stream session's own rate-limit events keep them current
254
+ between polls. A token the CLI has not renewed yet shows the last figures as
255
+ `(stale)`; a profile whose session was refused on a window is marked
256
+ `⛔ at its limit until …` and is skipped by the recommendation below.
257
+ - **Another account takes over on a limit.** When a topic's account hits a
258
+ usage limit the bot looks at the [fallback chain](#usage-limits-and-the-fallback-models-limits);
259
+ without one it ranks the other signed-in profiles by headroom on the windows
260
+ the topic's model drains (fresh figures, not marked limited). The limit
261
+ notice carries «🔁 Switch to <entry>» buttons, best first: a tap moves the
262
+ topic there (the running session is restarted under the new account with the
263
+ same conversation), drops the wait for the reset and tells the agent to
264
+ continue right away. With **switching** on («🔁 Auto switch to a
265
+ fallback model» in `/limits`, or `/limits switch on`; in General the default for all
266
+ topics) the bot does the same by itself and posts one line — «Usage
267
+ limit on a — this topic switched to b and continues», naming when the
268
+ exhausted account resets. It is OFF by default: moving work between
269
+ subscriptions is your call. The exhausted profile is marked limited until its
270
+ window resets, so it is not picked again before then; the topic is never
271
+ moved back by itself — switch it back by hand when the window resets. When
272
+ nothing can take over the bot waits for the reset as before. An agent that is
273
+ still working switches at the end of its turn (the wait stays armed).
274
+ - **Which account for a child process.** An agent that launches a detached
275
+ `claude` (a worker, a reviewer) asks the bot's `telegramBot` MCP tool
276
+ `claude_profiles` — optionally with the model it will run — and gets every
277
+ profile with its windows plus `recommended`: the signed-in, unlimited profile
278
+ with the most headroom (Fable → Fable's weekly window and the session window;
279
+ any other model → the shared weekly window and the session window). It then
280
+ starts the child with `CLAUDE_CONFIG_DIR=<configDir>` (`null` = the default
281
+ profile: set nothing). The same answer from a shell, for a worker without
282
+ MCP: `charness claude-profiles [--best] [--model <name>] [--json]` —
283
+ `--best` prints just the directory (an empty line for the default), so
284
+ `CLAUDE_CONFIG_DIR="$(charness claude-profiles --best --model fable)"`
285
+ works as is; it reads the bot's cache off `DATA_DIR/state.json`.
286
+
287
+ ### Usage limits and the fallback models (`/limits`)
288
+
289
+ When a topic's agent stops on a usage limit — a Claude account window, an
290
+ OpenAI quota through OpenCode, a Google `RESOURCE_EXHAUSTED` — the bot can keep
291
+ the work going somewhere else instead of waiting. `/limits` holds ONE
292
+ instance-wide, ordered list of **fallback models** (where to go), top = preferred:
293
+
294
+ - **Left out of switching.** ✅ / 🚫 on a row includes or excludes that entry from
295
+ automatic switching and from the notice's switch buttons. A connected
296
+ provider (say OpenAI on OpenCode) can stay usable by hand through `/model`
297
+ while the bot never moves a limited topic onto it. With an EMPTY chain the
298
+ bot still ranks the other signed-in Claude accounts by headroom; once the
299
+ chain has entries, only its ✅ entries count — all of them left out means
300
+ no switch, the wait stands.
301
+ - **Entries.** A Claude account profile (`/accounts`) with an optional model
302
+ (`fable`, `opus`, `sonnet`, `haiku`; «keep the topic's model» otherwise), or
303
+ an OpenCode provider with a model (`openai/gpt-5`, `google/gemini-2.5-pro`,
304
+ …). Only what is actually connected is offered: the signed-in profiles, and
305
+ the providers the OpenCode server is authenticated for (its live catalog).
306
+ - **Drafting.** «🔄 Fill from connected» (or `/limits rebuild`) writes a draft from what
307
+ is signed in: the Claude accounts in their `/accounts` order (keeping the
308
+ topic's model), then the OpenCode models topics picked recently, then every
309
+ other provider's strongest model; an account or provider you had left out of
310
+ switching (🚫) stays left out. Tap an entry to move it (⬆️ Up / ⬇️ Down),
311
+ include or leave it out, or remove it; add with «➕ Add» (pick the account or
312
+ provider, then the model). Editing works from **every** topic (it is one
313
+ instance-wide list); a topic also sees ✓ on the entry it runs on now.
314
+ - **On a limit** the bot marks the exhausted entry limited until its window
315
+ resets (the reset the error names, else the account's session window, else
316
+ an hour), skips entries that are limited, not signed in or no longer offered,
317
+ and takes the first remaining one. A topic whose account or model was picked
318
+ by hand (`/accounts`, `/model`) is left alone until it hits its own limit —
319
+ then the chain decides, from the top. The «🔁 Auto switch»
320
+ setting (auto switch to a fallback model) applies: OFF (the default) puts «🔁 Switch to …» buttons on the
321
+ limit notice, ON switches by itself. No entry available → the wait
322
+ (when «⏳ Wait for reset» is ON) — **for the entry that
323
+ comes back first**: when every enabled entry, the topic's current one
324
+ included, is limited, the armed wait is re-aimed at the entry whose limit
325
+ resets EARLIEST (the notice says which model the topic will continue on and
326
+ when, also with auto switch OFF). The target rides in the persisted retry
327
+ record, so a restart keeps it; when the timer fires the topic is moved there
328
+ first (a context bridge across backends), then the usual continue prompt
329
+ follows. If the current entry resets first (or within a minute of the first),
330
+ nothing changes.
331
+ - **Within a backend** the conversation is kept: Claude account → account keeps
332
+ the transcript (`--resume` under the other account), OpenCode provider →
333
+ provider keeps the session and changes the model. **Across backends**
334
+ (Claude ↔ OpenCode) the topic's agent changes: the old session is stopped
335
+ and its id parked, the new one is started (or resumed, when the topic ran on
336
+ that backend before) and its first prompt is a **context bridge** — why it
337
+ takes over, the previous agent's last turns verbatim, and the instruction to
338
+ check the project state (git status / diff / log) before carrying on and to
339
+ report in one short message what the task is, what is done and what remains.
340
+ A later `/claude` or `/opencode` returns to the parked conversation; `/new`
341
+ and `/quit` release it as usual.
342
+ - The topic is **never moved back by itself** when the exhausted entry resets
343
+ — the switch notice names the reset time; switch back by hand (`/accounts`,
344
+ `/model`, `/claude`, `/opencode`).
345
+
346
+ ### Scheduler (`/schedule`) (Telegram)
453
347
 
454
348
  A topic can have scheduled prompts: at fire time the bot posts the prompt
455
349
  into the topic, pins the announcement (pins accumulate as run history),
@@ -469,7 +363,7 @@ with the thread's last-used backend.
469
363
  them (an expired one-shot is dropped). Reminders keep running — see
470
364
  below. Run history: `DATA_DIR/scheduler-runs.jsonl`.
471
365
 
472
- ## Reminders (`/reminders`)
366
+ ### Reminders (`/reminders`) (Telegram)
473
367
 
474
368
  A reminder is the bot's own notification, not a job for an agent: at the due
475
369
  time the bot posts your text into the topic and pins it — and the pin is what
@@ -504,7 +398,7 @@ a single catch-up.
504
398
  Reminders are yours, not the agent's: the scheduling tools an agent can call
505
399
  do not see them, so it can neither list nor delete them.
506
400
 
507
- ## Raw terminal (`/terminal`)
401
+ ### Raw terminal (`/terminal`) (Telegram)
508
402
 
509
403
  `/terminal` binds the topic to a real interactive `$SHELL` (in tmux) in the
510
404
  bound folder — a third backend alongside the agents, mutually exclusive
@@ -516,7 +410,7 @@ re-adopted. Known v1 limitation: full-screen TUIs (vim, htop, less) render
516
410
  messy; normal commands, builds, and logs stream cleanly. The shell comes
517
411
  from the `SHELL` env (fallback `/bin/bash`).
518
412
 
519
- ## File intake
413
+ ### File intake (Telegram)
520
414
 
521
415
  Send a file to a bound topic with an active agent and the bot hands it to
522
416
  the agent:
@@ -532,9 +426,9 @@ the agent:
532
426
  bare `/clear` purges the topic's intake dir (the agent's context is gone,
533
427
  so the files are useless); files older than 30 days are swept daily.
534
428
 
535
- ## Observability
429
+ ### Observability
536
430
 
537
- - **Output trace** — ON by default for every thread: each incoming update,
431
+ - **Output trace** (Telegram) — ON by default for every thread: each incoming update,
538
432
  adapter emit, and outgoing Bot API call (with outcome, incl. 429 details)
539
433
  is recorded into hourly buckets `DATA_DIR/output-trace-*.jsonl` (pruned
540
434
  after 6h). `/trace off all` turns it off durably; bare `/trace` reports
@@ -543,11 +437,11 @@ the agent:
543
437
  - **Console tee** — the bot's stdout/stderr is mirrored to
544
438
  `DATA_DIR/bot-console-*.log` (same hourly buckets, same 6h prune), so
545
439
  boot logs stay readable post-incident without the operator's terminal.
546
- - **`/timestamps on`** — prepends each forwarded prompt's send time
440
+ - **`/timestamps on`** (Telegram) — prepends each forwarded prompt's send time
547
441
  (local-offset ISO) so a days-long session knows what "yesterday" means.
548
442
  Agent-facing only, default off, persisted per topic.
549
443
 
550
- ## Timezone
444
+ ### Timezone (Telegram)
551
445
 
552
446
  The bot runs on the host clock, which on a typical server is UTC. `/timezone`
553
447
  declares yours ONCE, instance-wide, and every clock the bot touches follows:
@@ -572,191 +466,7 @@ The current zone and its wall clock also show in `/status`. Nothing is stored
572
466
  until you set one, so an install that never runs `/timezone` behaves exactly as
573
467
  it did before.
574
468
 
575
- ## Environment Variables
576
-
577
- ### Set Before Launch
578
-
579
- | Variable | Description |
580
- |---|---|
581
- | `TELEGRAM_BOT_TOKEN` | Token from @BotFather |
582
-
583
- Start from the parent folder containing your projects: `cd ~/projects && telegramcode`.
584
- That `$PWD` is the folder the bot works in — nothing else to set for it.
585
-
586
- **Access control.** There is no user allow-list. Whoever is a **creator or
587
- administrator of the served forum group** may talk to the agent — read live from
588
- Telegram (`getChatAdministrators`) and cached for 1h. Promote someone in the
589
- group to grant access; demote/remove them to revoke it — the bot subscribes to
590
- `chat_member` updates, so an admin change invalidates the cache and takes
591
- effect immediately (the 1h TTL is only the fallback). The bot must be a group
592
- admin itself (it already needs that to create topics and pin). Anonymous admins
593
- can't be matched from their messages, so post non-anonymously. The DM surface
594
- (when enabled) is gated separately: only the configured `OWNER_USER_ID` may
595
- talk to the bot there.
596
-
597
- > **Security model — group admin (or the DM owner) ⇒ shell on the host.** The agents run with
598
- > permission checks disabled (`--dangerously-skip-permissions` for Claude,
599
- > auto-approve for OpenCode) and `/terminal` opens a raw `$SHELL` in the bound
600
- > folder, so anyone who can talk to the bot can execute arbitrary commands as
601
- > the bot's OS user. Only promote people you would trust with SSH access to
602
- > that machine, and keep the served group itself private.
603
-
604
- ### External Optional
605
-
606
- | Variable | Default | Description |
607
- |---|---|---|
608
- | `ALLOWED_GROUP_ID` | (auto-pair) | Numeric forum supergroup id (`-100…`). Leave empty to auto-pair with the first forum group a group **admin/creator** contacts the bot from (id is saved to `state.json`; re-point with `/pair`). A **name** is not accepted. A numeric value disables auto-pairing |
609
- | `DATA_DIR` | `~/.telegramCode` | Per-instance state. **Mandatory** if you run two bots on the same host — otherwise both share `state.json` and `mcp.json` and corrupt each other |
610
- | `CHAT_MODE` | `both` | Which surface(s) this instance serves: `group`, `dm`, or `both` — see [Two surfaces](#two-surfaces-group-topics-bot-dm-or-both) |
611
- | `OWNER_USER_ID` | — | **Optional.** Numeric Telegram user id of the owner — leave it unset to run group-only (the DM surface stays inert; a group works fully without it). Set it only to enable the owner-DM surface; **required** solely for `CHAT_MODE=dm` |
612
- | `GROQ_API_KEY` | — | Recommended for voice transcription. Without it, voice messages are not transcribed unless you intentionally configure the OpenAI fallback |
613
-
614
- **Localized in 12 languages** — the bot UI (commands, buttons, notices) speaks
615
- 中文, English, Français, ქართული, Deutsch, हिन्दी, 日本語, Português, Русский,
616
- Español, Українська, Oʻzbekcha. The language is automatic per Telegram chat:
617
- explicit `/language <locale>` override wins, then the sender's Telegram client
618
- language, then the last supported Telegram locale seen for that chat, then
619
- English.
620
- Supported locales: `en`, `de`, `fr`, `es`, `pt`, `ru`, `zh`, `ja`, `hi`, `uz`,
621
- `ka`, `uk`. Bare `/language` opens a single-message inline picker with each language
622
- shown by its own name (endonym), sorted A→Z by English name, and a `🌐 Auto` button
623
- (all 12 fit at once — no pagination). Tapping a language (or `🌐 Auto`) applies it, then the menu
624
- disappears and a short confirmation stays in the chosen language;
625
- `/language auto` returns a DM/group to automatic selection.
626
-
627
- Agent provider/auth setup is normally done inside the agents themselves:
628
- `claude login` for Claude CLI and `/connect <provider-id>` (for example,
629
- `/connect openrouter`) or OpenCode's own config/plugins for OpenCode. No provider
630
- API key env var is required by the bot for text sessions. For OpenCode, install
631
- any third-party provider plugins or authentication resolvers before launch if
632
- your chosen providers need them.
633
-
634
- ### Advanced / Not Normally Needed
635
-
636
- | Variable | Default | Set only when |
637
- |---|---|---|
638
- | `WORK_ROOT` | `$PWD` | You cannot control the process cwd; normal launch uses `cd <projects-parent> && telegramcode` |
639
- | `OPENCODE_URL` | `http://localhost:4096` | You use a custom OpenCode port or external server; the port must differ per instance |
640
- | `OPENCODE_USERNAME` | `opencode` | `OPENCODE_PASSWORD` is set for a protected OpenCode server |
641
- | `OPENCODE_PASSWORD` | — | Connecting to a protected OpenCode server |
642
- | `OPENCODE_ALLOW_REMOTE` | — | `OPENCODE_URL` intentionally points outside loopback |
643
- | `OPENCODE_BIN` | (auto) | The `opencode` binary is not on PATH or you use a fork |
644
- | `CLAUDE_BIN` | (auto) | The `claude` binary is not on PATH due to nvm/asdf/systemd PATH differences |
645
- | `OPENAI_API_KEY` | — | You intentionally use OpenAI Whisper as the voice fallback instead of Groq |
646
- | `ANTHROPIC_API_KEY` | — | A custom MCP/OpenCode plugin/auth resolver explicitly reads it; not needed for normal Claude CLI auth. The json-stream Claude backend strips it from the agent's env (subscription billing) |
647
- | `SHELL` | `/bin/bash` | You want `/terminal` to open a different shell than your login shell (host env var, not set by the bot) |
648
- | `SCHEDULER_MCP_PORT` | an OS-chosen free loopback port | You need a stable, explicitly chosen port; it must differ from this instance's `OPENCODE_URL` port |
649
- | `CLAUDE_SCRAPE_DEBUG` | off | You are debugging Claude tmux scraping and need full RAW/FILTERED chunks |
650
- | `AGENT_IDLE_MINUTES` | `55` | A json-stream Claude topic idle for this long is compacted (when `/compact_on_idle` allows) and its process stopped; the session sleeps and the next message resumes it — shorten it only for a test; a non-positive or non-numeric value keeps the default |
651
- | `REQUEST_BACKSTOP_MINUTES` | `90` | A request (a Jira hand-over, a message in an answers-only topic) with nothing seen working on it for this long is re-posted to its session — shorten it only for a test; a non-positive or non-numeric value keeps the default |
652
- | `TMUX_SOCKET_NAME` | — (the default tmux server) | The instance must run its agents on its OWN tmux server (`tmux -L <name>`; any plain name except `default`). Recommended for a second instance on one host: at boot an instance kills every agent session on its server that its own state does not know |
653
- | `ENV_FILE` | — | Absolute path of the ONLY env file to read — no `~/.config/telegramcode/.env`, no `$PWD/.env`; its values win over the inherited environment. Set it in the launching environment, never inside an env file (the start refuses that). `scripts/run-isolated.sh <env-file>` starts an instance with a clean environment plus this variable |
654
- | `CONNECTORS` | `telegram` | Experimental: the surfaces this instance serves, as a comma list — see [Jira connector](#jira-connector-experimental). An instance that lists `jira` refuses to start on Node below 22.12 and without `ENV_FILE`, `TMUX_SOCKET_NAME` and `DATA_DIR/jira.json`, and — with Telegram off — with a `TELEGRAM_BOT_TOKEN` or any `ATLASSIAN_*` variable in its environment. Any instance refuses to start on a `DATA_DIR` that holds conversations of a surface it does not serve |
655
-
656
- > `WORK_DIR` (1.x) is retired. Use the wrapper from the desired parent folder
657
- > instead of carrying the old env forward.
658
-
659
- ## Jira connector (experimental)
660
-
661
- The same core can serve **Jira Cloud issues** instead of (or next to) Telegram topics: an issue assigned to
662
- a dedicated AI account becomes a conversation with an agent, and the agent answers in comments.
663
-
664
- ```
665
- a person assigns an issue to the AI account (in a trigger status)
666
- → the instance polls Jira as the AI account and opens a request
667
- → the agent works in the project's folder; its streamed output never reaches Jira
668
- → it answers through the answer_request tool:
669
- progress → a comment, the issue stays with the AI
670
- question → a comment, the issue goes back to the person who handed it over
671
- final → a comment, the issue goes back to that person
672
- → an agent that stops answering is reminded; when the reminders give up, a
673
- comment says a person has to look, and the issue goes back
674
- ```
675
-
676
- - **One issue = one conversation = one agent session**, bound to the folder its project maps to. The agent
677
- reads the issue's text as information, never as instructions.
678
- - **The agent gets the whole issue.** Every request's prompt carries the issue's fields, the full description,
679
- its sub-tasks or an epic's children, links and remote links, an attachment list and ALL comments (oldest
680
- first, restricted ones marked). A screenshot or video pasted into the description or a comment shows up as a
681
- placeholder where it sat, naming its attachment. Nothing is cut: a comment over 10 000 characters, or any text
682
- that would not fit the prompt, is written whole to a file in the conversation's folder under `DATA_DIR/files`
683
- and the prompt says where. A later hand-over to the same conversation carries only what changed since the
684
- agent's last prompt (new and edited comments, deleted ones named, the rest listed as unchanged); a fresh
685
- session, or one whose context was compacted, gets the whole issue again.
686
- - **Who gets the answer.** Each hand-over is a request from its sender. Two people handing one issue over in
687
- turn get two answers, each their own comment; the first closing answer hands the issue back to its sender,
688
- the second finds the issue no longer the AI's and leaves the assignee alone. The same person handing over
689
- again replaces their earlier open request; the agent answers only what the new hand-over adds (if it
690
- already finished the first, a short pointer to that answer).
691
- - **Budget.** An issue handed over more than `runBudgetPer24h` times in 24 hours is handed back with a notice
692
- and opens no request.
693
-
694
- ### Setup
695
-
696
- 1. Create a Jira account for the AI (its API token is the instance's only secret) and note its account id.
697
- 2. An instance of its own: a `DATA_DIR`, a `WORK_ROOT` with one folder per project, a private tmux server, and
698
- an env file that is the ONLY configuration it reads:
699
-
700
- ```bash
701
- # /path/to/jira-instance.env
702
- CONNECTORS=jira
703
- DATA_DIR=/path/to/jira-instance/data
704
- WORK_ROOT=/path/to/jira-instance/work
705
- TMUX_SOCKET_NAME=jira-instance
706
- OPENCODE_URL=http://localhost:4097 # a port of its own — the default 4096 is refused (other instances use it)
707
- JIRA_AI_API_TOKEN=... # referenced by jira.json below, never written there
708
- ```
709
-
710
- 3. `DATA_DIR/jira.json` — the allowlist and the credentials (`${VAR}` expands from the env file; an unknown
711
- key is an error):
712
-
713
- ```json
714
- {
715
- "site": "example.atlassian.net",
716
- "email": "ai-account@example.com",
717
- "apiToken": "${JIRA_AI_API_TOKEN}",
718
- "accountId": "<the AI account's id>",
719
- "projects": {
720
- "PROJ": { "folder": "proj", "triggerStatuses": ["In Progress"], "extraFields": ["customfield_10042"] }
721
- },
722
- "pollIntervalSeconds": 90,
723
- "runBudgetPer24h": 5,
724
- "model": "opus",
725
- "effort": "high"
726
- }
727
- ```
728
-
729
- `projects` maps each served project key to its folder under `WORK_ROOT` and the status names in which an
730
- assigned issue is a request; a folder with Claude memory (`CLAUDE.md`, `.claude/`, …) in it or above it is
731
- refused, because the agent still loads project memory. `pollIntervalSeconds` is 10–600 (default 90);
732
- `runBudgetPer24h` defaults to 5; `model` and `effort` set the sessions' Claude model and reasoning effort
733
- (optional; absent → `opus` and `high`, either key overrides only its own default). `extraFields` (optional,
734
- none by default) names fields by id (`customfield_…`, or a system one like `duedate`) the agent should see next to the standard
735
- ones, shown under their site name; an id the site does not list is logged at start and left out. `agentBinaries` (optional, host runtime) maps a tool name to the absolute path of an executable — for
736
- example `{ "ffmpeg": "/opt/tools/ffmpeg" }` — which is checked at start and put on the agents' PATH. `adapter` is `claude-json-stream` (the default — the agent process is stopped when an issue
737
- idles) or `claude-per-turn` (stopped after every answer); either way the issue's conversation sleeps between
738
- requests and the next request resumes it.
739
-
740
- 4. Start it with a clean environment, so nothing of the calling shell reaches it:
741
-
742
- ```bash
743
- scripts/run-isolated.sh /path/to/jira-instance.env
744
- ```
745
-
746
- The start refuses a missing `ENV_FILE`, `TMUX_SOCKET_NAME` or `jira.json`, an `OPENCODE_URL` on the default
747
- port, a `TELEGRAM_BOT_TOKEN` or any `ATLASSIAN_*` variable when Telegram is off, a token that belongs to
748
- another account, an unknown project or status, and a `DATA_DIR` holding another surface's state. An unreachable Jira does not refuse the start —
749
- polling backs off and resumes.
750
-
751
- The agent sessions of a Jira instance run without the user-level Claude settings, hooks and skills, with the
752
- bot's MCP server only, without the native question tool, and with an environment reduced to a short allowlist
753
- — the Jira token is not in the agent's environment. The agent still runs as the instance's OS user and can read
754
- the instance's env file and `DATA_DIR`, so run the instance under an OS user that holds nothing else, with an AI
755
- account that sees only the allowlisted projects. **A production Jira account runs only in the Docker container**
756
- ([Run with Docker](#run-with-docker)): there the agent can still read the instance's env file and `DATA_DIR`,
757
- but nothing of the host outside the container's mounts. Module details: `src/connectors/jira/README.md`.
758
-
759
- ## Bot-injected agent tools
469
+ ### Bot-injected agent tools
760
470
 
761
471
  The bot injects its own `telegramBot` MCP server into every bot-started session
762
472
  — for Claude via a generated `--mcp-config`, for OpenCode via runtime
@@ -768,8 +478,6 @@ agent even when two clients use the same JSON-RPC request id. It exposes:
768
478
 
769
479
  - `schedule_create` / `schedule_list` / `schedule_cancel` — the agent-side
770
480
  scheduling API behind `/schedule`;
771
- - `jira_get_attachment` — Jira conversations only: saves the original of one attachment of the conversation's
772
- own issue (any size) and returns its path, so the agent can read an image or run `ffmpeg` on a video;
773
481
  - `compact_conversation` — lets the agent compact its OWN session when you ask it
774
482
  to in plain words ("compact our conversation"). It arms the compaction and
775
483
  returns immediately; the bot runs the real compaction the moment the current
@@ -820,52 +528,7 @@ Third-party OpenCode MCP servers, including a separate `telegram-mcp`, belong to
820
528
  the OpenCode configuration of the Linux user that runs the bot. They are not
821
529
  injected by Charness; run `opencode mcp list` as that user to verify them.
822
530
 
823
- ## Two instances on one host
824
-
825
- Two host instances, or a host instance next to a container: each pair of variables below must differ to avoid
826
- silent corruption. Two containers need only different tokens, groups, `DATA_DIR`s, container names and hostnames: their
827
- ports and tmux servers are their own.
828
-
829
- | What | Why it must differ |
830
- |---|---|
831
- | `TELEGRAM_BOT_TOKEN` | Telegram routes updates to a single long-poller per token; sharing → message loss |
832
- | `ALLOWED_GROUP_ID` | The bot gates by group id; sharing → cross-instance leakage |
833
- | `WORK_ROOT` | Each instance manages its subtree; sharing → tmux name collisions |
834
- | `DATA_DIR` | `state.json` / `mcp.json` / `threads/` per instance; sharing → corrupted JSON |
835
- | `OPENCODE_URL` port | OpenCode server binds the port; second start fails with `EADDRINUSE` and you'd silently share sessions |
836
- | `SCHEDULER_MCP_PORT` | Optional stable scheduler-MCP port; if set, it must differ from that instance's `OPENCODE_URL` port |
837
- | `TMUX_SOCKET_NAME` | Optional, recommended: each instance's boot kills the agent sessions on its tmux server that its own state does not know — on one shared server, the other instance's |
838
-
839
- ## Updating a deployment (self-update, no root)
840
-
841
- `scripts/self-update.sh` refreshes a checkout in place, running as the
842
- checkout's owning user — no root, no cross-user copying. It is safe to run
843
- blindly (e.g. from cron):
844
-
845
- - fast-forward only: it skips silently when the tree has tracked changes, a
846
- merge/rebase is in progress, or local history diverged from the upstream —
847
- a dev clone that is ahead of origin is never touched;
848
- - `yarn install --immutable` runs only when `yarn.lock` / `package.json`
849
- changed;
850
- - a hot-mode instance (`telegramcode hot`) rebuilds and restarts the worker
851
- by itself (after a dependency install the script touches `tsconfig.json`
852
- so `tsc -w` recompiles with the new modules); a non-hot instance gets
853
- `yarn build` plus a restart notice — the script never kills processes;
854
- - changes to the hot supervisor itself (`src/cli.ts`, `src/cli/hot.ts`,
855
- `nodemon.json`) are flagged with a warning: those need a manual
856
- `telegramcode hot` restart (nodemon reloads only the worker).
857
-
858
- For unattended updates give the deploying user read access to the repo (e.g.
859
- a read-only GitLab deploy key on a passphrase-less SSH key) and add a cron
860
- entry:
861
-
862
- ```cron
863
- */10 * * * * /path/to/telegramcode/scripts/self-update.sh >> "$HOME/.local/state/telegramcode/self-update.log" 2>&1
864
- ```
865
-
866
- (create the log directory once: `mkdir -p ~/.local/state/telegramcode`).
867
-
868
- ## Restart behaviour
531
+ ### Restart behaviour
869
532
 
870
533
  Bot restarts are designed to be invisible: agents run in external
871
534
  processes (`tmux`, `opencode serve`), so the bot re-adopts them instead
@@ -930,7 +593,7 @@ thread not found` from a send triggers binding cleanup. Closed topics
930
593
  are detected by `TOPIC_CLOSED` errors and surface a friendly message
931
594
  asking the user to reopen.
932
595
 
933
- In the Docker container (see [Run with Docker](#run-with-docker)) the same holds for a bot restart
596
+ In the Docker container (see [Run with Docker](SETUP.md#run-with-docker)) the same holds for a bot restart
934
597
  inside the container; a restart of the container itself ends every agent process, and each conversation
935
598
  resumes with its next message.
936
599
 
@@ -939,9 +602,9 @@ The default `control-group` mode kills tmux and `opencode serve` children,
939
602
  which defeats restart/reattach. Process restarts intentionally leave agent
940
603
  sessions alive; use `/quit` or `/quit-all` when you want to terminate them.
941
604
 
942
- ## Troubleshooting
605
+ ### Troubleshooting
943
606
 
944
- ### Bot doesn't see text
607
+ #### Bot doesn't see text (Telegram)
945
608
 
946
609
  You disabled privacy mode in @BotFather **after** adding the bot. The
947
610
  flag is cached on join. Fix:
@@ -952,7 +615,7 @@ flag is cached on join. Fix:
952
615
 
953
616
  Verify with `/doctor` — the privacy line should report it as disabled.
954
617
 
955
- ### `/bind` says "folder not found"
618
+ #### `/bind` says "folder not found" (Telegram)
956
619
 
957
620
  The folder you launched from doesn't contain a subfolder with that name (or
958
621
  it's a symlink pointing outside it). Run `/ls` to see what's available, or fix
@@ -960,19 +623,19 @@ the host path. Path-traversal attempts (`../`, absolute paths,
960
623
  NUL bytes, NFC-vs-NFD mismatches) are rejected by design — see
961
624
  `validateSubdir` in `src/validation.ts`.
962
625
 
963
- ### "Missing right" / `/clear_messages` does nothing
626
+ #### "Missing right" / `/clear_messages` does nothing (Telegram)
964
627
 
965
628
  The bot needs admin rights `can_delete_messages` and `can_pin_messages`
966
629
  in addition to `can_manage_topics`. Open group settings → admins →
967
630
  the bot → tick the missing boxes. `/doctor` shows the exact gap.
968
631
 
969
- ### Two instances on the same machine fight each other
632
+ #### Two instances on the same machine fight each other
970
633
 
971
634
  You forgot to set distinct `DATA_DIR` and `OPENCODE_URL`. The bot logs
972
635
  `[startup] DATA_DIR=<path>` on boot — if both instances log the same
973
- path, fix `.env` and `docker compose down && up -d`.
636
+ path, give each its own `DATA_DIR` and `OPENCODE_URL` port and restart both.
974
637
 
975
- ### Claude opens a session picker instead of resuming
638
+ #### Claude opens a session picker instead of resuming
976
639
 
977
640
  The 1.x adapter invoked `claude --resume` with no UUID and relied on the
978
641
  interactive picker, which doesn't survive a non-interactive pty. 2.0
@@ -982,12 +645,12 @@ anyway, your local claude CLI is older than 2.1.x — upgrade with
982
645
  `npm i -g @anthropic-ai/claude-code` (the bot also auto-installs on
983
646
  first use, see `src/installManager.ts`).
984
647
 
985
- ### OpenCode "address already in use"
648
+ #### OpenCode "address already in use"
986
649
 
987
650
  Two instances on the same host with the same `OPENCODE_URL`. Pick a
988
651
  different port for the second instance (e.g. `4097`).
989
652
 
990
- ## FAQ
653
+ ### FAQ
991
654
 
992
655
  **How do I run Claude Code from my phone?**
993
656
  Install Charness on your own machine or VPS, create a Telegram bot, and bind a forum topic (or the bot's DM) to a project folder. Start a Claude Code session in that topic and you drive it entirely from Telegram: type prompts, send voice notes, or drop in files, and the agent's output streams back into the same topic. Your phone never runs the agent; it stays on your machine.
@@ -996,7 +659,7 @@ Install Charness on your own machine or VPS, create a Telegram bot, and bind a f
996
659
  Yes. The bot only makes outbound connections to Telegram, so nothing listens for inbound traffic and you never expose a port. OpenCode runs as a local HTTP server that the bot talks to on loopback, and you reach it from anywhere through Telegram.
997
660
 
998
661
  **How do I run a coding agent on a VPS and drive it from Telegram?**
999
- Set up your VPS once with git, your repos, the agent CLIs, and `telegramcode`, then launch the bot from your projects folder. You get an always-on dev box you drive from any device: phone, tablet, or voice. Because the agent lives on the server, it keeps working even when your laptop sleeps, and the same sessions are still reachable over plain SSH.
662
+ Set up your VPS once with git, your repos, the agent CLIs, and `charness`, then launch the bot from your projects folder. You get an always-on dev box you drive from any device: phone, tablet, or voice. Because the agent lives on the server, it keeps working even when your laptop sleeps, and the same sessions are still reachable over plain SSH.
1000
663
 
1001
664
  **Does my session survive a restart?**
1002
665
  Yes, both a bot restart and an agent-server restart. State is persisted to disk; on restart the bot re-attaches to the running Claude session in tmux or re-connects to OpenCode, and an in-flight turn is delivered once it is back. A prompt sent during startup is buffered and replayed, never dropped.
@@ -1007,19 +670,22 @@ Yes. Each topic picks its backend independently: OpenCode over its native HTTP+S
1007
670
  **Can I talk to the agent by voice?**
1008
671
  Yes. Send a voice message to a topic and it is transcribed with Whisper (via Groq or OpenAI) and forwarded to the agent as a normal prompt, so you can vibe code hands-free from your phone.
1009
672
 
1010
- ## Documentation
673
+ ### Documentation
1011
674
 
675
+ - **[SETUP.md](SETUP.md)** — installing and configuring: Telegram, Jira, environment, updating; Docker as an alternative to npm.
1012
676
  - **[DEVELOPMENT.md](DEVELOPMENT.md)** — architecture and local development (build, test, hot-reload, Docker dev loop).
1013
677
  - **[MIGRATION_1_TO_2.md](MIGRATION_1_TO_2.md)** — upgrading a 1.x install to 2.0.
1014
678
 
1015
- ## The story behind it
679
+ ### The story behind it
1016
680
 
1017
681
  I started running Claude Code on my own machine, and I kept wanting to check on it after I stepped away from the desk. Back then there was no way to reach it from a phone, so I put together a small bot that launched the agent and let me talk to it over Telegram. It ran on my own computer, which had to stay on the whole time.
1018
682
 
1019
683
  Then I moved the whole thing onto a server that never sleeps, added OpenCode next to Claude Code, and it grew into what it is now: voice control, file intake, scheduling, a raw terminal, and sessions that survive restarts. These days I run it every day and drive everything from my phone or tablet, no laptop required.
1020
684
 
685
+ The project was called TelegramCode before it became Charness: its npm package was `telegramcode` up to 2.0.3 and is `charness` since 3.0.0.
686
+
1021
687
  Full write-up: [Vibe-coding by voice, from my phone](https://dev.to/olosegres/vibe-coding-by-voice-from-my-phone-claude-code-and-opencode-over-telegram-j75).
1022
688
 
1023
- ## License
689
+ ### License
1024
690
 
1025
691
  MIT