@wu529778790/open-im 0.3.10 → 0.3.12

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/dist/cli.js CHANGED
@@ -151,11 +151,9 @@ async function startService() {
151
151
  console.log('\n请运行以下命令重新配置:\n npx @wu529778790/open-im\n');
152
152
  process.exit(1);
153
153
  }
154
- // 获取当前工作目录
155
- const currentDir = process.cwd();
156
- // 更新配置中的工作目录
157
- await updateWorkDir(currentDir);
158
- console.log(`工作目录已设置为: ${currentDir}`);
154
+ // 显示配置的工作目录(不自动更新,避免在不同目录重启时导致配置混乱)
155
+ const config = loadConfig();
156
+ console.log(`使用配置的工作目录: ${config.claudeWorkDir}`);
159
157
  // 后台启动 - 跨平台方案
160
158
  const distPath = join(__dirname, '..', 'dist', 'index.js');
161
159
  // 使用 detached 模式创建独立进程
package/dist/config.d.ts CHANGED
@@ -14,6 +14,7 @@ export interface Config {
14
14
  claudeModel?: string;
15
15
  logDir: string;
16
16
  logLevel: LogLevel;
17
+ proxy?: string;
17
18
  }
18
19
  /** 检测是否需要交互式配置(无 token 且无环境变量) */
19
20
  export declare function needsSetup(): boolean;
package/dist/config.js CHANGED
@@ -91,6 +91,7 @@ export function loadConfig() {
91
91
  }
92
92
  const logDir = process.env.LOG_DIR ?? file.logDir ?? join(APP_HOME, 'logs');
93
93
  const logLevel = (process.env.LOG_LEVEL?.toUpperCase() ?? file.logLevel ?? 'INFO');
94
+ const proxy = process.env.HTTP_PROXY ?? process.env.HTTPS_PROXY ?? process.env.ALL_PROXY ?? file.proxy;
94
95
  return {
95
96
  enabledPlatforms,
96
97
  telegramBotToken,
@@ -104,5 +105,6 @@ export function loadConfig() {
104
105
  claudeModel: process.env.CLAUDE_MODEL ?? file.claudeModel,
105
106
  logDir,
106
107
  logLevel,
108
+ proxy,
107
109
  };
108
110
  }
package/dist/setup.js CHANGED
@@ -52,6 +52,12 @@ export async function runInteractiveSetup() {
52
52
  message: '白名单用户 ID(可选,逗号分隔,留空=所有人可访问)',
53
53
  initial: '',
54
54
  },
55
+ {
56
+ type: 'text',
57
+ name: 'proxy',
58
+ message: '代理地址(可选,用于访问 Telegram,如: http://127.0.0.1:7890 或 socks5://127.0.0.1:1080)',
59
+ initial: '',
60
+ },
55
61
  {
56
62
  type: 'select',
57
63
  name: 'aiCommand',
@@ -82,6 +88,7 @@ export async function runInteractiveSetup() {
82
88
  .map((s) => s.trim())
83
89
  .filter(Boolean)
84
90
  : [],
91
+ proxy: response.proxy ? response.proxy.trim() : undefined,
85
92
  claudeWorkDir: (response.workDir || process.cwd()).trim(),
86
93
  claudeSkipPermissions: true,
87
94
  aiCommand: response.aiCommand ?? 'claude',
@@ -1,5 +1,6 @@
1
1
  import { Telegraf } from 'telegraf';
2
2
  import { createLogger } from '../logger.js';
3
+ import { HttpsProxyAgent } from 'https-proxy-agent';
3
4
  const log = createLogger('Telegram');
4
5
  let bot;
5
6
  let botUsername;
@@ -12,7 +13,21 @@ export function getBotUsername() {
12
13
  return botUsername;
13
14
  }
14
15
  export async function initTelegram(config, setupHandlers) {
15
- bot = new Telegraf(config.telegramBotToken);
16
+ const telegrafOptions = {};
17
+ // 配置代理
18
+ if (config.proxy) {
19
+ try {
20
+ const agent = new HttpsProxyAgent(config.proxy);
21
+ telegrafOptions.telegram = {
22
+ agent,
23
+ };
24
+ log.info(`Using proxy: ${config.proxy}`);
25
+ }
26
+ catch (err) {
27
+ log.warn(`Failed to create proxy agent: ${err}. Continuing without proxy.`);
28
+ }
29
+ }
30
+ bot = new Telegraf(config.telegramBotToken, telegrafOptions);
16
31
  setupHandlers(bot);
17
32
  const me = (await bot.telegram.getMe());
18
33
  botUsername = me.username;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wu529778790/open-im",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
4
4
  "description": "Multi-platform IM bridge for AI CLI tools (Claude, Codex, Cursor)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -41,6 +41,7 @@
41
41
  "url": "https://github.com/wu529778790/open-im/issues"
42
42
  },
43
43
  "dependencies": {
44
+ "https-proxy-agent": "^7.0.6",
44
45
  "prompts": "^2.4.2",
45
46
  "telegraf": "^4.16.3"
46
47
  },