imtoagent 0.3.4 → 0.3.5

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 (39) hide show
  1. package/README.md +97 -97
  2. package/bin/imtoagent-real +96 -96
  3. package/bin/imtoagent.cjs +1 -1
  4. package/index.ts +106 -106
  5. package/modules/agent/claude-adapter.ts +6 -6
  6. package/modules/agent/claude.ts +6 -6
  7. package/modules/agent/codex-adapter.ts +13 -13
  8. package/modules/agent/codex-exec-server.ts +11 -11
  9. package/modules/agent/codex.ts +29 -29
  10. package/modules/agent/opencode-adapter.ts +17 -17
  11. package/modules/agent/opencode.ts +10 -10
  12. package/modules/capabilities.ts +33 -33
  13. package/modules/cli/setup.ts +164 -164
  14. package/modules/core/config.ts +5 -5
  15. package/modules/core/error.ts +8 -8
  16. package/modules/core/runtime.ts +10 -10
  17. package/modules/core/session.ts +4 -4
  18. package/modules/core/stats.ts +14 -14
  19. package/modules/core/types.ts +7 -7
  20. package/modules/im/feishu.ts +56 -56
  21. package/modules/im/telegram.ts +23 -23
  22. package/modules/im/wechat.ts +54 -54
  23. package/modules/im/wecom.ts +50 -50
  24. package/modules/media/feishu-inbound-adapter.ts +4 -4
  25. package/modules/media/resolver.ts +11 -11
  26. package/modules/media/telegram-inbound-adapter.ts +8 -8
  27. package/modules/prompt-builder.ts +12 -12
  28. package/modules/proxy/anthropic-proxy.ts +31 -31
  29. package/modules/proxy/codex-proxy.ts +18 -18
  30. package/modules/utils/backend-check.ts +12 -12
  31. package/modules/utils/paths.ts +8 -8
  32. package/package.json +1 -1
  33. package/scripts/postinstall.cjs +10 -10
  34. package/scripts/postinstall.ts +13 -13
  35. package/templates/soul.template/identity.md +5 -5
  36. package/templates/soul.template/profile.md +7 -7
  37. package/templates/soul.template/rules.md +5 -5
  38. package/templates/soul.template/skills.md +2 -2
  39. package/templates/soul.template/workspace.md +3 -3
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
- # imtoagent — IM ↔ Agent 统一网关
1
+ # imtoagent — IM ↔ Agent Unified Gateway
2
2
 
3
- 将飞书、Telegram、个人微信、企业微信对接到 Claude CodeCodex (GPT)OpenCode AI 编程 Agent。
3
+ Connect Feishu, Telegram, personal WeChat, and WeCom to AI coding agents like Claude Code, Codex (GPT), OpenCode, and more.
4
4
 
5
- 一个网关,多个 IM,多种 Agent,统一端口代理。
5
+ One gateway, multiple IMs, multiple agents, unified port proxy.
6
6
 
7
- ## 架构
7
+ ## Architecture
8
8
 
9
9
  ```
10
10
  飞书/Telegram/微信/企微 → IM Registry 工厂 → Bot 实例
@@ -12,48 +12,48 @@
12
12
  → 统一 Proxy (:18899) → 上游模型
13
13
  ```
14
14
 
15
- ### 已支持的 IM 适配器
15
+ ### Supported IM Adapters
16
16
 
17
- | IM | 连接方式 | 能力 |
17
+ | IM | Connection | Capabilities |
18
18
  |----|----------|------|
19
- | **飞书** | WebSocket 长连接 + 自动重连 | 文本、代码块、卡片、文件、图片、语音、按钮 |
20
- | **Telegram** | 长轮询 + HTTP 代理 | 文本、文件、图片、语音 |
21
- | **个人微信** | iLink HTTP long-poll + QR 扫码 | 文本、图片、文件、语音(AES-128-ECB 加密) |
22
- | **企业微信** | HTTP Webhook 回调 + REST API | 文本、文件、图片 |
19
+ | **Feishu** | WebSocket persistent connection + auto-reconnect | Text, code blocks, cards, files, images, voice, buttons |
20
+ | **Telegram** | Long polling + HTTP proxy | Text, files, images, voice |
21
+ | **Personal WeChat** | iLink HTTP long-poll + QR scan | Text, images, files, voice (AES-128-ECB encrypted) |
22
+ | **WeCom** | HTTP Webhook callback + REST API | Text, files, images |
23
23
 
24
- ### 已支持的 Agent 后端
24
+ ### Supported Agent Backends
25
25
 
26
- | 后端 | 对接方式 |
26
+ | Backend | Integration Method |
27
27
  |------|----------|
28
- | **Claude Code** | Claude Agent SDK spawn 子进程 |
28
+ | **Claude Code** | Claude Agent SDK spawn subprocess |
29
29
  | **Codex** | app-server v2 (stdio JSON-RPC) |
30
30
  | **OpenCode** | HTTP API client |
31
31
 
32
- ## 快速开始
32
+ ## Quick Start
33
33
 
34
- ### 前置条件
34
+ ### Prerequisites
35
35
 
36
- - **Bun** 运行时(≥1.0.0):`brew install oven-sh/bun/bun`
36
+ - **Bun** runtime (≥1.0.0): `brew install oven-sh/bun/bun`
37
37
  - **macOS / Linux**
38
- - **至少一个 Agent 后端**(见下表,安装 imtoagent 前或后安装均可)
38
+ - **At least one Agent backend** (see table below; can be installed before or after imtoagent)
39
39
 
40
- | 后端 | 安装命令 |
40
+ | Backend | Install Command |
41
41
  |------|----------|
42
42
  | Claude Code | `npm install -g @anthropic-ai/claude-agent-sdk` |
43
43
  | Codex | `npm install -g @openai/codex` |
44
44
  | OpenCode | `npm install -g opencode` |
45
45
 
46
- ### 安装
46
+ ### Installation
47
47
 
48
- #### 方式一:npm 全局安装(推荐)
48
+ #### Method 1: npm global install (recommended)
49
49
 
50
50
  ```bash
51
51
  npm install -g imtoagent
52
52
  ```
53
53
 
54
- 安装完成后自动检测是否需要初始配置,交互式终端会自动引导进入配置向导。
54
+ After installation, it automatically checks whether initial configuration is needed. An interactive terminal will guide you through the setup wizard.
55
55
 
56
- #### 方式二:源码安装
56
+ #### Method 2: Source install
57
57
 
58
58
  ```bash
59
59
  git clone https://github.com/YOUR_USERNAME/imtoagent.git
@@ -62,47 +62,47 @@ bun install
62
62
  bun run bin/imtoagent setup
63
63
  ```
64
64
 
65
- ### 首次配置
65
+ ### First-Time Configuration
66
66
 
67
67
  ```bash
68
68
  imtoagent setup
69
69
  ```
70
70
 
71
- 交互式配置向导引导你完成:
71
+ The interactive setup wizard guides you through:
72
72
 
73
- 1. **配置 Bot** — 选择 IM 平台 + Agent 后端
74
- 2. **配置模型供应商**添加 API 凭证(DeepSeekDashscope 等)
75
- 3. **生成灵魂文件** 为每个 Bot 创建 rules.md / identity.md
76
- 4. **写入配置文件**自动生成 `~/.imtoagent/config.json`
73
+ 1. **Configure Bot** — Select IM platform + Agent backend
74
+ 2. **Configure Model Providers** Add API credentials (DeepSeek, Dashscope, etc.)
75
+ 3. **Generate Soul Files** Create rules.md / identity.md etc. for each Bot
76
+ 4. **Write Config Files** Auto-generate `~/.imtoagent/config.json`
77
77
 
78
- #### 飞书 Bot 需要
78
+ #### Feishu Bot Requirements
79
79
 
80
- - 飞书 App ID(`cli_...`)
81
- - 飞书 App Secret
82
- - 飞书应用需开启:机器人、事件订阅、消息收发权限
80
+ - Feishu App ID (`cli_...`)
81
+ - Feishu App Secret
82
+ - Feishu app must enable: Bot, Event Subscription, Message Send/Receive permissions
83
83
 
84
- #### Telegram Bot 需要
84
+ #### Telegram Bot Requirements
85
85
 
86
- - Telegram Bot Token(从 @BotFather 获取)
87
- - 可选:代理地址(如 `http://127.0.0.1:7890`)
86
+ - Telegram Bot Token (obtain from @BotFather)
87
+ - Optional: Proxy address (e.g., `http://127.0.0.1:7890`)
88
88
 
89
- #### 个人微信
89
+ #### Personal WeChat
90
90
 
91
- - 首次运行 `imtoagent start` 后自动弹出 QR 码
92
- - 用手机微信扫码完成绑定
91
+ - QR code automatically pops up on first run of `imtoagent start`
92
+ - Scan with your phone's WeChat to complete binding
93
93
 
94
- ### 启动网关
94
+ ### Start the Gateway
95
95
 
96
96
  ```bash
97
- imtoagent start # 后台启动
98
- imtoagent status # 查看运行状态
99
- imtoagent stop # 停止网关
97
+ imtoagent start # Start in background
98
+ imtoagent status # Check running status
99
+ imtoagent stop # Stop the gateway
100
100
  ```
101
101
 
102
- ### 开机自启(macOS launchd
102
+ ### Auto-Start on Boot (macOS launchd)
103
103
 
104
104
  ```bash
105
- # 创建 launchd 配置
105
+ # Create launchd configuration
106
106
  cat > ~/Library/LaunchAgents/com.imtoagent.plist << 'EOF'
107
107
  <?xml version="1.0" encoding="UTF-8"?>
108
108
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -134,69 +134,69 @@ cat > ~/Library/LaunchAgents/com.imtoagent.plist << 'EOF'
134
134
  </plist>
135
135
  EOF
136
136
 
137
- # 加载
137
+ # Load
138
138
  launchctl load ~/Library/LaunchAgents/com.imtoagent.plist
139
139
  ```
140
140
 
141
- ### 常用命令
141
+ ### Common Commands
142
142
 
143
- | 命令 | 说明 |
143
+ | Command | Description |
144
144
  |------|------|
145
- | `imtoagent setup` | 交互式配置向导 |
146
- | `imtoagent start` | 后台启动网关 |
147
- | `imtoagent stop` | 停止网关 |
148
- | `imtoagent status` | 查看运行状态 |
149
- | `imtoagent restore` | 热重载恢复 |
150
- | `imtoagent daemon` | 前台守护模式(适合 launchd/systemd 托管) |
145
+ | `imtoagent setup` | Interactive setup wizard |
146
+ | `imtoagent start` | Start gateway in background |
147
+ | `imtoagent stop` | Stop the gateway |
148
+ | `imtoagent status` | Check running status |
149
+ | `imtoagent restore` | Hot reload recovery |
150
+ | `imtoagent daemon` | Foreground daemon mode (suitable for launchd/systemd) |
151
151
 
152
- ### 网关内建命令
152
+ ### Built-In Gateway Commands
153
153
 
154
- IM 聊天中发送给 Bot
154
+ Send to the Bot in IM chat:
155
155
 
156
- | 命令 | 说明 |
156
+ | Command | Description |
157
157
  |------|------|
158
- | `/help` | 帮助信息 |
159
- | `/status` | 网关状态 |
160
- | `/stats` | 使用统计 |
161
- | `/model` | 切换模型 |
162
- | `/providers` | 查看供应商 |
163
- | `/memory` | 查看记忆 |
164
- | `/soul` | 灵魂管理 |
165
- | `/reload` | 重新加载 |
166
- | `/clear` | 清除会话 |
167
- | `/mode` | 切换模式(权限/auto/plan |
168
- | `/dir` | 切换工作目录 |
169
-
170
- ## 项目结构
158
+ | `/help` | Help information |
159
+ | `/status` | Gateway status |
160
+ | `/stats` | Usage statistics |
161
+ | `/model` | Switch model |
162
+ | `/providers` | View providers |
163
+ | `/memory` | View memory |
164
+ | `/soul` | Soul management |
165
+ | `/reload` | Reload |
166
+ | `/clear` | Clear session |
167
+ | `/mode` | Switch mode (permission/auto/plan) |
168
+ | `/dir` | Switch working directory |
169
+
170
+ ## Project Structure
171
171
 
172
172
  ```
173
173
  imtoagent/
174
- ├── index.ts # 入口 — IM Registry + Bot 构造 + Proxy 启动
175
- ├── bin/imtoagent # CLI 命令入口
174
+ ├── index.ts # Entry — IM Registry + Bot construction + Proxy startup
175
+ ├── bin/imtoagent # CLI command entry point
176
176
  ├── modules/
177
177
  │ ├── core/ # SDK Core
178
- │ │ ├── AgentRuntime.ts # 消息处理中枢
179
- │ │ ├── AgentAdapter.ts # Agent 后端统一抽象
180
- │ │ ├── SessionManager.ts # 会话持久化
181
- │ │ └── types.ts # 类型定义
182
- │ ├── im/ # IM 适配器
183
- │ │ ├── feishu.ts # 飞书
178
+ │ │ ├── AgentRuntime.ts # Message processing hub
179
+ │ │ ├── AgentAdapter.ts # Unified Agent backend abstraction
180
+ │ │ ├── SessionManager.ts # Session persistence
181
+ │ │ └── types.ts # Type definitions
182
+ │ ├── im/ # IM adapters
183
+ │ │ ├── feishu.ts # Feishu
184
184
  │ │ ├── telegram.ts # Telegram
185
- │ │ ├── wechat.ts # 个人微信
186
- │ │ └── wecom.ts # 企业微信
187
- │ ├── agent/ # Agent 后端
185
+ │ │ ├── wechat.ts # Personal WeChat
186
+ │ │ └── wecom.ts # WeCom
187
+ │ ├── agent/ # Agent backends
188
188
  │ │ ├── claude-adapter.ts # Claude Code
189
189
  │ │ ├── codex-adapter.ts # Codex
190
190
  │ │ └── opencode-adapter.ts # OpenCode
191
- │ ├── proxy/ # 统一代理
192
- │ │ └── anthropic-proxy.ts # :18899 Anthropic 格式代理
191
+ │ ├── proxy/ # Unified proxy
192
+ │ │ └── anthropic-proxy.ts # :18899 Anthropic format proxy
193
193
  │ ├── cli/ # CLI
194
- │ │ └── setup.ts # 交互式配置向导
194
+ │ │ └── setup.ts # Interactive setup wizard
195
195
  │ └── utils/
196
- │ └── paths.ts # 路径解析 + 自动初始化
196
+ │ └── paths.ts # Path resolution + auto-init
197
197
  ├── scripts/
198
- │ └── postinstall.ts # npm 安装后引导
199
- ├── templates/ # 配置模板
198
+ │ └── postinstall.ts # Post-npm-install guidance
199
+ ├── templates/ # Config templates
200
200
  │ ├── config.template.json
201
201
  │ ├── providers.template.json
202
202
  │ ├── opencode.template.json
@@ -204,29 +204,29 @@ imtoagent/
204
204
  └── README.md
205
205
  ```
206
206
 
207
- ## 数据目录
207
+ ## Data Directory
208
208
 
209
- 所有运行时数据统一存储在 `~/.imtoagent/`:
209
+ All runtime data is stored centrally in `~/.imtoagent/`:
210
210
 
211
211
  ```
212
212
  ~/.imtoagent/
213
- ├── config.json # 主配置(Bot + 供应商 + 系统)
214
- ├── providers.json # 模型供应商配置
215
- ├── opencode.json # OpenCode 配置
216
- ├── sessions/ # 会话持久化
217
- ├── logs/ # 运行日志
218
- └── soul/ # 灵魂文件(每 Bot 一个目录)
213
+ ├── config.json # Main config (Bot + providers + system)
214
+ ├── providers.json # Model provider config
215
+ ├── opencode.json # OpenCode config
216
+ ├── sessions/ # Session persistence
217
+ ├── logs/ # Runtime logs
218
+ └── soul/ # Soul files (one directory per Bot)
219
219
  ├── ClaudeBot/
220
220
  ├── CodexBot/
221
221
  └── ...
222
222
  ```
223
223
 
224
- ## 开发
224
+ ## Development
225
225
 
226
226
  ```bash
227
227
  bun install
228
- bun run index.ts # 直接运行
229
- bun run bin/imtoagent setup # 运行配置向导
228
+ bun run index.ts # Run directly
229
+ bun run bin/imtoagent setup # Run setup wizard
230
230
  ```
231
231
 
232
232
  ## License