telecoder 1.2.0 → 1.3.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 (197) hide show
  1. package/.env.example +142 -130
  2. package/CHANGELOG.md +683 -2
  3. package/README.md +36 -32
  4. package/dist/audio/transcribe.js +0 -9
  5. package/dist/bin/mcp-server.js +46 -61
  6. package/dist/bot/bot.js +162 -181
  7. package/dist/bot/command-catalog.js +263 -0
  8. package/dist/bot/deleted-threads.js +103 -0
  9. package/dist/bot/file-access.js +35 -26
  10. package/dist/bot/handlers/album.handler.js +128 -0
  11. package/dist/bot/handlers/{fork.handler.js → branch.handler.js} +267 -280
  12. package/dist/bot/handlers/command/access.js +1 -1
  13. package/dist/bot/handlers/command/admin.js +86 -110
  14. package/dist/bot/handlers/command/all-view.js +33 -0
  15. package/dist/bot/handlers/command/auto-approve.js +3 -3
  16. package/dist/bot/handlers/command/background.js +37 -0
  17. package/dist/bot/handlers/command/botname.js +76 -0
  18. package/dist/bot/handlers/command/btw.js +20 -69
  19. package/dist/bot/handlers/command/cleanup.js +329 -0
  20. package/dist/bot/handlers/command/model.js +40 -119
  21. package/dist/bot/handlers/command/prefs-scope.js +255 -90
  22. package/dist/bot/handlers/command/project.js +31 -109
  23. package/dist/bot/handlers/command/resume.js +8 -4
  24. package/dist/bot/handlers/command/session.js +74 -213
  25. package/dist/bot/handlers/command/settings.js +92 -447
  26. package/dist/bot/handlers/command/shared.js +32 -35
  27. package/dist/bot/handlers/command/tasks.js +263 -95
  28. package/dist/bot/handlers/command/thread.js +128 -0
  29. package/dist/bot/handlers/command/topic-store.js +14 -53
  30. package/dist/bot/handlers/command/topic.js +8 -61
  31. package/dist/bot/handlers/command/{cost.js → usage.js} +32 -59
  32. package/dist/bot/handlers/command-fallback.js +179 -0
  33. package/dist/bot/handlers/command.handler.js +96 -422
  34. package/dist/bot/handlers/{schedule.handler.js → loop.handler.js} +159 -73
  35. package/dist/bot/handlers/media-fallback.js +12 -7
  36. package/dist/bot/handlers/message/replies.js +10 -87
  37. package/dist/bot/handlers/message/shared.js +9 -31
  38. package/dist/bot/handlers/message/turn-notify.js +15 -49
  39. package/dist/bot/handlers/message/turn-runner.js +18 -103
  40. package/dist/bot/handlers/message.handler.js +59 -52
  41. package/dist/bot/handlers/newbot.handler.js +13 -4
  42. package/dist/bot/handlers/photo.handler.js +88 -129
  43. package/dist/bot/handlers/prompts.handler.js +11 -11
  44. package/dist/bot/handlers/running-note.js +2 -2
  45. package/dist/bot/handlers/session-guard.js +4 -4
  46. package/dist/bot/handlers/suggestion.handler.js +2 -2
  47. package/dist/bot/handlers/tree.handler.js +20 -20
  48. package/dist/bot/handlers/voice.handler.js +23 -85
  49. package/dist/bot/kept-threads.js +51 -0
  50. package/dist/bot/middleware/album-collector.js +69 -0
  51. package/dist/bot/middleware/auth.middleware.js +1 -1
  52. package/dist/bot/middleware/group-mention.middleware.js +11 -5
  53. package/dist/bot/middleware/queued-messages.js +143 -32
  54. package/dist/bot/middleware/stale-filter.js +0 -22
  55. package/dist/build-info.json +5 -5
  56. package/dist/claude/ask-user-form.js +517 -0
  57. package/dist/claude/ask-user.js +94 -26
  58. package/dist/claude/auto-topic-haiku.js +17 -0
  59. package/dist/claude/available-commands.js +22 -19
  60. package/dist/claude/background-hint.js +91 -0
  61. package/dist/claude/{fork-tree.js → branch-tree.js} +9 -9
  62. package/dist/claude/carry-over.js +0 -2
  63. package/dist/claude/ccr-shim.js +12 -10
  64. package/dist/claude/claude-auth.js +6 -10
  65. package/dist/claude/command-parser.js +49 -43
  66. package/dist/claude/cost-overlay-scraper.js +7 -2
  67. package/dist/claude/effort-level.js +5 -0
  68. package/dist/claude/enabled-plugins.js +12 -16
  69. package/dist/claude/in-flight-tracker.js +21 -0
  70. package/dist/claude/mcp-bridge.js +86 -58
  71. package/dist/claude/memory-guard.js +400 -0
  72. package/dist/claude/message-offsets.js +5 -5
  73. package/dist/claude/modal-relay.js +401 -34
  74. package/dist/claude/model-catalog.js +20 -3
  75. package/dist/claude/monitor-relay.js +130 -15
  76. package/dist/claude/native-commands.js +40 -0
  77. package/dist/claude/{pending-forks.js → pending-branches.js} +26 -26
  78. package/dist/claude/permission-gate.js +11 -10
  79. package/dist/claude/permission-mode.js +19 -45
  80. package/dist/claude/prewarm.js +70 -0
  81. package/dist/claude/pty-idle-reaper.js +96 -0
  82. package/dist/claude/pty-provider.js +473 -188
  83. package/dist/claude/pty-spawn-config.js +79 -32
  84. package/dist/claude/pty-watch.js +201 -0
  85. package/dist/claude/request-queue.js +7 -35
  86. package/dist/claude/rewind.js +111 -0
  87. package/dist/claude/scheduled-runner.js +1 -3
  88. package/dist/claude/scheduler.js +6 -2
  89. package/dist/claude/scope-guard.js +8 -3
  90. package/dist/claude/screen-marks.js +83 -0
  91. package/dist/claude/screen-render.js +96 -0
  92. package/dist/claude/session-history.js +4 -2
  93. package/dist/claude/session-jsonl.js +162 -15
  94. package/dist/claude/session-manager.js +29 -8
  95. package/dist/claude/session-move.js +70 -0
  96. package/dist/claude/shell-mode-gate.js +60 -0
  97. package/dist/claude/side-question.js +20 -17
  98. package/dist/claude/stage-images.js +5 -5
  99. package/dist/claude/tasks-overlay-scraper.js +143 -20
  100. package/dist/claude/thread-judge-haiku.js +88 -0
  101. package/dist/claude/tip-scraper.js +3 -4
  102. package/dist/claude/tui-modal.js +272 -27
  103. package/dist/claude/tui-state.js +74 -2
  104. package/dist/claude/turn-end.js +15 -1
  105. package/dist/claude/turn-prose.js +1 -1
  106. package/dist/claude/typed-answer.js +104 -0
  107. package/dist/claude/update-banner-relay.js +1 -1
  108. package/dist/cli/commands/doctor.js +48 -15
  109. package/dist/cli/commands/help.js +11 -2
  110. package/dist/cli/commands/init.js +16 -13
  111. package/dist/cli/commands/service.js +40 -8
  112. package/dist/cli/commands/start.js +10 -0
  113. package/dist/cli/commands/watch.js +322 -0
  114. package/dist/cli/dispatch.js +5 -0
  115. package/dist/cli/init/env-file.js +1 -1
  116. package/dist/cli/init/flow.js +114 -47
  117. package/dist/cli/init/prompter.js +8 -0
  118. package/dist/cli/init/telegram.js +35 -9
  119. package/dist/cli/service/render.js +3 -3
  120. package/dist/config.js +156 -131
  121. package/dist/index.js +107 -31
  122. package/dist/launcher.js +34 -7
  123. package/dist/providers/ccr-introspect.js +1 -8
  124. package/dist/providers/ccr-provider.js +19 -20
  125. package/dist/providers/claude-provider.js +4 -57
  126. package/dist/providers/prefs-sync.js +16 -59
  127. package/dist/providers/provider-router.js +24 -23
  128. package/dist/providers/spawn-settings.js +45 -0
  129. package/dist/providers/user-preferences.js +127 -19
  130. package/dist/restart-when-idle.js +27 -7
  131. package/dist/startup/auto-continue.js +2 -2
  132. package/dist/startup/auto-resume.js +3 -15
  133. package/dist/startup/notices.js +1 -1
  134. package/dist/startup/verify-token.js +4 -4
  135. package/dist/telegram/action-logger.js +3 -165
  136. package/dist/telegram/background-activity-card.js +1 -1
  137. package/dist/telegram/botname-settings.js +71 -125
  138. package/dist/telegram/client-options.js +6 -7
  139. package/dist/telegram/force-reply-tracker.js +55 -16
  140. package/dist/telegram/message-sender.js +92 -360
  141. package/dist/telegram/prompt-label.js +11 -5
  142. package/dist/telegram/streaming-turn.js +5 -7
  143. package/dist/telegram/table-lists.js +56 -0
  144. package/dist/telegram/task-list.js +4 -4
  145. package/dist/telegram/task-tracker.js +45 -126
  146. package/dist/telegram/terminal-renderer.js +1 -5
  147. package/dist/telegram/thread-titles.js +74 -2
  148. package/dist/telegram/threads-setup.js +1 -1
  149. package/dist/utils/admins.js +2 -2
  150. package/dist/utils/bot-icon.js +248 -0
  151. package/dist/utils/bot-token.js +8 -5
  152. package/dist/utils/build-info.js +3 -3
  153. package/dist/utils/caffeinate.js +6 -3
  154. package/dist/utils/claude-env.js +0 -1
  155. package/dist/utils/claude-version.js +2 -2
  156. package/dist/utils/config-home.js +3 -3
  157. package/dist/utils/download.js +41 -15
  158. package/dist/utils/exit-codes.js +11 -0
  159. package/dist/utils/format.js +3 -6
  160. package/dist/utils/home-project.js +1 -1
  161. package/dist/utils/idle-restart.js +1 -1
  162. package/dist/utils/install-mode.js +1 -1
  163. package/dist/utils/instance-config.js +1 -1
  164. package/dist/utils/instances.js +1 -1
  165. package/dist/utils/keyed-settings.js +2 -2
  166. package/dist/utils/memory-pressure.js +60 -0
  167. package/dist/utils/npm-version.js +2 -2
  168. package/dist/utils/resolve-claude-bin.js +13 -24
  169. package/dist/utils/respawn-backoff.js +9 -0
  170. package/dist/utils/stale-launcher.js +1 -1
  171. package/dist/utils/systemd.js +8 -8
  172. package/dist/utils/telegram-proxy.js +72 -0
  173. package/dist/utils/uploads-dir.js +27 -0
  174. package/dist/utils/verbosity.js +8 -8
  175. package/dist/utils/version-check.js +5 -5
  176. package/package.json +3 -4
  177. package/dist/bot/handlers/command/media.js +0 -197
  178. package/dist/bot/handlers/command/streaming-mode.js +0 -16
  179. package/dist/bot/handlers/message/throttle.js +0 -49
  180. package/dist/claude/agent-watchdog.js +0 -162
  181. package/dist/claude/agent.js +0 -1458
  182. package/dist/claude/held-query.js +0 -190
  183. package/dist/claude/mcp-tools.js +0 -354
  184. package/dist/claude/sdk-permission-gate.js +0 -77
  185. package/dist/claude/session-cost.js +0 -41
  186. package/dist/claude/system-prompt.js +0 -162
  187. package/dist/providers/sdk-provider.js +0 -37
  188. package/dist/telegram/telegraph-settings.js +0 -31
  189. package/dist/telegram/telegraph.js +0 -453
  190. package/dist/telegram/terminal-settings.js +0 -25
  191. package/dist/tts/tts-settings.js +0 -62
  192. package/dist/tts/tts.js +0 -245
  193. package/dist/tts/voice-reply.js +0 -78
  194. package/dist/utils/debug-agent.js +0 -117
  195. package/dist/utils/debug-watchdog.js +0 -121
  196. package/dist/utils/project-data-dir.js +0 -33
  197. package/dist/utils/reasoning-summary.js +0 -12
@@ -21,19 +21,60 @@ import { config } from '../config.js';
21
21
  import { ALLOW_MARKER, DENY_MARKER_START, DENY_MARKER_END, hookCurlTimeoutSeconds, hookTimeoutSeconds, } from './permission-gate.js';
22
22
  import { IPC_TOKEN_ENV, IPC_TOKEN_HEADER } from './ipc-server.js';
23
23
  import { enabledPluginsSetting } from './enabled-plugins.js';
24
+ import { hasGuestUsers } from '../utils/admins.js';
24
25
  /** What claude is told when the PreToolUse hook gets no verdict from the bot. */
25
26
  export const GATE_UNREACHABLE_REASON = 'TeleCoder permission gate unreachable — tool blocked';
26
27
  const PROVIDER_DIR = path.dirname(fileURLToPath(import.meta.url));
27
28
  export const MCP_SERVER_JS = path.resolve(PROVIDER_DIR, '../bin/mcp-server.js');
29
+ /**
30
+ * Does a spawn bring the Claude Code setup of the account the bot runs as?
31
+ *
32
+ * That setup is everything a terminal session on this machine starts with and
33
+ * a project doesn't carry: ~/.claude (CLAUDE.md, skills, commands, agents and
34
+ * settings.json with its permission rules, hooks, plugins and default model),
35
+ * the MCP servers in ~/.claude.json, the servers plugins bring and the
36
+ * claude.ai connectors. With it, Claude in Telegram is the Claude of the
37
+ * terminal. Without it the pty knows the project and what the bot hands it.
38
+ *
39
+ * It used to stay out for everyone, for two reasons that no longer need it to.
40
+ * `editorMode: "vim"` changed what the provider's keys do, which the pins in
41
+ * buildSettingsJson now answer for the one key. And every MCP server the
42
+ * account has would land in the context, which is what a terminal session gets
43
+ * too, and claude loads their tools on demand.
44
+ *
45
+ * The reason that's left is a guest. Someone admitted to a shared bot would be
46
+ * working with the owner's own instructions, and with connectors signed in as
47
+ * the owner: their documents and mail are not part of the projects that were
48
+ * shared. So 'auto' follows the same roster the permission gate does, and
49
+ * CLAUDE_USER_SETUP says otherwise in either direction.
50
+ */
51
+ export function loadsUserSetup() {
52
+ if (config.CLAUDE_USER_SETUP === 'on')
53
+ return true;
54
+ if (config.CLAUDE_USER_SETUP === 'off')
55
+ return false;
56
+ return !hasGuestUsers();
57
+ }
58
+ /**
59
+ * The flags that keep the user setup out of a spawn, and none when it comes
60
+ * along. `--setting-sources` drops the user tier of settings and with it
61
+ * ~/.claude's instructions, skills, commands and agents. `--strict-mcp-config`
62
+ * limits MCP to what `--mcp-config` names: ours, and EXTRA_MCP_CONFIG's.
63
+ */
64
+ export function userSetupIsolationArgs(loads = loadsUserSetup()) {
65
+ return loads ? [] : ['--setting-sources', 'project,local', '--strict-mcp-config'];
66
+ }
28
67
  /**
29
68
  * Whether this account has accepted Claude Code's bypass-permissions warning.
30
69
  *
31
70
  * The pty needs --dangerously-skip-permissions (see _applyPermissionMode), which
32
71
  * opens that warning unless the answer is already on record, and accepting it
33
72
  * records the answer in ~/.claude/settings.json. Since 2.1.314 claude doesn't
34
- * read that file on a launch that leaves user settings out, as ours does, so the
35
- * warning opened on every new pty and "Yes, I accept" could never end it: it
36
- * wrote a key that was already there to a file nothing was going to read.
73
+ * read that file on a launch that leaves user settings out, as ours does while
74
+ * the user setup stays out, so the warning opened on every new pty and "Yes, I
75
+ * accept" could never end it: it wrote a key that was already there to a file
76
+ * nothing was going to read. A launch that reads the file gets the same answer
77
+ * twice, which costs nothing.
37
78
  *
38
79
  * Copied across rather than always set, so the bot never accepts the warning for
39
80
  * an account that hasn't, and read on every spawn, so a "Yes" counts from the
@@ -60,14 +101,29 @@ function hasAcceptedBypassWarning() {
60
101
  * at run time ($TELECODER_IPC_TOKEN) rather than written into this JSON: the
61
102
  * JSON is a command-line argument, which any local user can read in `ps`.
62
103
  *
63
- * Stop / SubagentStop are intentionally NOT registered here — Phase 2 will
64
- * use them as the end-of-turn signal. UserPromptSubmit is similarly deferred.
104
+ * Stop is registered as one of the end-of-turn signals, and CwdChanged so the
105
+ * bot follows Claude Code's /cd. SubagentStop and UserPromptSubmit are not
106
+ * registered.
65
107
  *
66
108
  * CLAUDE_PLUGINS rides along in the same payload. The flag tier this lands in
67
- * outranks project and local settings and merges with them, so naming a plugin
68
- * here adds it to whatever the project already enables — see enabled-plugins.ts
69
- * for why the user's own settings.json cannot carry it instead. The answer to
70
- * the bypass warning comes the same way, for the same reason.
109
+ * outranks user, project and local settings and merges with them, so naming a
110
+ * plugin here adds it to whatever those already enable (see enabled-plugins.ts).
111
+ * The answer to the bypass warning comes the same way.
112
+ *
113
+ * Two keys are pinned, because that tier wins and the settings below it are the
114
+ * user's and the project's to write. Both are about the terminal nobody is
115
+ * looking at, not about how Claude works:
116
+ * - `editorMode`. Every key the provider writes (Esc, Ctrl+U, Enter after a
117
+ * paste) was measured against the normal editor, and in vim mode Esc is
118
+ * also a mode switch. This key is why user settings were once left out
119
+ * altogether: prompts piled up in the editor unsent. On 2.1.325 a paste and
120
+ * Enter did submit in vim mode, after an Esc too, so the pin is a
121
+ * precaution for the rest. Measured there with `"vim"` in a lower tier: the
122
+ * pin brings the normal editor back.
123
+ * - `statusLine`. A custom one draws its rows between the input box and the
124
+ * mode indicator, where tui-state.ts and permission-mode.ts count rows from
125
+ * the bottom, and it can print anything, a `❯` included. An empty command
126
+ * draws nothing; `null` is a settings error that opens a dialog.
71
127
  */
72
128
  export function buildSettingsJson(ipcPort) {
73
129
  const curl = (eventName, extra = '') => `curl -s${extra} -X POST -H 'Content-Type: application/json' -H "${IPC_TOKEN_HEADER}: $${IPC_TOKEN_ENV}" ` +
@@ -98,6 +154,8 @@ export function buildSettingsJson(ipcPort) {
98
154
  `printf '%s' '${GATE_UNREACHABLE_REASON}' >&2; exit 2`;
99
155
  const enabledPlugins = enabledPluginsSetting();
100
156
  return JSON.stringify({
157
+ editorMode: 'normal',
158
+ statusLine: { type: 'command', command: '' },
101
159
  ...(enabledPlugins ? { enabledPlugins } : {}),
102
160
  ...(hasAcceptedBypassWarning() ? { skipDangerousModePermissionPrompt: true } : {}),
103
161
  hooks: {
@@ -105,6 +163,8 @@ export function buildSettingsJson(ipcPort) {
105
163
  PostToolUse: [{ hooks: [{ type: 'command', command: hookCommand('postToolUse') }] }],
106
164
  PostToolUseFailure: [{ hooks: [{ type: 'command', command: hookCommand('postToolUseFailure') }] }],
107
165
  Stop: [{ hooks: [{ type: 'command', command: hookCommand('stop') }] }],
166
+ // Claude Code's /cd moves the session; the bot follows (session-move.ts).
167
+ CwdChanged: [{ hooks: [{ type: 'command', command: hookCommand('cwdChanged') }] }],
108
168
  },
109
169
  });
110
170
  }
@@ -125,7 +185,7 @@ export function buildMcpToolsSystemPromptNote() {
125
185
  '- mcp__telecoder-tools__telecoder_switch_project — switch the working directory to a different project (call list_projects first). The change takes effect on the next user query.',
126
186
  '- mcp__telecoder-tools__telecoder_create_bot — when the user asks for a bot for a project: sends them a button that opens Telegram\'s create-a-bot screen; once they confirm, the new bot is added and starts in that project. Private chats and admins only. Prefer this over telling them to use BotFather or /newbot.',
127
187
  '- mcp__telecoder-tools__telecoder_send_file — send a file from the bot\'s filesystem (within the workspace or /tmp) to the user via Telegram. Use after creating files (reports, SVGs, images, etc.) to deliver them directly. Max 50MB.',
128
- '- mcp__telecoder-tools__telecoder_ask_user — ask the user a multiple-choice question via a Telegram inline keyboard (2-8 options). Pauses until the user taps a button. Prefer this over the built-in AskUserQuestion whenever you need a decision from the user — AskUserQuestion is for terminal users and does not render correctly through TeleCoder.',
188
+ '- mcp__telecoder-tools__telecoder_ask_user — ask the user a multiple-choice question via a Telegram inline keyboard (2-8 options). Pauses until the user taps a button or sends their own answer as a message. Several questions at once go in one call as `questions` (2-4): one form the user steps through, can revise, and submits. Prefer this over the built-in AskUserQuestion whenever you need a decision from the user — AskUserQuestion is for terminal users and does not render correctly through TeleCoder.',
129
189
  '- mcp__telecoder-tools__telecoder_poll_user — like ask_user but uses a Telegram poll. Pick this when multiple chat members should vote, when you want visible vote counts, or when you need multi-select. 2-10 options, non-anonymous, resolves on the first vote.',
130
190
  '- mcp__telecoder-tools__telecoder_request_secret — get a secret (API key, token, password) from the user without it entering this conversation: they send it in Telegram, the bot deletes their message, and your `command` gets it in $SECRET and on stdin. You get the exit code and the output with the secret blanked out. Use it whenever a task needs a credential from the user. Never ask them to paste one into the chat or to run a `!` command for it, and don\'t send them to a terminal over SSH. For a long-lived Claude token (CLAUDE_CODE_OAUTH_TOKEN), set source "claude-setup-token": the bot runs `claude setup-token` here and walks them through signing in from their phone.',
131
191
  '- mcp__telecoder-tools__telecoder_loop — schedule a prompt to re-fire on a fixed interval (min 60s). Use for periodic polling / "every N minutes do X" tasks. Prefer this over the built-in CronCreate or ScheduleWakeup — those don\'t reach back into Telegram. The user sees each fire as a "🔔 Scheduled" message.',
@@ -134,19 +194,13 @@ export function buildMcpToolsSystemPromptNote() {
134
194
  '- mcp__telecoder-tools__telecoder_cancel_schedule — remove a scheduled task by id.',
135
195
  ];
136
196
  // Async built-ins (Monitor, backgrounded Bash, Task subagent) aren't
137
- // telecoder_* tools, but PTY mode wires up a relay so task-notifications
197
+ // telecoder_* tools, but the bot wires up a relay so task-notifications
138
198
  // that arrive after the user-turn ends still reach Telegram. Mention it so
139
199
  // the model confidently uses these tools when they're the right fit.
140
- tools.push('- Async built-ins (Monitor, `Bash(run_in_background=true)`, `Task`/`Agent`) — supported in TeleCoder PTY mode. Task-notifications that fire between user turns are relayed to Telegram with a "📡 Monitor — ...", "⚙️ Backgrounded: ...", or "🤖 Subagent started: ..." header, paired with the actual event payload and your response. Use these freely for "watch X", "run X in background while continuing", or "delegate Y to a subagent" tasks.');
141
- tools.push('- PushNotification (built-in) — supported in TeleCoder PTY mode. The message text is relayed to Telegram as "🔔 <message>". Use the normal rules: only when the user might have walked away and there\'s something they\'d act on now.');
200
+ tools.push('- Async built-ins (Monitor, `Bash(run_in_background=true)`, `Task`/`Agent`) — supported in TeleCoder. Task-notifications that fire between user turns are relayed to Telegram with a "📡 Monitor — ...", "⚙️ Backgrounded: ...", or "🤖 Subagent started: ..." header, paired with the actual event payload and your response. Use these freely for "watch X", "run X in background while continuing", or "delegate Y to a subagent" tasks.');
201
+ tools.push('- PushNotification (built-in) — supported in TeleCoder. The message text is relayed to Telegram as "🔔 <message>". Use the normal rules: only when the user might have walked away and there\'s something they\'d act on now.');
142
202
  tools.push('- For scheduled/recurring tasks, prefer telecoder_loop / telecoder_schedule over the built-in CronCreate / ScheduleWakeup / RemoteTrigger — those don\'t reach back into Telegram.');
143
- tools.push('- *Destructive-op safety:* before running anything irreversible — `rm -rf` on real paths, `sudo`, `git push --force` on shared branches, `DROP TABLE` / `TRUNCATE` against real DBs, `terraform destroy`, mass file rewrites — call `telecoder_ask_user` with a one-line summary of what you\'re about to do and "Confirm" / "Cancel" options. This bot runs unsupervised in Telegram and the user can\'t intervene mid-tool. When in doubt, ask.');
144
- if (config.TELEGRAPH_ENABLED) {
145
- tools.push('- mcp__telecoder-tools__telecoder_publish_telegraph — publish a markdown document as a Telegraph (telegra.ph) Instant View page; returns the URL.');
146
- }
147
- if (config.DYNAMIC_BOT_NAME) {
148
- tools.push('- mcp__telecoder-tools__telecoder_set_topic — update the conversation topic shown in the bot display name. Call proactively when the topic of work shifts. Empty string clears it. Keep topics 1-4 words.');
149
- }
203
+ tools.push('- mcp__telecoder-tools__telecoder_set_topic — update the conversation topic shown in the footer under each reply and as the thread\'s name. Call proactively when the topic of work shifts. Empty string clears it. Keep topics 1-4 words.');
150
204
  return [
151
205
  'You have access to TeleCoder-specific MCP tools listed below. They are loaded lazily — call them directly when relevant; do not try to reproduce their behavior with WebFetch/Bash.',
152
206
  ...tools,
@@ -193,8 +247,7 @@ export function buildPtySystemPromptNote() {
193
247
  * - required routing info (TELECODER_IPC_PORT, _CLAUDE_SESSION_ID,
194
248
  * _WORKSPACE_ROOT)
195
249
  * - PATH/HOME/NODE_ENV so node can find binaries and home-relative files
196
- * - every TELECODER_*-prefixed var from this process's env (feature flags
197
- * like TELECODER_TELEGRAPH_ENABLED gate which tools register)
250
+ * - every TELECODER_*-prefixed var from this process's env
198
251
  */
199
252
  /** True if claude's status line reports that it isn't persisting the session. */
200
253
  export function buildMcpEnv(required) {
@@ -202,11 +255,6 @@ export function buildMcpEnv(required) {
202
255
  PATH: process.env.PATH || '',
203
256
  HOME: process.env.HOME || '',
204
257
  NODE_ENV: process.env.NODE_ENV || '',
205
- // Translate the bot's parsed config flags into the TELECODER_*_ENABLED
206
- // form the MCP subprocess gates on. The bot's own env vars are unprefixed
207
- // (TELEGRAPH_ENABLED, DYNAMIC_BOT_NAME) so we can't just pass through.
208
- TELECODER_TELEGRAPH_ENABLED: config.TELEGRAPH_ENABLED ? 'true' : 'false',
209
- TELECODER_DYNAMIC_BOT_NAME: config.DYNAMIC_BOT_NAME ? 'true' : 'false',
210
258
  ...required,
211
259
  };
212
260
  // Any extra TELECODER_*-prefixed vars the bot's env carries (e.g. user
@@ -242,11 +290,10 @@ export function buildMcpEnv(required) {
242
290
  * Extra MCP servers to spawn beside our own, from the file EXTRA_MCP_CONFIG
243
291
  * names. `{}` when the var is unset, which is the default.
244
292
  *
245
- * A file rather than the user's own MCP config, because the spawn passes
246
- * `--strict-mcp-config`: that flag is what stops every server in
247
- * ~/.claude.json — auth-expired ones, failing ones, and their combined tool
248
- * counts — from landing in the bot's context. Naming a file keeps that
249
- * property and adds only what was asked for.
293
+ * The account's own servers come with the user setup (loadsUserSetup). This
294
+ * file is for a server only the bot should have, and it is the one way to add
295
+ * any while that setup stays out: the spawn then passes `--strict-mcp-config`,
296
+ * and naming a file adds only what was asked for.
250
297
  *
251
298
  * Never throws. This runs on the path that starts the agent, and a typo in an
252
299
  * optional file must not be the reason the bot does not come up; a warning on
@@ -0,0 +1,201 @@
1
+ /**
2
+ * Lets `telecoder watch` look at a running claude's screen.
3
+ *
4
+ * Each chat's claude draws its screen into a terminal that exists
5
+ * only in this process. This module serves those screens, read-only, over a
6
+ * Unix socket: a watcher gets the screen as it is now and then everything
7
+ * claude writes after it. Nothing a watcher sends reaches claude.
8
+ *
9
+ * The socket is `~/.telecoder/watch/<bot username>.sock`, one per bot (several
10
+ * bots can share a process, as worker threads), in a directory only the owner
11
+ * can enter. So only the user the bot runs as can watch, which is the user who
12
+ * can already read every transcript.
13
+ *
14
+ * Protocol: one JSON object per line.
15
+ * → {"op":"list"} ← {"type":"sessions","bot":…,"sessions":[…]}
16
+ * → {"op":"watch","key":…} ← {"type":"screen","key","cols","rows","data"}
17
+ * ← {"type":"data","data"} …
18
+ * ← {"type":"end"} (claude exited)
19
+ * ← {"type":"error","message"}
20
+ */
21
+ import * as fs from 'fs';
22
+ import * as net from 'net';
23
+ import * as path from 'path';
24
+ import { getStateDir } from '../utils/json-store.js';
25
+ import { screenSnapshot } from './screen-render.js';
26
+ export const WATCH_DIR_NAME = 'watch';
27
+ /** A watcher this far behind is dropped rather than buffered for without end. */
28
+ const MAX_BACKLOG_BYTES = 8 * 1024 * 1024;
29
+ const watched = new Map();
30
+ const byTerm = new WeakMap();
31
+ let server = null;
32
+ let socketPath = null;
33
+ let botName = '';
34
+ export function getWatchDir() {
35
+ return path.join(getStateDir(), WATCH_DIR_NAME);
36
+ }
37
+ function send(socket, message) {
38
+ if (socket.destroyed)
39
+ return;
40
+ if (socket.writableLength > MAX_BACKLOG_BYTES) {
41
+ socket.destroy();
42
+ return;
43
+ }
44
+ socket.write(`${JSON.stringify(message)}\n`);
45
+ }
46
+ /** A claude has started: its screen can be watched from now on. */
47
+ export function watchRegister(key, cwd, xterm) {
48
+ watchUnregister(key);
49
+ const now = Date.now();
50
+ const entry = {
51
+ info: { key, cwd, cols: xterm.cols, rows: xterm.rows, startedAt: now, lastActiveAt: now },
52
+ xterm,
53
+ watchers: new Set(),
54
+ };
55
+ watched.set(key, entry);
56
+ byTerm.set(xterm, entry);
57
+ }
58
+ /**
59
+ * Output from the claude that draws into `xterm`. Call it right after the same
60
+ * chunk went into that xterm, so a snapshot and the chunks after it line up.
61
+ */
62
+ export function watchData(xterm, chunk) {
63
+ // Not found for a claude replaced at its key (/clear) that still writes as it exits.
64
+ const entry = byTerm.get(xterm);
65
+ if (!entry)
66
+ return;
67
+ entry.info.lastActiveAt = Date.now();
68
+ for (const watcher of entry.watchers) {
69
+ if (watcher.pending)
70
+ watcher.pending.push(chunk);
71
+ else
72
+ send(watcher.socket, { type: 'data', data: chunk });
73
+ }
74
+ }
75
+ /** `key`'s claude is gone. With `xterm`, only if it is still that one. */
76
+ export function watchUnregister(key, xterm) {
77
+ const entry = watched.get(key);
78
+ if (!entry || (xterm && entry.xterm !== xterm))
79
+ return;
80
+ watched.delete(key);
81
+ byTerm.delete(entry.xterm);
82
+ for (const watcher of entry.watchers)
83
+ send(watcher.socket, { type: 'end' });
84
+ entry.watchers.clear();
85
+ }
86
+ function subscribe(socket, key) {
87
+ const entry = watched.get(key);
88
+ if (!entry) {
89
+ send(socket, { type: 'error', message: 'No such session.' });
90
+ return null;
91
+ }
92
+ const watcher = { socket, pending: [] };
93
+ entry.watchers.add(watcher);
94
+ // xterm parses what it is given a little later. An empty write's callback
95
+ // runs once everything given before it is on the screen, so the snapshot
96
+ // holds exactly the output up to here, and `pending` everything after.
97
+ entry.xterm.write('', () => {
98
+ if (!entry.watchers.has(watcher))
99
+ return;
100
+ send(socket, {
101
+ type: 'screen',
102
+ key,
103
+ cols: entry.xterm.cols,
104
+ rows: entry.xterm.rows,
105
+ data: screenSnapshot(entry.xterm),
106
+ });
107
+ for (const chunk of watcher.pending ?? [])
108
+ send(socket, { type: 'data', data: chunk });
109
+ watcher.pending = null;
110
+ });
111
+ return watcher;
112
+ }
113
+ function unsubscribe(watcher) {
114
+ if (!watcher)
115
+ return;
116
+ for (const entry of watched.values())
117
+ entry.watchers.delete(watcher);
118
+ }
119
+ function onConnection(socket) {
120
+ let buffered = '';
121
+ let watcher = null;
122
+ socket.setEncoding('utf8');
123
+ socket.on('error', () => socket.destroy());
124
+ socket.on('close', () => unsubscribe(watcher));
125
+ socket.on('data', (data) => {
126
+ buffered += data;
127
+ // Requests are a few dozen bytes. Anything long is not a watcher.
128
+ if (buffered.length > 4096) {
129
+ socket.destroy();
130
+ return;
131
+ }
132
+ let newline;
133
+ while ((newline = buffered.indexOf('\n')) !== -1) {
134
+ const line = buffered.slice(0, newline);
135
+ buffered = buffered.slice(newline + 1);
136
+ let request;
137
+ try {
138
+ request = JSON.parse(line);
139
+ }
140
+ catch {
141
+ socket.destroy();
142
+ return;
143
+ }
144
+ if (request?.op === 'list') {
145
+ send(socket, { type: 'sessions', bot: botName, sessions: [...watched.values()].map((e) => e.info) });
146
+ }
147
+ else if (request?.op === 'watch' && typeof request.key === 'string') {
148
+ unsubscribe(watcher);
149
+ watcher = subscribe(socket, request.key);
150
+ }
151
+ else {
152
+ send(socket, { type: 'error', message: 'Unknown request.' });
153
+ }
154
+ }
155
+ });
156
+ }
157
+ /**
158
+ * Start serving this process's claude screens. `name` is the bot's username,
159
+ * shown to a watcher choosing between several bots.
160
+ */
161
+ export async function startWatchServer(name, dir = getWatchDir()) {
162
+ if (server)
163
+ return socketPath;
164
+ botName = name;
165
+ fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
166
+ fs.chmodSync(dir, 0o700);
167
+ const file = path.join(dir, `${name.replace(/[^A-Za-z0-9_-]/g, '_') || 'bot'}.sock`);
168
+ // One left by an earlier run of this bot: nothing listens on it any more.
169
+ try {
170
+ fs.unlinkSync(file);
171
+ }
172
+ catch { /* not there */ }
173
+ const created = net.createServer(onConnection);
174
+ await new Promise((resolve, reject) => {
175
+ created.once('error', reject);
176
+ created.listen(file, () => {
177
+ created.off('error', reject);
178
+ resolve();
179
+ });
180
+ });
181
+ fs.chmodSync(file, 0o600);
182
+ // The socket must not keep a stopping bot alive.
183
+ created.unref();
184
+ server = created;
185
+ socketPath = file;
186
+ return file;
187
+ }
188
+ export function stopWatchServer() {
189
+ for (const key of [...watched.keys()])
190
+ watchUnregister(key);
191
+ server?.close();
192
+ server = null;
193
+ if (socketPath) {
194
+ try {
195
+ fs.unlinkSync(socketPath);
196
+ }
197
+ catch { /* already gone */ }
198
+ }
199
+ socketPath = null;
200
+ }
201
+ //# sourceMappingURL=pty-watch.js.map
@@ -1,11 +1,9 @@
1
1
  import { markInFlight, clearInFlight } from './in-flight-tracker.js';
2
- import { releaseHeldQuery } from './held-query.js';
3
2
  const activeAbortControllers = new Map();
4
- const activeQueries = new Map();
5
3
  const pendingQueues = new Map();
6
4
  const processingFlags = new Map();
7
- // Tracks chats where a cancel was initiated — checked by agent.ts to detect
8
- // user-initiated cancellation without calling controller.abort() (which crashes the SDK).
5
+ // Chats where a cancel was initiated — checked by the pty provider to tell a
6
+ // /cancel from a turn that failed on its own.
9
7
  const cancelledChats = new Set();
10
8
  export function getAbortController(sessionKey) {
11
9
  return activeAbortControllers.get(sessionKey);
@@ -16,15 +14,6 @@ export function setAbortController(sessionKey, controller) {
16
14
  export function clearAbortController(sessionKey) {
17
15
  activeAbortControllers.delete(sessionKey);
18
16
  }
19
- export function setActiveQuery(sessionKey, q) {
20
- activeQueries.set(sessionKey, q);
21
- }
22
- export function getActiveQuery(sessionKey) {
23
- return activeQueries.get(sessionKey);
24
- }
25
- export function clearActiveQuery(sessionKey) {
26
- activeQueries.delete(sessionKey);
27
- }
28
17
  export function isCancelled(sessionKey) {
29
18
  return cancelledChats.has(sessionKey);
30
19
  }
@@ -83,7 +72,6 @@ async function processQueue(sessionKey) {
83
72
  finally {
84
73
  processingFlags.set(sessionKey, false);
85
74
  clearAbortController(sessionKey);
86
- clearActiveQuery(sessionKey);
87
75
  clearCancelled(sessionKey);
88
76
  clearInFlight(sessionKey);
89
77
  if (queue.length > 0) {
@@ -91,25 +79,11 @@ async function processQueue(sessionKey) {
91
79
  }
92
80
  }
93
81
  }
94
- /** Soft cancel: interrupt the running query but keep the session alive. */
82
+ /**
83
+ * Soft cancel: interrupt the running turn but keep the session alive. False
84
+ * when no turn is running.
85
+ */
95
86
  export async function cancelRequest(sessionKey) {
96
- const q = activeQueries.get(sessionKey);
97
- if (q) {
98
- // Set the cancelled flag BEFORE interrupt so agent.ts can detect it
99
- // when the error_during_execution result arrives.
100
- // Do NOT call controller.abort() — that crashes the SDK subprocess.
101
- // The input stays open: background tasks the turn started outlive it.
102
- cancelledChats.add(sessionKey);
103
- try {
104
- await q.interrupt();
105
- }
106
- catch (err) {
107
- console.debug('[cancelRequest] interrupt() threw for chat', sessionKey, err);
108
- }
109
- clearActiveQuery(sessionKey);
110
- return true;
111
- }
112
- // Fallback to AbortController if no query stored
113
87
  const controller = activeAbortControllers.get(sessionKey);
114
88
  if (controller) {
115
89
  cancelledChats.add(sessionKey);
@@ -117,9 +91,7 @@ export async function cancelRequest(sessionKey) {
117
91
  clearAbortController(sessionKey);
118
92
  return true;
119
93
  }
120
- // No turn running, but a query answered earlier is still open for its
121
- // background work: stop that.
122
- return releaseHeldQuery(sessionKey);
94
+ return false;
123
95
  }
124
96
  export function clearQueue(sessionKey) {
125
97
  const queue = pendingQueues.get(sessionKey);
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Claude Code's `/rewind`, once its dialog has been answered from the chat.
3
+ *
4
+ * `/rewind` is Claude Code's own: it goes to the pty like any prompt, and its
5
+ * two screens come to the chat through the dialog relay (modal-relay.ts) — the
6
+ * list of prompts to go back to, then what to restore. Two things are left
7
+ * over when it closes that only matter outside a terminal, and both are here.
8
+ *
9
+ * It says nothing. In a terminal the transcript redraws shorter and that is
10
+ * the confirmation; the log gets no record at all, so a chat would see "Done"
11
+ * for a conversation that just lost its last ten turns. {@link rewindReport}
12
+ * is what the chat is told instead, from the answers the relay pressed.
13
+ *
14
+ * And it hands the prompt back. A restored conversation leaves the prompt it
15
+ * went back to in the input box, for the person at the keyboard to edit and
16
+ * send again. Nobody is at this keyboard: whatever is typed next would be
17
+ * joined onto it. {@link restoredPromptNeedle} is how the caller finds it
18
+ * there to clear it.
19
+ *
20
+ * Measured against Claude Code 2.1.326.
21
+ */
22
+ /** The heading both of `/rewind`'s screens carry. */
23
+ const REWIND_TITLE = 'Rewind';
24
+ /**
25
+ * The rows of the second screen, by how they open. A row reads longer with
26
+ * the cursor on it (`Summarize from here: add context (optional)`), and the
27
+ * order matters: `Restore code` also opens `Restore code and conversation`.
28
+ */
29
+ const CHOICES = [
30
+ [/^Restore code and conversation\b/, 'code-and-conversation'],
31
+ [/^Restore conversation\b/, 'conversation'],
32
+ [/^Restore code\b/, 'code'],
33
+ [/^Summarize from here\b/, 'summarize-from'],
34
+ [/^Summarize up to here\b/, 'summarize-up-to'],
35
+ ];
36
+ /**
37
+ * The rewind a dialog's answers carried out, or null when they weren't one:
38
+ * another dialog, a rewind backed out of with `Never mind`, or one that closed
39
+ * on `(current)`, which goes nowhere.
40
+ *
41
+ * The screens are told apart by their rows. The prompts are not numbered and
42
+ * the choices are, which is also how the parser tells them apart.
43
+ */
44
+ export function rewindIn(steps) {
45
+ const ours = steps.filter((step) => step.dialog.title === REWIND_TITLE && step.option);
46
+ const latest = [...ours].reverse();
47
+ const chosen = latest.find((step) => step.option.number !== undefined);
48
+ const picked = latest.find((step) => step.option.number === undefined);
49
+ if (!chosen || !picked)
50
+ return null;
51
+ const choice = CHOICES.find(([opens]) => opens.test(chosen.option.text))?.[1];
52
+ return choice ? { prompt: picked.option.text, choice } : null;
53
+ }
54
+ /** Whether this rewind takes the conversation back, which is what puts the prompt in the input box. */
55
+ export function restoresConversation(rewind) {
56
+ return rewind.choice !== 'code';
57
+ }
58
+ /**
59
+ * Enough of the prompt to find it in the input box. The list cuts a long
60
+ * prompt with an ellipsis the box doesn't have, and shows only its first line.
61
+ */
62
+ export function restoredPromptNeedle(rewind) {
63
+ return rewind.prompt.replace(/…$/u, '').trim().slice(0, 24);
64
+ }
65
+ /**
66
+ * A line Claude Code prints when a rewind didn't go through, read off the
67
+ * screen it left: `Failed to restore the code: …`, `Couldn't summarize: …`,
68
+ * `Restored the code, but skipped …`. Only the last rows are looked at, since
69
+ * an older one may have scrolled up from a rewind before this.
70
+ */
71
+ export function rewindFailure(screenText) {
72
+ const tail = screenText.split('\n').map((line) => line.trim()).filter(Boolean).slice(-12);
73
+ return tail.find((line) => /Failed to restore|Couldn't summarize|Restored the code, but skipped/.test(line));
74
+ }
75
+ /**
76
+ * What the chat is told. `promptCleared` says the prompt was found in the
77
+ * input box and taken out again, which is the proof that the conversation
78
+ * went back; without it the report claims no more than what was pressed.
79
+ */
80
+ export function rewindReport(rewind, seen) {
81
+ const prompt = `“${rewind.prompt}”`;
82
+ if (seen.failure) {
83
+ return `⚠️ Claude Code couldn't finish the rewind to before ${prompt}:\n${seen.failure}`;
84
+ }
85
+ const lines = [];
86
+ switch (rewind.choice) {
87
+ case 'code-and-conversation':
88
+ lines.push(`⏪ Rewound to before ${prompt}: the conversation, and the files Claude edited since.`);
89
+ break;
90
+ case 'conversation':
91
+ lines.push(`⏪ The conversation is back to before ${prompt}. The files are as they were.`);
92
+ break;
93
+ case 'code':
94
+ lines.push(`⏪ The files Claude edited are back to how they were before ${prompt}. The conversation is unchanged.`);
95
+ break;
96
+ case 'summarize-from':
97
+ lines.push(`⏪ Summarized the conversation from ${prompt} on.`);
98
+ break;
99
+ case 'summarize-up-to':
100
+ lines.push(`⏪ Summarized the conversation up to ${prompt}.`);
101
+ break;
102
+ }
103
+ if (rewind.choice === 'code-and-conversation' || rewind.choice === 'code') {
104
+ lines.push('Changes made by shell commands are not undone.');
105
+ }
106
+ if (seen.promptCleared) {
107
+ lines.push('That prompt was not sent again. Send it, changed or not, to carry on from there.');
108
+ }
109
+ return lines.join('\n');
110
+ }
111
+ //# sourceMappingURL=rewind.js.map
@@ -4,7 +4,6 @@ import { sessionHistory } from './session-history.js';
4
4
  import { queueRequest } from './request-queue.js';
5
5
  import { messageSender } from '../telegram/message-sender.js';
6
6
  import { progressCallbacks, toolCallbacks, withStreamingTurn } from '../telegram/streaming-turn.js';
7
- import { maybeSendVoiceReply } from '../tts/voice-reply.js';
8
7
  import { closeTurn, relayCatchUpIfMissed } from '../bot/handlers/message.handler.js';
9
8
  import { parseSessionKey } from '../utils/session-key.js';
10
9
  import { buildSyntheticCtx } from './synthetic-ctx.js';
@@ -42,7 +41,7 @@ async function fireSchedule(bot, schedule) {
42
41
  // Can't fire — let the user know but keep the schedule armed; they may
43
42
  // restore the project shortly.
44
43
  try {
45
- await bot.api.sendMessage(chatId, '⚠️ Scheduled fire skipped — no project bound to this chat. Use /project to bind one, then the next fire will run.', threadOpts);
44
+ await bot.api.sendMessage(chatId, '⚠️ Scheduled fire skipped — no project bound to this chat. Use /dir to bind one, then the next fire will run.', threadOpts);
46
45
  }
47
46
  catch (err) {
48
47
  console.error('[ScheduledRunner] failed to notify missing session:', err);
@@ -81,7 +80,6 @@ async function runScheduledTurn(ctx, sessionKey, prompt) {
81
80
  });
82
81
  await messageSender.finishStreaming(ctx, response.text);
83
82
  await relayCatchUpIfMissed(ctx, sessionKey, response.text || '');
84
- await maybeSendVoiceReply(ctx, response.text);
85
83
  await messageSender.sendCompletionNotification(ctx, Date.now() - startTime);
86
84
  // The short form: a schedule can fire every minute, and the whole block
87
85
  // under each fire would outweigh the result it closes.
@@ -4,7 +4,7 @@ import { Cron } from 'croner';
4
4
  import { ensureStateDir, getStateDir, readJsonFile, writeJsonFile } from '../utils/json-store.js';
5
5
  import { BOT_ID } from '../config.js';
6
6
  /**
7
- * Persistent scheduler for /schedule Telegram commands. Schedules survive
7
+ * Persistent scheduler for /loop and the agent's telecoder_loop/telecoder_schedule tools. Schedules survive
8
8
  * bot restarts via ~/.telecoder/schedules-<BOT_ID>.json; in-memory timers
9
9
  * are re-armed on loadAll(). Hard caps enforced at create time so a user
10
10
  * can't accidentally cron themselves into a runaway billing crater.
@@ -72,7 +72,7 @@ class Scheduler {
72
72
  const existing = this.listSchedules(spec.sessionKey).filter((s) => !s.disabled);
73
73
  if (existing.length >= HARD_LIMITS.MAX_PER_SESSION) {
74
74
  throw new Error(`Schedule cap reached for this chat (${HARD_LIMITS.MAX_PER_SESSION} active). ` +
75
- `Delete one with /unschedule before adding another.`);
75
+ `Stop one in /loops before adding another.`);
76
76
  }
77
77
  if (spec.kind === 'interval') {
78
78
  if (!spec.intervalMs || spec.intervalMs < HARD_LIMITS.MIN_INTERVAL_MS) {
@@ -209,6 +209,10 @@ class Scheduler {
209
209
  }
210
210
  this.recordFire(id, success);
211
211
  }
212
+ /** Run a schedule once now, outside its timer: /loop's first run. It counts as a run. */
213
+ fireNow(id) {
214
+ return this.fire(id);
215
+ }
212
216
  /** Public so the runner can mark a fire complete after async work even if
213
217
  * it bypassed the internal `fire()` (e.g. coalesced/manual triggers). */
214
218
  recordFire(id, success) {