@openai-lite/codex-feishu 0.1.0 → 0.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openai-lite/codex-feishu",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Feishu bridge for Codex with dual-end synchronized conversations.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli.js CHANGED
@@ -85,6 +85,7 @@ export async function runCli(argv) {
85
85
  await runInit(flags, { startDaemon });
86
86
  if (startDaemon) {
87
87
  const result = await restartDaemonDetached();
88
+ const bindWaitMs = process.platform === "win32" ? 40000 : 20000;
88
89
  // eslint-disable-next-line no-console
89
90
  console.log("\nDaemon:");
90
91
  // eslint-disable-next-line no-console
@@ -106,13 +107,13 @@ export async function runCli(argv) {
106
107
  // eslint-disable-next-line no-console
107
108
  console.log(`- Watch log: ${watchLogCommand(result.logPath)}`);
108
109
  // eslint-disable-next-line no-console
109
- console.log("- Bind: waiting for daemon readiness (up to 20s)...");
110
+ console.log(`- Bind: waiting for daemon readiness (up to ${Math.round(bindWaitMs / 1000)}s)...`);
110
111
 
111
112
  try {
112
113
  const qr = await fetchQrcodeWithRetry({
113
114
  purpose: "init_daemon_start",
114
115
  cwdHint: process.cwd(),
115
- maxWaitMs: 20000,
116
+ maxWaitMs: bindWaitMs,
116
117
  intervalMs: 500,
117
118
  timeoutMs: 1500,
118
119
  });
@@ -120,6 +120,7 @@ async function trySpawnDetached(cmd, args, logPath) {
120
120
 
121
121
  return await new Promise((resolve) => {
122
122
  let settled = false;
123
+ const graceMs = process.platform === "win32" ? 1500 : 800;
123
124
  const finish = (value) => {
124
125
  if (settled) {
125
126
  return;
@@ -133,13 +134,25 @@ async function trySpawnDetached(cmd, args, logPath) {
133
134
  resolve(value);
134
135
  };
135
136
 
137
+ child.once("exit", (code, signal) => {
138
+ finish({
139
+ ok: false,
140
+ error: `process exited early (cmd=${cmd}) code=${code ?? "null"} signal=${signal ?? "null"}`,
141
+ });
142
+ });
143
+
136
144
  child.once("error", (err) => {
137
145
  finish({ ok: false, error: err?.message ?? String(err) });
138
146
  });
139
147
 
140
148
  child.once("spawn", () => {
141
- child.unref();
142
- finish({ ok: true, pid: child.pid });
149
+ setTimeout(() => {
150
+ if (settled) {
151
+ return;
152
+ }
153
+ child.unref();
154
+ finish({ ok: true, pid: child.pid });
155
+ }, graceMs);
143
156
  });
144
157
  });
145
158
  }
@@ -168,11 +181,24 @@ export async function restartDaemonDetached() {
168
181
  }
169
182
  await removePidFile();
170
183
 
171
- let startResult = await trySpawnDetached("codex-feishu", ["daemon"], logPath);
172
- if (!startResult.ok) {
173
- const entry = process.argv[1];
184
+ const entry = process.argv[1];
185
+ const attempts = [];
186
+ if (process.platform === "win32" && entry) {
187
+ attempts.push([process.execPath, [entry, "daemon"]]);
188
+ attempts.push(["codex-feishu", ["daemon"]]);
189
+ } else {
190
+ attempts.push(["codex-feishu", ["daemon"]]);
174
191
  if (entry) {
175
- startResult = await trySpawnDetached(process.execPath, [entry, "daemon"], logPath);
192
+ attempts.push([process.execPath, [entry, "daemon"]]);
193
+ }
194
+ }
195
+
196
+ let startResult = { ok: false, error: "no_start_attempt" };
197
+ for (const [cmd, args] of attempts) {
198
+ // eslint-disable-next-line no-await-in-loop
199
+ startResult = await trySpawnDetached(cmd, args, logPath);
200
+ if (startResult.ok) {
201
+ break;
176
202
  }
177
203
  }
178
204
  if (!startResult.ok) {