aai-lark-bridge 0.1.9 → 0.2.0

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
@@ -47,6 +47,10 @@ lark-cli --version # 见下方说明
47
47
  会话;不要通过删历史、改会话元数据或自动另开会话处理兼容问题。
48
48
  - 启动失败会显示 stderr 的最后 500 字符,避免真正的终止错误被前面的插件警告盖住。
49
49
 
50
+ ### SDLC 文档评论确认(可选)
51
+
52
+ `preferences.sdlcConfirmationWorkspace` 可设为 SDLC 工作区绝对路径,默认关闭。普通文档评论先保存最小线索,再唤醒固定只读核验;事件正文不作为授权。需同时安装并启用 SDLC 评论核验,部署后实测事件覆盖;配置与暂停方式见仓库 `plugins/aai-sdlc/agent/README.md`。
53
+
50
54
  ### 第 2 步:安装
51
55
 
52
56
  ```bash
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.1.9",
7
+ version: "0.2.0",
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",
@@ -6987,7 +6987,7 @@ function isWindowsCommandNotFoundLine2(line) {
6987
6987
 
6988
6988
  // src/bridge/bot/channel.ts
6989
6989
  import { createLarkChannel } from "@larksuite/channel";
6990
- import { dirname as dirname18, join as join23 } from "path";
6990
+ import { dirname as dirname18, join as join24 } from "path";
6991
6991
 
6992
6992
  // src/bridge/agent/capability.ts
6993
6993
  function claudeCapability(profile2) {
@@ -13388,6 +13388,46 @@ function preview(text) {
13388
13388
  return text.length > 80 ? `${text.slice(0, 80)}\u2026` : text;
13389
13389
  }
13390
13390
 
13391
+ // src/bridge/bot/doc-confirmation.ts
13392
+ import { createHash as createHash6 } from "crypto";
13393
+ import { mkdirSync as mkdirSync4, realpathSync, renameSync as renameSync3, writeFileSync as writeFileSync4 } from "fs";
13394
+ import { isAbsolute as isAbsolute4, join as join23, sep as sep2 } from "path";
13395
+ import { spawn } from "child_process";
13396
+ var waking = /* @__PURE__ */ new Set();
13397
+ function enqueueDocConfirmation(workspace, event, { selfReply = false } = {}) {
13398
+ if (!workspace || selfReply) return false;
13399
+ if (!isAbsolute4(workspace)) throw new Error("SDLC \u5DE5\u4F5C\u533A\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84");
13400
+ if (event.fileType !== "docx") return false;
13401
+ if (![event.fileToken, event.commentId, event.replyId ?? "none"].every((x) => /^[\w:-]{1,128}$/.test(x))) return false;
13402
+ const root = realpathSync(workspace);
13403
+ const script = realpathSync(join23(root, ".sdlc-intake/intake.mjs"));
13404
+ if (!script.startsWith(root + sep2)) throw new Error("SDLC \u6838\u9A8C\u5165\u53E3\u8D85\u51FA\u5DE5\u4F5C\u533A");
13405
+ const inbox = join23(root, ".sdlc-intake/state/confirmation-inbox");
13406
+ mkdirSync4(inbox, { recursive: true });
13407
+ if (!realpathSync(inbox).startsWith(root + sep2)) throw new Error("SDLC \u6536\u4EF6\u76EE\u5F55\u8D85\u51FA\u5DE5\u4F5C\u533A");
13408
+ const { fileToken: fileId, commentId: comment_id } = event;
13409
+ const hint = { file_token: fileId, comment_id, reply_id: event.replyId ?? null, received_at: (/* @__PURE__ */ new Date()).toISOString() };
13410
+ const key = createHash6("sha256").update(JSON.stringify([hint.file_token, hint.comment_id, hint.reply_id])).digest("hex");
13411
+ const target = join23(inbox, key + ".json");
13412
+ const tmp = target + `.new-${process.pid}`;
13413
+ writeFileSync4(tmp, JSON.stringify(hint), { mode: 384 });
13414
+ renameSync3(tmp, target);
13415
+ if (!waking.has(root)) {
13416
+ waking.add(root);
13417
+ try {
13418
+ const env = Object.fromEntries(Object.entries(process.env).filter(([key2]) => !key2.startsWith("LARK_CHANNEL") && !key2.startsWith("LARKSUITE_CLI_")));
13419
+ const child = spawn(process.execPath, [script, "reconcile-confirmations"], { cwd: root, env, stdio: "ignore", timeout: 7e4 });
13420
+ child.once("error", () => waking.delete(root));
13421
+ child.once("exit", () => waking.delete(root));
13422
+ child.unref();
13423
+ } catch (err) {
13424
+ waking.delete(root);
13425
+ throw err;
13426
+ }
13427
+ }
13428
+ return true;
13429
+ }
13430
+
13391
13431
  // src/bridge/bot/inbound-mark.ts
13392
13432
  import { readFile as readFile14 } from "fs/promises";
13393
13433
  function inboundGapFields(prev, now) {
@@ -14304,7 +14344,7 @@ async function startChannel(deps) {
14304
14344
  const pool = new ProcessPool(() => getMaxConcurrentRuns(controls.cfg));
14305
14345
  const executor = new RunExecutor({ agent, pool, activeRuns });
14306
14346
  const appSecret = await resolveAppSecret(cfg, deps.appPaths);
14307
- const callbackNonceStore = deps.appPaths?.mediaDir ? new CallbackNonceStore(join23(dirname18(deps.appPaths.mediaDir), "callback-nonces.json")) : void 0;
14347
+ const callbackNonceStore = deps.appPaths?.mediaDir ? new CallbackNonceStore(join24(dirname18(deps.appPaths.mediaDir), "callback-nonces.json")) : void 0;
14308
14348
  await callbackNonceStore?.load();
14309
14349
  const callbackAuth = callbackNonceStore ? new CallbackAuth({
14310
14350
  keys: [{ version: 1, secret: appSecret }],
@@ -14472,6 +14512,11 @@ async function startChannel(deps) {
14472
14512
  },
14473
14513
  comment: async (evt) => {
14474
14514
  markInbound("comment");
14515
+ try {
14516
+ enqueueDocConfirmation(controls.profileConfig.preferences.sdlcConfirmationWorkspace, evt, { selfReply: isBridgeSelfReply(channel, evt) });
14517
+ } catch (err) {
14518
+ log.fail("doc-confirmation", err);
14519
+ }
14475
14520
  await withTrace({ chatId: "comment" }, async () => {
14476
14521
  await handleCommentMention({
14477
14522
  channel,