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
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Per-chat settings menus: /
|
|
3
|
-
* /suggestions, /effort, /verbosity, /method and the status line.
|
|
2
|
+
* Per-chat settings menus: /suggestions, /effort, /verbosity and the status line.
|
|
4
3
|
*
|
|
5
4
|
* They share one shape — render an inline keyboard reflecting current state,
|
|
6
5
|
* flip a setting on tap, re-render — and several need the same pty-restart
|
|
@@ -9,91 +8,25 @@
|
|
|
9
8
|
import * as path from 'path';
|
|
10
9
|
import { config } from '../../../config.js';
|
|
11
10
|
import { sessionManager } from '../../../claude/session-manager.js';
|
|
12
|
-
import { promptsIn } from '../../../claude/
|
|
13
|
-
import {
|
|
11
|
+
import { promptsIn } from '../../../claude/branch-tree.js';
|
|
12
|
+
import { getEffort, isValidEffortLevel, getActiveProviderName, } from '../../../providers/provider-router.js';
|
|
14
13
|
import { userPreferences } from '../../../providers/user-preferences.js';
|
|
15
14
|
import { contextTokens } from '../../../providers/types.js';
|
|
16
15
|
import { isPremiumModel, PREMIUM_MODEL_ICON } from '../../../claude/model-catalog.js';
|
|
17
|
-
import {
|
|
16
|
+
import { getPtyProvider } from '../../../providers/claude-provider.js';
|
|
18
17
|
import { EntityText, joinMessages } from '../../../telegram/entities.js';
|
|
19
18
|
import { replyFormatted, editCallbackMessage } from '../../../telegram/send.js';
|
|
20
19
|
import { taskTracker } from '../../../telegram/task-tracker.js';
|
|
21
20
|
import { promptLabel, cutLabel } from '../../../telegram/prompt-label.js';
|
|
22
|
-
import { getTTSSettings, setTTSEnabled, setTTSVoice, setTTSAutoplay } from '../../../tts/tts-settings.js';
|
|
23
|
-
import { getTerminalUISettings, setTerminalUIEnabled } from '../../../telegram/terminal-settings.js';
|
|
24
|
-
import { getTelegraphSettings, setTelegraphEnabled } from '../../../telegram/telegraph-settings.js';
|
|
25
21
|
import { getSuggestionsSettings, setSuggestionsEnabled } from '../../../telegram/suggestions-settings.js';
|
|
26
22
|
import { VERBOSITY_INFO, isValidVerbosityLevel, getVerbosityLevel, resolveVerbosityFlags, } from '../../../utils/verbosity.js';
|
|
27
23
|
import { contextHealthColor, fmtTokens, getProgressBar } from '../../../utils/format.js';
|
|
28
|
-
import { getSessionKeyFromCtx
|
|
29
|
-
import { PERMISSION_MODES, isPermissionModeId, parsePermissionModeArg, permissionModeInfo,
|
|
30
|
-
import { replyMd,
|
|
24
|
+
import { getSessionKeyFromCtx } from '../../../utils/session-key.js';
|
|
25
|
+
import { PERMISSION_MODES, isPermissionModeId, parsePermissionModeArg, permissionModeInfo, defaultPermissionMode, } from '../../../claude/permission-mode.js';
|
|
26
|
+
import { replyMd, getEffortLabel, effortLevelLabel, EFFORT_LEVELS, } from './shared.js';
|
|
31
27
|
import { getSessionTopic } from './topic.js';
|
|
32
|
-
import { getStreamingMode, setStreamingMode } from './streaming-mode.js';
|
|
33
28
|
import { getBgProcesses } from './tasks.js';
|
|
34
|
-
import { parseScopeArg,
|
|
35
|
-
const OPENAI_TTS_VOICES = [
|
|
36
|
-
'alloy', 'ash', 'ballad', 'coral',
|
|
37
|
-
'echo', 'fable', 'nova', 'onyx',
|
|
38
|
-
'sage', 'shimmer', 'verse', 'marin', 'cedar',
|
|
39
|
-
];
|
|
40
|
-
const GROQ_TTS_VOICES = [
|
|
41
|
-
'autumn', 'diana', 'hannah', 'austin', 'daniel', 'troy',
|
|
42
|
-
];
|
|
43
|
-
function getActiveTTSVoices() {
|
|
44
|
-
return config.TTS_PROVIDER === 'groq' ? GROQ_TTS_VOICES : OPENAI_TTS_VOICES;
|
|
45
|
-
}
|
|
46
|
-
function buildTTSMenu(sessionKey, mode) {
|
|
47
|
-
const settings = getTTSSettings(sessionKey);
|
|
48
|
-
const hasKey = config.TTS_PROVIDER === 'groq' ? !!config.GROQ_API_KEY : !!config.OPENAI_API_KEY;
|
|
49
|
-
const apiStatus = hasKey ? 'configured' : 'missing';
|
|
50
|
-
const providerLabel = config.TTS_PROVIDER === 'groq' ? 'Groq Orpheus' : 'OpenAI';
|
|
51
|
-
const statusLine = settings.enabled ? 'ON' : 'OFF';
|
|
52
|
-
const autoplayLine = settings.autoplay ? 'ON' : 'OFF';
|
|
53
|
-
const header = () => new EntityText().add('🔊 ').bold('Voice Replies').newline(2);
|
|
54
|
-
if (mode === 'voices') {
|
|
55
|
-
const voices = getActiveTTSVoices();
|
|
56
|
-
const voiceRows = [];
|
|
57
|
-
const chunkSize = 3;
|
|
58
|
-
for (let i = 0; i < voices.length; i += chunkSize) {
|
|
59
|
-
const chunk = voices.slice(i, i + chunkSize);
|
|
60
|
-
voiceRows.push(chunk.map((voice) => ({
|
|
61
|
-
text: voice === settings.voice ? `✓ ${voice}` : voice,
|
|
62
|
-
callback_data: `tts:voice:${voice}`,
|
|
63
|
-
})));
|
|
64
|
-
}
|
|
65
|
-
const recommended = config.TTS_PROVIDER === 'groq'
|
|
66
|
-
? 'autumn, troy'
|
|
67
|
-
: 'marin, cedar';
|
|
68
|
-
return {
|
|
69
|
-
text: header().add(`Pick a voice.\nRecommended: ${recommended}.`).build(),
|
|
70
|
-
keyboard: [
|
|
71
|
-
...voiceRows,
|
|
72
|
-
[{ text: 'Back', callback_data: 'tts:back' }],
|
|
73
|
-
],
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
const autoplayLabel = settings.autoplay ? '✓ Autoplay' : 'Autoplay';
|
|
77
|
-
return {
|
|
78
|
-
text: header()
|
|
79
|
-
.add('Provider: ').bold(providerLabel).newline()
|
|
80
|
-
.add('Status: ').bold(statusLine).newline()
|
|
81
|
-
.add('Voice: ').bold(settings.voice).newline()
|
|
82
|
-
.add('Autoplay: ').bold(autoplayLine).newline()
|
|
83
|
-
.add('API key: ').bold(apiStatus)
|
|
84
|
-
.build(),
|
|
85
|
-
keyboard: [
|
|
86
|
-
[
|
|
87
|
-
{ text: settings.enabled ? '✓ On' : 'On', callback_data: 'tts:on' },
|
|
88
|
-
{ text: !settings.enabled ? '✓ Off' : 'Off', callback_data: 'tts:off' },
|
|
89
|
-
],
|
|
90
|
-
[
|
|
91
|
-
{ text: `Voice: ${settings.voice}`, callback_data: 'tts:voices' },
|
|
92
|
-
{ text: autoplayLabel, callback_data: 'tts:autoplay' },
|
|
93
|
-
],
|
|
94
|
-
],
|
|
95
|
-
};
|
|
96
|
-
}
|
|
29
|
+
import { parseScopeArg, isBareLevelWord, scopeSite, applyAtLevel, describeSource, levelHelp, EVERYWHERE_ADMIN_ONLY, } from './prefs-scope.js';
|
|
97
30
|
function buildSuggestionsMenu(sessionKey) {
|
|
98
31
|
const settings = getSuggestionsSettings(sessionKey);
|
|
99
32
|
const defaultLabel = config.PROMPT_SUGGESTIONS_DEFAULT ? 'on' : 'off';
|
|
@@ -116,217 +49,16 @@ function buildSuggestionsMenu(sessionKey) {
|
|
|
116
49
|
],
|
|
117
50
|
};
|
|
118
51
|
}
|
|
119
|
-
export function buildTelegraphMenu(sessionKey) {
|
|
120
|
-
const settings = getTelegraphSettings(sessionKey);
|
|
121
|
-
const globalEnabled = config.TELEGRAPH_ENABLED;
|
|
122
|
-
const globalStatus = globalEnabled ? 'enabled' : 'disabled';
|
|
123
|
-
const statusLine = settings.enabled ? 'ON' : 'OFF';
|
|
124
|
-
const header = () => new EntityText().add('📄 ').bold('Instant View (Telegraph)').newline(2);
|
|
125
|
-
// If global config is disabled, show warning and no toggle
|
|
126
|
-
if (!globalEnabled) {
|
|
127
|
-
return {
|
|
128
|
-
text: header()
|
|
129
|
-
.add('⚠️ ').bold('Disabled globally').newline(2)
|
|
130
|
-
.add('Telegraph is off in the bot configuration. It is opt-in because every page it publishes is public to anyone with the link.\nSet ')
|
|
131
|
-
.code('TELEGRAPH_ENABLED=true').add(' in .env to enable.')
|
|
132
|
-
.build(),
|
|
133
|
-
keyboard: [],
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
return {
|
|
137
|
-
text: header()
|
|
138
|
-
.add('Status: ').bold(statusLine).newline()
|
|
139
|
-
.add('Global config: ').bold(globalStatus).newline(2)
|
|
140
|
-
.italic('When enabled, replies over 2500 characters also get an Instant View link under the text. The reply itself is always sent in full either way.')
|
|
141
|
-
.build(),
|
|
142
|
-
keyboard: [
|
|
143
|
-
[
|
|
144
|
-
{ text: settings.enabled ? '✓ On' : 'On', callback_data: 'telegraph:on' },
|
|
145
|
-
{ text: !settings.enabled ? '✓ Off' : 'Off', callback_data: 'telegraph:off' },
|
|
146
|
-
],
|
|
147
|
-
],
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
export async function handleStreaming(ctx) {
|
|
151
|
-
const keyboard = [
|
|
152
|
-
[
|
|
153
|
-
{
|
|
154
|
-
text: getStreamingMode() === 'streaming' ? '✓ Streaming' : 'Streaming',
|
|
155
|
-
callback_data: 'mode:streaming'
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
text: getStreamingMode() === 'wait' ? '✓ Wait' : 'Wait',
|
|
159
|
-
callback_data: 'mode:wait'
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
];
|
|
163
|
-
await replyFormatted(ctx, new EntityText()
|
|
164
|
-
.add('⚙️ ').bold('Response Mode').newline(2)
|
|
165
|
-
.add('Current: ').bold(getStreamingMode()).newline()
|
|
166
|
-
.italic(streamingModeDescription(getStreamingMode()))
|
|
167
|
-
.build(), { reply_markup: { inline_keyboard: keyboard } });
|
|
168
|
-
}
|
|
169
|
-
function streamingModeDescription(mode) {
|
|
170
|
-
return mode === 'streaming' ? 'Updates progressively as Claude types' : 'Shows complete response when done';
|
|
171
|
-
}
|
|
172
|
-
export async function handleModeCallback(ctx) {
|
|
173
|
-
const data = ctx.callbackQuery?.data;
|
|
174
|
-
if (!data || !data.startsWith('mode:'))
|
|
175
|
-
return;
|
|
176
|
-
const newMode = data.replace('mode:', '');
|
|
177
|
-
setStreamingMode(newMode);
|
|
178
|
-
await ctx.answerCallbackQuery({ text: `Mode set to ${newMode}!` });
|
|
179
|
-
await editCallbackMessage(ctx, new EntityText()
|
|
180
|
-
.add('✅ Mode set to ').bold(newMode).newline(2)
|
|
181
|
-
.italic(streamingModeDescription(newMode))
|
|
182
|
-
.build());
|
|
183
|
-
}
|
|
184
|
-
export async function handleTerminalUI(ctx) {
|
|
185
|
-
const keyInfo = getSessionKeyFromCtx(ctx);
|
|
186
|
-
if (!keyInfo)
|
|
187
|
-
return;
|
|
188
|
-
const { sessionKey } = keyInfo;
|
|
189
|
-
const settings = getTerminalUISettings(sessionKey);
|
|
190
|
-
const currentStatus = settings.enabled ? 'ON' : 'OFF';
|
|
191
|
-
const keyboard = [
|
|
192
|
-
[
|
|
193
|
-
{
|
|
194
|
-
text: settings.enabled ? '✓ On' : 'On',
|
|
195
|
-
callback_data: 'terminalui:on'
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
text: !settings.enabled ? '✓ Off' : 'Off',
|
|
199
|
-
callback_data: 'terminalui:off'
|
|
200
|
-
},
|
|
201
|
-
],
|
|
202
|
-
];
|
|
203
|
-
await replyFormatted(ctx, new EntityText()
|
|
204
|
-
.add('🖥️ ').bold('Terminal UI Mode').newline(2)
|
|
205
|
-
.add('Current: ').bold(currentStatus).newline()
|
|
206
|
-
.italic(terminalUIDescription(settings.enabled))
|
|
207
|
-
.build(), { reply_markup: { inline_keyboard: keyboard } });
|
|
208
|
-
}
|
|
209
|
-
function terminalUIDescription(enabled) {
|
|
210
|
-
return enabled
|
|
211
|
-
? 'Shows spinner animations and tool status during operations'
|
|
212
|
-
: 'Classic streaming mode with simple cursor';
|
|
213
|
-
}
|
|
214
|
-
export async function handleTerminalUICallback(ctx) {
|
|
215
|
-
const cb = parseCallback(ctx, 'terminalui:');
|
|
216
|
-
if (!cb)
|
|
217
|
-
return;
|
|
218
|
-
const { sessionKey, data } = cb;
|
|
219
|
-
const newState = data.replace('terminalui:', '') === 'on';
|
|
220
|
-
setTerminalUIEnabled(sessionKey, newState);
|
|
221
|
-
const statusText = newState ? 'ON' : 'OFF';
|
|
222
|
-
await ctx.answerCallbackQuery({ text: `Terminal UI ${statusText}!` });
|
|
223
|
-
await editCallbackMessage(ctx, new EntityText()
|
|
224
|
-
.add('✅ Terminal UI ').bold(statusText).newline(2)
|
|
225
|
-
.italic(terminalUIDescription(newState))
|
|
226
|
-
.build());
|
|
227
|
-
}
|
|
228
|
-
export async function handleTTS(ctx) {
|
|
229
|
-
const keyInfo = getSessionKeyFromCtx(ctx);
|
|
230
|
-
if (!keyInfo)
|
|
231
|
-
return;
|
|
232
|
-
const { sessionKey } = keyInfo;
|
|
233
|
-
const menu = buildTTSMenu(sessionKey, 'main');
|
|
234
|
-
await replyFormatted(ctx, menu.text, {
|
|
235
|
-
reply_markup: { inline_keyboard: menu.keyboard },
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
export async function handleTTSCallback(ctx) {
|
|
239
|
-
const keyInfo = getSessionKeyFromCtx(ctx);
|
|
240
|
-
if (!keyInfo)
|
|
241
|
-
return;
|
|
242
|
-
const { sessionKey } = keyInfo;
|
|
243
|
-
const data = ctx.callbackQuery?.data;
|
|
244
|
-
if (!data || !data.startsWith('tts:'))
|
|
245
|
-
return;
|
|
246
|
-
if (data === 'tts:on') {
|
|
247
|
-
const hasKey = config.TTS_PROVIDER === 'groq' ? !!config.GROQ_API_KEY : !!config.OPENAI_API_KEY;
|
|
248
|
-
const keyName = config.TTS_PROVIDER === 'groq' ? 'GROQ_API_KEY' : 'OPENAI_API_KEY';
|
|
249
|
-
if (!hasKey) {
|
|
250
|
-
await ctx.answerCallbackQuery({ text: `${keyName} missing. Set it in .env and restart.` });
|
|
251
|
-
setTTSEnabled(sessionKey, false);
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
setTTSEnabled(sessionKey, true);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
else if (data === 'tts:off') {
|
|
258
|
-
setTTSEnabled(sessionKey, false);
|
|
259
|
-
}
|
|
260
|
-
else if (data === 'tts:autoplay') {
|
|
261
|
-
const current = getTTSSettings(sessionKey);
|
|
262
|
-
setTTSAutoplay(sessionKey, !current.autoplay);
|
|
263
|
-
}
|
|
264
|
-
else if (data.startsWith('tts:voice:')) {
|
|
265
|
-
const voice = data.replace('tts:voice:', '');
|
|
266
|
-
const voices = getActiveTTSVoices();
|
|
267
|
-
if (voices.includes(voice)) {
|
|
268
|
-
setTTSVoice(sessionKey, voice);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
const mode = data === 'tts:voices' || data.startsWith('tts:voice:')
|
|
272
|
-
? 'voices'
|
|
273
|
-
: 'main';
|
|
274
|
-
const menu = buildTTSMenu(sessionKey, mode);
|
|
275
|
-
await ctx.answerCallbackQuery();
|
|
276
|
-
try {
|
|
277
|
-
await editCallbackMessage(ctx, menu.text, {
|
|
278
|
-
reply_markup: { inline_keyboard: menu.keyboard },
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
catch (error) {
|
|
282
|
-
// Ignore "message is not modified" — happens with duplicate callbacks
|
|
283
|
-
if (!(error instanceof Error && error.message.includes('message is not modified'))) {
|
|
284
|
-
throw error;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
export async function handleTelegraphCallback(ctx) {
|
|
289
|
-
const cb = parseCallback(ctx, 'telegraph:');
|
|
290
|
-
if (!cb)
|
|
291
|
-
return;
|
|
292
|
-
const { sessionKey, data } = cb;
|
|
293
|
-
// Don't allow enabling if global config is disabled
|
|
294
|
-
if (data === 'telegraph:on') {
|
|
295
|
-
if (!config.TELEGRAPH_ENABLED) {
|
|
296
|
-
await ctx.answerCallbackQuery({ text: 'Telegraph disabled in config. Set TELEGRAPH_ENABLED=true in .env.' });
|
|
297
|
-
setTelegraphEnabled(sessionKey, false);
|
|
298
|
-
}
|
|
299
|
-
else {
|
|
300
|
-
setTelegraphEnabled(sessionKey, true);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
else if (data === 'telegraph:off') {
|
|
304
|
-
setTelegraphEnabled(sessionKey, false);
|
|
305
|
-
}
|
|
306
|
-
const menu = buildTelegraphMenu(sessionKey);
|
|
307
|
-
await ctx.answerCallbackQuery();
|
|
308
|
-
try {
|
|
309
|
-
await editCallbackMessage(ctx, menu.text, {
|
|
310
|
-
reply_markup: { inline_keyboard: menu.keyboard },
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
catch (error) {
|
|
314
|
-
// Ignore "message is not modified" — happens with duplicate callbacks
|
|
315
|
-
if (!(error instanceof Error && error.message.includes('message is not modified'))) {
|
|
316
|
-
throw error;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
52
|
// ── /effort ──────────────────────────────────────────────────────
|
|
321
53
|
export async function handleEffort(ctx) {
|
|
322
54
|
const keyInfo = getSessionKeyFromCtx(ctx);
|
|
323
55
|
if (!keyInfo)
|
|
324
56
|
return;
|
|
325
|
-
const {
|
|
57
|
+
const { sessionKey } = keyInfo;
|
|
326
58
|
const text = ctx.message?.text || '';
|
|
327
59
|
const parsed = parseScopeArg(text.split(' ').slice(1).join(' '));
|
|
328
60
|
const args = parsed.value.toLowerCase();
|
|
329
|
-
const
|
|
61
|
+
const site = scopeSite(ctx);
|
|
330
62
|
if (!args) {
|
|
331
63
|
const currentEffort = getEffort(sessionKey) || 'default';
|
|
332
64
|
const keyboard = EFFORT_LEVELS.map((level) => {
|
|
@@ -338,68 +70,39 @@ export async function handleEffort(ctx) {
|
|
|
338
70
|
keyboard.push([{ text: currentEffort === 'default' ? '✓ Auto (default)' : 'Auto (default)', callback_data: 'effort:auto' }]);
|
|
339
71
|
const picker = new EntityText()
|
|
340
72
|
.add('🎯 ').bold('Effort Level').newline(2)
|
|
341
|
-
.italic(`Current: ${currentEffort}`).newline(2);
|
|
73
|
+
.italic(`Current: ${currentEffort === 'default' ? 'auto' : currentEffort}, ${describeSource(sessionKey, 'effort')}`).newline(2);
|
|
342
74
|
for (const l of EFFORT_LEVELS) {
|
|
343
75
|
picker.add('• ').bold(l.label).add(` - ${l.description}\n`);
|
|
344
76
|
}
|
|
345
|
-
picker.add('• ').bold('Auto').add(
|
|
346
|
-
|
|
347
|
-
// the rest. Stated here so neither scope has to be guessed at.
|
|
348
|
-
if (hasSiblings()) {
|
|
349
|
-
picker.add('\n\nApplies to ').bold(config.BOT_NAME).add(' only — add ').code('all')
|
|
350
|
-
.add(' (').code('/effort high all').add(') or use the button afterwards to set every bot.');
|
|
351
|
-
}
|
|
77
|
+
picker.add('• ').bold('Auto').add(" - Claude Code's default");
|
|
78
|
+
picker.append(levelHelp('effort', 'high', site));
|
|
352
79
|
await replyFormatted(ctx, picker.build(), {
|
|
353
80
|
reply_markup: { inline_keyboard: keyboard },
|
|
354
81
|
});
|
|
355
82
|
return;
|
|
356
83
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
await replyWithScope(ctx, sessionKey, confirmation.build(), 'effort', null, 'auto', scope);
|
|
84
|
+
// A level word on its own has no effort level attached — point at the form
|
|
85
|
+
// that works rather than rejecting it as an unknown level. `default` stays
|
|
86
|
+
// the reset it always was.
|
|
87
|
+
if (args !== 'default' && isBareLevelWord(args)) {
|
|
88
|
+
await replyMd(ctx, `\`${args}\` says how far to apply an effort level, but it needs the level too.\n\n` +
|
|
89
|
+
`Try \`/effort high ${args}\`, or /effort to pick one.`);
|
|
364
90
|
return;
|
|
365
91
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
if (args === 'all' || args === 'everywhere') {
|
|
369
|
-
await replyMd(ctx, '`all` sets every bot, but it needs a level to set them to.\n\n' +
|
|
370
|
-
'Try `/effort high all`, or /effort to pick one.');
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
if (!isValidEffortLevel(args)) {
|
|
92
|
+
const reset = args === 'auto' || args === 'default' || args === 'reset';
|
|
93
|
+
if (!reset && !isValidEffortLevel(args)) {
|
|
374
94
|
await replyFormatted(ctx, `❌ Unknown effort level "${args}".\n\nValid: low, medium, high, xhigh, max, auto`);
|
|
375
95
|
return;
|
|
376
96
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
const confirmation = new EntityText().append(prefsConfirmation('effort', info?.label || args));
|
|
381
|
-
if (restarted)
|
|
382
|
-
confirmation.append(PTY_RESTART_NOTE);
|
|
383
|
-
await replyWithScope(ctx, sessionKey, confirmation.build(), 'effort', args, args, scope);
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Send a settings confirmation, either fanning the change out to the other
|
|
387
|
-
* bots (scope 'all') or offering to. `buttonValue` is what the fan-out button
|
|
388
|
-
* carries — the same spelling the picker uses, so 'auto' rather than null.
|
|
389
|
-
*/
|
|
390
|
-
async function replyWithScope(ctx, sessionKey, confirmation, setting, value, buttonValue, scope) {
|
|
391
|
-
if (scope === 'all') {
|
|
392
|
-
const summary = await applyToAllBots({
|
|
393
|
-
chatId: parseSessionKey(sessionKey).chatId,
|
|
394
|
-
setting,
|
|
395
|
-
value,
|
|
396
|
-
provider: getActiveProviderName(sessionKey),
|
|
397
|
-
});
|
|
398
|
-
await replyFormatted(ctx, new EntityText().append(confirmation).append(summary).build());
|
|
97
|
+
const level = parsed.level ?? 'thread';
|
|
98
|
+
if (level === 'all' && !site.admin) {
|
|
99
|
+
await replyFormatted(ctx, new EntityText().add(`⛔ ${EVERYWHERE_ADMIN_ONLY}`).build());
|
|
399
100
|
return;
|
|
400
101
|
}
|
|
401
|
-
const
|
|
402
|
-
|
|
102
|
+
const value = reset ? null : args;
|
|
103
|
+
const label = reset ? 'Auto (CLI default)' : EFFORT_LEVELS.find(l => l.id === args)?.label || args;
|
|
104
|
+
const { message, keyboard } = await applyAtLevel(ctx, { sessionKey, setting: 'effort', value, label, level, site });
|
|
105
|
+
await replyFormatted(ctx, message.build(), {
|
|
403
106
|
...(keyboard ? { reply_markup: { inline_keyboard: keyboard } } : {}),
|
|
404
107
|
});
|
|
405
108
|
}
|
|
@@ -407,45 +110,31 @@ export async function handleEffortCallback(ctx) {
|
|
|
407
110
|
const keyInfo = getSessionKeyFromCtx(ctx);
|
|
408
111
|
if (!keyInfo)
|
|
409
112
|
return;
|
|
410
|
-
const {
|
|
113
|
+
const { sessionKey } = keyInfo;
|
|
411
114
|
const data = ctx.callbackQuery?.data;
|
|
412
115
|
if (!data || !data.startsWith('effort:'))
|
|
413
116
|
return;
|
|
414
|
-
const
|
|
415
|
-
if (
|
|
416
|
-
clearEffort(sessionKey);
|
|
417
|
-
const restarted = restartPtyForSettingChange(sessionKey);
|
|
418
|
-
await ctx.answerCallbackQuery({ text: 'Effort reset to auto!' });
|
|
419
|
-
const keyboard = buildApplyToAllKeyboard('effort', 'auto');
|
|
420
|
-
const confirmation = new EntityText().append(effortResetConfirmation());
|
|
421
|
-
if (restarted)
|
|
422
|
-
confirmation.append(PTY_RESTART_NOTE);
|
|
423
|
-
await editCallbackMessage(ctx, confirmation.build(), {
|
|
424
|
-
...(keyboard ? { reply_markup: { inline_keyboard: keyboard } } : {}),
|
|
425
|
-
});
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
if (!isValidEffortLevel(level)) {
|
|
117
|
+
const choice = data.replace('effort:', '');
|
|
118
|
+
if (choice !== 'auto' && !isValidEffortLevel(choice)) {
|
|
429
119
|
await ctx.answerCallbackQuery({ text: 'Invalid effort level' });
|
|
430
120
|
return;
|
|
431
121
|
}
|
|
432
|
-
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
const
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
confirmation.append(PTY_RESTART_NOTE);
|
|
441
|
-
await editCallbackMessage(ctx, confirmation.build(), {
|
|
122
|
+
const value = choice === 'auto' ? null : choice;
|
|
123
|
+
const label = value === null ? 'Auto (CLI default)' : EFFORT_LEVELS.find(l => l.id === value)?.label || value;
|
|
124
|
+
await ctx.answerCallbackQuery({ text: value === null ? 'Effort reset to auto!' : `Effort set to ${label}!` });
|
|
125
|
+
const site = scopeSite(ctx);
|
|
126
|
+
const { message, keyboard } = await applyAtLevel(ctx, {
|
|
127
|
+
sessionKey, setting: 'effort', value, label, level: 'thread', site,
|
|
128
|
+
});
|
|
129
|
+
await editCallbackMessage(ctx, message.build(), {
|
|
442
130
|
...(keyboard ? { reply_markup: { inline_keyboard: keyboard } } : {}),
|
|
443
131
|
});
|
|
444
132
|
}
|
|
445
|
-
// ── /
|
|
133
|
+
// ── /footer ─────────────────────────────────────────────────
|
|
446
134
|
// A small italic message sent after each turn so the user can always see
|
|
447
|
-
// the current
|
|
448
|
-
//
|
|
135
|
+
// the current state right above the compose box without scrolling. On by
|
|
136
|
+
// default (STATUS_LINE_DEFAULT); /footer turns it off per chat. It
|
|
137
|
+
// follows the reply, which already rang the phone, so it's sent silently.
|
|
449
138
|
function shortenModelName(model) {
|
|
450
139
|
// Strip "vendor/" prefix (OpenRouter / CCR style: "anthropic/claude-4-sonnet-...")
|
|
451
140
|
const slashIdx = model.lastIndexOf('/');
|
|
@@ -504,7 +193,7 @@ function usageFooter(chatId, usage) {
|
|
|
504
193
|
const used = contextTokens(usage);
|
|
505
194
|
const pct = usage.contextWindow > 0 ? Math.round((used / usage.contextWindow) * 100) : 0;
|
|
506
195
|
const bar = getProgressBar(pct, contextHealthColor(used, usage.contextWindow));
|
|
507
|
-
return `${bar} ${pct}% context · ${fmtTokens(used)}/${fmtTokens(usage.contextWindow)} ·
|
|
196
|
+
return `${bar} ${pct}% context · ${fmtTokens(used)}/${fmtTokens(usage.contextWindow)} · ${usage.numTurns} turns`;
|
|
508
197
|
}
|
|
509
198
|
/**
|
|
510
199
|
* Build the status-line message body.
|
|
@@ -545,14 +234,17 @@ function buildStatusLine(chatId, sessionKey, usage, lastPrompt, brief = false) {
|
|
|
545
234
|
const project = sessionKey ? sessionManager.getSession(sessionKey)?.workingDirectory : undefined;
|
|
546
235
|
if (project)
|
|
547
236
|
stats.push(`📁 ${path.basename(project) || project}`);
|
|
548
|
-
|
|
237
|
+
// The chat's own /effort pick, else the effort the log says the reply ran
|
|
238
|
+
// at; "Auto" only while neither is known.
|
|
239
|
+
const label = getEffortLabel(sessionKey ?? chatId)
|
|
240
|
+
?? (usage?.effort ? effortLevelLabel(usage.effort) : undefined);
|
|
549
241
|
stats.push(label || '🧠 Auto');
|
|
550
242
|
const footer = usageFooter(chatId, usage);
|
|
551
243
|
const provider = getActiveProviderName(sessionKey ?? chatId);
|
|
552
244
|
if (usage) {
|
|
553
245
|
if (usage.model) {
|
|
554
246
|
const shortened = shortenModelName(usage.model);
|
|
555
|
-
// The
|
|
247
|
+
// The alias doesn't reflect CCR's actual backend; tag accordingly.
|
|
556
248
|
// A premium model swaps the robot for a badge, so it stands out of the
|
|
557
249
|
// row rather than reading as one more stat.
|
|
558
250
|
if (provider === 'ccr')
|
|
@@ -562,24 +254,21 @@ function buildStatusLine(chatId, sessionKey, usage, lastPrompt, brief = false) {
|
|
|
562
254
|
else
|
|
563
255
|
stats.push(`🤖 ${shortened}`);
|
|
564
256
|
}
|
|
565
|
-
// The footer gives
|
|
566
|
-
if (!footer) {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
stats.push(`${health === '🟢' ? '📊' : health} ${pct}%`);
|
|
574
|
-
}
|
|
575
|
-
stats.push(`💰 $${usage.totalCostUsd.toFixed(2)}`);
|
|
257
|
+
// The footer gives this right below, in more detail.
|
|
258
|
+
if (!footer && usage.contextWindow > 0) {
|
|
259
|
+
const used = contextTokens(usage);
|
|
260
|
+
const pct = Math.round((used / usage.contextWindow) * 100);
|
|
261
|
+
// The chart while it's healthy; amber or red once it's grown big
|
|
262
|
+
// enough that a /clear or branch is worth thinking about.
|
|
263
|
+
const health = contextHealthColor(used, usage.contextWindow);
|
|
264
|
+
stats.push(`${health === '🟢' ? '📊' : health} ${pct}%`);
|
|
576
265
|
}
|
|
577
266
|
}
|
|
578
267
|
// Activity counters — only rendered when non-zero so quiet turns stay quiet.
|
|
579
|
-
// Tasks/monitors come from the
|
|
580
|
-
//
|
|
268
|
+
// Tasks/monitors come from the task tracker; bg shells from the pty's
|
|
269
|
+
// /proc children, so that count is left out when no pty is live.
|
|
581
270
|
if (sessionKey) {
|
|
582
|
-
const bg = taskTracker.
|
|
271
|
+
const bg = taskTracker.getTasks(sessionKey);
|
|
583
272
|
const monitorCount = bg.filter((t) => t.taskType === 'monitor_mcp').length;
|
|
584
273
|
const taskCount = bg.length - monitorCount;
|
|
585
274
|
if (taskCount > 0)
|
|
@@ -601,7 +290,7 @@ function buildStatusLine(chatId, sessionKey, usage, lastPrompt, brief = false) {
|
|
|
601
290
|
}
|
|
602
291
|
/**
|
|
603
292
|
* The message that closes a turn: the status line, with the usage footer at its
|
|
604
|
-
* bottom when the chat shows both. /
|
|
293
|
+
* bottom when the chat shows both. /footer and /verbosity set them apart,
|
|
605
294
|
* so with the status line off, a chat that shows the footer gets it on its own.
|
|
606
295
|
*
|
|
607
296
|
* `lastPrompt` is the turn's own, for a session whose log has no prompts to
|
|
@@ -610,12 +299,14 @@ function buildStatusLine(chatId, sessionKey, usage, lastPrompt, brief = false) {
|
|
|
610
299
|
export async function sendStatusLine(ctx, chatId, sessionKey, usage, lastPrompt, { brief = false } = {}) {
|
|
611
300
|
try {
|
|
612
301
|
if (userPreferences.getShowStatusLine(chatId)) {
|
|
613
|
-
await replyFormatted(ctx, buildStatusLine(chatId, sessionKey, usage, lastPrompt, brief)
|
|
302
|
+
await replyFormatted(ctx, buildStatusLine(chatId, sessionKey, usage, lastPrompt, brief), {
|
|
303
|
+
disable_notification: true,
|
|
304
|
+
});
|
|
614
305
|
return;
|
|
615
306
|
}
|
|
616
307
|
const footer = usageFooter(chatId, usage);
|
|
617
308
|
if (footer)
|
|
618
|
-
await ctx.reply(footer);
|
|
309
|
+
await ctx.reply(footer, { disable_notification: true });
|
|
619
310
|
}
|
|
620
311
|
catch (err) {
|
|
621
312
|
console.debug('[StatusLine] Failed to send:', err instanceof Error ? err.message : err);
|
|
@@ -628,27 +319,27 @@ function buildStatusLineMenu(chatId, sessionKey) {
|
|
|
628
319
|
const showPrompt = userPreferences.getShowPromptInStatusLine(chatId);
|
|
629
320
|
const keyboard = [
|
|
630
321
|
[
|
|
631
|
-
{ text: enabled ? '✓
|
|
632
|
-
{ text: !enabled ? '✓
|
|
322
|
+
{ text: enabled ? '✓ Footer: On' : 'Footer: On', callback_data: 'footer:on' },
|
|
323
|
+
{ text: !enabled ? '✓ Footer: Off' : 'Footer: Off', callback_data: 'footer:off' },
|
|
633
324
|
],
|
|
634
325
|
[
|
|
635
|
-
{ text: showTopic ? '✓ Show topic: On' : 'Show topic: On', callback_data: '
|
|
636
|
-
{ text: !showTopic ? '✓ Show topic: Off' : 'Show topic: Off', callback_data: '
|
|
326
|
+
{ text: showTopic ? '✓ Show topic: On' : 'Show topic: On', callback_data: 'footer:topic:on' },
|
|
327
|
+
{ text: !showTopic ? '✓ Show topic: Off' : 'Show topic: Off', callback_data: 'footer:topic:off' },
|
|
637
328
|
],
|
|
638
329
|
[
|
|
639
|
-
{ text: showPrompt ? '✓ Show last prompts: On' : 'Show last prompts: On', callback_data: '
|
|
640
|
-
{ text: !showPrompt ? '✓ Show last prompts: Off' : 'Show last prompts: Off', callback_data: '
|
|
330
|
+
{ text: showPrompt ? '✓ Show last prompts: On' : 'Show last prompts: On', callback_data: 'footer:prompt:on' },
|
|
331
|
+
{ text: !showPrompt ? '✓ Show last prompts: Off' : 'Show last prompts: Off', callback_data: 'footer:prompt:off' },
|
|
641
332
|
],
|
|
642
333
|
[
|
|
643
|
-
{ text: showSession ? '✓ Show session: On' : 'Show session: On', callback_data: '
|
|
644
|
-
{ text: !showSession ? '✓ Show session: Off' : 'Show session: Off', callback_data: '
|
|
334
|
+
{ text: showSession ? '✓ Show session: On' : 'Show session: On', callback_data: 'footer:session:on' },
|
|
335
|
+
{ text: !showSession ? '✓ Show session: Off' : 'Show session: Off', callback_data: 'footer:session:off' },
|
|
645
336
|
],
|
|
646
337
|
];
|
|
647
338
|
const preview = buildStatusLine(chatId, sessionKey, undefined, 'example prompt for preview');
|
|
648
339
|
const onOff = (on) => (on ? 'ON' : 'OFF');
|
|
649
340
|
const text = new EntityText()
|
|
650
|
-
.add('📍 ').bold('
|
|
651
|
-
.add('
|
|
341
|
+
.add('📍 ').bold('Footer').newline(2)
|
|
342
|
+
.add('Footer: ').bold(onOff(enabled)).newline()
|
|
652
343
|
.add('Show topic: ').bold(onOff(showTopic)).newline()
|
|
653
344
|
.add('Show last prompts: ').bold(onOff(showPrompt)).newline()
|
|
654
345
|
.add('Show session: ').bold(onOff(showSession)).newline(2)
|
|
@@ -666,7 +357,7 @@ function buildStatusLineMenu(chatId, sessionKey) {
|
|
|
666
357
|
.build();
|
|
667
358
|
return { text, keyboard };
|
|
668
359
|
}
|
|
669
|
-
export async function
|
|
360
|
+
export async function handleFooter(ctx) {
|
|
670
361
|
const keyInfo = getSessionKeyFromCtx(ctx);
|
|
671
362
|
if (!keyInfo)
|
|
672
363
|
return;
|
|
@@ -676,15 +367,15 @@ export async function handleStatusLine(ctx) {
|
|
|
676
367
|
reply_markup: { inline_keyboard: menu.keyboard },
|
|
677
368
|
});
|
|
678
369
|
}
|
|
679
|
-
export async function
|
|
370
|
+
export async function handleFooterCallback(ctx) {
|
|
680
371
|
const keyInfo = getSessionKeyFromCtx(ctx);
|
|
681
372
|
if (!keyInfo)
|
|
682
373
|
return;
|
|
683
374
|
const { chatId, sessionKey } = keyInfo;
|
|
684
375
|
const data = ctx.callbackQuery?.data;
|
|
685
|
-
if (!data || !data.startsWith('
|
|
376
|
+
if (!data || !data.startsWith('footer:'))
|
|
686
377
|
return;
|
|
687
|
-
const action = data.replace('
|
|
378
|
+
const action = data.replace('footer:', '');
|
|
688
379
|
let toastText;
|
|
689
380
|
if (action === 'topic:on' || action === 'topic:off') {
|
|
690
381
|
const newState = action === 'topic:on';
|
|
@@ -704,7 +395,7 @@ export async function handleStatusLineCallback(ctx) {
|
|
|
704
395
|
else if (action === 'on' || action === 'off') {
|
|
705
396
|
const newState = action === 'on';
|
|
706
397
|
userPreferences.setShowStatusLine(chatId, newState);
|
|
707
|
-
toastText = `
|
|
398
|
+
toastText = `Footer ${newState ? 'ON' : 'OFF'}`;
|
|
708
399
|
}
|
|
709
400
|
else {
|
|
710
401
|
return;
|
|
@@ -719,7 +410,7 @@ export async function handleStatusLineCallback(ctx) {
|
|
|
719
410
|
// Pick a verbosity tier (quiet | normal | verbose | debug) for this chat.
|
|
720
411
|
// The tier sets defaults for rendering flags (usage footer, compaction
|
|
721
412
|
// notice, completion ping, untruncated tool inputs). Explicit env vars
|
|
722
|
-
// (CONTEXT_SHOW_USAGE, CONTEXT_NOTIFY_COMPACTION,
|
|
413
|
+
// (CONTEXT_SHOW_USAGE, CONTEXT_NOTIFY_COMPACTION, FULL_TOOL_INPUTS)
|
|
723
414
|
// still win over the tier. "Default" clears the chat-specific pref so the
|
|
724
415
|
// env-level VERBOSITY_DEFAULT applies.
|
|
725
416
|
function buildVerbosityMenu(chatId) {
|
|
@@ -808,48 +499,6 @@ export async function handleVerbosityCallback(ctx) {
|
|
|
808
499
|
await ctx.answerCallbackQuery({ text: `Verbosity: ${info?.label ?? level}` });
|
|
809
500
|
await editCallbackMessage(ctx, verbositySetText(level));
|
|
810
501
|
}
|
|
811
|
-
export async function handleMethodCommand(ctx) {
|
|
812
|
-
const keyInfo = getSessionKeyFromCtx(ctx);
|
|
813
|
-
if (!keyInfo)
|
|
814
|
-
return;
|
|
815
|
-
const { sessionKey } = keyInfo;
|
|
816
|
-
const descriptions = {
|
|
817
|
-
sdk: "Use Claude Code SDK (default, recommended)",
|
|
818
|
-
pty: "Use interactive PTY session (experimental, for Max subscription)",
|
|
819
|
-
};
|
|
820
|
-
const currentMethod = userPreferences.getMethod(sessionKey) ?? 'sdk';
|
|
821
|
-
const availableMethods = ['sdk', 'pty'];
|
|
822
|
-
const keyboard = availableMethods.map((method) => {
|
|
823
|
-
const label = method === currentMethod ? `✓ ${method}` : method;
|
|
824
|
-
return [{ text: label, callback_data: `method:${method}` }];
|
|
825
|
-
});
|
|
826
|
-
const descriptionText = new EntityText();
|
|
827
|
-
Object.entries(descriptions).forEach(([key, value], i) => {
|
|
828
|
-
if (i > 0)
|
|
829
|
-
descriptionText.newline();
|
|
830
|
-
descriptionText.bold(key).add(`: ${value}`);
|
|
831
|
-
});
|
|
832
|
-
await replyFormatted(ctx, descriptionText.build(), {
|
|
833
|
-
reply_markup: {
|
|
834
|
-
inline_keyboard: keyboard,
|
|
835
|
-
},
|
|
836
|
-
});
|
|
837
|
-
}
|
|
838
|
-
export async function handleMethodCallback(ctx) {
|
|
839
|
-
const keyInfo = getSessionKeyFromCtx(ctx);
|
|
840
|
-
if (!keyInfo)
|
|
841
|
-
return;
|
|
842
|
-
const { sessionKey } = keyInfo;
|
|
843
|
-
const data = ctx.callbackQuery?.data;
|
|
844
|
-
if (!data || !data.startsWith('method:'))
|
|
845
|
-
return;
|
|
846
|
-
const newMethod = data.replace('method:', '');
|
|
847
|
-
if (newMethod === 'sdk' || newMethod === 'pty') {
|
|
848
|
-
userPreferences.setMethod(sessionKey, newMethod);
|
|
849
|
-
}
|
|
850
|
-
await ctx.answerCallbackQuery();
|
|
851
|
-
await editCallbackMessage(ctx, new EntityText().add('✅ Method set to ').bold(newMethod).build());
|
|
852
|
-
}
|
|
853
502
|
export async function handleSuggestions(ctx) {
|
|
854
503
|
const keyInfo = getSessionKeyFromCtx(ctx);
|
|
855
504
|
if (!keyInfo)
|
|
@@ -891,29 +540,25 @@ export async function handleSuggestionsCallback(ctx) {
|
|
|
891
540
|
* `/mode` — how much claude asks before acting, per chat.
|
|
892
541
|
*
|
|
893
542
|
* The callback prefix is `permmode:` rather than the obvious `mode:`, which
|
|
894
|
-
*
|
|
895
|
-
* keyboard from that older menu can be sitting in someone's chat
|
|
896
|
-
*
|
|
543
|
+
* belonged to the streaming/wait toggle this command took its name from. A
|
|
544
|
+
* keyboard from that older menu can still be sitting in someone's chat, and
|
|
545
|
+
* its buttons carry `mode:streaming`.
|
|
897
546
|
*/
|
|
898
547
|
/**
|
|
899
548
|
* What "Default" actually resolves to for this chat, and why.
|
|
900
549
|
*
|
|
901
550
|
* The menu used to call it "what this bot has always used" — true, and no help
|
|
902
551
|
* at all to someone deciding whether to leave it there. Which mode that is
|
|
903
|
-
* depends on the chat's transport,
|
|
904
|
-
*
|
|
905
|
-
*
|
|
552
|
+
* depends on the chat's transport, so the row names the mode and the reason
|
|
553
|
+
* rather than making a person read two files to find out what they already
|
|
554
|
+
* picked.
|
|
906
555
|
*/
|
|
907
|
-
function describeTransportDefault(
|
|
908
|
-
|
|
909
|
-
const label = permissionModeInfo(transportDefaultMode(method, config.DANGEROUS_MODE)).label;
|
|
910
|
-
if (method === 'pty')
|
|
911
|
-
return { label, why: "Claude Code's own default" };
|
|
912
|
-
return { label, why: config.DANGEROUS_MODE ? 'SDK, DANGEROUS_MODE=true' : 'the SDK default' };
|
|
556
|
+
function describeTransportDefault() {
|
|
557
|
+
return { label: permissionModeInfo(defaultPermissionMode()).label, why: "Claude Code's own default" };
|
|
913
558
|
}
|
|
914
559
|
function buildPermissionModeMenu(scope) {
|
|
915
560
|
const current = userPreferences.getPermissionMode(scope);
|
|
916
|
-
const fallback = describeTransportDefault(
|
|
561
|
+
const fallback = describeTransportDefault();
|
|
917
562
|
const keyboard = PERMISSION_MODES.map((info) => [{
|
|
918
563
|
text: info.id === current ? `✓ ${info.label}` : info.label,
|
|
919
564
|
callback_data: `permmode:${info.id}`,
|
|
@@ -951,7 +596,7 @@ function permissionModeSetText(id) {
|
|
|
951
596
|
}
|
|
952
597
|
/** Same, for the reset — which names the mode it reset *to*, not just "default". */
|
|
953
598
|
function permissionModeResetText(scope) {
|
|
954
|
-
const { label, why } = describeTransportDefault(
|
|
599
|
+
const { label, why } = describeTransportDefault();
|
|
955
600
|
return new EntityText()
|
|
956
601
|
.add('✅ Permission mode reset to the transport default: ').bold(label).newline(2)
|
|
957
602
|
.italic(why)
|
|
@@ -998,7 +643,7 @@ export async function handlePermissionModeCallback(ctx) {
|
|
|
998
643
|
const choice = data.replace('permmode:', '');
|
|
999
644
|
if (choice === 'default') {
|
|
1000
645
|
userPreferences.clearPermissionMode(sessionKey);
|
|
1001
|
-
const { label } = describeTransportDefault(
|
|
646
|
+
const { label } = describeTransportDefault();
|
|
1002
647
|
await ctx.answerCallbackQuery({ text: `Default: ${label}` });
|
|
1003
648
|
await editCallbackMessage(ctx, permissionModeResetText(sessionKey));
|
|
1004
649
|
return;
|