charness 3.12.0 → 3.13.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 (232) hide show
  1. package/.env.example +5 -0
  2. package/CHANGELOG.md +27 -0
  3. package/DEVELOPMENT.md +78 -15
  4. package/README.md +2 -1
  5. package/SETUP.md +65 -20
  6. package/agent-plugin/skills/charness-delegate-claude/SKILL.md +14 -5
  7. package/dist/accessControl.d.ts +43 -0
  8. package/dist/accessControl.d.ts.map +1 -1
  9. package/dist/accessControl.js +50 -1
  10. package/dist/accessControl.js.map +1 -1
  11. package/dist/adapters/claudeCliAdapter.d.ts.map +1 -1
  12. package/dist/adapters/claudeCliAdapter.js +9 -4
  13. package/dist/adapters/claudeCliAdapter.js.map +1 -1
  14. package/dist/adapters/claudeJsonStreamAdapter.js +1 -1
  15. package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -1
  16. package/dist/adapters/claudePlatformFlags.d.ts +4 -3
  17. package/dist/adapters/claudePlatformFlags.d.ts.map +1 -1
  18. package/dist/adapters/claudePlatformFlags.js +4 -3
  19. package/dist/adapters/claudePlatformFlags.js.map +1 -1
  20. package/dist/adapters/openCodeAdapter.d.ts +37 -13
  21. package/dist/adapters/openCodeAdapter.d.ts.map +1 -1
  22. package/dist/adapters/openCodeAdapter.js +73 -41
  23. package/dist/adapters/openCodeAdapter.js.map +1 -1
  24. package/dist/adapters/terminalAdapter.d.ts.map +1 -1
  25. package/dist/adapters/terminalAdapter.js +5 -3
  26. package/dist/adapters/terminalAdapter.js.map +1 -1
  27. package/dist/agentLogin/agentLogin.d.ts.map +1 -1
  28. package/dist/agentLogin/agentLogin.js +2 -14
  29. package/dist/agentLogin/agentLogin.js.map +1 -1
  30. package/dist/bot.d.ts +12 -3
  31. package/dist/bot.d.ts.map +1 -1
  32. package/dist/bot.js +476 -133
  33. package/dist/bot.js.map +1 -1
  34. package/dist/cli/claudeProfiles.js +2 -2
  35. package/dist/cli/claudeProfiles.js.map +1 -1
  36. package/dist/connectors/jira/client.js +1 -1
  37. package/dist/connectors/jira/client.js.map +1 -1
  38. package/dist/connectors/jira/config.d.ts +7 -0
  39. package/dist/connectors/jira/config.d.ts.map +1 -1
  40. package/dist/connectors/jira/config.js +12 -1
  41. package/dist/connectors/jira/config.js.map +1 -1
  42. package/dist/connectors/jira/connector.d.ts +7 -0
  43. package/dist/connectors/jira/connector.d.ts.map +1 -1
  44. package/dist/connectors/jira/connector.js +20 -3
  45. package/dist/connectors/jira/connector.js.map +1 -1
  46. package/dist/connectors/jira/inbound.d.ts.map +1 -1
  47. package/dist/connectors/jira/inbound.js +4 -3
  48. package/dist/connectors/jira/inbound.js.map +1 -1
  49. package/dist/connectors/jira/issueBlocks.d.ts +1 -1
  50. package/dist/connectors/jira/trustedGroup.d.ts +21 -6
  51. package/dist/connectors/jira/trustedGroup.d.ts.map +1 -1
  52. package/dist/connectors/jira/trustedGroup.js +46 -6
  53. package/dist/connectors/jira/trustedGroup.js.map +1 -1
  54. package/dist/connectors/telegram/commands/botCore.d.ts +19 -2
  55. package/dist/connectors/telegram/commands/botCore.d.ts.map +1 -1
  56. package/dist/connectors/telegram/commands/compaction.d.ts +5 -3
  57. package/dist/connectors/telegram/commands/compaction.d.ts.map +1 -1
  58. package/dist/connectors/telegram/commands/compaction.js +9 -6
  59. package/dist/connectors/telegram/commands/compaction.js.map +1 -1
  60. package/dist/connectors/telegram/commands/todo.d.ts.map +1 -1
  61. package/dist/connectors/telegram/commands/todo.js +2 -2
  62. package/dist/connectors/telegram/commands/todo.js.map +1 -1
  63. package/dist/connectors/telegram/commands/topicAccess.d.ts +30 -0
  64. package/dist/connectors/telegram/commands/topicAccess.d.ts.map +1 -0
  65. package/dist/connectors/telegram/commands/topicAccess.js +399 -0
  66. package/dist/connectors/telegram/commands/topicAccess.js.map +1 -0
  67. package/dist/connectors/telegram/inbound.d.ts +44 -7
  68. package/dist/connectors/telegram/inbound.d.ts.map +1 -1
  69. package/dist/connectors/telegram/inbound.js +142 -24
  70. package/dist/connectors/telegram/inbound.js.map +1 -1
  71. package/dist/i18n/de.d.ts.map +1 -1
  72. package/dist/i18n/de.js +68 -0
  73. package/dist/i18n/de.js.map +1 -1
  74. package/dist/i18n/en.d.ts.map +1 -1
  75. package/dist/i18n/en.js +68 -0
  76. package/dist/i18n/en.js.map +1 -1
  77. package/dist/i18n/es.d.ts.map +1 -1
  78. package/dist/i18n/es.js +68 -0
  79. package/dist/i18n/es.js.map +1 -1
  80. package/dist/i18n/fr.d.ts.map +1 -1
  81. package/dist/i18n/fr.js +68 -0
  82. package/dist/i18n/fr.js.map +1 -1
  83. package/dist/i18n/hi.d.ts.map +1 -1
  84. package/dist/i18n/hi.js +68 -0
  85. package/dist/i18n/hi.js.map +1 -1
  86. package/dist/i18n/ja.d.ts.map +1 -1
  87. package/dist/i18n/ja.js +68 -0
  88. package/dist/i18n/ja.js.map +1 -1
  89. package/dist/i18n/ka.d.ts.map +1 -1
  90. package/dist/i18n/ka.js +68 -0
  91. package/dist/i18n/ka.js.map +1 -1
  92. package/dist/i18n/pt.d.ts.map +1 -1
  93. package/dist/i18n/pt.js +68 -0
  94. package/dist/i18n/pt.js.map +1 -1
  95. package/dist/i18n/ru.d.ts.map +1 -1
  96. package/dist/i18n/ru.js +68 -0
  97. package/dist/i18n/ru.js.map +1 -1
  98. package/dist/i18n/uk.d.ts.map +1 -1
  99. package/dist/i18n/uk.js +68 -0
  100. package/dist/i18n/uk.js.map +1 -1
  101. package/dist/i18n/uz.d.ts.map +1 -1
  102. package/dist/i18n/uz.js +68 -0
  103. package/dist/i18n/uz.js.map +1 -1
  104. package/dist/i18n/zh.d.ts.map +1 -1
  105. package/dist/i18n/zh.js +68 -0
  106. package/dist/i18n/zh.js.map +1 -1
  107. package/dist/installManager.d.ts +37 -1
  108. package/dist/installManager.d.ts.map +1 -1
  109. package/dist/installManager.js +205 -14
  110. package/dist/installManager.js.map +1 -1
  111. package/dist/platform/commandRouter.d.ts +13 -1
  112. package/dist/platform/commandRouter.d.ts.map +1 -1
  113. package/dist/platform/commandRouter.js +14 -2
  114. package/dist/platform/commandRouter.js.map +1 -1
  115. package/dist/platform/inbound.d.ts +2 -0
  116. package/dist/platform/inbound.d.ts.map +1 -1
  117. package/dist/runners/runnerLock.d.ts +36 -1
  118. package/dist/runners/runnerLock.d.ts.map +1 -1
  119. package/dist/runners/runnerLock.js +94 -30
  120. package/dist/runners/runnerLock.js.map +1 -1
  121. package/dist/scheduler/checkRun.d.ts +0 -2
  122. package/dist/scheduler/checkRun.d.ts.map +1 -1
  123. package/dist/scheduler/checkRun.js +0 -10
  124. package/dist/scheduler/checkRun.js.map +1 -1
  125. package/dist/selfUpdate/bootRollback.d.ts.map +1 -1
  126. package/dist/selfUpdate/bootRollback.js +3 -2
  127. package/dist/selfUpdate/bootRollback.js.map +1 -1
  128. package/dist/selfUpdate/updateRuntime.d.ts.map +1 -1
  129. package/dist/selfUpdate/updateRuntime.js +6 -3
  130. package/dist/selfUpdate/updateRuntime.js.map +1 -1
  131. package/dist/state.d.ts +49 -0
  132. package/dist/state.d.ts.map +1 -1
  133. package/dist/state.js +112 -0
  134. package/dist/state.js.map +1 -1
  135. package/dist/threadContextPreamble.d.ts +15 -1
  136. package/dist/threadContextPreamble.d.ts.map +1 -1
  137. package/dist/threadContextPreamble.js +15 -3
  138. package/dist/threadContextPreamble.js.map +1 -1
  139. package/dist/threadRouting.d.ts +47 -4
  140. package/dist/threadRouting.d.ts.map +1 -1
  141. package/dist/threadRouting.js +31 -4
  142. package/dist/threadRouting.js.map +1 -1
  143. package/dist/todos/projects.d.ts +1 -1
  144. package/dist/todos/projects.d.ts.map +1 -1
  145. package/dist/todos/projects.js +3 -14
  146. package/dist/todos/projects.js.map +1 -1
  147. package/dist/topicTalkerMemory.d.ts +37 -0
  148. package/dist/topicTalkerMemory.d.ts.map +1 -0
  149. package/dist/topicTalkerMemory.js +61 -0
  150. package/dist/topicTalkerMemory.js.map +1 -0
  151. package/dist/topicTalkers.d.ts +123 -0
  152. package/dist/topicTalkers.d.ts.map +1 -0
  153. package/dist/topicTalkers.js +276 -0
  154. package/dist/topicTalkers.js.map +1 -0
  155. package/dist/types.d.ts +5 -4
  156. package/dist/types.d.ts.map +1 -1
  157. package/dist/utils/agentEnvironment.d.ts +23 -0
  158. package/dist/utils/agentEnvironment.d.ts.map +1 -1
  159. package/dist/utils/agentEnvironment.js +33 -1
  160. package/dist/utils/agentEnvironment.js.map +1 -1
  161. package/dist/utils/agentPlugin.d.ts +7 -2
  162. package/dist/utils/agentPlugin.d.ts.map +1 -1
  163. package/dist/utils/agentPlugin.js +11 -5
  164. package/dist/utils/agentPlugin.js.map +1 -1
  165. package/dist/utils/authorMark.d.ts +59 -0
  166. package/dist/utils/authorMark.d.ts.map +1 -0
  167. package/dist/utils/authorMark.js +86 -0
  168. package/dist/utils/authorMark.js.map +1 -0
  169. package/dist/utils/claudeLimitSwitch.d.ts +5 -1
  170. package/dist/utils/claudeLimitSwitch.d.ts.map +1 -1
  171. package/dist/utils/claudeLimitSwitch.js +6 -2
  172. package/dist/utils/claudeLimitSwitch.js.map +1 -1
  173. package/dist/utils/claudeProfileUsageLines.d.ts +1 -1
  174. package/dist/utils/claudeProfileUsageLines.js +3 -3
  175. package/dist/utils/claudeProfileUsageLines.js.map +1 -1
  176. package/dist/utils/claudeProfiles.d.ts +7 -0
  177. package/dist/utils/claudeProfiles.d.ts.map +1 -1
  178. package/dist/utils/claudeProfiles.js +15 -0
  179. package/dist/utils/claudeProfiles.js.map +1 -1
  180. package/dist/utils/claudeUsage.d.ts +56 -20
  181. package/dist/utils/claudeUsage.d.ts.map +1 -1
  182. package/dist/utils/claudeUsage.js +81 -38
  183. package/dist/utils/claudeUsage.js.map +1 -1
  184. package/dist/utils/fallbackChain.d.ts.map +1 -1
  185. package/dist/utils/fallbackChain.js +8 -4
  186. package/dist/utils/fallbackChain.js.map +1 -1
  187. package/dist/utils/folderGit.d.ts +9 -0
  188. package/dist/utils/folderGit.d.ts.map +1 -0
  189. package/dist/utils/folderGit.js +33 -0
  190. package/dist/utils/folderGit.js.map +1 -0
  191. package/dist/utils/forwardedMark.d.ts +8 -0
  192. package/dist/utils/forwardedMark.d.ts.map +1 -1
  193. package/dist/utils/forwardedMark.js +2 -0
  194. package/dist/utils/forwardedMark.js.map +1 -1
  195. package/dist/utils/jsonStreamHost.d.ts +2 -1
  196. package/dist/utils/jsonStreamHost.d.ts.map +1 -1
  197. package/dist/utils/jsonStreamHost.js +4 -2
  198. package/dist/utils/jsonStreamHost.js.map +1 -1
  199. package/dist/utils/messageContext.d.ts +22 -7
  200. package/dist/utils/messageContext.d.ts.map +1 -1
  201. package/dist/utils/messageContext.js +19 -5
  202. package/dist/utils/messageContext.js.map +1 -1
  203. package/dist/utils/personLabel.d.ts +13 -0
  204. package/dist/utils/personLabel.d.ts.map +1 -0
  205. package/dist/utils/personLabel.js +15 -0
  206. package/dist/utils/personLabel.js.map +1 -0
  207. package/dist/utils/replyQuote.d.ts +17 -3
  208. package/dist/utils/replyQuote.d.ts.map +1 -1
  209. package/dist/utils/replyQuote.js +25 -2
  210. package/dist/utils/replyQuote.js.map +1 -1
  211. package/dist/utils/talkerAccess.d.ts +9 -0
  212. package/dist/utils/talkerAccess.d.ts.map +1 -0
  213. package/dist/utils/talkerAccess.js +20 -0
  214. package/dist/utils/talkerAccess.js.map +1 -0
  215. package/dist/utils/tmuxExec.d.ts +20 -8
  216. package/dist/utils/tmuxExec.d.ts.map +1 -1
  217. package/dist/utils/tmuxExec.js +27 -7
  218. package/dist/utils/tmuxExec.js.map +1 -1
  219. package/dist/utils/topicAccessScreenPlan.d.ts +253 -0
  220. package/dist/utils/topicAccessScreenPlan.d.ts.map +1 -0
  221. package/dist/utils/topicAccessScreenPlan.js +287 -0
  222. package/dist/utils/topicAccessScreenPlan.js.map +1 -0
  223. package/dist/utils/topicLabel.d.ts +12 -0
  224. package/dist/utils/topicLabel.d.ts.map +1 -0
  225. package/dist/utils/topicLabel.js +12 -0
  226. package/dist/utils/topicLabel.js.map +1 -0
  227. package/dist/utils/topicRequest.d.ts +8 -5
  228. package/dist/utils/topicRequest.d.ts.map +1 -1
  229. package/dist/utils/topicRequest.js +9 -7
  230. package/dist/utils/topicRequest.js.map +1 -1
  231. package/npm-shrinkwrap.json +1003 -0
  232. package/package.json +4 -2
package/.env.example CHANGED
@@ -70,6 +70,11 @@ ALLOWED_GROUP_ID=
70
70
  # OpenCode HTTP server URL. Leave unset for the built-in loopback server on
71
71
  # http://localhost:4096. Set it for a custom port or an external server.
72
72
  # OPENCODE_URL=http://localhost:4096
73
+ # The server the bot starts always requires a password: a random one per start,
74
+ # or this one when set (also what the bot sends to a server you run yourself).
75
+ # A password-less `opencode serve` of the bot's user on that port is replaced,
76
+ # also one you run yourself (a turn of yours in it ends): start your own with
77
+ # OPENCODE_SERVER_PASSWORD and set OPENCODE_PASSWORD to the same value.
73
78
  # OPENCODE_PASSWORD=
74
79
  # OPENCODE_USERNAME=opencode
75
80
  # OPENCODE_ALLOW_REMOTE=1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,33 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.13.0 — 2026-11-12
6
+
7
+ **A Jira instance with a `trustedGroup` can now trust only the apps and automations you list: the new `jira.json` key `trustedApps` names their account ids, and any other app is treated like a person outside the group.**
8
+ Before, `trustedGroup` trusted its members, the AI account and EVERY app or automation account (`accountType` `app`): the text any of them wrote reached the agent and any of their hand-overs started it. On a real site the group holds dozens of app users — chat, mail, error-tracking and help-desk integrations — that can relay text written by outsiders into an issue, so an outsider's words could steer the agent through one of them. Now, with `"trustedApps": ["<account id>", …]` set (even `[]`), an app is trusted only when its id is listed — membership in the group is not enough for an app — and every other app gets what a person outside the group gets: its text is withheld, its hand-over opens no request (the usual notice, the issue goes back to the requester), its @-mention is ignored. Each app that is not listed is logged once — the first time it acts on an issue, not at the start — with its name and account id, so you can copy the ids to trust. A listed id adds no trust to a person's account.
9
+ Nothing changes for an instance that does not set the key — every app stays trusted — except one warning at the start that names `trustedApps` (it is not logged without a `trustedGroup`). `trustedApps` without a `trustedGroup` refuses the start: without a group everyone is trusted anyway. See SETUP.md, «Jira setup».
10
+
11
+ **`npm install -g charness` and the bot's own npm update now install exactly the dependency versions that were tested — not whatever is newest within the ranges on the day.**
12
+ Before, a global npm install resolved every dependency range afresh (and ran the install scripts of what it found), so a package version published since — a hijacked one, say — could reach your machine with the next update. The package now ships an `npm-shrinkwrap.json` that pins its whole dependency tree, every package by its hash, and npm installs by it (npm 11 and older; npm 12 no longer reads such a file and resolves the ranges as before). The release itself was hardened too: the job that holds the right to publish no longer installs or runs anything of the repository's — it publishes the tarball another job built and a third one installed and checked —, and npm now gets a version before the repository does, so a release that fails no longer leaves a `vX.Y.Z` tag (and a version bump on `main`) for a version npm never received.
13
+
14
+ **A stranger can no longer take over your bot by making a group, adding the bot and sending `/pair` (or any message) there — with `OWNER_USER_ID` set only you pair the bot with a group, without it only the creator of the group it serves can move it.**
15
+ Before, pairing checked only that the sender administered the NEW group — which whoever made that group always does — so anyone who knew the bot's username could re-point it to their own group and drive its agents, with your files and keys; an install that served only your DM (`CHAT_MODE=both` with `OWNER_USER_ID`) stayed unpaired, and the first message in any stranger's group paired it. Now, with `OWNER_USER_ID` set, the bot pairs a group only from your own message there and refuses everyone else's `/pair` («Only the bot's owner can pair it with a group.»). Without an owner the first group is still paired by an admin who talks to the bot there, and after that only the creator of the group it serves can move it with `/pair` («The bot serves another group; only that group's creator can move it here.»). A numeric `ALLOWED_GROUP_ID` still locks pairing altogether. Every language has both refusals.
16
+
17
+ **Agents, terminals and scheduled checks no longer get the bot's Telegram token (or your `OPENCODE_PASSWORD`) in their environment, so it no longer turns up by accident in an `env` an agent prints, a log, a job record or an install's output.**
18
+ Before, every process the bot started inherited its whole environment: Claude and OpenCode agents, a `/terminal` shell, the tmux server they run on (any process there could read it back with `tmux show-environment -g`), git in a bound folder (whose config the agent can write), npm installs and updates. Now they all get the bot's environment without its own secrets: `TELEGRAM_BOT_TOKEN` and `OPENCODE_PASSWORD`. The agents reach Telegram only through the bot's tools, so nothing they do changes. Your other variables — provider keys, tool tokens your agents use for their work — still reach them. A tmux server started by an older bot is cleared of the two before the next agent session is made on it; on a Telegram instance that is the default tmux server, so windows you open there later no longer inherit the two either. This stops the bot from handing its secrets out; it does not hide them from a process that sets out to find them: the agents run as the bot's own user, who can read the bot's config file.
19
+
20
+ **The OpenCode server the bot starts now requires a password, so another account on the same machine can no longer drive your agents through it.**
21
+ Before, `opencode serve` listened on `127.0.0.1:4096` with no password: loopback is open to every account of the machine, so any local user or process could read the conversations and send prompts that ran as the bot's user. Now every server the bot starts gets a random password of its own (or your `OPENCODE_PASSWORD`, when you set one), kept in `DATA_DIR/.opencode-server-credential`, readable by the bot's user only, and the bot sends it with every request — also after a restart, a hot reload or the adoption of a running server. The bot always sends what the running server was started with, so adding, changing or removing `OPENCODE_PASSWORD` takes effect at the next server start and never locks the bot out of its own server. A password-less server on the bot's port is not left open: when the bot starts, it asks it once without a password, and if it answers, the bot replaces it as soon as no topic works in it (looking again every 10 minutes) — in hot mode and without it, on Linux and macOS. That is one an older bot left running, and also an `opencode serve` you run yourself on that port (a turn of yours in it ends with it): start your own with `OPENCODE_SERVER_PASSWORD` and set `OPENCODE_PASSWORD` to the same value. A process that is not an `opencode serve` of the bot's own user is never stopped (on Windows the bot cannot tell, so it says so in the log). A port held by a server that wants a password the bot does not have is left alone, and the error says so ([troubleshooting](docs/troubleshooting.md)).
22
+
23
+ **You can now let a group member talk to the agent in ONE topic without making them a group admin — `/access` (admins only) keeps that topic's list, and General's list covers every topic.**
24
+ Before, the bot answered only the group's creator and administrators, so letting a colleague write to an agent meant making them an admin: every command in every topic, a shell on the host. Now an admin opens `/access` in a topic and adds a person three ways — a tap on someone who wrote there and was ignored, a reply to their message with `/access add`, or `/access add @username` (a name the bot has not seen waits as «⏳ @alice» until that person's first message, within 7 days, and turns into a grant by itself). **Each grant shows a warning first** — a talker can make the agent run any command in the topic's folder, as the bot's OS account — and a typed add takes effect only on «✅ Add». A revoke is one tap; a person who leaves the group loses every entry; the lists live in `state.json`. What a talker can do: write, speak and send files to the agent in that topic, answer its questions, and run `/esc`, `/status`, `/whoami` and `/help`; everything else answers «Only group admins can use this command.», the bot's pickers refuse their taps, and what they type never feeds an input step an admin started. What the agent reads: their messages lead with `[Message from topic member "Alice Smith" (@alice) · not the operator]` (a line of theirs that would open like one of the bot's own headers is escaped), the topic's preamble says people other than the operator write there, a request names who sent it, and the answer a talker gives to the agent's question says who chose it. A talker is not a read restriction: everyone in the group still reads every topic. An admin or the bot named by a typed @username is refused like their id would be (no dead invitation), `/help` lists `/access`, and the welcome after a bind counts General's list and the waiting invitations too. A person joining or leaving the group does not count as their first message (an invitation waits for a real one), a talker's refused message leaves a usage-limit wait armed, and `/access remove` points to General's list for a person who is on it. Details: [`/access`](docs/commands.md#access), [Who may write in a topic](docs/commands.md#who-may-write-in-a-topic), SETUP.md § Access control.
25
+
26
+ **A reply to a message written by somebody who may not talk to the agent now reaches the agent as untrusted text — it is no longer labelled `from: user`, as if you had written it.**
27
+ Before, the quote the bot folds ahead of a reply named only two authors, the agent and «user»: a message of a group member the bot does not serve, a channel's post or an anonymous admin's, once you replied to it, was handed to the agent under `from: user`, so what a stranger wrote could be read as your own instruction. Now the header names who wrote the quoted message — `from: assistant` for the agent, `from: user` for you and the other group admins, and `from: group member "Bob Stone" (@bob), not allowed to talk to you; untrusted text` for anybody else, with the name quoted and cleaned of brackets and control characters (a post made as the group or a channel is named by that chat's title). It holds for text, voice notes and files, both agents.
28
+
29
+ **`/limits` and `/accounts` no longer show an account that reset by itself as «100% 🔄 in 1m» — a window whose reset time has passed is shown as a bare `0%`, and the account is offered again.**
30
+ Before, the last reading of an account that ran out of its limit and was then left unused stayed on screen after the window had reset, printed with a reset «in 1m» that never came. Likely cause (the code path is certain, the token lifetime was measured at about eight hours on another account): an unused account's login token expires, the CLI renews tokens only when it runs on the account and the bot never does, so the bot had nothing to poll with and kept the old figures, marked `(stale)`. The same frozen figure also kept the account out of the eligible list of the `claude_profiles` answer, of the fallback chain's availability check and — being stale — of the topic's switch candidates. Now every screen and every pick reads a window against the clock: one whose reset has passed since it was read is `0%` with no countdown (nothing says when its next period ends), `(stale)` still says the figures were not re-read, and the account counts as free. `0%` only means the old window is over: what the account has used since, through a login on another machine or another host user, is not visible to the bot — a topic that meets the limit there again is moved on as usual. The first poll after the CLI renewed the token shows fresh figures again.
31
+
5
32
  ## 3.12.0 — 2026-11-10
6
33
 
7
34
  **Jobs on a Mac runner no longer print «Killed: 9» lines into their output — a line like `runner.sh: line N: <pid> Killed: 9 ( sleep $limit_sec; kill -9 "$command_pid" )` that read like a failure after every step with a Simulator call.**
package/DEVELOPMENT.md CHANGED
@@ -205,19 +205,75 @@ docker exec charness-main charness-restart-bot # restart only the bot; agents
205
205
  Two workflows. **`.github/workflows/test.yml` (`Tests`)** runs typecheck, build and the FULL `yarn test` on every push to
206
206
  `main`. **`.github/workflows/publish.yml`** releases charness to npm without anyone doing anything: every day at 09:17
207
207
  (Asia/Tbilisi) it decides by itself: nothing shipped changed → a green run, no tag, no publish; otherwise it checks the tests
208
- of the commit it would release (below), checks the package, commits `chore(release): X.Y.Z`, tags `vX.Y.Z`, publishes to the
209
- `latest` dist-tag with provenance (npm trusted publishing from the `release` environment, no npm token anywhere) and creates
210
- the GitHub Release from the CHANGELOG section. Red anywhere → no tag, no publish, the run is red; the next day's run tries
211
- again by itself. The logic is in `src/release/` (pure `releasePlan.ts` and `testGate.ts` + the `cli.ts` wrapper, run by
212
- `tsx`, never built into `dist/`).
208
+ of the commit it would release (below), checks and packs the package, publishes it to the `latest` dist-tag with provenance
209
+ (npm trusted publishing from the `release` environment, no npm token anywhere), and only THEN commits `chore(release): X.Y.Z`,
210
+ tags `vX.Y.Z`, pushes `main` and creates the GitHub Release from the CHANGELOG section. Red anywhere before the publish → no
211
+ publish, no tag, no push, the run is red; the next day's run tries again by itself. The logic is in `src/release/` (pure
212
+ `releasePlan.ts` and `testGate.ts` + the `cli.ts` wrapper, run by `tsx`, never built into `dist/`).
213
+
214
+ - **Jobs and rights**, in order: `gate` (the plan, the unfinished-release check below and the `Tests` gate; its outputs — the
215
+ version, the tag, go or not — are what every later job goes by; the released commit is always the run's own `github.sha`) → `test` (only when no `Tests`
216
+ run covers the commit: `test.yml` itself, called, with every install script; it hands on nothing but its result) →
217
+ `package` (applies the version, checks the release is the tested commit plus its bump, builds, checks the contents and the
218
+ publish dry run, packs; reports the tarball's sha256 and integrity) → `check-install` (the release commit merged LOCALLY into
219
+ `main` as it stands — a conflict fails here, before the publish — and the tarball installed the way a user does, below) →
220
+ `publish` (the only job with `id-token: write`: it checks out nothing and installs nothing but the pinned npm with no scripts —
221
+ it checks the tarball's sha256 and publishes THAT file, `npm publish <tarball> --provenance`) → `release` (the only job that can
222
+ write: `commit-release --prepare --tarball` makes the release commit — the tested commit plus `package.json`,
223
+ `npm-shrinkwrap.json` and `CHANGELOG.md` taken out of the very tarball npm has (npm packs them byte for byte) —, the tag and
224
+ the merge with a moved `main`, locally and without the token; then a plain `git push --atomic` of `main` and the tag, and the
225
+ GitHub Release. Its checkout keeps no credentials; the token is in the environment of the push step (git only) and the Release
226
+ step (`gh`) alone. A step is not a boundary against code that ran earlier in the same job — such a process runs as the same
227
+ user and could read a later step's environment —, so what runs there is pinned by hash: Yarn by `packageManager`
228
+ (`yarn@4.9.2+sha512.…`, which corepack checks), its packages by `yarn.lock`, the actions by commit). Every job but `test` installs
229
+ from `yarn.lock` with no install scripts (`--mode=skip-build`) and nothing from a cache. npm is pinned to an exact version in
230
+ every job (`npm@11.21.1`, installed with `--ignore-scripts`); npm 12 reads no shrinkwrap and packs none — move past 11 only
231
+ together with another lock (the package check refuses a tarball without `npm-shrinkwrap.json`). Every action is pinned to a
232
+ full commit SHA (the version beside it in a comment): bump one by looking its release tag's commit up, never back to a tag.
233
+ - **When a release fails:** npm gets the version BEFORE the repository, so a failure leaves at most one half-done state, and
234
+ only after the publish:
235
+ - anything up to and including `publish` (the gate, the suite, a package or install check, a conflict with `main` that the
236
+ `check-install` merge finds, the npm publish itself — OIDC, provenance, the registry): nothing is published, tagged or
237
+ pushed; the next daily run (or a dispatch, or "Re-run failed jobs") starts that version over;
238
+ - `publish` reached npm but its job failed, or `release` failed (a push refused — also by a `main` that moved in the seconds
239
+ between the merge and the push —, a conflict with a commit that landed on `main` after `check-install`): **npm has a version
240
+ the repository does not** (no tag, `main` still on the old version). Every later run then stops before publishing anything,
241
+ naming the version, until the release is finished: in `gate` when it would release ANOTHER version (`check-registry`: npm
242
+ holds a version, not the run's own, newer than the newest one both tagged and on npm — a tag npm never got does not count —;
243
+ releasing past it would lose it for good, its bump moving `package.json` beyond it; a registry that does not answer is read
244
+ again after 1 s and 3 s), in `package` when it packs another tarball of THAT version (npm cannot take it, and tagging it
245
+ would be wrong); a run that packs the very same tarball goes on and finishes the release. To finish it:
246
+ 1. "Re-run failed jobs" on THAT run (within 7 days, the artifact's life; the version's provenance on npmjs.com links the run)
247
+ — not "Re-run all jobs", which packs anew and, on another day, is refused: `publish` sees npm holds exactly its tarball
248
+ and goes on, `release` commits, tags, pushes and makes the Release; a re-run after the push went through finds the tag
249
+ and only makes the Release;
250
+ 2. by hand, when the re-run cannot finish it: on a checkout of the run's commit (the tested SHA, in the provenance),
251
+ `npm pack charness@X.Y.Z`, then `yarn tsx src/release/cli.ts commit-release X.Y.Z --tarball charness-X.Y.Z.tgz --base <SHA>`
252
+ (`--remote <name>` when GitHub is not your `origin`)
253
+ — it commits that commit plus the tarball's version files and nothing else, merges `main` and pushes; a real conflict
254
+ with `main` is resolved by hand, then push `main` and the tag —, and `yarn tsx src/release/cli.ts notes X.Y.Z > notes.md`,
255
+ `gh release create vX.Y.Z --verify-tag --title vX.Y.Z --notes-file notes.md`.
256
+ - A version with no release run — published by hand, or its tag only on another remote (a clone whose `origin` is not
257
+ GitHub) — stops the runs the same way: push its `vX.Y.Z` tag to GitHub.
258
+ - A hand-pushed tag is in the repository before its publish: when that fails, "Re-run failed jobs" on its run.
259
+ - **The shrinkwrap:** `npm-shrinkwrap.json` (`src/release/hubShrinkwrap.ts`) pins the package's whole run-time tree as
260
+ `yarn.lock` resolved it — every tarball by its sha512, `hasInstallScript` where the registry says so (or npm would not
261
+ run `node-pty`'s install script from it) —, so `npm install -g charness` and the npm self-update install what was tested,
262
+ with npm 11 and older (npm 12 resolves the ranges again). Run `yarn shrinkwrap` after every dependency change, beside
263
+ `yarn runner-lock` (`releaseHubShrinkwrap.test.ts` fails until you do; it asks the registry only about packages it does not
264
+ know yet). Its version is the package's: `apply` writes it, as `npm version` does, and `verify-delta` lets it differ from
265
+ the tested commit in exactly those two lines. Those two lines sit between lines a dependency change never touches (`"name"`,
266
+ `"lockfileVersion"`, `"dependencies": {`), so a dependency change that lands on `main` during a release merges with it
267
+ (`releaseCli.test.ts` holds that).
213
268
 
214
269
  - **Tests gate:** the release does not run the suite again when the exact commit already passed. It asks GitHub for the
215
270
  `Tests` workflow's runs of that commit's SHA (the newest run of the commit decides): **passed** → go on; **no run at all**
216
271
  (a manual dispatch before CI ran) → the release runs the suite itself; **failed or still running** → the daily run
217
272
  releases nothing that day and ends green with the reason (a red head is not skipped over to an older green commit), a
218
273
  manual dispatch or a hand-pushed tag fails with it. The release commit may differ from the tested one ONLY in
219
- `package.json`'s `"version"` line and `CHANGELOG.md`: `verify-delta` checks the diff before the tag and again in the publish
220
- job (the tag against the tested SHA) and refuses otherwise. A hand-pushed tag (`npm version`, then push `main` with the tag) is gated through its
274
+ `package.json`'s `"version"` line, the two version lines of `npm-shrinkwrap.json` and `CHANGELOG.md`: `verify-delta` checks
275
+ the diff in `package` before packing, and `commit-release --base` again before it commits (in `check-install` and `release`),
276
+ and refuses otherwise. A hand-pushed tag (`npm version`, then push `main` with the tag) is gated through its
221
277
  PARENT: when the commit before the tag has a green `Tests` run and the tag differs from it only in the version and the CHANGELOG,
222
278
  that run is the gate — the tag's own run, started by the same push, is not waited for. When the parent is not green or the tag
223
279
  carries more than the bump, the tagged commit's own run decides (still running → refused: re-run the release once it is green).
@@ -231,8 +287,9 @@ again by itself. The logic is in `src/release/` (pure `releasePlan.ts` and `test
231
287
  day, or a change and its revert, publishes nothing; README / SETUP changes reach the npm page with the next code
232
288
  release.
233
289
  - **Manual run** (Actions → Release to npm → Run workflow): `bump` `auto|patch|minor|major`; `force` releases even when
234
- the skip rules say skip (never past the breaking-change guard of `auto`); `dryRun` does everything but the push, the
235
- publish and the GitHub Release and prints the plan, the CHANGELOG diff, the notes and the package check.
290
+ the skip rules say skip (never past the breaking-change guard of `auto`); `dryRun` does everything but the publish, the
291
+ push and the GitHub Release — it runs `package` and `check-install` (the install and the merge with `main`) — and prints the
292
+ plan, the CHANGELOG diff and the notes.
236
293
  - **By hand:** `npm version minor` locally (its `preversion` runs typecheck, build and the tests, its
237
294
  `version` script moves the CHANGELOG heading, `.npmrc` gives the commit npm's message `chore(release): X.Y.Z`), then
238
295
  push `main` with the tag; the workflow gates that tag on its commit's `Tests` run (above) and publishes it.
@@ -241,13 +298,19 @@ again by itself. The logic is in `src/release/` (pure `releasePlan.ts` and `test
241
298
  paragraph or `- ` bullet, in any `###` subsection — starts with a bold first sentence (`**…**`); the run fails,
242
299
  quoting the line, otherwise (`changelogFormat.test.ts` fails first on a commit that breaks it). An empty
243
300
  `## Unreleased` is filled with the `feat` / `fix` subjects.
244
- - **Package check** before any tag: the tarball holds `dist/cli.js`, `stt/gigaam_sidecar.py`, `CHANGELOG.md`,
245
- `README.md`, `LICENSE` and no `src/` or tests, and `charness --version` of it, installed into a temp prefix, prints
246
- the new version (`yarn tsx src/release/cli.ts check-pack`, after `yarn build`). `bin` paths are written
301
+ - **Package check** before anything is published: the tarball holds `dist/cli.js`, `stt/gigaam_sidecar.py`, `npm-shrinkwrap.json`,
302
+ `CHANGELOG.md`, `README.md`, `LICENSE` and no `src/` or tests, and installed the way a user installs it — `npm install -g`
303
+ from a loopback registry that serves the tarball and marks its shrinkwrap, as the npm registry does (an install of the
304
+ tarball FILE ignores the shrinkwrap), dependencies passed on to the real registry — `charness --version` prints the new
305
+ version and every package sits at the version the shrinkwrap pins (`yarn tsx src/release/cli.ts check-pack`, after
306
+ `yarn build`; the `check-install` job runs the same install on the tarball `package` packed: `check-install --tarball`). `bin` paths are written
247
307
  `dist/cli.js`, never `./dist/cli.js`: npm >= 11.10 silently drops a "./" entry from the manifest it publishes (3.3.0
248
308
  reached the registry without its commands), so `check-pack` and `packageManifest.test.ts` refuse one, and
249
- `check-publish` (`npm publish --dry-run`, run before the tag and again right before the publish) refuses a package.json
309
+ `check-publish` (`npm publish --dry-run`, run in the package job) refuses a package.json
250
310
  that npm reports it would drop or rewrite anything from.
251
311
  - **After a release** the clone is one commit behind `main`: `git pull --rebase` before pushing. A new CHANGELOG entry
252
- goes under `## Unreleased` (a push that races the release can conflict there; the run then fails with nothing
253
- published).
312
+ goes under `## Unreleased`; one that lands on `main` while a release runs stays there — the release's merge with `main`
313
+ keeps everything added during the run under `## Unreleased` (`mergeReleaseChangelog`), where git alone conflicts on an
314
+ entry added at the top and files one added at the end under the version that did not ship it. Only rewording or removing
315
+ an entry that is being released conflicts: before the install check, the run fails with nothing published; after it, see
316
+ "When a release fails".
package/README.md CHANGED
@@ -121,7 +121,8 @@ Think **OpenClaw for vibe coding**, driven entirely from Telegram: no complex se
121
121
  | Voice input | Voice notes are transcribed by an ordered chain of engines — Groq, OpenAI or your own OpenAI-compatible server — set up in `/stt` (or `stt.json`); a local GigaAM engine is optional; if one fails, the next takes over | [`/stt`](docs/commands.md#stt), [Voice input](SETUP.md#voice-input) |
122
122
  | Display verbosity and view | Per topic: detail `minimal\|short\|full`, and what the topic shows — `stream` (default), `stream_answers` or `answers` (only the agent's pinned answers, no stream) | [`/verbosity`](docs/commands.md#verbosity), [`/thinking`](docs/commands.md#thinking), [`/tool_results`](docs/commands.md#tool_results), [`/subagent`](docs/commands.md#subagent) |
123
123
  | 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 | [`/timestamps`](docs/commands.md#timestamps) |
124
- | 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, both agents | [Reply context](docs/commands.md#reply-context) |
124
+ | 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, and who wrote it — a message of somebody who may not talk to the agent is quoted as untrusted text; works for text, voice and files, both agents | [Reply context](docs/commands.md#reply-context) |
125
+ | Talkers | An admin lets a group member talk to the agent in ONE topic (or in every topic, from General's list) without making them an admin: `/access` adds them with a tap, a reply or an @username, after a warning that they can make the agent run any command in the folder; the agent reads their words under a mark that says they are not the operator | [`/access`](docs/commands.md#access), [Who may write in a topic](docs/commands.md#who-may-write-in-a-topic) |
125
126
  | Forwarded messages | Forward a message into a topic and the agent is told it is forwarded, from whom and when it was originally sent — so a forwarded alert or quote is never read as your own words; works for text, voice and files, both agents | [Forwarded messages](docs/commands.md#forwarded-messages) |
126
127
  | 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 | [`/timezone`](docs/commands.md#timezone) |
127
128
  | Observability | An always-on output trace and a console log, the source of truth for "a message never reached the topic" | [`/trace`](docs/commands.md#trace), [`/doctor`](docs/commands.md#doctor), [Troubleshooting](docs/troubleshooting.md) |
package/SETUP.md CHANGED
@@ -247,6 +247,15 @@ stopped; this is not confirmed on current WSL. If the bot stops after you log in
247
247
  These settings apply to every surface. The Telegram ones — the bot token, the group and the DM, voice — are listed
248
248
  under [Telegram environment variables](#telegram-environment-variables).
249
249
 
250
+ The agents (Claude, OpenCode, a terminal), a scheduled check, git in a bound folder, a sign-in and an install or update
251
+ the bot runs get the bot's environment WITHOUT its own secrets — `TELEGRAM_BOT_TOKEN` and `OPENCODE_PASSWORD`: an agent
252
+ reaches Telegram only through the bot's tools. Your other variables (provider keys, tool tokens your agents use for their
253
+ work) reach them as before. This keeps the two out of what agents print, log and install; it is no barrier against a
254
+ process that looks for them, since the agents run as the bot's own user, who can read its config file. Without
255
+ `TMUX_SOCKET_NAME` the agents run on your default tmux server, and the bot removes the two from that server's environment
256
+ before each agent session: a window or session you open there afterwards no longer inherits them (one already open keeps
257
+ what it has).
258
+
250
259
  #### External Optional
251
260
 
252
261
  | Variable | Default | Description |
@@ -266,8 +275,8 @@ your chosen providers need them.
266
275
  |---|---|---|
267
276
  | `WORK_ROOT` | `$PWD` | You cannot control the process cwd; normal launch uses `cd <projects-parent> && charness` |
268
277
  | `OPENCODE_URL` | `http://localhost:4096` | You use a custom OpenCode port or external server; the port must differ per instance |
269
- | `OPENCODE_USERNAME` | `opencode` | `OPENCODE_PASSWORD` is set for a protected OpenCode server |
270
- | `OPENCODE_PASSWORD` | — | Connecting to a protected OpenCode server |
278
+ | `OPENCODE_USERNAME` | `opencode` | `OPENCODE_PASSWORD` is set and its user is not `opencode` |
279
+ | `OPENCODE_PASSWORD` | a random one per server start | You run the OpenCode server yourself with a password, or other tools of yours must reach the server the bot starts: the bot then starts it with this password instead of a random one (a change reaches a server the bot already runs at its next start). Without it the bot's server still requires a password — a new one each start, kept in `DATA_DIR/.opencode-server-credential` (readable by the bot's user only) — so no other account of the machine can drive the agents through it. A password-less `opencode serve` of the bot's user on the bot's port is stopped and replaced once no topic works in it: one an older bot left running, and also one you run yourself (only the bot's topics count, so a turn of yours in its TUI ends with it). To run your own server there, start it with `OPENCODE_SERVER_PASSWORD` and set `OPENCODE_PASSWORD` to the same value |
271
280
  | `OPENCODE_ALLOW_REMOTE` | — | `OPENCODE_URL` intentionally points outside loopback |
272
281
  | `OPENCODE_BIN` | (auto) | The `opencode` binary is not on PATH or you use a fork. Auto: the first `opencode` on PATH (on Windows with each `PATHEXT` extension — npm's `opencode.cmd` shim is run as the Node script it wraps, another `.cmd` / `.bat` through `cmd.exe`), else the copy the bot installed in `~/.npm-global` |
273
282
  | `CLAUDE_BIN` | (auto) | The `claude` binary is not on PATH due to nvm/asdf/systemd PATH differences |
@@ -322,7 +331,7 @@ What it does depends on how this instance is installed — `/update` names the k
322
331
 
323
332
  | Install | What the updater does |
324
333
  |---|---|
325
- | **npm global** (`npm install -g charness`, a prefix the bot's user can write) | Takes a new version from the registry **4 hours after the bot first saw it**, so a hastily fixed release never reaches you first; installs it with the `npm` beside the running `node`, runs `charness self-check` on the NEW install before switching, then restarts onto it. Never `sudo`. |
334
+ | **npm global** (`npm install -g charness`, a prefix the bot's user can write) | Takes a new version from the registry **4 hours after the bot first saw it**, so a hastily fixed release never reaches you first; installs it with the `npm` beside the running `node` — by the package's `npm-shrinkwrap.json`, so every dependency at the version that release was tested with (npm 12 ignores that file and resolves the ranges) —, runs `charness self-check` on the NEW install before switching, then restarts onto it. Never `sudo`. |
326
335
  | **git checkout** (a clone, an `npm link`, the one the Docker container mounts) | Fast-forwards through `scripts/self-update.sh`, with no hold — a checkout follows `main` — and rebuilds. In hot mode the watcher reloads the worker by itself (a pull that changes no compiled source — docs, the CHANGELOG, scripts — rebuilds nothing, so the updater asks the worker to reload); when a file the hot supervisor loaded changed, the worker asks the supervisor to re-execute itself (same pid; the OpenCode server and the speech engine are left alone). |
327
336
  | anything else — a read-only folder (a root-owned npm prefix), pnpm / yarn / bun, a project-local install, a Node without `process.execve` (needs 22.15+, not Windows), `npx` | Says that a new version is out and how to update by hand; `npx` gets nothing to update. |
328
337
 
@@ -481,12 +490,18 @@ visible topic list, per-topic names/icons, quick agent switching — but it is
481
490
  </p>
482
491
 
483
492
  The group **id is automatic** — leave `ALLOWED_GROUP_ID` empty and the bot
484
- auto-pairs with the first forum supergroup an admin talks to it from (the
485
- `-100…` id is saved to `state.json`; re-point later with `/pair`). To pin a
486
- specific id by hand, set `ALLOWED_GROUP_ID` to the numeric value (a group
487
- **name** is not accepted) — that also disables auto-pairing. **Access control:**
488
- whoever is a creator/administrator of that group may drive the bot — there is no
489
- separate allow-list.
493
+ auto-pairs with the first forum supergroup it is talked to from (the `-100…` id
494
+ is saved to `state.json`; re-point later with `/pair`). Anyone can make a group,
495
+ add your bot and be its creator, so who may pair is limited: with
496
+ `OWNER_USER_ID` set, **only you** — the bot pairs a group only from your message
497
+ there, and `/pair` from anyone else is refused; without it, the first group an
498
+ admin talks to the bot from is paired, and after that only the **creator of the
499
+ group it serves** can move it with `/pair`. To pin a specific id by hand, set
500
+ `ALLOWED_GROUP_ID` to the numeric value (a group **name** is not accepted) —
501
+ that also disables auto-pairing (the safest choice when the bot is reachable by
502
+ others: BotFather's **Allow Groups** off does the same for every new group).
503
+ **Access control:** whoever is a creator/administrator of that group may drive
504
+ the bot — there is no separate allow-list.
490
505
 
491
506
  **To use the DM instead (or as well):** **[manual]** send `/start` to
492
507
  [@userinfobot](https://t.me/userinfobot) for your numeric user id, then add it
@@ -701,20 +716,33 @@ can't be matched from their messages, so post non-anonymously. The DM surface
701
716
  (when enabled) is gated separately: only the configured `OWNER_USER_ID` may
702
717
  talk to the bot there.
703
718
 
704
- > **Security model — group admin (or the DM owner) ⇒ shell on the host.** The agents run with
705
- > permission checks disabled (`--dangerously-skip-permissions` for Claude,
719
+ **Who is who.**
720
+
721
+ | Role | Who | What they may do |
722
+ |---|---|---|
723
+ | **Owner** | `OWNER_USER_ID` | The DM surface. In the group the owner is an admin like any other. |
724
+ | **Admin** | Creator or administrator of the served group | Everything, in every topic — **including shell commands on the host** (below). Manages talkers with `/access`. |
725
+ | **Talker** | A member an admin added to ONE topic's list (or to General's, which is group-wide) | Talks to the agent in that topic only: text, voice notes, files, albums, answers to the agent's questions, and `/esc`, `/status`, `/whoami`, `/help`. Every other command, picker and wizard is refused. |
726
+ | **Anyone else** | Other members, strangers | Ignored, silently. |
727
+
728
+ **Letting someone talk in one topic without making them an admin** is `/access` (admins only, see [the command](docs/commands.md#access)): tap someone who wrote in the topic, reply to their message with `/access add`, or `/access add @username` — each grant shows the warning below before it takes effect. The lists live in `state.json`; a person who leaves the group loses every entry. A talker is **not** a read restriction: everyone in the group still READS every topic (Telegram has no per-topic read rights) — remove a person from the group to stop that.
729
+
730
+ > **Security model — group admin (or the DM owner) ⇒ shell on the host; a talker ⇒ the same, in their topic's folder.**
731
+ > The agents run with permission checks disabled (`--dangerously-skip-permissions` for Claude,
706
732
  > auto-approve for OpenCode) and `/terminal` opens a raw `$SHELL` in the bound
707
733
  > folder, so anyone who can talk to the bot can execute arbitrary commands as
708
- > the bot's OS user. Only promote people you would trust with SSH access to
709
- > that machine, and keep the served group itself private.
734
+ > the bot's OS user. **An admin can do everything.** **A talker can make the agent run any command in that
735
+ > topic's folder** (never in a raw-shell topic, and their words reach the agent marked as theirs, so the agent
736
+ > can tell them from you — but that is a guard, not a sandbox). Only promote or add people you would trust with SSH
737
+ > access to that machine, and keep the served group itself private.
710
738
 
711
739
  #### External Optional (Telegram)
712
740
 
713
741
  | Variable | Default | Description |
714
742
  |---|---|---|
715
- | `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 |
743
+ | `ALLOWED_GROUP_ID` | (auto-pair) | Numeric forum supergroup id (`-100…`). Leave empty to auto-pair: with `OWNER_USER_ID` set, with the first forum group the **owner** writes in; without it, with the first forum group a group **admin/creator** contacts the bot from (id is saved to `state.json`; re-point with `/pair` — the owner only, or without one the creator of the group served now). A **name** is not accepted. A numeric value disables auto-pairing |
716
744
  | `CHAT_MODE` | `both` | Which surface(s) this instance serves: `group`, `dm`, or `both` — see [Two surfaces](docs/backends.md#two-surfaces-group-topics-bot-dm-or-both) |
717
- | `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` |
745
+ | `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 to enable the owner-DM surface (**required** for `CHAT_MODE=dm`); with it set, the owner is also the only person who may pair the bot with a group (auto-pairing and `/pair`) |
718
746
 
719
747
  **Localized in 12 languages** — the bot UI (commands, buttons, notices) speaks
720
748
  中文, English, Français, ქართული, Deutsch, हिन्दी, 日本語, Português, Русский,
@@ -743,8 +771,8 @@ connector behaves is described in [`src/connectors/jira/README.md`](src/connecto
743
771
  1. Create a Jira account for the AI (its API token is the instance's only secret) and note its account id.
744
772
  2. Recommended: create or choose a Jira group of the people whose words may steer the AI (for example
745
773
  `ai-trusted`), and give the AI account the *Browse users and groups* global permission so that it can read
746
- the group. Then the agent reads only the text and files of its members and of Jira's apps and automations,
747
- and only their hand-overs start it.
774
+ the group. Then the agent reads only the text and files of its members and of the apps you list in
775
+ `trustedApps` (step 4), and only their hand-overs start it.
748
776
  3. An instance of its own: a `DATA_DIR`, a `WORK_ROOT` with one folder per project, a private tmux server, and
749
777
  an env file that is the ONLY configuration it reads:
750
778
 
@@ -771,6 +799,7 @@ connector behaves is described in [`src/connectors/jira/README.md`](src/connecto
771
799
  "PROJ": { "folder": "proj", "triggerStatuses": ["In Progress"], "extraFields": ["customfield_10042"] }
772
800
  },
773
801
  "trustedGroup": "ai-trusted",
802
+ "trustedApps": ["<an app account's id>"],
774
803
  "wakeOnMention": true,
775
804
  "pollIntervalSeconds": 30,
776
805
  "runBudgetPer24h": 5,
@@ -785,12 +814,28 @@ connector behaves is described in [`src/connectors/jira/README.md`](src/connecto
785
814
  members again whenever its last read is older than 5 minutes: a removed member loses the AI's trust within
786
815
  that time. List only projects where only your team can write, and where no automation acts on text or
787
816
  actions from outside it — an e-mail handler, a portal form, a copy from another project, a rule that
788
- hands an issue to the AI when someone outside the team acts: an app's or automation's text and hand-over
789
- are trusted, so such a rule brings that outside text, or that person's hand-over, to the agent. Nor list a
817
+ hands an issue to the AI when someone outside the team acts: the text and hand-over of an app or automation
818
+ you trust (see `trustedApps` below) are trusted, so such a rule brings that outside text, or that person's
819
+ hand-over, to the agent. Nor list a
790
820
  project where anyone outside the team holds the *Edit all comments* permission: Jira Cloud keeps no history
791
821
  of a comment's edits, so a comment is judged by its author and its LAST editor only — an outsider's edit of a
792
822
  member's comment, followed by a member's own edit, reads as trusted.
793
823
 
824
+ `trustedApps` (optional, needs `trustedGroup`) is a list of Jira **account ids of app accounts** — the
825
+ integrations and automations (`accountType` `app`) whose text may steer the agent and whose hand-over may
826
+ start it. The group of a site often holds dozens of app users (chat, mail, error-tracking and help-desk
827
+ integrations) that can relay text written by outsiders into an issue, so with the key set an app is trusted
828
+ only when its id is listed — being a member of the group is not enough — and any other app is treated exactly
829
+ like a person outside the group: its text is withheld, its hand-over starts nothing, its mention is ignored.
830
+ `[]` trusts no app. Each app that is not listed is written to the log once, the first time it acts on an issue,
831
+ with its name and account id (`[jira] app "<name>" (account id "<id>") is not in trustedApps: …`), so you can
832
+ copy the ids to trust from there. To find an app's id beforehand, search the site's users by the app's name
833
+ (`GET /rest/api/3/user/search?query=<name>` answers each match's `accountId` and `accountType`, an app's is
834
+ `app`) or look it up in the admin user list; `GET /rest/api/3/user?accountId=<id>` confirms an id you hold.
835
+ Absent, every app is trusted as before, and the start logs one warning that names the key; with no
836
+ `trustedGroup` the key is refused — without a group everyone is trusted anyway. A listed id adds no trust
837
+ to a person's account: people stay trusted by membership alone.
838
+
794
839
  `wakeOnMention` (optional) decides whether an @-mention of the AI account in a comment wakes it to answer
795
840
  only, without the issue being handed over; absent, it is on exactly when `trustedGroup` is set, and `true`
796
841
  without a group is refused — without one, anyone who can comment could start the AI.
@@ -829,7 +874,7 @@ connector behaves is described in [`src/connectors/jira/README.md`](src/connecto
829
874
  The start refuses a missing `ENV_FILE`, `TMUX_SOCKET_NAME` or `jira.json`, an `OPENCODE_URL` on the default
830
875
  port, a `TELEGRAM_BOT_TOKEN` or any `ATLASSIAN_*` variable when Telegram is off, a token that belongs to
831
876
  another account, an unknown project or status, a `trustedGroup` the site does not have or the AI account
832
- may not read, and a `DATA_DIR` holding another surface's state. An unreachable Jira does not refuse the start —
877
+ may not read, a `trustedApps` without a `trustedGroup`, and a `DATA_DIR` holding another surface's state. An unreachable Jira does not refuse the start —
833
878
  polling backs off and resumes.
834
879
 
835
880
  The agent sessions of a Jira instance run without the user-level Claude settings, hooks and skills, with the
@@ -37,9 +37,10 @@ Unless the user names others:
37
37
 
38
38
  ## Launch
39
39
 
40
- 1. Make a private run directory, generate a UUID for the session, write the brief into `<run-dir>/brief.md`:
41
- the task and its context (the worker does not see this conversation), the skills it must load by name, every
42
- resource another live process holds, and "report every changed file and how you verified".
40
+ 1. Make a private run directory (an absolute path: a resume starts from the checkout), generate a UUID for the
41
+ session, write the brief into `<run-dir>/brief.md`: the task and its context (the worker does not see this
42
+ conversation), the skills it must load by name, every resource another live process holds, and "report every
43
+ changed file and how you verified".
43
44
  2. Run it in the target checkout:
44
45
 
45
46
  ```bash
@@ -61,10 +62,14 @@ printf '%s\n' "<uuid>" > "<run-dir>/session"
61
62
  ends; `BASH_MAX_TIMEOUT_MS` lets one foreground command run up to 2 hours. Longer work → split it.
62
63
  - Full privileges with deny rules, never a restricted allowlist: a refused ordinary command ends the worker's
63
64
  turn early.
64
- - A checkout below the folder that holds `.claude/skills` does not see those skills: add
65
+ - A checkout below the folder that holds `.claude/skills` does not see those skills, nor does a worker started above
66
+ it (skills in a subfolder of the checkout, e.g. a repository root whose agents work in one of its folders): add
65
67
  `--add-dir "<that folder>"` and check that the `init` event's `skills` lists every skill the brief names.
66
68
  3. Check the PID: `ps -o args= -p "$(cat "<run-dir>/pid")"` must show `claude -p … <uuid>`. If it does not (the CLI
67
- handed over to a new process), take it from `pgrep -f "^claude -p .*<uuid>"` and write that into the pid file.
69
+ handed over to a new process), take the newest match, `pgrep -n -f "^claude -p .*<uuid>"`, and write that one PID
70
+ into the pid file. `$!` is often the wrapper shell that started it, gone a moment later: wait about 2 seconds after
71
+ the launch, check, and never arm the watch on a PID this check has not confirmed. Neither finds it → the worker
72
+ died at start: read `stderr.log` and the log, fix the cause and relaunch.
68
73
  4. Record the UUID (it is in `<run-dir>/session`), the profile name you launched on, the checkout and the run directory
69
74
  in the plan, then arm the watch check from `charness-orchestration` with this PID and run directory.
70
75
 
@@ -81,6 +86,10 @@ printf '%s\n' "<uuid>" > "<run-dir>/session"
81
86
  - Confirm the old PID is gone, then repeat the launch with `--resume "<uuid>"` instead of `--session-id`, a new
82
87
  brief and new log files (`events-2.jsonl`, …), `touch "<run-dir>/watch-armed"` (the run directory is reused, so the
83
88
  marker of the first run is old) and arm a new check. Never `--continue` or `--fork-session`.
89
+ - Start it in the SAME checkout as the first run, in the same command: `cd "<checkout>" && setsid nohup …`. Your
90
+ shell's working folder may have been reset since, and elsewhere the CLI may not find the session or loads another
91
+ folder's rules. `$!` is then the shell running that line at best: the PID check of step 3 applies. Check that the
92
+ new `init` event's `cwd` is the checkout; another folder → stop the worker and resume it from the checkout.
84
93
  - `<uuid>` comes only from `<run-dir>/session` or the `session_id` of the first (`system`/`init`) event of the first
85
94
  run's log — never from memory or a shortened prefix.
86
95
  - Keep the model, effort and flags of the first run.
@@ -28,6 +28,31 @@ export declare const ADMIN_CACHE_FAILURE_RETRY_MS = 60000;
28
28
  * never an authorised human operator.
29
29
  */
30
30
  export declare function getElevatedMemberIds(members: PlatformMember[]): string[];
31
+ /**
32
+ * @description The @names, as the platform spells them, of the humans who hold elevated rights, for the places that only have a
33
+ * typed @name to go by (the id of someone the bot has not seen is unknown): the same people as {@link getElevatedMemberIds}, minus
34
+ * those with no @name. Kept free of the lists' own name matching (`normaliseUsername`): this module is loaded before any state is.
35
+ */
36
+ export declare function getElevatedMemberHandles(members: PlatformMember[]): string[];
37
+ /**
38
+ * @name SenderRole
39
+ * @description What a sender is to the bot in one conversation: an `admin` (the group's creator or an administrator —
40
+ * everything, everywhere), a `talker` (an admin put them on this topic's list, or on General's: they talk to the agent
41
+ * there and may use only the commands flagged for talkers) or `none` (ignored, silently).
42
+ */
43
+ export type SenderRole = 'admin' | 'talker' | 'none';
44
+ export interface SenderRoleInput {
45
+ userId: string;
46
+ /** The admin set ({@link AdminCache}). */
47
+ adminIds: ReadonlySet<string>;
48
+ /** The ids that may talk in THIS conversation — its own list and General's group-wide one (`getEffectiveTalkerIds`). */
49
+ talkerIds: ReadonlySet<string>;
50
+ }
51
+ /**
52
+ * @description The sender's role. Admin wins: a talker who is later made an admin keeps their list entries, and they
53
+ * stay harmless while the person is an admin and apply again after a demotion.
54
+ */
55
+ export declare function getSenderRole({ userId, adminIds, talkerIds }: SenderRoleInput): SenderRole;
31
56
  export interface AdminCacheDeps {
32
57
  /**
33
58
  * Fetches the ids currently holding elevated rights in the served space —
@@ -36,6 +61,11 @@ export interface AdminCacheDeps {
36
61
  * the platform's status vocabulary out of the policy entirely.
37
62
  */
38
63
  fetchElevatedMemberIds: () => Promise<string[]>;
64
+ /**
65
+ * Fetches the @names of those same members ({@link getElevatedMemberHandles}), refreshed together with the ids. Absent: the cache
66
+ * knows no names ({@link AdminCache.getAdminHandles} is empty). Their spelling is the fetcher's business: the cache keeps what it is given.
67
+ */
68
+ fetchElevatedMemberHandles?: () => Promise<string[]>;
39
69
  /** Cache lifetime; defaults to {@link ADMIN_CACHE_TTL_MS}. */
40
70
  ttlMs?: number;
41
71
  /** Backoff after a failed fetch; defaults to {@link ADMIN_CACHE_FAILURE_RETRY_MS}. */
@@ -53,10 +83,12 @@ export interface AdminCacheDeps {
53
83
  */
54
84
  export declare class AdminCache {
55
85
  private readonly fetchElevatedMemberIds;
86
+ private readonly fetchElevatedMemberHandles;
56
87
  private readonly ttlMs;
57
88
  private readonly failureRetryMs;
58
89
  private readonly now;
59
90
  private ids;
91
+ private handles;
60
92
  /** Timestamp of the last SUCCESSFUL fetch, or `null` if never fetched. */
61
93
  private fetchedAt;
62
94
  /** Timestamp of the last FAILED fetch, or `null`. */
@@ -64,6 +96,17 @@ export declare class AdminCache {
64
96
  private inFlight;
65
97
  constructor(deps: AdminCacheDeps);
66
98
  getAdminIds(): Promise<Set<string>>;
99
+ /**
100
+ * The admins' @names, from the same refresh as {@link getAdminIds}: for deciding about a typed @name whose id the bot
101
+ * has not seen (an admin is never added, and no message of theirs would ever turn the invitation into a person).
102
+ */
103
+ getAdminHandles(): Promise<ReadonlySet<string>>;
104
+ /**
105
+ * The admin set as last fetched, WITHOUT fetching: for the synchronous marks that tell the operator's words from anyone
106
+ * else's. Meaningful right after {@link getAdminIds} (every gated handler awaits it first); empty before the first
107
+ * successful fetch.
108
+ */
109
+ getCachedAdminIds(): ReadonlySet<string>;
67
110
  /** Drop freshness so the next {@link getAdminIds} re-fetches (used on re-pair). */
68
111
  invalidate(): void;
69
112
  private refresh;
@@ -1 +1 @@
1
- {"version":3,"file":"accessControl.d.ts","sourceRoot":"","sources":["../src/accessControl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD;;;;;;;;;;;;;;GAcG;AAEH,sFAAsF;AACtF,eAAO,MAAM,kBAAkB,UAAY,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,QAAS,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,MAAM,EAAE,CAQxE;AAED,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,sBAAsB,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAChD,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sFAAsF;IACtF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+DAA+D;IAC/D,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAA0B;IACjE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IAEnC,OAAO,CAAC,GAAG,CAAqB;IAChC,0EAA0E;IAC1E,OAAO,CAAC,SAAS,CAAuB;IACxC,qDAAqD;IACrD,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,QAAQ,CAAqC;gBAEzC,IAAI,EAAE,cAAc;IAO1B,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAkBzC,mFAAmF;IACnF,UAAU,IAAI,IAAI;YAKJ,OAAO;CAetB"}
1
+ {"version":3,"file":"accessControl.d.ts","sourceRoot":"","sources":["../src/accessControl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD;;;;;;;;;;;;;;GAcG;AAEH,sFAAsF;AACtF,eAAO,MAAM,kBAAkB,UAAY,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,QAAS,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,MAAM,EAAE,CAQxE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,MAAM,EAAE,CAO5E;AAED;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAErD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,wHAAwH;IACxH,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAChC;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,eAAe,GAAG,UAAU,CAI1F;AAED,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,sBAAsB,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAChD;;;OAGG;IACH,0BAA0B,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACrD,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sFAAsF;IACtF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+DAA+D;IAC/D,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAA0B;IACjE,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAwC;IACnF,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IAEnC,OAAO,CAAC,GAAG,CAAqB;IAChC,OAAO,CAAC,OAAO,CAAqB;IACpC,0EAA0E;IAC1E,OAAO,CAAC,SAAS,CAAuB;IACxC,qDAAqD;IACrD,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,QAAQ,CAAqC;gBAEzC,IAAI,EAAE,cAAc;IAQ1B,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAkBzC;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAKrD;;;;OAIG;IACH,iBAAiB,IAAI,WAAW,CAAC,MAAM,CAAC;IAIxC,mFAAmF;IACnF,UAAU,IAAI,IAAI;YAKJ,OAAO;CAkBtB"}
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AdminCache = exports.ADMIN_CACHE_FAILURE_RETRY_MS = exports.ADMIN_CACHE_TTL_MS = void 0;
4
4
  exports.getElevatedMemberIds = getElevatedMemberIds;
5
+ exports.getElevatedMemberHandles = getElevatedMemberHandles;
6
+ exports.getSenderRole = getSenderRole;
5
7
  /**
6
8
  * @description Access control for the bot: who may talk to the agent.
7
9
  *
@@ -41,6 +43,31 @@ function getElevatedMemberIds(members) {
41
43
  }
42
44
  return ids;
43
45
  }
46
+ /**
47
+ * @description The @names, as the platform spells them, of the humans who hold elevated rights, for the places that only have a
48
+ * typed @name to go by (the id of someone the bot has not seen is unknown): the same people as {@link getElevatedMemberIds}, minus
49
+ * those with no @name. Kept free of the lists' own name matching (`normaliseUsername`): this module is loaded before any state is.
50
+ */
51
+ function getElevatedMemberHandles(members) {
52
+ const handles = [];
53
+ for (const member of members) {
54
+ if (!member.hasElevatedRights || member.isBot || !member.handle)
55
+ continue;
56
+ handles.push(member.handle);
57
+ }
58
+ return handles;
59
+ }
60
+ /**
61
+ * @description The sender's role. Admin wins: a talker who is later made an admin keeps their list entries, and they
62
+ * stay harmless while the person is an admin and apply again after a demotion.
63
+ */
64
+ function getSenderRole({ userId, adminIds, talkerIds }) {
65
+ if (adminIds.has(userId))
66
+ return 'admin';
67
+ if (talkerIds.has(userId))
68
+ return 'talker';
69
+ return 'none';
70
+ }
44
71
  /**
45
72
  * @description Lazily-refreshed cache of the served group's admin user ids.
46
73
  *
@@ -51,10 +78,12 @@ function getElevatedMemberIds(members) {
51
78
  */
52
79
  class AdminCache {
53
80
  fetchElevatedMemberIds;
81
+ fetchElevatedMemberHandles;
54
82
  ttlMs;
55
83
  failureRetryMs;
56
84
  now;
57
85
  ids = new Set();
86
+ handles = new Set();
58
87
  /** Timestamp of the last SUCCESSFUL fetch, or `null` if never fetched. */
59
88
  fetchedAt = null;
60
89
  /** Timestamp of the last FAILED fetch, or `null`. */
@@ -62,6 +91,7 @@ class AdminCache {
62
91
  inFlight = null;
63
92
  constructor(deps) {
64
93
  this.fetchElevatedMemberIds = deps.fetchElevatedMemberIds;
94
+ this.fetchElevatedMemberHandles = deps.fetchElevatedMemberHandles;
65
95
  this.ttlMs = deps.ttlMs ?? exports.ADMIN_CACHE_TTL_MS;
66
96
  this.failureRetryMs = deps.failureRetryMs ?? exports.ADMIN_CACHE_FAILURE_RETRY_MS;
67
97
  this.now = deps.now ?? Date.now;
@@ -85,6 +115,22 @@ class AdminCache {
85
115
  this.inFlight = null;
86
116
  }
87
117
  }
118
+ /**
119
+ * The admins' @names, from the same refresh as {@link getAdminIds}: for deciding about a typed @name whose id the bot
120
+ * has not seen (an admin is never added, and no message of theirs would ever turn the invitation into a person).
121
+ */
122
+ async getAdminHandles() {
123
+ await this.getAdminIds();
124
+ return this.handles;
125
+ }
126
+ /**
127
+ * The admin set as last fetched, WITHOUT fetching: for the synchronous marks that tell the operator's words from anyone
128
+ * else's. Meaningful right after {@link getAdminIds} (every gated handler awaits it first); empty before the first
129
+ * successful fetch.
130
+ */
131
+ getCachedAdminIds() {
132
+ return this.ids;
133
+ }
88
134
  /** Drop freshness so the next {@link getAdminIds} re-fetches (used on re-pair). */
89
135
  invalidate() {
90
136
  this.fetchedAt = null;
@@ -92,7 +138,10 @@ class AdminCache {
92
138
  }
93
139
  async refresh() {
94
140
  try {
95
- this.ids = new Set(await this.fetchElevatedMemberIds());
141
+ // Both are awaited before either is kept: a failure of either leaves the last-known ids AND names.
142
+ const [ids, handles] = await Promise.all([this.fetchElevatedMemberIds(), this.fetchElevatedMemberHandles?.() ?? []]);
143
+ this.ids = new Set(ids);
144
+ this.handles = new Set(handles);
96
145
  this.fetchedAt = this.now();
97
146
  this.lastFailAt = null;
98
147
  return this.ids;