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