@raolin2025/claude-code-node 2.6.2 → 2.6.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raolin2025/claude-code-node",
3
- "version": "2.6.2",
3
+ "version": "2.6.4",
4
4
  "description": "Node.js AI Code Agent CLI - Zero dependencies, pure JavaScript, security hardened, multi-channel notifications, Telegram & QQ Bot remote programming, rich media upload, multi-account management",
5
5
  "type": "module",
6
6
  "main": "src/core/index.js",
package/src/core/cli.js CHANGED
@@ -98,11 +98,19 @@ function startSocketServer(engine, session, sessionManager, channelManager, verb
98
98
 
99
99
  server.listen(SOCK_PATH, () => {
100
100
  // v1.1 修复: socket 文件权限 0600(仅所有者可读写),阻止其他用户连接
101
- try { chmodSync(SOCK_PATH, 0o600) } catch {}
101
+ // Windows named pipe 不支持 chmod,跳过
102
+ try { if (!process.platform.startsWith('win')) chmodSync(SOCK_PATH, 0o600) } catch {}
102
103
  // 写 PID 文件(权限 0644)
103
104
  writeFileSync(CC_NODE_PID, String(process.pid), { mode: 0o644 })
104
105
  })
105
106
 
107
+ // 关键修复: 监听 socket 失败时绝不能崩溃(如 Windows 权限 / 端口占用)。
108
+ // 否则触发 Unhandled 'error' event 导致整个 cc-node 进程退出。
109
+ server.on('error', (err) => {
110
+ console.error(`⚠️ Socket 监听失败(${err.code || err.message})— cc-notify 远程转发将不可用,但 REPL 仍可正常使用。`)
111
+ console.error(` Path: ${SOCK_PATH}`)
112
+ })
113
+
106
114
  // 退出时清理
107
115
  const cleanup = () => {
108
116
  try { unlinkSync(SOCK_PATH) } catch {}
@@ -899,7 +907,9 @@ const systemPrompt = cliArgs.systemPrompt || DEFAULT_SYSTEM_PROMPT
899
907
  // - Telegram 消息会作为 REPL 输入,与 CLI 共享同一个引擎和对话记忆
900
908
  // ============================================================
901
909
  const tgToken = process.env.CC_NODE_CHANNEL_TELEGRAM_TOKEN || config.get('channels')?.telegram?.token || ''
902
- if (tgToken) {
910
+ // 关键修复: 使用 --with-notify 时,由 startBuiltinListeners 统一启动 Telegram 监听器,
911
+ // 这里不能再独立启动一个,否则同一 token 会有两个 getUpdates 长轮询 → Telegram 报 HTTP 409 Conflict。
912
+ if (tgToken && !cliArgs.withNotify) {
903
913
  try {
904
914
  tgListener = new TelegramListener({
905
915
  channels: {
package/src/core/paths.js CHANGED
@@ -3,9 +3,15 @@
3
3
  */
4
4
  import { join } from 'path'
5
5
  import { homedir } from 'os'
6
+ import { platform } from 'process'
7
+
8
+ const isWindows = platform === 'win32'
6
9
 
7
10
  export const SOCK_DIR = join(homedir(), '.cc-node')
8
- export const SOCK_PATH = join(SOCK_DIR, 'repl.sock')
11
+ // Windows 不支持传统 Unix domain socket(会抛 EACCES),改用 named pipe。
12
+ // Unix socket: C:\Users\xxx\.cc-node\repl.sock → 报错
13
+ // named pipe : \\.\pipe\cc-node → 正常
14
+ export const SOCK_PATH = isWindows ? '\\\\.\\pipe\\cc-node' : join(SOCK_DIR, 'repl.sock')
9
15
  export const CC_NODE_PID = join(SOCK_DIR, 'cc-node.pid')
10
16
  export const CC_NOTIFY_PID = join(SOCK_DIR, 'cc-notify.pid')
11
17
  export const CC_NOTIFY_LOG = join(SOCK_DIR, 'cc-notify.log')