aai-lark-bridge 0.2.26 → 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 +71 -7
- 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",
|
|
@@ -7304,6 +7304,16 @@ function seatFromEnv(env) {
|
|
|
7304
7304
|
const list = (env.SDLC_CLAUDE_SEAT_LIST ?? "").split(",").map((s) => s.trim()).filter((s) => /^ou_[A-Za-z0-9_-]{1,100}$/.test(s));
|
|
7305
7305
|
return { mode, list };
|
|
7306
7306
|
}
|
|
7307
|
+
function codeShape(code) {
|
|
7308
|
+
const c = code.trim();
|
|
7309
|
+
const i = c.indexOf("#");
|
|
7310
|
+
return i < 0 ? `len=${c.length} hash=no` : `len=${c.length} hash=yes head=${i} tail=${c.length - i - 1}`;
|
|
7311
|
+
}
|
|
7312
|
+
function scrub(text, code) {
|
|
7313
|
+
let t = text;
|
|
7314
|
+
for (const part of code.trim().split("#")) if (part.length >= 6) t = t.split(part).join("<code>");
|
|
7315
|
+
return t.replace(/[A-Za-z0-9_-]{40,}/g, "<long>").replace(/\s+/g, " ").trim().slice(0, 300);
|
|
7316
|
+
}
|
|
7307
7317
|
function realClaudeCli(binary = process.env.SDLC_REAL_CLAUDE || "claude") {
|
|
7308
7318
|
const baseEnv = (dir) => {
|
|
7309
7319
|
const keep = Object.fromEntries(Object.entries(process.env).filter(([k]) => /^(PATH|LANG|https?_proxy|no_proxy|HTTPS?_PROXY|NO_PROXY)$/.test(k)));
|
|
@@ -7362,11 +7372,16 @@ function realClaudeCli(binary = process.env.SDLC_REAL_CLAUDE || "claude") {
|
|
|
7362
7372
|
setTimeout(() => resolve3("invalid"), SUBMIT_MAX_MS).unref();
|
|
7363
7373
|
});
|
|
7364
7374
|
clearTimeout(timer);
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7375
|
+
const ok = verdict !== "invalid" && verdict === 0 && /Login successful/i.test(out);
|
|
7376
|
+
if (!ok) {
|
|
7377
|
+
log.warn("user-gateway", "claude.login-submit-failed", {
|
|
7378
|
+
verdict: verdict === "invalid" ? "invalid-or-timeout" : `exit-${verdict}`,
|
|
7379
|
+
codeShape: codeShape(code),
|
|
7380
|
+
cliOutput: scrub(out.slice(before), code)
|
|
7381
|
+
});
|
|
7368
7382
|
}
|
|
7369
|
-
|
|
7383
|
+
if (verdict === "invalid") p3.kill("SIGTERM");
|
|
7384
|
+
return ok;
|
|
7370
7385
|
},
|
|
7371
7386
|
cancel() {
|
|
7372
7387
|
clearTimeout(timer);
|
|
@@ -7679,6 +7694,7 @@ import {
|
|
|
7679
7694
|
existsSync as existsSync7,
|
|
7680
7695
|
linkSync,
|
|
7681
7696
|
mkdirSync as mkdirSync3,
|
|
7697
|
+
readdirSync,
|
|
7682
7698
|
readFileSync as readFileSync4,
|
|
7683
7699
|
realpathSync,
|
|
7684
7700
|
renameSync as renameSync2,
|
|
@@ -7792,6 +7808,41 @@ function taskOfMessage(dir, messageId) {
|
|
|
7792
7808
|
return void 0;
|
|
7793
7809
|
}
|
|
7794
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
|
+
}
|
|
7795
7846
|
var LOCK_WAIT_MS = 2e3;
|
|
7796
7847
|
var LOCK_STEP_MS = 50;
|
|
7797
7848
|
var LOCK_STALE_MS = 1e4;
|
|
@@ -15965,6 +16016,18 @@ async function intakeMessage(deps) {
|
|
|
15965
16016
|
function dmBinding(controls, msg, scope, opts = {}) {
|
|
15966
16017
|
const cfg = controls.profileConfig.preferences.taskBindings;
|
|
15967
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
|
+
}
|
|
15968
16031
|
const threadRootId = msg.threadId ? msg.rootId : void 0;
|
|
15969
16032
|
if (opts.switchByReply && !threadRootId) {
|
|
15970
16033
|
try {
|
|
@@ -16135,9 +16198,10 @@ async function runAgentBatchInner(deps) {
|
|
|
16135
16198
|
channel.botIdentity,
|
|
16136
16199
|
extraInstructions
|
|
16137
16200
|
);
|
|
16201
|
+
const dispatchStart = firstMsg.chatType === "p2p" && !threadId && Boolean(controls.profileConfig.preferences.taskBindings) && isDispatchMarker(firstMsg.content);
|
|
16138
16202
|
const sendOpts = {
|
|
16139
|
-
replyTo: lastMsg.messageId,
|
|
16140
|
-
...mode === "topic" && threadId ? { replyInThread: true } : {}
|
|
16203
|
+
replyTo: dispatchStart ? firstMsg.messageId : lastMsg.messageId,
|
|
16204
|
+
...mode === "topic" && threadId || dispatchStart ? { replyInThread: true } : {}
|
|
16141
16205
|
};
|
|
16142
16206
|
log.info("flush", "reply-target", {
|
|
16143
16207
|
scope,
|