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.
- package/README.md +97 -97
- package/bin/imtoagent-real +96 -96
- package/bin/imtoagent.cjs +1 -1
- package/index.ts +106 -106
- package/modules/agent/claude-adapter.ts +6 -6
- package/modules/agent/claude.ts +6 -6
- package/modules/agent/codex-adapter.ts +13 -13
- package/modules/agent/codex-exec-server.ts +11 -11
- package/modules/agent/codex.ts +29 -29
- package/modules/agent/opencode-adapter.ts +17 -17
- package/modules/agent/opencode.ts +10 -10
- package/modules/capabilities.ts +33 -33
- package/modules/cli/setup.ts +164 -164
- package/modules/core/config.ts +5 -5
- package/modules/core/error.ts +8 -8
- package/modules/core/runtime.ts +10 -10
- package/modules/core/session.ts +4 -4
- package/modules/core/stats.ts +14 -14
- package/modules/core/types.ts +7 -7
- package/modules/im/feishu.ts +56 -56
- package/modules/im/telegram.ts +23 -23
- package/modules/im/wechat.ts +54 -54
- package/modules/im/wecom.ts +50 -50
- package/modules/media/feishu-inbound-adapter.ts +4 -4
- package/modules/media/resolver.ts +11 -11
- package/modules/media/telegram-inbound-adapter.ts +8 -8
- package/modules/prompt-builder.ts +12 -12
- package/modules/proxy/anthropic-proxy.ts +31 -31
- package/modules/proxy/codex-proxy.ts +18 -18
- package/modules/utils/backend-check.ts +12 -12
- package/modules/utils/paths.ts +8 -8
- package/package.json +1 -1
- package/scripts/postinstall.cjs +10 -10
- package/scripts/postinstall.ts +13 -13
- package/templates/soul.template/identity.md +5 -5
- package/templates/soul.template/profile.md +7 -7
- package/templates/soul.template/rules.md +5 -5
- package/templates/soul.template/skills.md +2 -2
- 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
|
-
|
|
3
|
+
Connect Feishu, Telegram, personal WeChat, and WeCom to AI coding agents like Claude Code, Codex (GPT), OpenCode, and more.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
###
|
|
15
|
+
### Supported IM Adapters
|
|
16
16
|
|
|
17
|
-
| IM |
|
|
17
|
+
| IM | Connection | Capabilities |
|
|
18
18
|
|----|----------|------|
|
|
19
|
-
|
|
|
20
|
-
| **Telegram** |
|
|
21
|
-
|
|
|
22
|
-
|
|
|
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
|
-
###
|
|
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**
|
|
36
|
+
- **Bun** runtime (≥1.0.0): `brew install oven-sh/bun/bun`
|
|
37
37
|
- **macOS / Linux**
|
|
38
|
-
-
|
|
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
|
-
####
|
|
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.
|
|
74
|
-
2.
|
|
75
|
-
3.
|
|
76
|
-
4.
|
|
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
|
-
####
|
|
78
|
+
#### Feishu Bot Requirements
|
|
79
79
|
|
|
80
|
-
-
|
|
81
|
-
-
|
|
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
|
|
87
|
-
-
|
|
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
|
-
-
|
|
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
|
-
###
|
|
102
|
+
### Auto-Start on Boot (macOS launchd)
|
|
103
103
|
|
|
104
104
|
```bash
|
|
105
|
-
#
|
|
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` |
|
|
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
|
-
|
|
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` |
|
|
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 #
|
|
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
|
-
|
|
209
|
+
All runtime data is stored centrally in `~/.imtoagent/`:
|
|
210
210
|
|
|
211
211
|
```
|
|
212
212
|
~/.imtoagent/
|
|
213
|
-
├── config.json #
|
|
214
|
-
├── providers.json #
|
|
215
|
-
├── opencode.json # OpenCode
|
|
216
|
-
├── sessions/ #
|
|
217
|
-
├── logs/ #
|
|
218
|
-
└── soul/ #
|
|
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
|