aai-lark-bridge 0.2.35 → 0.2.36

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/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import { Command } from "commander";
4
4
  // package.json
5
5
  var package_default = {
6
6
  name: "aai-lark-bridge",
7
- version: "0.2.35",
7
+ version: "0.2.36",
8
8
  description: "Lark AI Native Bridge - Lark\u57FA\u7840\u8BBE\u65BD\u5C42\u548CCLI\u96C6\u6210",
9
9
  type: "module",
10
10
  main: "./dist/index.js",
@@ -7545,15 +7545,26 @@ function seatCovers(cfg, senderId) {
7545
7545
  function isClaudeLogout(text) {
7546
7546
  return text.trim() === LOGOUT_TEXT;
7547
7547
  }
7548
+ var SEAT_REUSE_TTL_MS = 15 * 6e4;
7549
+ var issuedSeat = /* @__PURE__ */ new Map();
7548
7550
  async function requestClaudeSeat(cfg, msg, deps = {}) {
7549
7551
  if (!seatCovers(cfg, msg.senderId)) return { kind: "shared" };
7552
+ const nowMs = Date.now();
7553
+ for (const [id, v] of issuedSeat) if (nowMs - v.at > SEAT_REUSE_TTL_MS) issuedSeat.delete(id);
7554
+ const reused = issuedSeat.get(msg.messageId);
7555
+ if (reused) {
7556
+ log.info("claude-seat", "reuse", { messageId: msg.messageId });
7557
+ return { kind: "token", env: { ...reused.env } };
7558
+ }
7550
7559
  const runId = `seat-${randomBytes5(8).toString("hex")}`;
7551
7560
  try {
7552
7561
  const r = await callGateway(cfg, "POST", "/claude/token", { messageId: msg.messageId, runId }, deps);
7553
7562
  log.info("claude-seat", "token", { messageId: msg.messageId, status: String(r.status) });
7554
7563
  switch (r.status) {
7555
7564
  case "ok":
7556
- return typeof r.token === "string" && r.token ? { kind: "token", env: { [CLAUDE_TOKEN_ENV]: r.token } } : { kind: "reply", text: SEAT_TEXT.unavailable };
7565
+ if (typeof r.token !== "string" || !r.token) return { kind: "reply", text: SEAT_TEXT.unavailable };
7566
+ issuedSeat.set(msg.messageId, { env: { [CLAUDE_TOKEN_ENV]: r.token }, at: nowMs });
7567
+ return { kind: "token", env: { [CLAUDE_TOKEN_ENV]: r.token } };
7557
7568
  case "need_login":
7558
7569
  return { kind: "reply", text: SEAT_TEXT.needLogin };
7559
7570
  case "login_pending":