@modelzen/feishu-codex-bridge 0.1.3 → 0.1.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 (2) hide show
  1. package/dist/cli.js +130 -49
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1,9 +1,19 @@
1
1
  // src/cli/index.ts
2
- import { readFileSync as readFileSync3 } from "fs";
3
- import { dirname as dirname9, resolve as resolve4 } from "path";
4
- import { fileURLToPath as fileURLToPath3 } from "url";
5
2
  import { Command } from "commander";
6
3
 
4
+ // src/core/version.ts
5
+ import { readFileSync } from "fs";
6
+ import { dirname, resolve } from "path";
7
+ import { fileURLToPath } from "url";
8
+ function bridgeVersion() {
9
+ try {
10
+ const pkgPath = resolve(dirname(fileURLToPath(import.meta.url)), "..", "package.json");
11
+ return JSON.parse(readFileSync(pkgPath, "utf8")).version ?? "0.0.0";
12
+ } catch {
13
+ return "0.0.0";
14
+ }
15
+ }
16
+
7
17
  // src/cli/commands/doctor.ts
8
18
  import { execFileSync as execFileSync2 } from "child_process";
9
19
  import { existsSync as existsSync3 } from "fs";
@@ -65,11 +75,11 @@ var paths = {
65
75
  // src/config/bots.ts
66
76
  import { existsSync } from "fs";
67
77
  import { chmod as chmod2, mkdir as mkdir2, readFile as readFile2, rename as rename2, writeFile as writeFile2 } from "fs/promises";
68
- import { dirname as dirname2, join as join2 } from "path";
78
+ import { dirname as dirname3, join as join2 } from "path";
69
79
 
70
80
  // src/config/store.ts
71
81
  import { chmod, mkdir, readFile, rename, writeFile } from "fs/promises";
72
- import { dirname } from "path";
82
+ import { dirname as dirname2 } from "path";
73
83
 
74
84
  // src/config/schema.ts
75
85
  function isComplete(cfg) {
@@ -158,7 +168,7 @@ async function ensureSecretsGetterWrapper() {
158
168
  # Auto-generated by feishu-codex-bridge. Do not edit.
159
169
  exec ${sq(node)} ${sq(bridgeEntry)} secrets get "$@"
160
170
  `;
161
- await mkdir(dirname(wrapperPath), { recursive: true });
171
+ await mkdir(dirname2(wrapperPath), { recursive: true });
162
172
  const tmp = `${wrapperPath}.tmp-${process.pid}`;
163
173
  await writeFile(tmp, content, "utf8");
164
174
  await chmod(tmp, 448);
@@ -166,7 +176,7 @@ exec ${sq(node)} ${sq(bridgeEntry)} secrets get "$@"
166
176
  return wrapperPath;
167
177
  }
168
178
  async function saveConfig(cfg, path = paths.configFile) {
169
- await mkdir(dirname(path), { recursive: true });
179
+ await mkdir(dirname2(path), { recursive: true });
170
180
  const tmp = `${path}.tmp-${process.pid}`;
171
181
  await writeFile(tmp, `${JSON.stringify(cfg, null, 2)}
172
182
  `, "utf8");
@@ -187,7 +197,7 @@ async function loadBots() {
187
197
  }
188
198
  }
189
199
  async function saveBots(reg) {
190
- await mkdir2(dirname2(paths.botsFile), { recursive: true });
200
+ await mkdir2(dirname3(paths.botsFile), { recursive: true });
191
201
  const tmp = `${paths.botsFile}.tmp-${process.pid}`;
192
202
  await writeFile2(tmp, `${JSON.stringify(reg, null, 2)}
193
203
  `, "utf8");
@@ -358,7 +368,7 @@ import { createInterface } from "readline/promises";
358
368
  import { createCipheriv, createDecipheriv, pbkdf2Sync, randomBytes } from "crypto";
359
369
  import { chmod as chmod3, mkdir as mkdir3, readFile as readFile3, rename as rename3, writeFile as writeFile3 } from "fs/promises";
360
370
  import { hostname, userInfo } from "os";
361
- import { dirname as dirname3 } from "path";
371
+ import { dirname as dirname4 } from "path";
362
372
  var KEY_LEN = 32;
363
373
  var IV_LEN = 12;
364
374
  var TAG_LEN = 16;
@@ -377,7 +387,7 @@ async function readStore() {
377
387
  }
378
388
  }
379
389
  async function writeStore(store) {
380
- await mkdir3(dirname3(paths.secretsFile), { recursive: true });
390
+ await mkdir3(dirname4(paths.secretsFile), { recursive: true });
381
391
  const tmp = `${paths.secretsFile}.tmp-${process.pid}`;
382
392
  await writeFile3(tmp, `${JSON.stringify(store, null, 2)}
383
393
  `, "utf8");
@@ -392,7 +402,7 @@ async function loadOrCreateSalt() {
392
402
  if (err.code !== "ENOENT") throw err;
393
403
  }
394
404
  const salt = randomBytes(KEY_LEN);
395
- await mkdir3(dirname3(paths.keystoreSaltFile), { recursive: true });
405
+ await mkdir3(dirname4(paths.keystoreSaltFile), { recursive: true });
396
406
  const tmp = `${paths.keystoreSaltFile}.tmp-${process.pid}`;
397
407
  await writeFile3(tmp, salt);
398
408
  await chmod3(tmp, 384);
@@ -2618,6 +2628,7 @@ var RunCardStream = class {
2618
2628
  function openChatUrl(chatId) {
2619
2629
  return `https://applink.feishu.cn/client/chat/open?openChatId=${encodeURIComponent(chatId)}`;
2620
2630
  }
2631
+ var REPO = "https://github.com/modelzen/feishu-codex-bridge";
2621
2632
  var DM = {
2622
2633
  menu: "dm.menu",
2623
2634
  newProject: "dm.newProject",
@@ -2739,6 +2750,74 @@ function buildUpdateCard(state) {
2739
2750
  );
2740
2751
  }
2741
2752
  }
2753
+ function connLabel(state) {
2754
+ switch (state) {
2755
+ case "connected":
2756
+ return "\u2705 \u5DF2\u8FDE\u63A5";
2757
+ case "connecting":
2758
+ return "\u23F3 \u8FDE\u63A5\u4E2D";
2759
+ case "reconnecting":
2760
+ return "\u21BB \u91CD\u8FDE\u4E2D";
2761
+ case "disconnected":
2762
+ return "\u274C \u5DF2\u65AD\u5F00";
2763
+ default:
2764
+ return state;
2765
+ }
2766
+ }
2767
+ function codexDiagnosePrompt(i) {
2768
+ return [
2769
+ "\u6211\u5728\u7528 feishu-codex-bridge\uFF08\u98DE\u4E66 \u2194 \u672C\u5730 Codex \u6865\u63A5\uFF09\u9047\u5230\u95EE\u9898\uFF0C\u8BF7\u5E2E\u6211\u5B9A\u4F4D\u539F\u56E0\u5E76\u7ED9\u51FA\u4FEE\u590D\u6B65\u9AA4\u3002",
2770
+ "",
2771
+ "\u3010\u73AF\u5883\u3011",
2772
+ `- bridge \u7248\u672C\uFF1Av${i.bridgeVer}`,
2773
+ `- codex \u7248\u672C\uFF1A${i.codexVer ?? "\u672A\u627E\u5230\uFF08PATH / CODEX_BIN \u91CC\u90FD\u6CA1\u6709 codex\uFF09"}`,
2774
+ `- Node\uFF1A${i.node}`,
2775
+ `- \u5E73\u53F0\uFF1A${i.platform}`,
2776
+ `- \u9879\u76EE\u4ED3\u5E93\uFF1A${REPO}`,
2777
+ "",
2778
+ "\u3010\u8FD0\u884C\u5FEB\u7167\u3011",
2779
+ `- codex \u53EF\u7528\uFF1A${i.codexOk ? "\u662F" : "\u5426"}`,
2780
+ `- \u98DE\u4E66\u957F\u8FDE\u63A5\uFF1A${i.conn}`,
2781
+ "",
2782
+ "\u3010\u8BF7\u4F60\u505A\u7684\u4E8B\u3011",
2783
+ "1. \u8BFB\u53D6\u5E76\u5206\u6790\u65E5\u5FD7\uFF0C\u627E\u51FA\u6700\u8FD1\u7684\u62A5\u9519\u6216\u5F02\u5E38\u5806\u6808\uFF1A",
2784
+ ` - \u540E\u53F0\u5B88\u62A4\u8F93\u51FA\u65E5\u5FD7\uFF1A${i.logStdout}`,
2785
+ ` - \u540E\u53F0\u5B88\u62A4\u9519\u8BEF\u65E5\u5FD7\uFF1A${i.logStderr}`,
2786
+ " \uFF08\u82E5\u662F\u524D\u53F0 feishu-codex-bridge run \u6A21\u5F0F\uFF0C\u65E5\u5FD7\u5728\u542F\u52A8\u5B83\u7684\u7EC8\u7AEF\u7A97\u53E3\uFF0C\u8BF7\u628A\u7EC8\u7AEF\u91CC\u7684\u62A5\u9519\u4E00\u8D77\u53D1\u6211\uFF09",
2787
+ `2. \u5224\u65AD\u95EE\u9898\u5C5E\u4E8E\u54EA\u7C7B\uFF1Acodex \u542F\u52A8 / \u767B\u5F55\u3001\u98DE\u4E66\u9274\u6743\u6216\u6743\u9650\u4E0D\u8DB3\u3001\u957F\u8FDE\u63A5\u65AD\u5F00\u3001\u8FD8\u662F\u914D\u7F6E\u7F3A\u5931\uFF08\u914D\u7F6E\u6587\u4EF6\uFF1A${i.configFile}\uFF09\u3002`,
2788
+ `3. \u5FC5\u8981\u65F6\u5BF9\u7167\u4ED3\u5E93 README \u4E0E issues \u7ED9\u65B9\u6848\uFF1A${REPO}/issues`,
2789
+ "4. \u7ED9\u51FA\u53EF\u76F4\u63A5\u6267\u884C\u7684\u4FEE\u590D\u6B65\u9AA4\u3002",
2790
+ "",
2791
+ "\u3010\u6211\u9047\u5230\u7684\u73B0\u8C61\u3011",
2792
+ "\uFF08\u5728\u8FD9\u91CC\u8865\u5145\uFF1A\u6BD4\u5982 @\u673A\u5668\u4EBA\u4E0D\u56DE\u590D / \u5361\u7247\u6309\u94AE\u70B9\u4E86\u6CA1\u53CD\u5E94 / \u542F\u52A8\u5C31\u62A5\u9519\u2026\u2026\uFF09"
2793
+ ].join("\n");
2794
+ }
2795
+ function buildDoctorCard(i) {
2796
+ const prompt = codexDiagnosePrompt(i);
2797
+ return card(
2798
+ [
2799
+ md("**\u521D\u6B65\u8BCA\u65AD**"),
2800
+ md(
2801
+ `- Codex\uFF1A${i.codexOk ? `\u2705 \u53EF\u7528${i.codexVer ? `\uFF08${i.codexVer}\uFF09` : ""}` : "\u274C \u4E0D\u53EF\u7528\uFF08\u68C0\u67E5 CODEX_BIN / PATH\uFF09"}`
2802
+ ),
2803
+ md(`- \u98DE\u4E66\u957F\u8FDE\u63A5\uFF1A${connLabel(i.conn)}`),
2804
+ note(`bridge v${i.bridgeVer}\u3000\xB7\u3000Node ${i.node}\u3000\xB7\u3000${i.platform}`),
2805
+ hr(),
2806
+ md("**\u65E5\u5FD7\u8DEF\u5F84**"),
2807
+ note(`\u540E\u53F0\u5B88\u62A4\u8F93\u51FA\uFF1A\`${i.logStdout}\``),
2808
+ note(`\u540E\u53F0\u5B88\u62A4\u9519\u8BEF\uFF1A\`${i.logStderr}\``),
2809
+ note("\u524D\u53F0 `run` \u6A21\u5F0F\uFF1A\u65E5\u5FD7\u5728\u542F\u52A8\u5B83\u7684\u7EC8\u7AEF\u7A97\u53E3\u91CC"),
2810
+ hr(),
2811
+ md("**\u8BA9 Codex \u5E2E\u4F60\u6DF1\u5EA6\u8BCA\u65AD** \u2014 \u590D\u5236\u4E0B\u9762\u6574\u6BB5\uFF0C\u5230\u4EFB\u610F\u9879\u76EE\u7FA4\u91CC **@\u6211** \u7C98\u8D34\u53D1\u9001\uFF1A"),
2812
+ md("```\n" + prompt + "\n```"),
2813
+ actions([
2814
+ linkButton("\u{1F4E6} \u9879\u76EE\u4ED3\u5E93", REPO),
2815
+ linkButton("\u{1F41E} \u63D0 Issue", `${REPO}/issues`)
2816
+ ])
2817
+ ],
2818
+ { header: { title: "\u{1FA7A} \u8BCA\u65AD", template: i.codexOk ? "blue" : "orange" } }
2819
+ );
2820
+ }
2742
2821
  function buildNewProjectFormCard(opts = {}) {
2743
2822
  const elements = [];
2744
2823
  if (opts.error) elements.push(md(`\u274C **\u521B\u5EFA\u5931\u8D25**\uFF1A${opts.error}`));
@@ -2873,9 +2952,9 @@ function buildGroupSettingsCard(project) {
2873
2952
 
2874
2953
  // src/service/update.ts
2875
2954
  import { execFile, spawn as spawn5 } from "child_process";
2876
- import { existsSync as existsSync5, readFileSync } from "fs";
2877
- import { dirname as dirname5, join as join8, resolve as resolve2 } from "path";
2878
- import { fileURLToPath as fileURLToPath2 } from "url";
2955
+ import { existsSync as existsSync5, readFileSync as readFileSync2 } from "fs";
2956
+ import { dirname as dirname6, join as join8, resolve as resolve3 } from "path";
2957
+ import { fileURLToPath as fileURLToPath3 } from "url";
2879
2958
  import { promisify } from "util";
2880
2959
 
2881
2960
  // src/service/launchd.ts
@@ -2883,8 +2962,8 @@ import { spawn as spawn4, spawnSync } from "child_process";
2883
2962
  import { existsSync as existsSync4 } from "fs";
2884
2963
  import { appendFile, mkdir as mkdir4, rm as rm2, writeFile as writeFile4 } from "fs/promises";
2885
2964
  import { homedir as homedir3, userInfo as userInfo2 } from "os";
2886
- import { dirname as dirname4, join as join7, resolve } from "path";
2887
- import { fileURLToPath } from "url";
2965
+ import { dirname as dirname5, join as join7, resolve as resolve2 } from "path";
2966
+ import { fileURLToPath as fileURLToPath2 } from "url";
2888
2967
  var LAUNCHD_LABEL = "ai.feishu-codex-bridge.bot";
2889
2968
  function launchAgentPlistPath() {
2890
2969
  return join7(homedir3(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
@@ -2896,8 +2975,8 @@ function serviceStderrPath() {
2896
2975
  return join7(paths.appDir, "service.err.log");
2897
2976
  }
2898
2977
  function resolveCliBinPath() {
2899
- const distDir = dirname4(fileURLToPath(import.meta.url));
2900
- return resolve(distDir, "..", "bin", "feishu-codex-bridge.mjs");
2978
+ const distDir = dirname5(fileURLToPath2(import.meta.url));
2979
+ return resolve2(distDir, "..", "bin", "feishu-codex-bridge.mjs");
2901
2980
  }
2902
2981
  function escapeXml(value) {
2903
2982
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
@@ -2937,7 +3016,7 @@ function buildPlist() {
2937
3016
  }
2938
3017
  async function installLaunchd() {
2939
3018
  const plistPath = launchAgentPlistPath();
2940
- await mkdir4(dirname4(plistPath), { recursive: true });
3019
+ await mkdir4(dirname5(plistPath), { recursive: true });
2941
3020
  await ensureLogFiles();
2942
3021
  await writeFile4(plistPath, buildPlist(), "utf8");
2943
3022
  if (isLoaded()) {
@@ -2962,9 +3041,9 @@ async function restartLaunchd() {
2962
3041
  throw new Error(`launchd service \u672A\u5B89\u88C5\uFF1A${launchAgentPlistPath()}`);
2963
3042
  }
2964
3043
  if (isLoaded()) {
2965
- const bootout = runLaunchctl(["bootout", serviceTarget()]);
2966
- if (!bootout.ok) throw launchctlError("launchctl bootout", bootout);
2967
- await waitUntilUnloaded();
3044
+ const kick = runLaunchctl(["kickstart", "-k", serviceTarget()]);
3045
+ if (!kick.ok) throw launchctlError("launchctl kickstart", kick);
3046
+ return statusLaunchd();
2968
3047
  }
2969
3048
  const bootstrap = runLaunchctl(["bootstrap", userTarget(), launchAgentPlistPath()]);
2970
3049
  if (!bootstrap.ok) throw launchctlError("launchctl bootstrap", bootstrap);
@@ -3063,11 +3142,11 @@ function getServiceAdapter() {
3063
3142
  var execFileP = promisify(execFile);
3064
3143
  var NPM = process.platform === "win32" ? "npm.cmd" : "npm";
3065
3144
  function pkgRoot() {
3066
- return resolve2(dirname5(fileURLToPath2(import.meta.url)), "..");
3145
+ return resolve3(dirname6(fileURLToPath3(import.meta.url)), "..");
3067
3146
  }
3068
3147
  function pkgJson() {
3069
3148
  try {
3070
- return JSON.parse(readFileSync(join8(pkgRoot(), "package.json"), "utf8"));
3149
+ return JSON.parse(readFileSync2(join8(pkgRoot(), "package.json"), "utf8"));
3071
3150
  } catch {
3072
3151
  return {};
3073
3152
  }
@@ -3130,7 +3209,7 @@ async function restartDaemon() {
3130
3209
 
3131
3210
  // src/project/registry.ts
3132
3211
  import { mkdir as mkdir5, readFile as readFile5, rename as rename4, writeFile as writeFile5 } from "fs/promises";
3133
- import { dirname as dirname6 } from "path";
3212
+ import { dirname as dirname7 } from "path";
3134
3213
  var FILE_VERSION2 = 1;
3135
3214
  async function read() {
3136
3215
  try {
@@ -3143,7 +3222,7 @@ async function read() {
3143
3222
  }
3144
3223
  }
3145
3224
  async function write(projects) {
3146
- await mkdir5(dirname6(paths.projectsFile), { recursive: true });
3225
+ await mkdir5(dirname7(paths.projectsFile), { recursive: true });
3147
3226
  const tmp = `${paths.projectsFile}.tmp-${process.pid}`;
3148
3227
  const body = { version: FILE_VERSION2, projects };
3149
3228
  await writeFile5(tmp, `${JSON.stringify(body, null, 2)}
@@ -3189,7 +3268,7 @@ async function removeProject(name) {
3189
3268
  // src/project/lifecycle.ts
3190
3269
  import { mkdir as mkdir6 } from "fs/promises";
3191
3270
  import { existsSync as existsSync6 } from "fs";
3192
- import { isAbsolute, join as join9, resolve as resolve3 } from "path";
3271
+ import { isAbsolute, join as join9, resolve as resolve4 } from "path";
3193
3272
 
3194
3273
  // src/project/git-info.ts
3195
3274
  import { execFile as execFile2 } from "child_process";
@@ -3327,7 +3406,7 @@ async function createProject(channel, input2) {
3327
3406
  let cwd;
3328
3407
  let blank;
3329
3408
  if (input2.existingPath) {
3330
- cwd = isAbsolute(input2.existingPath) ? input2.existingPath : resolve3(input2.existingPath);
3409
+ cwd = isAbsolute(input2.existingPath) ? input2.existingPath : resolve4(input2.existingPath);
3331
3410
  if (!existsSync6(cwd)) throw new Error(`\u6587\u4EF6\u5939\u4E0D\u5B58\u5728\uFF1A${cwd}`);
3332
3411
  blank = false;
3333
3412
  } else {
@@ -3366,7 +3445,7 @@ async function transferOwnership(channel, chatId, toOpenId) {
3366
3445
 
3367
3446
  // src/bot/session-store.ts
3368
3447
  import { mkdir as mkdir7, readFile as readFile6, rename as rename5, writeFile as writeFile6 } from "fs/promises";
3369
- import { dirname as dirname7 } from "path";
3448
+ import { dirname as dirname8 } from "path";
3370
3449
  var FILE_VERSION3 = 1;
3371
3450
  async function read2() {
3372
3451
  try {
@@ -3379,7 +3458,7 @@ async function read2() {
3379
3458
  }
3380
3459
  }
3381
3460
  async function write2(sessions) {
3382
- await mkdir7(dirname7(paths.sessionsFile), { recursive: true });
3461
+ await mkdir7(dirname8(paths.sessionsFile), { recursive: true });
3383
3462
  const tmp = `${paths.sessionsFile}.tmp-${process.pid}`;
3384
3463
  const body = { version: FILE_VERSION3, sessions };
3385
3464
  await writeFile6(tmp, `${JSON.stringify(body, null, 2)}
@@ -4122,11 +4201,21 @@ function createOrchestrator(channel, cfg, fallbackCwd) {
4122
4201
  if (dmAdmin(evt.operator?.openId)) await patch(evt, buildSettingsCard(cfg));
4123
4202
  }).on(DM.doctor, async ({ evt }) => {
4124
4203
  if (!dmAdmin(evt.operator?.openId)) return;
4125
- const ok = await backend.isAvailable().catch(() => false);
4126
- const conn = channel.getConnectionStatus?.()?.state ?? "unknown";
4127
- await channel.send(evt.chatId, { markdown: `\u{1FA7A} **\u8BCA\u65AD**
4128
- - codex: ${ok ? "\u2705 \u53EF\u7528" : "\u274C \u4E0D\u53EF\u7528\uFF08\u68C0\u67E5 CODEX_BIN/PATH\uFF09"}
4129
- - \u957F\u8FDE\u63A5: ${conn}` }, { replyTo: evt.messageId }).catch(() => void 0);
4204
+ const codexBin = resolveCodexBin();
4205
+ const info = {
4206
+ codexOk: await backend.isAvailable().catch(() => false),
4207
+ codexVer: codexBin ? codexVersion(codexBin) : null,
4208
+ conn: channel.getConnectionStatus?.()?.state ?? "unknown",
4209
+ bridgeVer: bridgeVersion(),
4210
+ node: process.version,
4211
+ platform: `${process.platform}-${process.arch}`,
4212
+ logStdout: serviceStdoutPath(),
4213
+ logStderr: serviceStderrPath(),
4214
+ configFile: paths.configFile
4215
+ };
4216
+ await sendManagedCard(channel, evt.chatId, buildDoctorCard(info), evt.messageId).catch(
4217
+ (err) => log.fail("console", err, { cmd: "doctor" })
4218
+ );
4130
4219
  }).on(DM.reconnect, async ({ evt }) => {
4131
4220
  if (!dmAdmin(evt.operator?.openId)) return;
4132
4221
  const conn = channel.getConnectionStatus?.()?.state ?? "unknown";
@@ -4585,8 +4674,8 @@ async function startBridge(opts) {
4585
4674
  }
4586
4675
 
4587
4676
  // src/core/single-instance.ts
4588
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, unlinkSync, writeFileSync } from "fs";
4589
- import { dirname as dirname8 } from "path";
4677
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, unlinkSync, writeFileSync } from "fs";
4678
+ import { dirname as dirname9 } from "path";
4590
4679
  var BridgeAlreadyRunningError = class extends Error {
4591
4680
  constructor(pid) {
4592
4681
  super(
@@ -4608,20 +4697,20 @@ function isAlive(pid) {
4608
4697
  function acquireSingleInstanceLock(appId) {
4609
4698
  const file = paths.processesFile;
4610
4699
  try {
4611
- const rec = JSON.parse(readFileSync2(file, "utf8"));
4700
+ const rec = JSON.parse(readFileSync3(file, "utf8"));
4612
4701
  if (rec.pid && rec.pid !== process.pid && rec.appId === appId && isAlive(rec.pid)) {
4613
4702
  throw new BridgeAlreadyRunningError(rec.pid);
4614
4703
  }
4615
4704
  } catch (err) {
4616
4705
  if (err instanceof BridgeAlreadyRunningError) throw err;
4617
4706
  }
4618
- mkdirSync2(dirname8(file), { recursive: true });
4707
+ mkdirSync2(dirname9(file), { recursive: true });
4619
4708
  const record = { pid: process.pid, appId, startedAt: Date.now() };
4620
4709
  writeFileSync(file, `${JSON.stringify(record)}
4621
4710
  `, "utf8");
4622
4711
  const release = () => {
4623
4712
  try {
4624
- const rec = JSON.parse(readFileSync2(file, "utf8"));
4713
+ const rec = JSON.parse(readFileSync3(file, "utf8"));
4625
4714
  if (rec.pid === process.pid) unlinkSync(file);
4626
4715
  } catch {
4627
4716
  }
@@ -4892,15 +4981,7 @@ function readStdin() {
4892
4981
 
4893
4982
  // src/cli/index.ts
4894
4983
  var program = new Command();
4895
- function readVersion() {
4896
- try {
4897
- const pkgPath = resolve4(dirname9(fileURLToPath3(import.meta.url)), "..", "package.json");
4898
- return JSON.parse(readFileSync3(pkgPath, "utf8")).version ?? "0.0.0";
4899
- } catch {
4900
- return "0.0.0";
4901
- }
4902
- }
4903
- program.name("feishu-codex-bridge").description("\u628A\u98DE\u4E66/Lark \u6865\u63A5\u5230\u672C\u673A Codex\uFF08\u9879\u76EE=\u7FA4, \u8BDD\u9898=\u4F1A\u8BDD\uFF09").version(readVersion());
4984
+ program.name("feishu-codex-bridge").description("\u628A\u98DE\u4E66/Lark \u6865\u63A5\u5230\u672C\u673A Codex\uFF08\u9879\u76EE=\u7FA4, \u8BDD\u9898=\u4F1A\u8BDD\uFF09").version(bridgeVersion());
4904
4985
  program.command("run").description("\u524D\u53F0\u542F\u52A8 bot\uFF08\u6CA1\u914D\u7F6E\u5219\u5148\u626B\u7801 init\uFF1BCtrl+C \u4F18\u96C5\u9000\u51FA\uFF09").action(async () => {
4905
4986
  await runRun();
4906
4987
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelzen/feishu-codex-bridge",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Bridge Feishu/Lark messenger with local Codex via app-server (project=group, thread=session)",
5
5
  "type": "module",
6
6
  "bin": {