aai-lark-bridge 0.2.50 → 0.2.51

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.50",
7
+ version: "0.2.51",
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",
@@ -21489,7 +21489,7 @@ function createGateway(opts) {
21489
21489
  sweep();
21490
21490
  const h = handles.get(handle2);
21491
21491
  if (!h) noteExpired("read.expired", api, handle2);
21492
- if (!h || h.kind !== "dm") return { status: "expired" };
21492
+ if (!h || h.kind !== "dm" && !(h.kind === "task" && h.read)) return { status: "expired" };
21493
21493
  if (!h.read) {
21494
21494
  log.info("user-gateway", "read.need-auth", { identity: "user", sender: tail6(h.openId), messageId: h.messageId, runId: h.runId, api, detail: "handle-without-read" });
21495
21495
  return { status: "need_auth" };
@@ -21633,6 +21633,7 @@ function createGateway(opts) {
21633
21633
  /**
21634
21634
  * POST /db/task-handle:调度的只读运行(只读分析、出文档、补报告)起 claude 前凭任务申请查库句柄(intent 0049 R-04)。
21635
21635
  * 负责人得是这个任务的 assignee(网关向飞书核对,同 0048 的 /claude/task-token);不看私聊查库名单(spec D-3)。
21636
+ * 带 userRead: true(intent 0113 R-09,只给查证运行):负责人已授权就签 read: true 的读句柄,查库关着也能签;没授权回 need_auth,不发授权卡片、不签句柄。
21636
21637
  * 评测(intent 0050,带 eval: true):评测的任务号不是真飞书任务,不带 taskGuid,只看查库总开关(intent 0068 起没有名单),日志记 task=eval。
21637
21638
  */
21638
21639
  async dbTaskHandle(input) {
@@ -21645,7 +21646,9 @@ function createGateway(opts) {
21645
21646
  } catch {
21646
21647
  return { status: "bad_request" };
21647
21648
  }
21648
- if (!db.enabled) return { status: "off" };
21649
+ const userRead = input.userRead === true;
21650
+ if (isEval && userRead) return { status: "bad_request" };
21651
+ if (!db.enabled && !userRead) return { status: "off" };
21649
21652
  if (taskGuid !== null) {
21650
21653
  const assignees = await taskAssignees(taskGuid);
21651
21654
  if (assignees === "lark_error") return { status: "lark_error" };
@@ -21654,10 +21657,14 @@ function createGateway(opts) {
21654
21657
  return { status: "not_assignee" };
21655
21658
  }
21656
21659
  }
21660
+ if (userRead && !isAuthorized(openId)) {
21661
+ log.info("user-gateway", "db.handle-refused", { sender: tail6(openId), runId, result: "need_auth" });
21662
+ return { status: "need_auth" };
21663
+ }
21657
21664
  const handle2 = randomBytes11(32).toString("base64url");
21658
21665
  const expiresAt = now() + TASK_HANDLE_TTL_MS;
21659
- handles.set(handle2, { openId, messageId: "", runId, expiresAt, kind: "task", db: true, read: false });
21660
- log.info("user-gateway", "db.handle-issued", { sender: tail6(openId), runId, task: taskGuid ?? "eval" });
21666
+ handles.set(handle2, { openId, messageId: "", runId, expiresAt, kind: "task", db: db.enabled, read: userRead });
21667
+ log.info("user-gateway", "db.handle-issued", { sender: tail6(openId), runId, task: taskGuid ?? "eval", read: userRead });
21661
21668
  return { status: "ok", handle: handle2, expiresAt };
21662
21669
  },
21663
21670
  /** POST /db/query:凭句柄替 agent 查一条,每次记一条 db.query(intent 0049 R-01、R-03、R-05)。 */