@ekay/claude-im 0.1.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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +119 -0
  3. package/dist/index.js +1710 -0
  4. package/package.json +48 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ekay
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # claude-im
2
+
3
+ 通过 IM 与 Claude Code 对话。WebSocket 长连接,流式卡片输出。
4
+
5
+ ## 与 larkcc 的关键区别
6
+
7
+ | 维度 | larkcc | claude-im |
8
+ |------|--------|---------------|
9
+ | app_secret 存储 | 明文 YAML | 优先环境变量 → Vault 加密 → 明文(告警) |
10
+ | 会话存储 | 明文 JSON | AES-256-GCM 加密 |
11
+ | 日志 | 打印消息内容 + openId | 仅打印脱敏标识 |
12
+ | Secret 传递 | 随 replyContext 传输 | 仅初始化时注入 Client |
13
+ | 依赖 | undici, https-proxy-agent 等 | 仅 5 个核心依赖 |
14
+ | 加密 | 无 | Node 内置 crypto |
15
+
16
+ ## 安装
17
+
18
+ ```bash
19
+ cd claude-im
20
+ npm install
21
+ npm run build
22
+ npm link # 可选,全局安装
23
+ ```
24
+
25
+ ## 快速开始
26
+
27
+ ### 1. 飞书开放平台配置
28
+
29
+ 1. 打开 [飞书开放平台](https://open.feishu.cn/app)
30
+ 2. 创建「自建应用」
31
+ 3. 在「添加应用能力」中添加「机器人」
32
+ 4. 在「权限管理」中开启:
33
+ - `im:message` — 获取与发送消息
34
+ - `im:message:send_as_bot` — 以机器人身份发消息
35
+ - `im:message.p2p_msg:readonly` — 读取私聊消息
36
+ 5. 发布应用(无需审核,企业内部应用可直接发布)
37
+
38
+ ### 2. 配置
39
+
40
+ ```bash
41
+ # 设置环境变量(推荐)
42
+ export LARK_APP_SECRET="your_app_secret"
43
+
44
+ # 或使用交互式配置向导
45
+ claude-im --setup
46
+ ```
47
+
48
+ ### 3. 启动
49
+
50
+ ```bash
51
+ cd /your/project
52
+ claude-im # 启动默认 profile
53
+ claude-im -p mybot # 指定 profile
54
+ claude-im -c # 继续上次会话
55
+ claude-im -d # 守护进程模式
56
+ ```
57
+
58
+ 然后在飞书中向你的机器人发送消息即可。
59
+
60
+ ## 多 Profile 管理
61
+
62
+ ```bash
63
+ claude-im --new-profile # 添加新 profile
64
+ claude-im --list-profiles # 列出所有 profile
65
+ claude-im --ps # 查看运行中的进程
66
+ claude-im --kill mybot # 停止指定 profile
67
+ claude-im --reset-session # 清除会话状态
68
+ ```
69
+
70
+ ### 环境变量(多 Profile)
71
+
72
+ ```bash
73
+ LARK_APP_SECRET # 默认 profile
74
+ LARK_MYBOT_APP_SECRET # mybot profile
75
+ LARK_APP_ID # 覆盖 app_id
76
+ LARK_MYBOT_APP_ID # 覆盖 mybot 的 app_id
77
+ CLAUDE_IM_HOME # 配置目录(默认 ~/.claude-im)
78
+ ```
79
+
80
+ ## 配置存储结构
81
+
82
+ ```
83
+ ~/.claude-im/
84
+ ├── config.yml # 主配置(不含 app_secret)
85
+ ├── .key # 加密密钥 (chmod 600)
86
+ ├── vault/ # 加密 secrets
87
+ │ ├── default # 默认 profile
88
+ │ └── mybot # 自定义 profile
89
+ ├── state/ # 加密会话状态
90
+ │ ├── default.json.enc
91
+ │ └── mybot.json.enc
92
+ └── lock-{profile}.pid # 进程锁
93
+ ```
94
+
95
+ ## 命令
96
+
97
+ 在飞书聊天中发送:
98
+
99
+ | 命令 | 说明 |
100
+ |------|------|
101
+ | `/help` | 显示可用命令 |
102
+ | `/new` | 开始新会话 |
103
+ | `/stop` | 停止当前处理 |
104
+ | `/status` | 查看会话状态 |
105
+
106
+ 可在 `config.yml` 的 `commands` 和 `exec_commands` 中添加自定义命令。
107
+
108
+ ## 安全
109
+
110
+ - 所有网络请求仅发往飞书 API 和 Anthropic API
111
+ - 无遥测、无数据收集、无第三方上传
112
+ - app_secret 优先从环境变量读取,配置文件支持加密存储
113
+ - 日志不包含用户消息内容、用户标识、密钥
114
+ - 会话数据 AES-256-GCM 加密存储
115
+ - 错误处理自动脱敏敏感值
116
+
117
+ ## License
118
+
119
+ MIT