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.
- package/.env.example +142 -130
- package/CHANGELOG.md +683 -2
- package/README.md +36 -32
- package/dist/audio/transcribe.js +0 -9
- package/dist/bin/mcp-server.js +46 -61
- package/dist/bot/bot.js +162 -181
- package/dist/bot/command-catalog.js +263 -0
- package/dist/bot/deleted-threads.js +103 -0
- package/dist/bot/file-access.js +35 -26
- package/dist/bot/handlers/album.handler.js +128 -0
- package/dist/bot/handlers/{fork.handler.js → branch.handler.js} +267 -280
- package/dist/bot/handlers/command/access.js +1 -1
- package/dist/bot/handlers/command/admin.js +86 -110
- package/dist/bot/handlers/command/all-view.js +33 -0
- package/dist/bot/handlers/command/auto-approve.js +3 -3
- package/dist/bot/handlers/command/background.js +37 -0
- package/dist/bot/handlers/command/botname.js +76 -0
- package/dist/bot/handlers/command/btw.js +20 -69
- package/dist/bot/handlers/command/cleanup.js +329 -0
- package/dist/bot/handlers/command/model.js +40 -119
- package/dist/bot/handlers/command/prefs-scope.js +255 -90
- package/dist/bot/handlers/command/project.js +31 -109
- package/dist/bot/handlers/command/resume.js +8 -4
- package/dist/bot/handlers/command/session.js +74 -213
- package/dist/bot/handlers/command/settings.js +92 -447
- package/dist/bot/handlers/command/shared.js +32 -35
- package/dist/bot/handlers/command/tasks.js +263 -95
- package/dist/bot/handlers/command/thread.js +128 -0
- package/dist/bot/handlers/command/topic-store.js +14 -53
- package/dist/bot/handlers/command/topic.js +8 -61
- package/dist/bot/handlers/command/{cost.js → usage.js} +32 -59
- package/dist/bot/handlers/command-fallback.js +179 -0
- package/dist/bot/handlers/command.handler.js +96 -422
- package/dist/bot/handlers/{schedule.handler.js → loop.handler.js} +159 -73
- package/dist/bot/handlers/media-fallback.js +12 -7
- package/dist/bot/handlers/message/replies.js +10 -87
- package/dist/bot/handlers/message/shared.js +9 -31
- package/dist/bot/handlers/message/turn-notify.js +15 -49
- package/dist/bot/handlers/message/turn-runner.js +18 -103
- package/dist/bot/handlers/message.handler.js +59 -52
- package/dist/bot/handlers/newbot.handler.js +13 -4
- package/dist/bot/handlers/photo.handler.js +88 -129
- package/dist/bot/handlers/prompts.handler.js +11 -11
- package/dist/bot/handlers/running-note.js +2 -2
- package/dist/bot/handlers/session-guard.js +4 -4
- package/dist/bot/handlers/suggestion.handler.js +2 -2
- package/dist/bot/handlers/tree.handler.js +20 -20
- package/dist/bot/handlers/voice.handler.js +23 -85
- package/dist/bot/kept-threads.js +51 -0
- package/dist/bot/middleware/album-collector.js +69 -0
- package/dist/bot/middleware/auth.middleware.js +1 -1
- package/dist/bot/middleware/group-mention.middleware.js +11 -5
- package/dist/bot/middleware/queued-messages.js +143 -32
- package/dist/bot/middleware/stale-filter.js +0 -22
- package/dist/build-info.json +5 -5
- package/dist/claude/ask-user-form.js +517 -0
- package/dist/claude/ask-user.js +94 -26
- package/dist/claude/auto-topic-haiku.js +17 -0
- package/dist/claude/available-commands.js +22 -19
- package/dist/claude/background-hint.js +91 -0
- package/dist/claude/{fork-tree.js → branch-tree.js} +9 -9
- package/dist/claude/carry-over.js +0 -2
- package/dist/claude/ccr-shim.js +12 -10
- package/dist/claude/claude-auth.js +6 -10
- package/dist/claude/command-parser.js +49 -43
- package/dist/claude/cost-overlay-scraper.js +7 -2
- package/dist/claude/effort-level.js +5 -0
- package/dist/claude/enabled-plugins.js +12 -16
- package/dist/claude/in-flight-tracker.js +21 -0
- package/dist/claude/mcp-bridge.js +86 -58
- package/dist/claude/memory-guard.js +400 -0
- package/dist/claude/message-offsets.js +5 -5
- package/dist/claude/modal-relay.js +401 -34
- package/dist/claude/model-catalog.js +20 -3
- package/dist/claude/monitor-relay.js +130 -15
- package/dist/claude/native-commands.js +40 -0
- package/dist/claude/{pending-forks.js → pending-branches.js} +26 -26
- package/dist/claude/permission-gate.js +11 -10
- package/dist/claude/permission-mode.js +19 -45
- package/dist/claude/prewarm.js +70 -0
- package/dist/claude/pty-idle-reaper.js +96 -0
- package/dist/claude/pty-provider.js +473 -188
- package/dist/claude/pty-spawn-config.js +79 -32
- package/dist/claude/pty-watch.js +201 -0
- package/dist/claude/request-queue.js +7 -35
- package/dist/claude/rewind.js +111 -0
- package/dist/claude/scheduled-runner.js +1 -3
- package/dist/claude/scheduler.js +6 -2
- package/dist/claude/scope-guard.js +8 -3
- package/dist/claude/screen-marks.js +83 -0
- package/dist/claude/screen-render.js +96 -0
- package/dist/claude/session-history.js +4 -2
- package/dist/claude/session-jsonl.js +162 -15
- package/dist/claude/session-manager.js +29 -8
- package/dist/claude/session-move.js +70 -0
- package/dist/claude/shell-mode-gate.js +60 -0
- package/dist/claude/side-question.js +20 -17
- package/dist/claude/stage-images.js +5 -5
- package/dist/claude/tasks-overlay-scraper.js +143 -20
- package/dist/claude/thread-judge-haiku.js +88 -0
- package/dist/claude/tip-scraper.js +3 -4
- package/dist/claude/tui-modal.js +272 -27
- package/dist/claude/tui-state.js +74 -2
- package/dist/claude/turn-end.js +15 -1
- package/dist/claude/turn-prose.js +1 -1
- package/dist/claude/typed-answer.js +104 -0
- package/dist/claude/update-banner-relay.js +1 -1
- package/dist/cli/commands/doctor.js +48 -15
- package/dist/cli/commands/help.js +11 -2
- package/dist/cli/commands/init.js +16 -13
- package/dist/cli/commands/service.js +40 -8
- package/dist/cli/commands/start.js +10 -0
- package/dist/cli/commands/watch.js +322 -0
- package/dist/cli/dispatch.js +5 -0
- package/dist/cli/init/env-file.js +1 -1
- package/dist/cli/init/flow.js +114 -47
- package/dist/cli/init/prompter.js +8 -0
- package/dist/cli/init/telegram.js +35 -9
- package/dist/cli/service/render.js +3 -3
- package/dist/config.js +156 -131
- package/dist/index.js +107 -31
- package/dist/launcher.js +34 -7
- package/dist/providers/ccr-introspect.js +1 -8
- package/dist/providers/ccr-provider.js +19 -20
- package/dist/providers/claude-provider.js +4 -57
- package/dist/providers/prefs-sync.js +16 -59
- package/dist/providers/provider-router.js +24 -23
- package/dist/providers/spawn-settings.js +45 -0
- package/dist/providers/user-preferences.js +127 -19
- package/dist/restart-when-idle.js +27 -7
- package/dist/startup/auto-continue.js +2 -2
- package/dist/startup/auto-resume.js +3 -15
- package/dist/startup/notices.js +1 -1
- package/dist/startup/verify-token.js +4 -4
- package/dist/telegram/action-logger.js +3 -165
- package/dist/telegram/background-activity-card.js +1 -1
- package/dist/telegram/botname-settings.js +71 -125
- package/dist/telegram/client-options.js +6 -7
- package/dist/telegram/force-reply-tracker.js +55 -16
- package/dist/telegram/message-sender.js +92 -360
- package/dist/telegram/prompt-label.js +11 -5
- package/dist/telegram/streaming-turn.js +5 -7
- package/dist/telegram/table-lists.js +56 -0
- package/dist/telegram/task-list.js +4 -4
- package/dist/telegram/task-tracker.js +45 -126
- package/dist/telegram/terminal-renderer.js +1 -5
- package/dist/telegram/thread-titles.js +74 -2
- package/dist/telegram/threads-setup.js +1 -1
- package/dist/utils/admins.js +2 -2
- package/dist/utils/bot-icon.js +248 -0
- package/dist/utils/bot-token.js +8 -5
- package/dist/utils/build-info.js +3 -3
- package/dist/utils/caffeinate.js +6 -3
- package/dist/utils/claude-env.js +0 -1
- package/dist/utils/claude-version.js +2 -2
- package/dist/utils/config-home.js +3 -3
- package/dist/utils/download.js +41 -15
- package/dist/utils/exit-codes.js +11 -0
- package/dist/utils/format.js +3 -6
- package/dist/utils/home-project.js +1 -1
- package/dist/utils/idle-restart.js +1 -1
- package/dist/utils/install-mode.js +1 -1
- package/dist/utils/instance-config.js +1 -1
- package/dist/utils/instances.js +1 -1
- package/dist/utils/keyed-settings.js +2 -2
- package/dist/utils/memory-pressure.js +60 -0
- package/dist/utils/npm-version.js +2 -2
- package/dist/utils/resolve-claude-bin.js +13 -24
- package/dist/utils/respawn-backoff.js +9 -0
- package/dist/utils/stale-launcher.js +1 -1
- package/dist/utils/systemd.js +8 -8
- package/dist/utils/telegram-proxy.js +72 -0
- package/dist/utils/uploads-dir.js +27 -0
- package/dist/utils/verbosity.js +8 -8
- package/dist/utils/version-check.js +5 -5
- package/package.json +3 -4
- package/dist/bot/handlers/command/media.js +0 -197
- package/dist/bot/handlers/command/streaming-mode.js +0 -16
- package/dist/bot/handlers/message/throttle.js +0 -49
- package/dist/claude/agent-watchdog.js +0 -162
- package/dist/claude/agent.js +0 -1458
- package/dist/claude/held-query.js +0 -190
- package/dist/claude/mcp-tools.js +0 -354
- package/dist/claude/sdk-permission-gate.js +0 -77
- package/dist/claude/session-cost.js +0 -41
- package/dist/claude/system-prompt.js +0 -162
- package/dist/providers/sdk-provider.js +0 -37
- package/dist/telegram/telegraph-settings.js +0 -31
- package/dist/telegram/telegraph.js +0 -453
- package/dist/telegram/terminal-settings.js +0 -25
- package/dist/tts/tts-settings.js +0 -62
- package/dist/tts/tts.js +0 -245
- package/dist/tts/voice-reply.js +0 -78
- package/dist/utils/debug-agent.js +0 -117
- package/dist/utils/debug-watchdog.js +0 -121
- package/dist/utils/project-data-dir.js +0 -33
- package/dist/utils/reasoning-summary.js +0 -12
package/README.md
CHANGED
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
# TeleCoder
|
|
4
4
|
|
|
5
5
|
**Claude Code in Telegram.** The real agent runs on your machine; you drive it from Telegram's
|
|
6
|
-
native apps, with a thread per conversation,
|
|
6
|
+
native apps, with a thread per conversation, branches and the full CLI.
|
|
7
7
|
|
|
8
|
-
[](https://github.com/telecoderbot/telecoder/actions/workflows/ci.yml)
|
|
9
9
|
[](https://www.npmjs.com/package/telecoder)
|
|
10
10
|
[](https://nodejs.org/)
|
|
11
11
|
[](LICENSE)
|
|
12
12
|
|
|
13
|
-
[Website](https://telecoder.dev) · [Quick start](#quick-start) · [Features](docs/features.md) · [Commands](docs/commands.md) · [Docs](#documentation) · [Changelog](CHANGELOG.md)
|
|
13
|
+
[Website](https://telecoder.dev) · [Quick start](#quick-start) · [Features](site/src/content/docs/guides/features.md) · [Commands](site/src/content/docs/reference/commands.md) · [Docs](#documentation) · [Changelog](CHANGELOG.md)
|
|
14
14
|
|
|
15
15
|
</div>
|
|
16
16
|
|
|
17
|
-
<!-- Demo GIF goes here: a thread, a
|
|
17
|
+
<!-- Demo GIF goes here: a thread, a branch into a new thread, a permission prompt, a voice note. -->
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
@@ -30,37 +30,39 @@ TeleCoder puts Claude Code inside them.
|
|
|
30
30
|
- **A thread per conversation.** Each thread is its own Claude session, in groups and in
|
|
31
31
|
private chats. Start a thread and you have a new session; run five tasks side by side and
|
|
32
32
|
switch between them like chats.
|
|
33
|
-
- **
|
|
33
|
+
- **Branches.** `/branch` copies the conversation into a new thread; `/spinoff` splits a task off
|
|
34
34
|
with a compacted copy of the context; `/tree` draws the branches and lets you jump between
|
|
35
35
|
them.
|
|
36
|
-
- **The full CLI, not a subset.**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
`/
|
|
36
|
+
- **The full CLI, not a subset.** TeleCoder drives the real `claude` TUI, so a project's
|
|
37
|
+
`CLAUDE.md`, settings, skills and slash commands work as they do in your terminal, and its
|
|
38
|
+
permission dialogs arrive as buttons. `/model`, `/effort`, `/compact`, `/context`, `/usage`,
|
|
39
|
+
`/rewind` and `/resume` are there too, and `/cc <command>` reaches a Claude Code command
|
|
40
|
+
the bot has its own version of.
|
|
40
41
|
- **Claude can reach you.** It can ask with buttons, send you files, ask for an API key
|
|
41
42
|
(your message is deleted the moment it arrives), schedule prompts, and report background
|
|
42
43
|
tasks as they finish.
|
|
43
|
-
- **Built for working away from your desk.**
|
|
44
|
-
a side question without stopping the task, `/steer` corrects it mid-turn,
|
|
45
|
-
an idea aside for when Claude is done
|
|
44
|
+
- **Built for working away from your desk.** Send voice notes as prompts. `/btw` asks
|
|
45
|
+
a side question without stopping the task, `/steer` corrects it mid-turn, `/later` sets
|
|
46
|
+
an idea aside for when Claude is done, and `/ctrlb` is Claude Code's Ctrl+B. Sessions
|
|
47
|
+
carry on by themselves after a restart.
|
|
46
48
|
- **More than one bot.** Run a bot per project from one process, and make a new one from
|
|
47
49
|
chat with `/newbot`, without a BotFather conversation.
|
|
48
50
|
- **Shareable, carefully.** Admins, guests and approvers, a permission gate on every
|
|
49
|
-
|
|
51
|
+
tool call, a scope guard for paths, and a charter checked before a guest's message runs.
|
|
50
52
|
|
|
51
|
-
The full list is
|
|
53
|
+
The full list is on the [Features](site/src/content/docs/guides/features.md) page.
|
|
52
54
|
|
|
53
55
|
## How it compares
|
|
54
56
|
|
|
55
57
|
- **Claude Code Channels** (the official Telegram and Discord plugin) pushes chat messages
|
|
56
58
|
into a Claude Code session you started in a terminal. It's a good fit for nudging one running
|
|
57
59
|
session. TeleCoder starts and keeps its own sessions, so you get as many as you have
|
|
58
|
-
threads, plus
|
|
60
|
+
threads, plus branches, resume, voice and the commands above.
|
|
59
61
|
- **Remote Control** lets you look in on a terminal session from the Claude app. Use it when
|
|
60
62
|
you want the session you already have, on Anthropic's own UI.
|
|
61
63
|
- **[claude-code-telegram](https://github.com/RichardAtCT/claude-code-telegram)** is the
|
|
62
64
|
most popular community bot: Python, SDK-based, with cost caps and webhooks. TeleCoder
|
|
63
|
-
|
|
65
|
+
drives the full CLI itself, and adds threads, branches and multiple bots.
|
|
64
66
|
- **Web UIs** such as [CloudCLI](https://github.com/siteboon/claudecodeui) give you a
|
|
65
67
|
browser dashboard with file trees and diffs. TeleCoder gives up the dashboard for native
|
|
66
68
|
apps, notifications and voice.
|
|
@@ -80,31 +82,33 @@ telecoder service install # keep it running, and start it at boot
|
|
|
80
82
|
|
|
81
83
|
`telecoder init` checks the token with Telegram, learns your user ID when you send the bot
|
|
82
84
|
`/start`, and writes `~/.telecoder/.env`, readable by you only. Then open your bot in Telegram,
|
|
83
|
-
pick a project with `/
|
|
85
|
+
pick a project with `/dir` and start talking.
|
|
84
86
|
|
|
85
|
-
`telecoder doctor` checks your setup, `telecoder service logs` follows the output and `/
|
|
87
|
+
`telecoder doctor` checks your setup, `telecoder service logs` follows the output and `/botupdate`
|
|
86
88
|
upgrades from chat. To run from a git checkout instead, see
|
|
87
|
-
[
|
|
89
|
+
[Install and run](site/src/content/docs/start/install.md#from-source).
|
|
88
90
|
|
|
89
91
|
## Documentation
|
|
90
92
|
|
|
91
|
-
- [
|
|
92
|
-
- [
|
|
93
|
-
- [
|
|
94
|
-
- [
|
|
95
|
-
- [
|
|
96
|
-
- [
|
|
97
|
-
- [
|
|
98
|
-
- [
|
|
99
|
-
- [
|
|
93
|
+
- [Get started](site/src/content/docs/start/get-started.md): a first setup, step by step, from BotFather to threads
|
|
94
|
+
- [Install and run](site/src/content/docs/start/install.md): prerequisites, the wizard, the background service, running from source
|
|
95
|
+
- [Features](site/src/content/docs/guides/features.md): everything TeleCoder does
|
|
96
|
+
- [Commands](site/src/content/docs/reference/commands.md): every bot command
|
|
97
|
+
- [Multiple bots](site/src/content/docs/guides/multiple-bots.md): `instances.json`, `/newbot` and a home project per bot
|
|
98
|
+
- [Providers](site/src/content/docs/guides/providers.md): Claude Code Router for when Max throttles
|
|
99
|
+
- [Sharing a bot](site/src/content/docs/guides/sharing.md): admins, guests, group roles, the permission gate and a separate Unix account
|
|
100
|
+
- [Configuration](site/src/content/docs/reference/configuration.md): every `.env` setting
|
|
101
|
+
- [Security](site/src/content/docs/reference/security.md): what's protected, what's stored and where data goes
|
|
102
|
+
- [Architecture and development](site/src/content/docs/reference/architecture.md): how it's built, and how to work on it
|
|
103
|
+
- [Troubleshooting](site/src/content/docs/help/troubleshooting.md) and [FAQ](site/src/content/docs/help/faq.md)
|
|
100
104
|
- [Roadmap](ROADMAP.md), [changelog](CHANGELOG.md) and [contributing](CONTRIBUTING.md)
|
|
101
105
|
|
|
102
106
|
## Project status
|
|
103
107
|
|
|
104
108
|
In active development, and used every day for my own work, including building TeleCoder
|
|
105
|
-
itself. The latest release is 1.
|
|
109
|
+
itself. The latest release is 1.3.0, on [npm](https://www.npmjs.com/package/telecoder) and
|
|
106
110
|
tagged here; the [changelog](CHANGELOG.md) lists what's in each release. The code is about
|
|
107
|
-
53k lines of TypeScript, plus
|
|
111
|
+
53k lines of TypeScript, plus 37k lines of tests (203 test files, 2,672 tests), and CI runs
|
|
108
112
|
the type check, tests and build on every push.
|
|
109
113
|
|
|
110
114
|
TeleCoder is self-hosted: it runs on your machine with your own Claude account, and there is no
|
|
@@ -115,8 +119,8 @@ hosted version.
|
|
|
115
119
|
TeleCoder began as a fork of [Claudegram](https://github.com/NachoSEO/claudegram) by
|
|
116
120
|
[@NachoSEO](https://github.com/NachoSEO), MIT-licensed, whose last commit was in March 2026.
|
|
117
121
|
Claudegram's copyright notice is kept in [LICENSE](LICENSE). Since April 2026 TeleCoder has
|
|
118
|
-
been developed independently by [@gitaarik](https://github.com/gitaarik):
|
|
119
|
-
about
|
|
122
|
+
been developed independently by [@gitaarik](https://github.com/gitaarik): 600+ commits, adding
|
|
123
|
+
about 145k lines and removing 47k. The history since the fork is all in this repository, which
|
|
120
124
|
was created in July 2026 when the project was renamed, so its GitHub creation date is later than
|
|
121
125
|
its first commits.
|
|
122
126
|
|
package/dist/audio/transcribe.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import { config } from '../config.js';
|
|
4
|
-
import { downloadFileSecure, getTelegramFileUrl } from '../utils/download.js';
|
|
5
4
|
const GROQ_WHISPER_ENDPOINT = 'https://api.groq.com/openai/v1/audio/transcriptions';
|
|
6
5
|
const GROQ_WHISPER_MODEL = 'whisper-large-v3-turbo';
|
|
7
6
|
/**
|
|
@@ -39,12 +38,4 @@ export async function transcribeFile(filePath, options) {
|
|
|
39
38
|
}
|
|
40
39
|
return transcript;
|
|
41
40
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Download a file from Telegram servers securely.
|
|
44
|
-
* Constructs the URL via getTelegramFileUrl and delegates to downloadFileSecure.
|
|
45
|
-
*/
|
|
46
|
-
export function downloadTelegramAudio(botToken, filePath, destPath) {
|
|
47
|
-
const fileUrl = getTelegramFileUrl(botToken, filePath);
|
|
48
|
-
return downloadFileSecure(fileUrl, destPath);
|
|
49
|
-
}
|
|
50
41
|
//# sourceMappingURL=transcribe.js.map
|
package/dist/bin/mcp-server.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Spawned by `claude --mcp-config` when running under PtyProvider, communicates
|
|
5
5
|
* over stdio. Tools that need bot-side context (Telegram send_file / ask_user /
|
|
6
6
|
* set_topic, …) POST to the main bot process's loopback IPC server; tools that
|
|
7
|
-
* are pure local work (list_projects,
|
|
7
|
+
* are pure local work (list_projects, …) run inline.
|
|
8
8
|
*
|
|
9
9
|
* Env vars set by PtyProvider when spawning this process. These are an internal
|
|
10
10
|
* contract between the two — PtyProvider writes them and only this file reads
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
* inherited from claude's env, never in args
|
|
16
16
|
* TELECODER_CLAUDE_SESSION_ID claude's session_id; used as the IPC routing key
|
|
17
17
|
* TELECODER_WORKSPACE_ROOT workspace root for security checks
|
|
18
|
-
* TELECODER_TELEGRAPH_ENABLED feature flag for publish_telegraph
|
|
19
18
|
*/
|
|
20
19
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
21
20
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
@@ -97,11 +96,6 @@ function ipc(routePath, payload = {}, signal) {
|
|
|
97
96
|
req.end(body);
|
|
98
97
|
});
|
|
99
98
|
}
|
|
100
|
-
// Lazy imports — keep startup fast, and only load modules whose tool is
|
|
101
|
-
// actually present in this configuration.
|
|
102
|
-
async function importTelegraph() {
|
|
103
|
-
return import('../telegram/telegraph.js');
|
|
104
|
-
}
|
|
105
99
|
const server = new McpServer({
|
|
106
100
|
name: 'telecoder-tools',
|
|
107
101
|
version: '1.0.0',
|
|
@@ -131,8 +125,8 @@ server.tool('telecoder_list_projects', 'List all available projects in the works
|
|
|
131
125
|
}
|
|
132
126
|
});
|
|
133
127
|
// ── telecoder_ask_user (IPC: long-poll on Telegram button tap) ──────
|
|
134
|
-
server.tool('telecoder_ask_user', 'Ask the user a multiple-choice question via a Telegram inline keyboard. Use when you need a clear decision from the user (e.g. picking between approaches, confirming a destructive action, choosing among options)
|
|
135
|
-
question: z.string().describe('The question to display to the user. Keep concise (1-2 sentences).'),
|
|
128
|
+
server.tool('telecoder_ask_user', 'Ask the user a multiple-choice question via a Telegram inline keyboard. Use when you need a clear decision from the user (e.g. picking between approaches, confirming a destructive action, choosing among options) rather than asking in prose. Pauses the agent loop until the user answers or the question times out. The user can always answer in their own words instead of tapping, by sending a message; you then get `User answered in their own words: …`, so don\'t add an "Other" option. Keep the question short and the options crisp — a label of ≤ 25 chars stays on its button; anything longer makes the whole keyboard fall back to lettered buttons (A/B/C) with the full labels listed in the message body. Prefer this over the built-in AskUserQuestion when interacting through TeleCoder. Several questions at once: pass `questions` (2-4) instead of `question`/`options` — they arrive as ONE form the user steps through, can revise, and submits; nothing reaches you before Submit. Never fire separate calls in a row for questions that belong together. IMPORTANT: `context` is required and carries everything the user needs to decide (the comparison, trade-offs, findings, rationale) — it renders in the SAME message as the buttons. Do NOT write that explanation as prose before calling this tool: text you emit before an ask_user call is not delivered to the user until after they answer, so they would be choosing blind.', {
|
|
129
|
+
question: z.string().optional().describe('The question to display to the user. Keep concise (1-2 sentences). Required unless `questions` is given.'),
|
|
136
130
|
context: z
|
|
137
131
|
.string()
|
|
138
132
|
.min(1)
|
|
@@ -144,10 +138,28 @@ server.tool('telecoder_ask_user', 'Ask the user a multiple-choice question via a
|
|
|
144
138
|
}))
|
|
145
139
|
.min(2)
|
|
146
140
|
.max(8)
|
|
147
|
-
.
|
|
148
|
-
|
|
141
|
+
.optional()
|
|
142
|
+
.describe('Between 2 and 8 options for the user to choose from. Required unless `questions` is given.'),
|
|
143
|
+
questions: z
|
|
144
|
+
.array(z.object({
|
|
145
|
+
question: z.string().min(1).describe('One question, 1-2 sentences.'),
|
|
146
|
+
options: z
|
|
147
|
+
.array(z.object({
|
|
148
|
+
label: z.string().describe('Button label; ≤ 25 chars keeps it on its button.'),
|
|
149
|
+
description: z.string().optional().describe('Optional one-line note shown in the body.'),
|
|
150
|
+
}))
|
|
151
|
+
.min(2)
|
|
152
|
+
.max(8),
|
|
153
|
+
}))
|
|
154
|
+
.min(1)
|
|
155
|
+
.max(4)
|
|
156
|
+
.optional()
|
|
157
|
+
.describe('Several related questions as one form, in place of `question`/`options`. The user answers each with a button or in their own words, can go back and change any answer, and nothing is sent until they tap Submit — like AskUserQuestion with several questions. 2-4 questions, 2-8 options each; `context` is shown once at the top.'),
|
|
158
|
+
}, async ({ question, context, options, questions }, extra) => {
|
|
149
159
|
try {
|
|
150
|
-
|
|
160
|
+
// The signal lets the bot close the question when claude cancels the
|
|
161
|
+
// call, rather than leave it waiting out the clock.
|
|
162
|
+
const result = await ipc('/mcp/ask_user', { question, context, options, questions }, extra.signal);
|
|
151
163
|
return toolResult(result);
|
|
152
164
|
}
|
|
153
165
|
catch (error) {
|
|
@@ -208,7 +220,7 @@ server.tool('telecoder_create_bot', "Create a Telegram bot for one project: send
|
|
|
208
220
|
}
|
|
209
221
|
});
|
|
210
222
|
// ── telecoder_send_file (IPC: needs bot for Telegram sendDocument) ──
|
|
211
|
-
server.tool('telecoder_send_file', 'Send a file from the server to the user via Telegram. The file must be within the
|
|
223
|
+
server.tool('telecoder_send_file', 'Send a file from the server to the user via Telegram. The file must be within the project (or the workspace, for an admin) or /tmp; credential files such as .env or ~/.ssh are never sent. Use this after creating files (SVGs, images, reports, etc.) to deliver them directly to the user. Maximum file size: 50MB.', {
|
|
212
224
|
file_path: z.string().describe('Absolute or workspace-relative path to the file to send.'),
|
|
213
225
|
caption: z.string().optional().describe('Optional caption to display with the file in Telegram.'),
|
|
214
226
|
}, async ({ file_path, caption }) => {
|
|
@@ -223,54 +235,27 @@ server.tool('telecoder_send_file', 'Send a file from the server to the user via
|
|
|
223
235
|
};
|
|
224
236
|
}
|
|
225
237
|
});
|
|
226
|
-
// ── telecoder_set_topic (IPC:
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
// ── telecoder_publish_telegraph ─────────────────────────────────────
|
|
250
|
-
if (process.env.TELECODER_TELEGRAPH_ENABLED === 'true') {
|
|
251
|
-
server.tool('telecoder_publish_telegraph', 'Publish markdown content as a Telegraph (telegra.ph) Instant View page. Returns the URL. Useful for sharing long-form content as a readable link.', {
|
|
252
|
-
title: z.string().describe('Page title'),
|
|
253
|
-
markdown: z.string().describe('Markdown content for the page'),
|
|
254
|
-
}, async ({ title, markdown }) => {
|
|
255
|
-
try {
|
|
256
|
-
const { createTelegraphPage } = await importTelegraph();
|
|
257
|
-
const url = await createTelegraphPage(title, markdown);
|
|
258
|
-
if (!url) {
|
|
259
|
-
return {
|
|
260
|
-
content: [{ type: 'text', text: 'Failed to create Telegraph page.' }],
|
|
261
|
-
isError: true,
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
return { content: [{ type: 'text', text: `Telegraph page created: ${url}` }] };
|
|
265
|
-
}
|
|
266
|
-
catch (error) {
|
|
267
|
-
return {
|
|
268
|
-
content: [{ type: 'text', text: `Telegraph error: ${error instanceof Error ? error.message : String(error)}` }],
|
|
269
|
-
isError: true,
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
}
|
|
238
|
+
// ── telecoder_set_topic (IPC: the topic lives in the bot's state) ────
|
|
239
|
+
server.tool('telecoder_set_topic', 'Update the conversation topic shown in the footer under each reply and as the thread\'s name. Call this proactively when the work topic changes. Pass an empty string to clear. Keep topics very short (1-4 words, e.g. "auth refactor", "CI fix", "dark mode").', {
|
|
240
|
+
topic: z.string().describe('Short topic label (1-4 words). Empty string to clear.'),
|
|
241
|
+
}, async ({ topic }) => {
|
|
242
|
+
try {
|
|
243
|
+
const result = await ipc('/mcp/set_topic', { topic });
|
|
244
|
+
return {
|
|
245
|
+
content: [{
|
|
246
|
+
type: 'text',
|
|
247
|
+
text: result.message || (result.success ? `Topic set to "${topic}".` : 'Topic update failed.'),
|
|
248
|
+
}],
|
|
249
|
+
isError: !result.success,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
return {
|
|
254
|
+
content: [{ type: 'text', text: `set_topic error: ${error instanceof Error ? error.message : String(error)}` }],
|
|
255
|
+
isError: true,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
});
|
|
274
259
|
// ── telecoder_poll_user (IPC: Telegram poll) ────────────────────────
|
|
275
260
|
server.tool('telecoder_poll_user', 'Ask the user (or a group) a question via a Telegram poll. Prefer this over telecoder_ask_user when (a) multiple chat members should vote, (b) you want vote counts shown alongside, or (c) you need multi-select. Polls are non-anonymous (vote identities visible). Resolves on the first vote — for multi-select, the snapshot at that moment is returned. 2-10 options.', {
|
|
276
261
|
question: z.string().describe('The poll question. ≤ 300 chars (Telegram cap).'),
|