aai-lark-bridge 0.2.27 → 0.2.29
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 +54 -4
- package/dist/cli.js.map +1 -1
- package/package.json +3 -2
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.29",
|
|
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",
|
|
@@ -59,7 +59,8 @@ var package_default = {
|
|
|
59
59
|
author: "Ariseai",
|
|
60
60
|
repository: {
|
|
61
61
|
type: "git",
|
|
62
|
-
url: "https://
|
|
62
|
+
url: "git+https://github.com/AriseAIEnterprise/ai-infra.git",
|
|
63
|
+
directory: "packages/aai-lark-bridge"
|
|
63
64
|
},
|
|
64
65
|
bin: {
|
|
65
66
|
"aai-lark-bridge": "./bin/aai-lark-bridge.mjs",
|
|
@@ -7694,6 +7695,7 @@ import {
|
|
|
7694
7695
|
existsSync as existsSync7,
|
|
7695
7696
|
linkSync,
|
|
7696
7697
|
mkdirSync as mkdirSync3,
|
|
7698
|
+
readdirSync,
|
|
7697
7699
|
readFileSync as readFileSync4,
|
|
7698
7700
|
realpathSync,
|
|
7699
7701
|
renameSync as renameSync2,
|
|
@@ -7807,6 +7809,41 @@ function taskOfMessage(dir, messageId) {
|
|
|
7807
7809
|
return void 0;
|
|
7808
7810
|
}
|
|
7809
7811
|
}
|
|
7812
|
+
var DISPATCH_MARKER = /^\s*(菜单|派活)·/;
|
|
7813
|
+
var DISPATCH_ROOT_TTL_MS = 7 * 24 * 36e5;
|
|
7814
|
+
function isDispatchMarker(text) {
|
|
7815
|
+
return typeof text === "string" && DISPATCH_MARKER.test(text);
|
|
7816
|
+
}
|
|
7817
|
+
function registerDispatchRoot(dir, rootMessageId, chatId, now = /* @__PURE__ */ new Date()) {
|
|
7818
|
+
if (!safeName(rootMessageId)) return;
|
|
7819
|
+
const folder = join20(dir, "dispatch");
|
|
7820
|
+
mkdirSync3(folder, { recursive: true });
|
|
7821
|
+
const file = join20(folder, `${rootMessageId}.json`);
|
|
7822
|
+
if (existsSync7(file)) return;
|
|
7823
|
+
const tmp = `${file}.${randomBytes6(4).toString("hex")}.tmp`;
|
|
7824
|
+
writeFileSync3(tmp, `${JSON.stringify({ chat_id: chatId, at: now.toISOString() })}
|
|
7825
|
+
`);
|
|
7826
|
+
renameSync2(tmp, file);
|
|
7827
|
+
pruneDispatchRoots(folder, now);
|
|
7828
|
+
}
|
|
7829
|
+
function pruneDispatchRoots(folder, now) {
|
|
7830
|
+
try {
|
|
7831
|
+
for (const name of readdirSync(folder)) {
|
|
7832
|
+
if (!name.endsWith(".json")) continue;
|
|
7833
|
+
const f = join20(folder, name);
|
|
7834
|
+
if (now.getTime() - statSync(f).mtimeMs > DISPATCH_ROOT_TTL_MS) rmSync2(f, { force: true });
|
|
7835
|
+
}
|
|
7836
|
+
} catch {
|
|
7837
|
+
}
|
|
7838
|
+
}
|
|
7839
|
+
function isDispatchRoot(dir, rootMessageId) {
|
|
7840
|
+
if (!rootMessageId || !safeName(rootMessageId)) return false;
|
|
7841
|
+
return existsSync7(join20(dir, "dispatch", `${rootMessageId}.json`));
|
|
7842
|
+
}
|
|
7843
|
+
function dispatchRoute(dir, m) {
|
|
7844
|
+
if (m.threadId) return isDispatchRoot(dir, m.rootId) ? "thread" : void 0;
|
|
7845
|
+
return isDispatchMarker(m.content) ? "start" : void 0;
|
|
7846
|
+
}
|
|
7810
7847
|
var LOCK_WAIT_MS = 2e3;
|
|
7811
7848
|
var LOCK_STEP_MS = 50;
|
|
7812
7849
|
var LOCK_STALE_MS = 1e4;
|
|
@@ -15980,6 +16017,18 @@ async function intakeMessage(deps) {
|
|
|
15980
16017
|
function dmBinding(controls, msg, scope, opts = {}) {
|
|
15981
16018
|
const cfg = controls.profileConfig.preferences.taskBindings;
|
|
15982
16019
|
if (!cfg) return void 0;
|
|
16020
|
+
const dispatch = dispatchRoute(cfg.dir, msg);
|
|
16021
|
+
if (dispatch) {
|
|
16022
|
+
if (dispatch === "start") {
|
|
16023
|
+
try {
|
|
16024
|
+
registerDispatchRoot(cfg.dir, msg.messageId, msg.chatId);
|
|
16025
|
+
} catch (err) {
|
|
16026
|
+
log.warn("binding", "dispatch-root-failed", { scope, reason: err instanceof Error ? err.message : String(err) });
|
|
16027
|
+
}
|
|
16028
|
+
}
|
|
16029
|
+
log.info("binding", "dispatch", { scope, route: dispatch, messageId: msg.messageId });
|
|
16030
|
+
return { kind: "none" };
|
|
16031
|
+
}
|
|
15983
16032
|
const threadRootId = msg.threadId ? msg.rootId : void 0;
|
|
15984
16033
|
if (opts.switchByReply && !threadRootId) {
|
|
15985
16034
|
try {
|
|
@@ -16150,9 +16199,10 @@ async function runAgentBatchInner(deps) {
|
|
|
16150
16199
|
channel.botIdentity,
|
|
16151
16200
|
extraInstructions
|
|
16152
16201
|
);
|
|
16202
|
+
const dispatchStart = firstMsg.chatType === "p2p" && !threadId && Boolean(controls.profileConfig.preferences.taskBindings) && isDispatchMarker(firstMsg.content);
|
|
16153
16203
|
const sendOpts = {
|
|
16154
|
-
replyTo: lastMsg.messageId,
|
|
16155
|
-
...mode === "topic" && threadId ? { replyInThread: true } : {}
|
|
16204
|
+
replyTo: dispatchStart ? firstMsg.messageId : lastMsg.messageId,
|
|
16205
|
+
...mode === "topic" && threadId || dispatchStart ? { replyInThread: true } : {}
|
|
16156
16206
|
};
|
|
16157
16207
|
log.info("flush", "reply-target", {
|
|
16158
16208
|
scope,
|