imtoagent 0.3.13 → 0.3.15

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.
@@ -10,6 +10,10 @@ import type { AgentAdapter, AgentInput, AgentOutput } from '../core/types';
10
10
  import { buildAttachmentHint } from '../core/types';
11
11
  import { buildSystemPrompt } from '../prompt-builder';
12
12
  import { getDataDir } from '../utils/paths';
13
+ import { getNpmGlobalBin } from '../utils/backend-check';
14
+ import * as fs from 'fs';
15
+ import * as os from 'os';
16
+ import * as path from 'path';
13
17
 
14
18
  // ================================================================
15
19
  // OpenCodeAdapter 上下文
@@ -248,8 +252,21 @@ export async function startOpenCodeServer(): Promise<void> {
248
252
  } catch {}
249
253
 
250
254
  console.log('[OpenCodeAdapter] starting opencode serve...');
255
+
256
+ // Resolve opencode binary with fallbacks (matches checkOne() logic)
257
+ const home = os.homedir();
258
+ const customPath = path.join(home, '.opencode', 'bin', 'opencode');
259
+ const npmBin = getNpmGlobalBin();
260
+ const npmBinPath = npmBin ? path.join(npmBin, 'opencode') : null;
261
+ const ocBinPath =
262
+ (npmBinPath && fs.existsSync(npmBinPath)) ? npmBinPath :
263
+ fs.existsSync(customPath) ? customPath :
264
+ 'opencode'; // fallback to PATH lookup
265
+
266
+ console.log(`[OpenCodeAdapter] Using opencode binary: ${ocBinPath}`);
267
+
251
268
  const child = Bun.spawn(
252
- ['opencode', 'serve', '--port', String(OC_PORT), '--hostname', '127.0.0.1'],
269
+ [ocBinPath, 'serve', '--port', String(OC_PORT), '--hostname', '127.0.0.1'],
253
270
  {
254
271
  cwd: getDataDir(),
255
272
  env: {
@@ -187,71 +187,71 @@ const PROVIDER_PRESETS: ProviderPreset[] = [
187
187
  name: 'DashScope (Alibaba Bailian)',
188
188
  baseUrl: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
189
189
  format: 'openai',
190
- models: ['qwen-max', 'qwen-plus', 'qwen-turbo'],
190
+ models: ['qwen3.7-max', 'qwen3.6-plus', 'qwen3.6-flash'],
191
191
  },
192
192
  {
193
193
  name: 'DeepSeek',
194
194
  baseUrl: 'https://api.deepseek.com/v1',
195
195
  format: 'openai',
196
- models: ['deepseek-chat', 'deepseek-reasoner'],
196
+ models: ['deepseek-v4-pro', 'deepseek-v4-flash'],
197
197
  },
198
198
  {
199
199
  name: 'Zhipu AI (Zhipu)',
200
200
  baseUrl: 'https://open.bigmodel.cn/api/paas/v4',
201
201
  format: 'openai',
202
- models: ['glm-4-plus', 'glm-4-flash', 'glm-4'],
202
+ models: ['glm-5.1', 'glm-5', 'glm-5-turbo', 'glm-4.7'],
203
203
  },
204
204
  {
205
205
  name: 'MiniMax',
206
- baseUrl: 'https://api.minimax.io/v1',
206
+ baseUrl: 'https://api.minimaxi.com/v1',
207
207
  format: 'openai',
208
- models: ['MiniMax-M2.5', 'MiniMax-M1'],
208
+ models: ['MiniMax-M2.7', 'MiniMax-M2.5'],
209
209
  },
210
210
  {
211
211
  name: 'SiliconFlow',
212
212
  baseUrl: 'https://api.siliconflow.cn/v1',
213
213
  format: 'openai',
214
- models: ['Qwen/Qwen2.5-72B-Instruct', 'deepseek-ai/DeepSeek-V3'],
214
+ models: ['Qwen/Qwen3-235B-A22B', 'deepseek-ai/DeepSeek-V4', 'Qwen/Qwen3-32B'],
215
215
  },
216
216
  {
217
217
  name: 'Moonshot (Moonshot AI)',
218
218
  baseUrl: 'https://api.moonshot.cn/v1',
219
219
  format: 'openai',
220
- models: ['moonshot-v1-8k', 'moonshot-v1-32k', 'moonshot-v1-128k'],
220
+ models: ['kimi-k2', 'moonshot-v1-8k', 'moonshot-v1-32k', 'moonshot-v1-128k'],
221
221
  },
222
222
  {
223
223
  name: 'OpenAI',
224
224
  baseUrl: 'https://api.openai.com/v1',
225
225
  format: 'openai',
226
- models: ['gpt-4o', 'gpt-4o-mini', 'o3', 'o4-mini'],
226
+ models: ['gpt-5', 'gpt-5-mini', 'o3', 'o4-mini'],
227
227
  hint: 'Proxy required to access',
228
228
  },
229
229
  {
230
230
  name: 'Anthropic',
231
231
  baseUrl: 'https://api.anthropic.com',
232
232
  format: 'anthropic',
233
- models: ['claude-sonnet-4-20250514', 'claude-haiku-4-20250514', 'claude-opus-4-20250514'],
233
+ models: ['claude-sonnet-4-5-20251101', 'claude-opus-4-6-20260416', 'claude-haiku-4-20250514'],
234
234
  hint: 'Proxy required to access',
235
235
  },
236
236
  {
237
237
  name: 'Gemini (Google)',
238
238
  baseUrl: 'https://generativelanguage.googleapis.com/v1beta/openai',
239
239
  format: 'openai',
240
- models: ['gemini-2.5-pro', 'gemini-2.5-flash'],
240
+ models: ['gemini-3-pro', 'gemini-3-flash', 'gemini-2.5-pro'],
241
241
  hint: 'Proxy required to access',
242
242
  },
243
243
  {
244
244
  name: 'xAI (Grok)',
245
245
  baseUrl: 'https://api.x.ai/v1',
246
246
  format: 'openai',
247
- models: ['grok-3', 'grok-3-mini'],
247
+ models: ['grok-4', 'grok-4-fast', 'grok-3'],
248
248
  hint: 'Requires proxy to access',
249
249
  },
250
250
  {
251
251
  name: 'Ollama (Local)',
252
252
  baseUrl: 'http://localhost:11434/v1',
253
253
  format: 'openai',
254
- models: ['qwen2.5', 'llama3.2', 'deepseek-r1'],
254
+ models: ['qwen3', 'qwen2.5', 'llama3.3', 'deepseek-r1'],
255
255
  },
256
256
  ];
257
257
 
@@ -28,7 +28,7 @@ const BACKEND_DEFS: Omit<BackendInfo, 'installed' | 'version'>[] = [
28
28
 
29
29
  let _cachedNpmBin: string | null | undefined = undefined;
30
30
 
31
- function getNpmGlobalBin(): string | null {
31
+ export function getNpmGlobalBin(): string | null {
32
32
  if (_cachedNpmBin !== undefined) return _cachedNpmBin;
33
33
  try {
34
34
  const prefix = execSync('npm get prefix', { encoding: 'utf-8', timeout: 5000 }).trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imtoagent",
3
- "version": "0.3.13",
3
+ "version": "0.3.15",
4
4
  "description": "IM ↔ Agent 统一网关 — 飞书/Telegram/微信/企业微信对接 Claude Code/Codex/OpenCode",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,5 +1,20 @@
1
1
  {
2
2
  "providers": {
3
+ "dashscope": {
4
+ "baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1",
5
+ "apiKey": "YOUR_DASHSCOPE_API_KEY",
6
+ "models": [
7
+ "qwen3.7-max",
8
+ "qwen3.6-plus",
9
+ "qwen3.6-flash"
10
+ ],
11
+ "format": "openai",
12
+ "pricing": {
13
+ "inputPerMillion": 1.2,
14
+ "outputPerMillion": 6.0,
15
+ "currency": "CNY"
16
+ }
17
+ },
3
18
  "deepseek": {
4
19
  "baseUrl": "https://api.deepseek.com/v1",
5
20
  "apiKey": "YOUR_DEEPSEEK_API_KEY",
@@ -9,11 +24,72 @@
9
24
  ],
10
25
  "format": "openai",
11
26
  "pricing": {
12
- "inputPerMillion": 0.55,
13
- "outputPerMillion": 2.19,
14
- "currency": "USD"
27
+ "inputPerMillion": 3.0,
28
+ "outputPerMillion": 6.0,
29
+ "currency": "CNY"
30
+ }
31
+ },
32
+ "zhipu": {
33
+ "baseUrl": "https://open.bigmodel.cn/api/paas/v4",
34
+ "apiKey": "YOUR_ZHIPU_API_KEY",
35
+ "models": [
36
+ "glm-5.1",
37
+ "glm-5",
38
+ "glm-5-turbo",
39
+ "glm-4.7"
40
+ ],
41
+ "format": "openai",
42
+ "pricing": {
43
+ "inputPerMillion": 1.0,
44
+ "outputPerMillion": 5.0,
45
+ "currency": "CNY"
46
+ }
47
+ },
48
+ "minimax": {
49
+ "baseUrl": "https://api.minimaxi.com/v1",
50
+ "apiKey": "YOUR_MINIMAX_API_KEY",
51
+ "models": [
52
+ "MiniMax-M2.7",
53
+ "MiniMax-M2.5"
54
+ ],
55
+ "format": "openai",
56
+ "pricing": {
57
+ "inputPerMillion": 1.0,
58
+ "outputPerMillion": 4.0,
59
+ "currency": "CNY"
60
+ }
61
+ },
62
+ "moonshot": {
63
+ "baseUrl": "https://api.moonshot.cn/v1",
64
+ "apiKey": "YOUR_MOONSHOT_API_KEY",
65
+ "models": [
66
+ "kimi-k2",
67
+ "moonshot-v1-8k",
68
+ "moonshot-v1-32k",
69
+ "moonshot-v1-128k"
70
+ ],
71
+ "format": "openai",
72
+ "pricing": {
73
+ "inputPerMillion": 3.0,
74
+ "outputPerMillion": 12.0,
75
+ "currency": "CNY"
76
+ }
77
+ },
78
+ "siliconflow": {
79
+ "baseUrl": "https://api.siliconflow.cn/v1",
80
+ "apiKey": "YOUR_SILICONFLOW_API_KEY",
81
+ "models": [
82
+ "Qwen/Qwen3-235B-A22B",
83
+ "deepseek-ai/DeepSeek-V4",
84
+ "Qwen/Qwen3-32B"
85
+ ],
86
+ "format": "openai",
87
+ "pricing": {
88
+ "inputPerMillion": 0.5,
89
+ "outputPerMillion": 2.0,
90
+ "currency": "CNY"
15
91
  }
16
92
  }
17
93
  },
18
- "defaultModel": "deepseek/deepseek-v4-pro"
94
+ "defaultModel": "dashscope/qwen3.7-max"
19
95
  }