aai-lark-bridge 0.2.34 → 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 +14 -5
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
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.
|
|
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",
|
|
@@ -7244,12 +7244,10 @@ function createClaudeSeat(opts) {
|
|
|
7244
7244
|
if (!c) return { status: await startLogin(openId) };
|
|
7245
7245
|
const recent = now() - (refreshedAt.get(openId) ?? -Infinity) < REFRESH_COOLDOWN_MS && c.expiresAt - now() >= MIN_AFTER_REFRESH_MS;
|
|
7246
7246
|
if (c.expiresAt - now() < MIN_TOKEN_LEFT_MS && !recent) {
|
|
7247
|
-
const before = c.expiresAt;
|
|
7248
7247
|
const ok = await opts.cli.refresh(dir).catch(() => false);
|
|
7249
7248
|
c = readCredentials(dir);
|
|
7250
7249
|
const left = c ? c.expiresAt - now() : 0;
|
|
7251
|
-
|
|
7252
|
-
if (!ok || !c || !fresh) {
|
|
7250
|
+
if (!ok || !c || left < MIN_AFTER_REFRESH_MS) {
|
|
7253
7251
|
log.warn("user-gateway", "claude.refresh-failed", { sender: tail62(openId), proof, runId });
|
|
7254
7252
|
return { status: "refresh_failed" };
|
|
7255
7253
|
}
|
|
@@ -7547,15 +7545,26 @@ function seatCovers(cfg, senderId) {
|
|
|
7547
7545
|
function isClaudeLogout(text) {
|
|
7548
7546
|
return text.trim() === LOGOUT_TEXT;
|
|
7549
7547
|
}
|
|
7548
|
+
var SEAT_REUSE_TTL_MS = 15 * 6e4;
|
|
7549
|
+
var issuedSeat = /* @__PURE__ */ new Map();
|
|
7550
7550
|
async function requestClaudeSeat(cfg, msg, deps = {}) {
|
|
7551
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
|
+
}
|
|
7552
7559
|
const runId = `seat-${randomBytes5(8).toString("hex")}`;
|
|
7553
7560
|
try {
|
|
7554
7561
|
const r = await callGateway(cfg, "POST", "/claude/token", { messageId: msg.messageId, runId }, deps);
|
|
7555
7562
|
log.info("claude-seat", "token", { messageId: msg.messageId, status: String(r.status) });
|
|
7556
7563
|
switch (r.status) {
|
|
7557
7564
|
case "ok":
|
|
7558
|
-
|
|
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 } };
|
|
7559
7568
|
case "need_login":
|
|
7560
7569
|
return { kind: "reply", text: SEAT_TEXT.needLogin };
|
|
7561
7570
|
case "login_pending":
|