lark-coding-assistant 0.2.4 → 0.2.6

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 CHANGED
@@ -230,6 +230,8 @@ lca daemon restart
230
230
 
231
231
  `daemon stop/restart` 只断开或恢复飞书连接,不停止受管 tmux session。顶层 `stop [name]` 才会停止对应 agent 和 tmux session。
232
232
 
233
+ 电脑休眠或网络暂时断开时,飞书长连接会自动重连;这不会停止 daemon 或受管 tmux session。唤醒后等待连接恢复即可,只有明确执行 `lca daemon stop` 才会停止 daemon。
234
+
233
235
  `lca status` 会先显示 daemon 状态,再用一个表格列出全部 session;session 按 `codex`、`traex`、`claude` 分组排序,每个 session 占一行,当前连接使用 `●` 标记。表格同时显示终端状态、tmux 状态和绝对工作目录。使用 `lca status <name>` 可只查看指定 session;daemon 不可用时仍会读取本地状态,并将无法确认的运行信息明确标出。
234
236
 
235
237
  ## 绑定规则
@@ -2280,7 +2280,6 @@ var LarkGateway = class {
2280
2280
  source: "lark-coding-assistant",
2281
2281
  policy: { dmMode: "open", requireMention: false, respondToMentionAll: false },
2282
2282
  safety: { chatQueue: { enabled: true, mergeWhileBusy: false } },
2283
- handshakeTimeoutMs: 8e3,
2284
2283
  httpTimeoutMs: 3e4,
2285
2284
  respectProxyEnv: true
2286
2285
  });
@@ -4336,13 +4335,25 @@ ${escapeFence2(output).slice(-6500)}
4336
4335
  if (focusedIndex === targetIndex) return { ok: true };
4337
4336
  const direction = targetIndex > focusedIndex ? "Down" : "Up";
4338
4337
  await this.tmux.sendKey(paneId, direction);
4339
- await new Promise((resolve2) => setTimeout(resolve2, 40));
4340
- await this.poll();
4341
- const nextFocused = this.screen?.actions.findIndex(({ focused }) => focused) ?? -1;
4342
- if (nextFocused === focusedIndex) return { ok: false, error: "terminal focus did not move as expected" };
4338
+ const moved = await this.waitForFocusMove(interactionId, focusedIndex);
4339
+ if (!moved.ok) return moved;
4343
4340
  }
4344
4341
  return { ok: false, error: "terminal focus navigation exceeded its safe step limit" };
4345
4342
  }
4343
+ async waitForFocusMove(interactionId, previousIndex) {
4344
+ const deadline = Date.now() + 1200;
4345
+ while (Date.now() < deadline) {
4346
+ await new Promise((resolve2) => setTimeout(resolve2, 60));
4347
+ await this.poll();
4348
+ const interaction = this.screen?.interaction;
4349
+ if (!interaction || interaction.interactionId !== interactionId) {
4350
+ return { ok: false, error: "interaction changed while navigating; refusing action" };
4351
+ }
4352
+ const focusedIndex = this.screen?.actions.findIndex(({ focused }) => focused) ?? -1;
4353
+ if (focusedIndex !== -1 && focusedIndex !== previousIndex) return { ok: true };
4354
+ }
4355
+ return { ok: false, error: "terminal focus did not move before the navigation timeout" };
4356
+ }
4346
4357
  async waitForInteractionChange(interactionId) {
4347
4358
  const deadline = Date.now() + 1500;
4348
4359
  while (Date.now() < deadline) {
@@ -5207,6 +5218,14 @@ function resolveAppPaths(root = process.env.LARK_CODING_ASSISTANT_HOME) {
5207
5218
 
5208
5219
  // src/daemon-entry.ts
5209
5220
  import { readFile as readFile4 } from "fs/promises";
5221
+
5222
+ // src/daemon/transport-errors.ts
5223
+ function isRecoverableTransportError(error) {
5224
+ if (!(error instanceof Error)) return false;
5225
+ return error.message === "WebSocket was closed before the connection was established";
5226
+ }
5227
+
5228
+ // src/daemon-entry.ts
5210
5229
  var paths = resolveAppPaths();
5211
5230
  var packageInfo = JSON.parse(
5212
5231
  await readFile4(new URL("../package.json", import.meta.url), "utf8")
@@ -5233,10 +5252,18 @@ try {
5233
5252
  process.exitCode = 1;
5234
5253
  }
5235
5254
  process.on("uncaughtException", (error) => {
5255
+ if (isRecoverableTransportError(error)) {
5256
+ console.error(`${(/* @__PURE__ */ new Date()).toISOString()} daemon recoverable transport exception; keeping daemon alive`, error);
5257
+ return;
5258
+ }
5236
5259
  console.error(`${(/* @__PURE__ */ new Date()).toISOString()} daemon uncaught exception`, error);
5237
5260
  process.exit(1);
5238
5261
  });
5239
5262
  process.on("unhandledRejection", (error) => {
5263
+ if (isRecoverableTransportError(error)) {
5264
+ console.error(`${(/* @__PURE__ */ new Date()).toISOString()} daemon recoverable transport rejection; keeping daemon alive`, error);
5265
+ return;
5266
+ }
5240
5267
  console.error(`${(/* @__PURE__ */ new Date()).toISOString()} daemon unhandled rejection`, error);
5241
5268
  process.exit(1);
5242
5269
  });