@grinev/opencode-telegram-bot 0.11.0 → 0.11.1
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/README.md +3 -1
- package/dist/app/start-bot-app.js +3 -0
- package/dist/bot/commands/status.js +1 -2
- package/dist/bot/index.js +3 -3
- package/dist/config.js +1 -1
- package/dist/i18n/de.js +8 -6
- package/dist/i18n/en.js +8 -6
- package/dist/i18n/es.js +8 -6
- package/dist/i18n/ru.js +15 -13
- package/dist/i18n/zh.js +8 -6
- package/dist/runtime/bootstrap.js +26 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,6 +35,8 @@ Languages: English (`en`), Deutsch (`de`), Español (`es`), Русский (`ru`
|
|
|
35
35
|
- **Security** — strict user ID whitelist; no one else can access your bot, even if they find it
|
|
36
36
|
- **Localization** — UI localization is supported for multiple languages (`BOT_LOCALE`)
|
|
37
37
|
|
|
38
|
+
Planned features currently in development are listed in [Current Task List](PRODUCT.md#current-task-list).
|
|
39
|
+
|
|
38
40
|
## Prerequisites
|
|
39
41
|
|
|
40
42
|
- **Node.js 20+** — [download](https://nodejs.org)
|
|
@@ -71,7 +73,7 @@ npx @grinev/opencode-telegram-bot
|
|
|
71
73
|
|
|
72
74
|
> Quick start is for npm usage. You do not need to clone this repository. If you run this command from the source directory (repository root), it may fail with `opencode-telegram: not found`. To run from sources, use the [Development](#development) section.
|
|
73
75
|
|
|
74
|
-
On first launch, an interactive wizard will guide you through the configuration — it asks for interface language first, then your bot token, user ID, and OpenCode
|
|
76
|
+
On first launch, an interactive wizard will guide you through the configuration — it asks for interface language first, then your bot token, user ID, OpenCode API URL, and optional OpenCode server credentials (username/password). After that, you're ready to go. Open your bot in Telegram and start sending tasks.
|
|
75
77
|
|
|
76
78
|
#### Alternative: Global Install
|
|
77
79
|
|
|
@@ -5,6 +5,7 @@ import { loadSettings } from "../settings/manager.js";
|
|
|
5
5
|
import { processManager } from "../process/manager.js";
|
|
6
6
|
import { warmupSessionDirectoryCache } from "../session/cache-manager.js";
|
|
7
7
|
import { getRuntimeMode } from "../runtime/mode.js";
|
|
8
|
+
import { getRuntimePaths } from "../runtime/paths.js";
|
|
8
9
|
import { logger } from "../utils/logger.js";
|
|
9
10
|
async function getBotVersion() {
|
|
10
11
|
try {
|
|
@@ -20,8 +21,10 @@ async function getBotVersion() {
|
|
|
20
21
|
}
|
|
21
22
|
export async function startBotApp() {
|
|
22
23
|
const mode = getRuntimeMode();
|
|
24
|
+
const runtimePaths = getRuntimePaths();
|
|
23
25
|
const version = await getBotVersion();
|
|
24
26
|
logger.info(`Starting OpenCode Telegram Bot v${version}...`);
|
|
27
|
+
logger.info(`Config loaded from ${runtimePaths.envFilePath}`);
|
|
25
28
|
logger.info(`Allowed User ID: ${config.telegram.allowedUserId}`);
|
|
26
29
|
logger.debug(`[Runtime] Application start mode: ${mode}`);
|
|
27
30
|
await loadSettings();
|
|
@@ -4,7 +4,6 @@ import { getCurrentProject } from "../../settings/manager.js";
|
|
|
4
4
|
import { fetchCurrentAgent } from "../../agent/manager.js";
|
|
5
5
|
import { getAgentDisplayName } from "../../agent/types.js";
|
|
6
6
|
import { fetchCurrentModel } from "../../model/manager.js";
|
|
7
|
-
import { formatModelForDisplay } from "../../model/types.js";
|
|
8
7
|
import { processManager } from "../../process/manager.js";
|
|
9
8
|
import { keyboardManager } from "../../keyboard/manager.js";
|
|
10
9
|
import { pinnedMessageManager } from "../../pinned/manager.js";
|
|
@@ -42,7 +41,7 @@ export async function statusCommand(ctx) {
|
|
|
42
41
|
message += `${t("status.line.mode", { mode: agentDisplay })}\n`;
|
|
43
42
|
// Add model information
|
|
44
43
|
const currentModel = fetchCurrentModel();
|
|
45
|
-
const modelDisplay =
|
|
44
|
+
const modelDisplay = `🤖 ${currentModel.providerID}/${currentModel.modelID}`;
|
|
46
45
|
message += `${t("status.line.model", { model: modelDisplay })}\n`;
|
|
47
46
|
const currentProject = getCurrentProject();
|
|
48
47
|
if (currentProject) {
|
package/dist/bot/index.js
CHANGED
|
@@ -122,7 +122,7 @@ async function ensureCommandsInitialized(ctx, next) {
|
|
|
122
122
|
},
|
|
123
123
|
});
|
|
124
124
|
commandsInitialized = true;
|
|
125
|
-
logger.
|
|
125
|
+
logger.debug(`[Bot] Commands initialized for authorized user (chat_id=${ctx.chat.id})`);
|
|
126
126
|
}
|
|
127
127
|
catch (err) {
|
|
128
128
|
logger.error("[Bot] Failed to set commands:", err);
|
|
@@ -385,7 +385,7 @@ async function ensureEventSubscription(directory) {
|
|
|
385
385
|
export function createBot() {
|
|
386
386
|
clearAllInteractionState("bot_startup");
|
|
387
387
|
toolMessageBatcher.setIntervalSeconds(config.bot.serviceMessagesIntervalSec);
|
|
388
|
-
logger.
|
|
388
|
+
logger.debug(`[ToolBatcher] Service messages interval: ${config.bot.serviceMessagesIntervalSec}s`);
|
|
389
389
|
const botOptions = {};
|
|
390
390
|
if (config.telegram.proxyUrl) {
|
|
391
391
|
const proxyUrl = config.telegram.proxyUrl;
|
|
@@ -584,7 +584,7 @@ export function createBot() {
|
|
|
584
584
|
},
|
|
585
585
|
onSuccess: (result) => {
|
|
586
586
|
if (result.success) {
|
|
587
|
-
logger.
|
|
587
|
+
logger.debug("[Bot] Cleared global commands (default and all_private_chats scopes)");
|
|
588
588
|
return;
|
|
589
589
|
}
|
|
590
590
|
logger.warn("[Bot] Could not clear global commands:", result.error);
|
package/dist/config.js
CHANGED
|
@@ -2,7 +2,7 @@ import dotenv from "dotenv";
|
|
|
2
2
|
import { getRuntimePaths } from "./runtime/paths.js";
|
|
3
3
|
import { normalizeLocale } from "./i18n/index.js";
|
|
4
4
|
const runtimePaths = getRuntimePaths();
|
|
5
|
-
dotenv.config({ path: runtimePaths.envFilePath });
|
|
5
|
+
dotenv.config({ path: runtimePaths.envFilePath, quiet: true });
|
|
6
6
|
function getEnvVar(key, required = true) {
|
|
7
7
|
const value = process.env[key];
|
|
8
8
|
if (required && !value) {
|
package/dist/i18n/de.js
CHANGED
|
@@ -59,18 +59,18 @@ export const de = {
|
|
|
59
59
|
"status.health.unhealthy": "Nicht OK",
|
|
60
60
|
"status.line.health": "Status: {health}",
|
|
61
61
|
"status.line.version": "Version: {version}",
|
|
62
|
-
"status.line.managed_yes": "Vom Bot
|
|
63
|
-
"status.line.managed_no": "Vom Bot
|
|
62
|
+
"status.line.managed_yes": "Vom Bot gestartet: Ja",
|
|
63
|
+
"status.line.managed_no": "Vom Bot gestartet: Nein",
|
|
64
64
|
"status.line.pid": "PID: {pid}",
|
|
65
65
|
"status.line.uptime_sec": "Betriebszeit: {seconds} s",
|
|
66
66
|
"status.line.mode": "Modus: {mode}",
|
|
67
67
|
"status.line.model": "Modell: {model}",
|
|
68
68
|
"status.agent_not_set": "nicht gesetzt",
|
|
69
|
-
"status.project_selected": "
|
|
70
|
-
"status.project_not_selected": "
|
|
69
|
+
"status.project_selected": "Projekt: {project}",
|
|
70
|
+
"status.project_not_selected": "Projekt: nicht ausgewählt",
|
|
71
71
|
"status.project_hint": "Nutze /projects, um ein Projekt auszuwahlen",
|
|
72
|
-
"status.session_selected": "
|
|
73
|
-
"status.session_not_selected": "
|
|
72
|
+
"status.session_selected": "Aktuelle Sitzung: {title}",
|
|
73
|
+
"status.session_not_selected": "Aktuelle Sitzung: nicht ausgewählt",
|
|
74
74
|
"status.session_hint": "Nutze /sessions zur Auswahl oder /new zum Erstellen",
|
|
75
75
|
"status.server_unavailable": "🔴 OpenCode-Server ist nicht verfügbar\n\nNutze /opencode_start, um den Server zu starten.",
|
|
76
76
|
"projects.empty": "📭 Keine Projekte gefunden.\n\nÖffne ein Verzeichnis in OpenCode und erstelle mindestens eine Sitzung, dann erscheint es hier.",
|
|
@@ -228,6 +228,8 @@ export const de = {
|
|
|
228
228
|
"runtime.wizard.ask_user_id": "Gib deine Telegram User ID ein (du bekommst sie bei @userinfobot).\n> ",
|
|
229
229
|
"runtime.wizard.user_id_invalid": "Gib eine positive ganze Zahl ein (> 0).\n",
|
|
230
230
|
"runtime.wizard.ask_api_url": "OpenCode API URL eingeben (optional).\nEnter drücken für Standard: {defaultUrl}\n> ",
|
|
231
|
+
"runtime.wizard.ask_server_username": "OpenCode-Server-Benutzername eingeben (optional).\nEnter drücken für Standard: {defaultUsername}\n> ",
|
|
232
|
+
"runtime.wizard.ask_server_password": "OpenCode-Server-Passwort eingeben (optional).\nEnter drücken, um es leer zu lassen.\n> ",
|
|
231
233
|
"runtime.wizard.api_url_invalid": "Gib eine gültige URL (http/https) ein oder drücke Enter für Standard.\n",
|
|
232
234
|
"runtime.wizard.start": "OpenCode Telegram Bot Einrichtung.\n",
|
|
233
235
|
"runtime.wizard.saved": "Konfiguration gespeichert:\n- {envPath}\n- {settingsPath}\n",
|
package/dist/i18n/en.js
CHANGED
|
@@ -59,18 +59,18 @@ export const en = {
|
|
|
59
59
|
"status.health.unhealthy": "Unhealthy",
|
|
60
60
|
"status.line.health": "Status: {health}",
|
|
61
61
|
"status.line.version": "Version: {version}",
|
|
62
|
-
"status.line.managed_yes": "
|
|
63
|
-
"status.line.managed_no": "
|
|
62
|
+
"status.line.managed_yes": "Started by bot: Yes",
|
|
63
|
+
"status.line.managed_no": "Started by bot: No",
|
|
64
64
|
"status.line.pid": "PID: {pid}",
|
|
65
65
|
"status.line.uptime_sec": "Uptime: {seconds} sec",
|
|
66
66
|
"status.line.mode": "Mode: {mode}",
|
|
67
67
|
"status.line.model": "Model: {model}",
|
|
68
68
|
"status.agent_not_set": "not set",
|
|
69
|
-
"status.project_selected": "
|
|
70
|
-
"status.project_not_selected": "
|
|
69
|
+
"status.project_selected": "Project: {project}",
|
|
70
|
+
"status.project_not_selected": "Project: not selected",
|
|
71
71
|
"status.project_hint": "Use /projects to select a project",
|
|
72
|
-
"status.session_selected": "
|
|
73
|
-
"status.session_not_selected": "
|
|
72
|
+
"status.session_selected": "Current session: {title}",
|
|
73
|
+
"status.session_not_selected": "Current session: not selected",
|
|
74
74
|
"status.session_hint": "Use /sessions to select one or /new to create one",
|
|
75
75
|
"status.server_unavailable": "🔴 OpenCode Server is unavailable\n\nUse /opencode_start to start the server.",
|
|
76
76
|
"projects.empty": "📭 No projects found.\n\nOpen a directory in OpenCode and create at least one session, then it will appear here.",
|
|
@@ -228,6 +228,8 @@ export const en = {
|
|
|
228
228
|
"runtime.wizard.ask_user_id": "Enter your Telegram User ID (you can get it from @userinfobot).\n> ",
|
|
229
229
|
"runtime.wizard.user_id_invalid": "Enter a positive integer (> 0).\n",
|
|
230
230
|
"runtime.wizard.ask_api_url": "Enter OpenCode API URL (optional).\nPress Enter to use default: {defaultUrl}\n> ",
|
|
231
|
+
"runtime.wizard.ask_server_username": "Enter OpenCode server username (optional).\nPress Enter to use default: {defaultUsername}\n> ",
|
|
232
|
+
"runtime.wizard.ask_server_password": "Enter OpenCode server password (optional).\nPress Enter to keep it empty.\n> ",
|
|
231
233
|
"runtime.wizard.api_url_invalid": "Enter a valid URL (http/https) or press Enter for default.\n",
|
|
232
234
|
"runtime.wizard.start": "OpenCode Telegram Bot setup.\n",
|
|
233
235
|
"runtime.wizard.saved": "Configuration saved:\n- {envPath}\n- {settingsPath}\n",
|
package/dist/i18n/es.js
CHANGED
|
@@ -59,18 +59,18 @@ export const es = {
|
|
|
59
59
|
"status.health.unhealthy": "No saludable",
|
|
60
60
|
"status.line.health": "Estado: {health}",
|
|
61
61
|
"status.line.version": "Versión: {version}",
|
|
62
|
-
"status.line.managed_yes": "
|
|
63
|
-
"status.line.managed_no": "
|
|
62
|
+
"status.line.managed_yes": "Iniciado por el bot: Sí",
|
|
63
|
+
"status.line.managed_no": "Iniciado por el bot: No",
|
|
64
64
|
"status.line.pid": "PID: {pid}",
|
|
65
65
|
"status.line.uptime_sec": "Tiempo activo: {seconds} s",
|
|
66
66
|
"status.line.mode": "Modo: {mode}",
|
|
67
67
|
"status.line.model": "Modelo: {model}",
|
|
68
68
|
"status.agent_not_set": "no configurado",
|
|
69
|
-
"status.project_selected": "
|
|
70
|
-
"status.project_not_selected": "
|
|
69
|
+
"status.project_selected": "Proyecto: {project}",
|
|
70
|
+
"status.project_not_selected": "Proyecto: no seleccionado",
|
|
71
71
|
"status.project_hint": "Usa /projects para seleccionar un proyecto",
|
|
72
|
-
"status.session_selected": "
|
|
73
|
-
"status.session_not_selected": "
|
|
72
|
+
"status.session_selected": "Sesión actual: {title}",
|
|
73
|
+
"status.session_not_selected": "Sesión actual: no seleccionada",
|
|
74
74
|
"status.session_hint": "Usa /sessions para elegir una o /new para crear una",
|
|
75
75
|
"status.server_unavailable": "🔴 OpenCode Server no está disponible\n\nUsa /opencode_start para iniciar el servidor.",
|
|
76
76
|
"projects.empty": "📭 No se encontraron proyectos.\n\nAbre un directorio en OpenCode y crea al menos una sesión; entonces aparecerá aquí.",
|
|
@@ -228,6 +228,8 @@ export const es = {
|
|
|
228
228
|
"runtime.wizard.ask_user_id": "Introduce tu Telegram User ID (puedes obtenerlo de @userinfobot).\n> ",
|
|
229
229
|
"runtime.wizard.user_id_invalid": "Introduce un entero positivo (> 0).\n",
|
|
230
230
|
"runtime.wizard.ask_api_url": "Introduce la URL de la API de OpenCode (opcional).\nPulsa Enter para usar el valor por defecto: {defaultUrl}\n> ",
|
|
231
|
+
"runtime.wizard.ask_server_username": "Introduce el nombre de usuario del servidor OpenCode (opcional).\nPulsa Enter para usar el valor por defecto: {defaultUsername}\n> ",
|
|
232
|
+
"runtime.wizard.ask_server_password": "Introduce la contrasena del servidor OpenCode (opcional).\nPulsa Enter para dejarla vacia.\n> ",
|
|
231
233
|
"runtime.wizard.api_url_invalid": "Introduce una URL válida (http/https) o pulsa Enter para usar el valor por defecto.\n",
|
|
232
234
|
"runtime.wizard.start": "Configuración de OpenCode Telegram Bot.\n",
|
|
233
235
|
"runtime.wizard.saved": "Configuración guardada:\n- {envPath}\n- {settingsPath}\n",
|
package/dist/i18n/ru.js
CHANGED
|
@@ -59,18 +59,18 @@ export const ru = {
|
|
|
59
59
|
"status.health.unhealthy": "Unhealthy",
|
|
60
60
|
"status.line.health": "Статус: {health}",
|
|
61
61
|
"status.line.version": "Версия: {version}",
|
|
62
|
-
"status.line.managed_yes": "
|
|
63
|
-
"status.line.managed_no": "
|
|
62
|
+
"status.line.managed_yes": "Запущен ботом: Да",
|
|
63
|
+
"status.line.managed_no": "Запущен ботом: Нет",
|
|
64
64
|
"status.line.pid": "PID: {pid}",
|
|
65
65
|
"status.line.uptime_sec": "Uptime: {seconds} сек",
|
|
66
66
|
"status.line.mode": "Режим: {mode}",
|
|
67
67
|
"status.line.model": "Модель: {model}",
|
|
68
68
|
"status.agent_not_set": "не установлен",
|
|
69
|
-
"status.project_selected": "
|
|
70
|
-
"status.project_not_selected": "
|
|
69
|
+
"status.project_selected": "Проект: {project}",
|
|
70
|
+
"status.project_not_selected": "Проект: не выбран",
|
|
71
71
|
"status.project_hint": "Используйте /projects для выбора проекта",
|
|
72
|
-
"status.session_selected": "
|
|
73
|
-
"status.session_not_selected": "
|
|
72
|
+
"status.session_selected": "Текущая сессия: {title}",
|
|
73
|
+
"status.session_not_selected": "Текущая сессия: не выбрана",
|
|
74
74
|
"status.session_hint": "Используйте /sessions для выбора или /new для создания",
|
|
75
75
|
"status.server_unavailable": "🔴 OpenCode Server недоступен\n\nИспользуйте /opencode_start для запуска сервера.",
|
|
76
76
|
"projects.empty": "📭 Проектов нет.\n\nОткройте директорию в OpenCode и создайте хотя бы одну сессию, после этого она появится здесь.",
|
|
@@ -208,14 +208,14 @@ export const ru = {
|
|
|
208
208
|
"keyboard.variant": "💭 {name}",
|
|
209
209
|
"keyboard.variant_default": "💡 Default",
|
|
210
210
|
"keyboard.updated": "⌨️ Клавиатура обновлена",
|
|
211
|
-
"pinned.default_session_title": "
|
|
212
|
-
"pinned.unknown": "
|
|
213
|
-
"pinned.line.project": "
|
|
214
|
-
"pinned.line.model": "
|
|
215
|
-
"pinned.line.context": "
|
|
216
|
-
"pinned.files.title": "
|
|
211
|
+
"pinned.default_session_title": "новая сессия",
|
|
212
|
+
"pinned.unknown": "Неизвестно",
|
|
213
|
+
"pinned.line.project": "Проект: {project}",
|
|
214
|
+
"pinned.line.model": "Модель: {model}",
|
|
215
|
+
"pinned.line.context": "Контекст: {used} / {limit} ({percent}%)",
|
|
216
|
+
"pinned.files.title": "Файлы ({count}):",
|
|
217
217
|
"pinned.files.item": " {path}{diff}",
|
|
218
|
-
"pinned.files.more": " ...
|
|
218
|
+
"pinned.files.more": " ... и еще {count}",
|
|
219
219
|
"tool.todo.overflow": "*(ещё {count} задач)*",
|
|
220
220
|
"tool.file_header.write": "Write File/Path: {path}\n============================================================\n\n",
|
|
221
221
|
"tool.file_header.edit": "Edit File/Path: {path}\n============================================================\n\n",
|
|
@@ -228,6 +228,8 @@ export const ru = {
|
|
|
228
228
|
"runtime.wizard.ask_user_id": "Введите ваш Telegram User ID (можно узнать у @userinfobot).\n> ",
|
|
229
229
|
"runtime.wizard.user_id_invalid": "Введите положительное целое число (> 0).\n",
|
|
230
230
|
"runtime.wizard.ask_api_url": "Введите URL OpenCode API (опционально).\nНажмите Enter для значения по умолчанию: {defaultUrl}\n> ",
|
|
231
|
+
"runtime.wizard.ask_server_username": "Введите логин OpenCode сервера (опционально).\nНажмите Enter для значения по умолчанию: {defaultUsername}\n> ",
|
|
232
|
+
"runtime.wizard.ask_server_password": "Введите пароль OpenCode сервера (опционально).\nНажмите Enter, чтобы оставить пустым.\n> ",
|
|
231
233
|
"runtime.wizard.api_url_invalid": "Введите корректный URL (http/https) или нажмите Enter для значения по умолчанию.\n",
|
|
232
234
|
"runtime.wizard.start": "Настройка OpenCode Telegram Bot.\n",
|
|
233
235
|
"runtime.wizard.saved": "Конфигурация сохранена:\n- {envPath}\n- {settingsPath}\n",
|
package/dist/i18n/zh.js
CHANGED
|
@@ -59,18 +59,18 @@ export const zh = {
|
|
|
59
59
|
"status.health.unhealthy": "不健康",
|
|
60
60
|
"status.line.health": "状态:{health}",
|
|
61
61
|
"status.line.version": "版本:{version}",
|
|
62
|
-
"status.line.managed_yes": "
|
|
63
|
-
"status.line.managed_no": "
|
|
62
|
+
"status.line.managed_yes": "由机器人启动:是",
|
|
63
|
+
"status.line.managed_no": "由机器人启动:否",
|
|
64
64
|
"status.line.pid": "PID:{pid}",
|
|
65
65
|
"status.line.uptime_sec": "运行时间:{seconds} 秒",
|
|
66
66
|
"status.line.mode": "模式:{mode}",
|
|
67
67
|
"status.line.model": "模型:{model}",
|
|
68
68
|
"status.agent_not_set": "未设置",
|
|
69
|
-
"status.project_selected": "
|
|
70
|
-
"status.project_not_selected": "
|
|
69
|
+
"status.project_selected": "项目:{project}",
|
|
70
|
+
"status.project_not_selected": "项目:未选择",
|
|
71
71
|
"status.project_hint": "使用 /projects 选择项目",
|
|
72
|
-
"status.session_selected": "
|
|
73
|
-
"status.session_not_selected": "
|
|
72
|
+
"status.session_selected": "当前会话:{title}",
|
|
73
|
+
"status.session_not_selected": "当前会话:未选择",
|
|
74
74
|
"status.session_hint": "使用 /sessions 选择一个会话,或 /new 创建",
|
|
75
75
|
"status.server_unavailable": "🔴 OpenCode 服务器不可用\n\n使用 /opencode_start 启动服务器。",
|
|
76
76
|
"projects.empty": "📭 未找到项目。\n\n在 OpenCode 中打开一个目录并至少创建一个会话,然后它会出现在这里。",
|
|
@@ -228,6 +228,8 @@ export const zh = {
|
|
|
228
228
|
"runtime.wizard.ask_user_id": "请输入你的 Telegram User ID(可从 @userinfobot 获取)。\n> ",
|
|
229
229
|
"runtime.wizard.user_id_invalid": "请输入一个正整数(> 0)。\n",
|
|
230
230
|
"runtime.wizard.ask_api_url": "请输入 OpenCode API URL(可选)。\n按 Enter 使用默认值:{defaultUrl}\n> ",
|
|
231
|
+
"runtime.wizard.ask_server_username": "请输入 OpenCode 服务器用户名(可选)。\n按 Enter 使用默认值:{defaultUsername}\n> ",
|
|
232
|
+
"runtime.wizard.ask_server_password": "请输入 OpenCode 服务器密码(可选)。\n按 Enter 保持为空。\n> ",
|
|
231
233
|
"runtime.wizard.api_url_invalid": "请输入有效 URL(http/https),或按 Enter 使用默认值。\n",
|
|
232
234
|
"runtime.wizard.start": "OpenCode Telegram Bot 设置。\n",
|
|
233
235
|
"runtime.wizard.saved": "配置已保存:\n- {envPath}\n- {settingsPath}\n",
|
|
@@ -7,6 +7,7 @@ import dotenv from "dotenv";
|
|
|
7
7
|
import { getRuntimePaths } from "./paths.js";
|
|
8
8
|
import { getLocale, getLocaleOptions, resolveSupportedLocale, setRuntimeLocale, t, } from "../i18n/index.js";
|
|
9
9
|
const DEFAULT_API_URL = "http://localhost:4096";
|
|
10
|
+
const DEFAULT_SERVER_USERNAME = "opencode";
|
|
10
11
|
const FALLBACK_MODEL_PROVIDER = "opencode";
|
|
11
12
|
const FALLBACK_MODEL_ID = "big-pickle";
|
|
12
13
|
function isPositiveInteger(value) {
|
|
@@ -64,6 +65,8 @@ export function buildEnvFileContent(existingContent, values) {
|
|
|
64
65
|
["TELEGRAM_BOT_TOKEN", values.TELEGRAM_BOT_TOKEN],
|
|
65
66
|
["TELEGRAM_ALLOWED_USER_ID", values.TELEGRAM_ALLOWED_USER_ID],
|
|
66
67
|
["OPENCODE_API_URL", values.OPENCODE_API_URL],
|
|
68
|
+
["OPENCODE_SERVER_USERNAME", values.OPENCODE_SERVER_USERNAME],
|
|
69
|
+
["OPENCODE_SERVER_PASSWORD", values.OPENCODE_SERVER_PASSWORD],
|
|
67
70
|
["OPENCODE_MODEL_PROVIDER", values.OPENCODE_MODEL_PROVIDER],
|
|
68
71
|
["OPENCODE_MODEL_ID", values.OPENCODE_MODEL_ID],
|
|
69
72
|
];
|
|
@@ -242,6 +245,23 @@ async function askApiUrl() {
|
|
|
242
245
|
return apiUrl;
|
|
243
246
|
}
|
|
244
247
|
}
|
|
248
|
+
async function askServerUsername() {
|
|
249
|
+
const prompt = t("runtime.wizard.ask_server_username", {
|
|
250
|
+
defaultUsername: DEFAULT_SERVER_USERNAME,
|
|
251
|
+
});
|
|
252
|
+
const username = await askVisible(prompt);
|
|
253
|
+
if (!username) {
|
|
254
|
+
return DEFAULT_SERVER_USERNAME;
|
|
255
|
+
}
|
|
256
|
+
return username;
|
|
257
|
+
}
|
|
258
|
+
async function askServerPassword() {
|
|
259
|
+
const password = await askHidden(t("runtime.wizard.ask_server_password"));
|
|
260
|
+
if (!password) {
|
|
261
|
+
return undefined;
|
|
262
|
+
}
|
|
263
|
+
return password;
|
|
264
|
+
}
|
|
245
265
|
async function collectWizardValues() {
|
|
246
266
|
const locale = await askLocale();
|
|
247
267
|
setRuntimeLocale(locale);
|
|
@@ -258,12 +278,16 @@ async function collectWizardValues() {
|
|
|
258
278
|
const token = await askToken();
|
|
259
279
|
const allowedUserId = await askAllowedUserId();
|
|
260
280
|
const apiUrl = await askApiUrl();
|
|
281
|
+
const serverUsername = await askServerUsername();
|
|
282
|
+
const serverPassword = await askServerPassword();
|
|
261
283
|
process.stdout.write("\n");
|
|
262
284
|
return {
|
|
263
285
|
locale,
|
|
264
286
|
token,
|
|
265
287
|
allowedUserId,
|
|
266
288
|
apiUrl,
|
|
289
|
+
serverUsername,
|
|
290
|
+
serverPassword,
|
|
267
291
|
};
|
|
268
292
|
}
|
|
269
293
|
function ensureInteractiveTty() {
|
|
@@ -294,6 +318,8 @@ async function runWizardAndPersist(runtimePaths) {
|
|
|
294
318
|
TELEGRAM_BOT_TOKEN: wizardValues.token,
|
|
295
319
|
TELEGRAM_ALLOWED_USER_ID: wizardValues.allowedUserId,
|
|
296
320
|
OPENCODE_API_URL: wizardValues.apiUrl,
|
|
321
|
+
OPENCODE_SERVER_USERNAME: wizardValues.serverUsername,
|
|
322
|
+
OPENCODE_SERVER_PASSWORD: wizardValues.serverPassword,
|
|
297
323
|
OPENCODE_MODEL_PROVIDER: provider,
|
|
298
324
|
OPENCODE_MODEL_ID: modelId,
|
|
299
325
|
};
|