imtoagent 0.2.1 → 0.2.3

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.
@@ -13,7 +13,6 @@
13
13
 
14
14
  import * as fs from 'fs';
15
15
  import * as path from 'path';
16
- import * as readline from 'readline';
17
16
  import { getDataDir } from '../modules/utils/paths';
18
17
 
19
18
  const PID_FILE = '/tmp/imtoagent.pid';
@@ -127,40 +126,12 @@ async function cmdStart() {
127
126
  }
128
127
  }
129
128
  if (missingBackends.length > 0) {
130
- console.error(`\n⚠️ 以下后端已配置但未安装:`);
131
- for (const name of missingBackends) {
132
- const b = BACKEND_DEFS.find((d) => d.type === name);
133
- console.error(` ❌ ${name} ${b ? `(${b.label})` : ''}`);
134
- }
135
-
136
- // 交互式询问是否自动安装
137
- const rl = readline.createInterface({
138
- input: process.stdin,
139
- output: process.stdout,
140
- });
141
-
142
- const answer = await new Promise<string>((resolve) => {
143
- rl.question('\n🔧 是否自动安装缺失的后端?[Y/n]: ', resolve);
144
- });
145
- rl.close();
146
-
147
- if (answer.trim().toLowerCase() !== 'n') {
148
- const { installBackend } = await import('../modules/utils/backend-check');
149
- let allInstalled = true;
150
-
151
- for (const name of missingBackends) {
152
- const ok = await installBackend(name as 'claude' | 'codex' | 'opencode');
153
- if (!ok) allInstalled = false;
154
- }
155
-
156
- if (allInstalled) {
157
- console.log('\n✅ 所有后端安装完成,正在启动网关...\n');
158
- } else {
159
- console.error('\n⚠️ 部分后端安装失败。网关仍可启动,但使用未安装的后端时会报错。\n');
160
- }
161
- } else {
162
- console.error('\n跳过安装。网关仍可启动,但使用未安装的后端时会报错。\n');
129
+ console.error(`\n⚠️ 以下后端已配置但未安装,网关启动后发消息会报错:`);
130
+ for (const b of missingBackends) {
131
+ console.error(` ❌ ${b}`);
163
132
  }
133
+ console.error(`\n请先安装缺失的后端,或运行 "imtoagent setup" 修改配置。\n`);
134
+ // 不强制退出,允许用户先启动网关再慢慢装后端
164
135
  }
165
136
  } catch {
166
137
  // 检查失败不影响启动
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+ // imtoagent CLI wrapper — finds bun and delegates
3
+ "use strict";
4
+ var path = require("path");
5
+ var fs = require("fs");
6
+ var spawnSync = require("child_process").spawnSync;
7
+
8
+ var candidates = [
9
+ process.env.BUN_BIN,
10
+ path.join(process.env.HOME || "", ".bun", "bin", "bun"),
11
+ "/usr/local/bin/bun",
12
+ "/opt/homebrew/bin/bun",
13
+ ];
14
+ try {
15
+ var r = spawnSync("which", ["bun"]);
16
+ if (r.status === 0) candidates.unshift(r.stdout.toString().trim());
17
+ } catch (e) {}
18
+
19
+ var bunPath = null;
20
+ for (var i = 0; i < candidates.length; i++) {
21
+ if (candidates[i] && fs.existsSync(candidates[i])) {
22
+ bunPath = candidates[i];
23
+ break;
24
+ }
25
+ }
26
+
27
+ if (!bunPath) {
28
+ console.error("❌ bun 未找到,请先安装: https://bun.sh");
29
+ console.error(" curl -fsSL https://bun.sh/install | bash");
30
+ process.exit(1);
31
+ }
32
+
33
+ var pkgDir = path.resolve(__dirname, "..");
34
+ var real = path.join(pkgDir, "bin", "imtoagent-real");
35
+ var result = spawnSync(bunPath, [real].concat(process.argv.slice(2)), {
36
+ stdio: "inherit",
37
+ env: Object.assign({}, process.env),
38
+ });
39
+ process.exit(result.status || 0);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "imtoagent",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "IM ↔ Agent 统一网关 — 飞书/Telegram/微信/企业微信对接 Claude Code/Codex/OpenCode",
5
5
  "type": "module",
6
6
  "bin": {
7
- "imtoagent": "./bin/imtoagent"
7
+ "imtoagent": "./bin/imtoagent.cjs"
8
8
  },
9
9
  "files": [
10
10
  "index.ts",
@@ -12,7 +12,10 @@
12
12
  "bin/",
13
13
  "templates/",
14
14
  "scripts/",
15
- "README.md"
15
+ "README.md",
16
+ "bin/imtoagent.ts",
17
+ "bin/imtoagent.cjs",
18
+ "bin/imtoagent-real"
16
19
  ],
17
20
  "scripts": {
18
21
  "postinstall": "node scripts/postinstall.cjs",