@clawos-dev/clawd 0.2.488 → 0.2.489
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.cjs +60 -24
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -48974,11 +48974,14 @@ var SessionManager = class {
|
|
|
48974
48974
|
* 该群的专属 guest session,turn-idle 后从 reducer buffer 提取回复文本。
|
|
48975
48975
|
*
|
|
48976
48976
|
* 跟 createShiftSession 的差异:
|
|
48977
|
-
* - **find-or-create**:按 capId `lark-<chatId>` 找现存 session
|
|
48978
|
-
*
|
|
48977
|
+
* - **find-or-create**:按 capId `lark-<chatId>` 找现存 session,没有才建;daemon
|
|
48978
|
+
* `create` 的无 dedupe 语义不变——dedupe 是本方法私有实现。
|
|
48979
|
+
* 粒度由云端给的 chatId 决定,daemon 只当它是不透明 key:群消息是虚拟三段式
|
|
48980
|
+
* `<真实 chat_id>:<thread_id>:<open_id>`(spec 2026-09-10,一话题一人一条),
|
|
48981
|
+
* p2p 是裸 chat_id,文档评论是 `doc:<fileToken>`
|
|
48979
48982
|
* - guest scope + 沙箱:群成员 query 不带 owner 权限;10min guest idle-kill + resume
|
|
48980
|
-
* - turn-idle 后**不 kill**(session
|
|
48981
|
-
* text 落盘(schemas.ts turn_end
|
|
48983
|
+
* - turn-idle 后**不 kill**(session 常驻,记忆即价值);TUI 下延迟 settleDelayMs 等
|
|
48984
|
+
* 尾随 text 落盘(schemas.ts turn_end 注释 ②)再读 buffer,SDK / codex 同步读
|
|
48982
48985
|
* - 回复提取:extractLarkReplyText(最后一条 user_text 之后的 text 事件拼接)
|
|
48983
48986
|
*/
|
|
48984
48987
|
runLarkChatTurn(args) {
|
|
@@ -49045,21 +49048,23 @@ var SessionManager = class {
|
|
|
49045
49048
|
if (!r) return;
|
|
49046
49049
|
r.input({ kind: "command", command: { kind: "stop" } });
|
|
49047
49050
|
};
|
|
49048
|
-
const settleDelayMs = args.settleDelayMs ?? 500;
|
|
49051
|
+
const settleDelayMs = args.settleDelayMs ?? (this.deps.mode === "tui" ? 500 : 0);
|
|
49052
|
+
const extractAndSettle = () => {
|
|
49053
|
+
try {
|
|
49054
|
+
const events = this.readHistoryEventsForScope(sessionId, scope);
|
|
49055
|
+
const replyText = extractLarkReplyText(events);
|
|
49056
|
+
settle(replyText ? { ok: true, replyText } : { error: "empty reply" });
|
|
49057
|
+
} catch (err) {
|
|
49058
|
+
settle({ error: err.message });
|
|
49059
|
+
}
|
|
49060
|
+
};
|
|
49049
49061
|
unsubscribe = this.subscribe(
|
|
49050
49062
|
sessionId,
|
|
49051
49063
|
scope,
|
|
49052
49064
|
makeEndFrameHandler(sessionId, (info) => {
|
|
49053
49065
|
if (info.kind === "idle") {
|
|
49054
|
-
|
|
49055
|
-
|
|
49056
|
-
const events = this.readHistoryEventsForScope(sessionId, scope);
|
|
49057
|
-
const replyText = extractLarkReplyText(events);
|
|
49058
|
-
settle(replyText ? { ok: true, replyText } : { error: "empty reply" });
|
|
49059
|
-
} catch (err) {
|
|
49060
|
-
settle({ error: err.message });
|
|
49061
|
-
}
|
|
49062
|
-
}, settleDelayMs);
|
|
49066
|
+
if (settleDelayMs === 0) extractAndSettle();
|
|
49067
|
+
else setTimeout(extractAndSettle, settleDelayMs);
|
|
49063
49068
|
} else if (info.kind === "stopped") {
|
|
49064
49069
|
settle({ error: "session stopped before reply" });
|
|
49065
49070
|
} else {
|
|
@@ -56413,6 +56418,18 @@ init_protocol();
|
|
|
56413
56418
|
var ERROR_REPLY_TEXT = "\u5904\u7406\u51FA\u9519\u4E86\uFF0C\u8BF7\u91CD\u8BD5";
|
|
56414
56419
|
var LOCAL_TURN_RETRIES = 2;
|
|
56415
56420
|
var STOPPED_ERROR = "session stopped before reply";
|
|
56421
|
+
var isChatOf = (key, realChatId) => key === realChatId || key.startsWith(`${realChatId}:`);
|
|
56422
|
+
var THREAD_TITLE_MAX = 20;
|
|
56423
|
+
var threadTitleOf = (env) => {
|
|
56424
|
+
const root = env.threadContext?.[0]?.text?.trim();
|
|
56425
|
+
if (!root) return void 0;
|
|
56426
|
+
return root.length > THREAD_TITLE_MAX ? `${root.slice(0, THREAD_TITLE_MAX)}\u2026` : root;
|
|
56427
|
+
};
|
|
56428
|
+
var sessionNameOf = (env) => {
|
|
56429
|
+
if (env.type === "doc_comment" || (env.chatType ?? "group") !== "group") return env.chatName;
|
|
56430
|
+
const speaker = env.senderName || env.senderOpenId;
|
|
56431
|
+
return [env.chatName, threadTitleOf(env), speaker].filter(Boolean).join("\xB7") || void 0;
|
|
56432
|
+
};
|
|
56416
56433
|
var DEBOUNCE_MS = 1e3;
|
|
56417
56434
|
var MAX_IMAGE_BYTES = 8 * 1024 * 1024;
|
|
56418
56435
|
var EXT_BY_MIME = {
|
|
@@ -56517,9 +56534,23 @@ function createLarkChatRouter(deps) {
|
|
|
56517
56534
|
if (lines.length === 0) lines.push("[\u6709\u4EBA\u5728\u98DE\u4E66\u6587\u6863\u91CC @ \u4E86\u4F60\uFF0C\u4F46\u8BC4\u8BBA\u5185\u5BB9\u62C9\u53D6\u5931\u8D25]");
|
|
56518
56535
|
return lines.join("\n");
|
|
56519
56536
|
};
|
|
56537
|
+
const buildThreadContextSection = async (env, batchMessageIds) => {
|
|
56538
|
+
const rows = (env.threadContext ?? []).filter((r) => !batchMessageIds.has(r.messageId));
|
|
56539
|
+
if (rows.length === 0) return void 0;
|
|
56540
|
+
const head = env.threadContextTruncated ? `[\u8BDD\u9898\u4E0A\u4E0B\u6587 \xB7 \u5171 ${rows.length} \u6761\uFF0C\u66F4\u65E9\u7684\u5DF2\u7565]` : `[\u8BDD\u9898\u4E0A\u4E0B\u6587 \xB7 \u5171 ${rows.length} \u6761]`;
|
|
56541
|
+
const lines = [head];
|
|
56542
|
+
for (const row of rows) {
|
|
56543
|
+
lines.push(`${row.senderName}\uFF1A${row.text?.trim() ?? ""}`);
|
|
56544
|
+
lines.push(...await imageLinesFor(env, row.messageId, row.imageKeys ?? []));
|
|
56545
|
+
lines.push(...await fileLinesFor(env, row.messageId, row.files ?? []));
|
|
56546
|
+
}
|
|
56547
|
+
lines.push("---");
|
|
56548
|
+
return lines.join("\n");
|
|
56549
|
+
};
|
|
56520
56550
|
const buildSection = async (env) => {
|
|
56521
56551
|
if (env.type === "doc_comment") return buildDocCommentSection(env);
|
|
56522
56552
|
const parentLines = env.parentMessageId ? [
|
|
56553
|
+
...env.parentText?.trim() ? [`[\u88AB\u5F15\u7528\u7684\u6D88\u606F] ${env.parentText.trim()}`] : [],
|
|
56523
56554
|
...await imageLinesFor(env, env.parentMessageId, env.parentImageKeys ?? []),
|
|
56524
56555
|
...await fileLinesFor(env, env.parentMessageId, env.parentFiles ?? [])
|
|
56525
56556
|
] : [];
|
|
@@ -56560,19 +56591,21 @@ ${body}
|
|
|
56560
56591
|
const section = [quoteAnnotation(env, i, idxByMessageId), sectionBody].filter(Boolean).join("\n");
|
|
56561
56592
|
if (section) sections.push(section);
|
|
56562
56593
|
}
|
|
56563
|
-
const
|
|
56594
|
+
const threadSection = await buildThreadContextSection(envs[0], new Set(idxByMessageId.keys()));
|
|
56595
|
+
const body = [threadSection, ...sections].filter(Boolean).join("\n") || "[\u975E\u6587\u672C\u6D88\u606F]";
|
|
56564
56596
|
const runTurn = (text) => {
|
|
56565
56597
|
const turn = deps.manager.runLarkChatTurn({
|
|
56566
56598
|
personaId: last.personaId,
|
|
56567
56599
|
chatId: last.chatId,
|
|
56568
|
-
chatName: last
|
|
56600
|
+
chatName: sessionNameOf(last),
|
|
56569
56601
|
chatType: last.chatType ?? "group",
|
|
56570
56602
|
senderOpenId: last.senderOpenId ?? "",
|
|
56571
56603
|
senderName: last.senderName ?? last.senderOpenId ?? "\u672A\u77E5\u6210\u5458",
|
|
56572
56604
|
text
|
|
56573
56605
|
});
|
|
56574
|
-
|
|
56575
|
-
|
|
56606
|
+
const activityChatId = last.realChatId ?? last.chatId;
|
|
56607
|
+
activity.set(activityChatId, {
|
|
56608
|
+
chatId: activityChatId,
|
|
56576
56609
|
chatName: last.chatName,
|
|
56577
56610
|
lastActiveAt: Date.now(),
|
|
56578
56611
|
personaId: last.personaId
|
|
@@ -56607,7 +56640,8 @@ ${formatLarkSpeakerReminder(speaker)}`
|
|
|
56607
56640
|
try {
|
|
56608
56641
|
await deps.cloud.reply({
|
|
56609
56642
|
appId: last.appId,
|
|
56610
|
-
chatId
|
|
56643
|
+
// 回复走真身:chatId 自 spec 2026-09-10 起是虚拟三段式,只作会话 key 用
|
|
56644
|
+
chatId: last.realChatId ?? last.chatId,
|
|
56611
56645
|
// envs 已过滤保证锚点非空
|
|
56612
56646
|
replyToMessageId: replyAnchorOf(last),
|
|
56613
56647
|
text: replyText,
|
|
@@ -56650,11 +56684,13 @@ ${formatLarkSpeakerReminder(speaker)}`
|
|
|
56650
56684
|
if (env.type === "bot_removed") {
|
|
56651
56685
|
deps.store.addRemovedChat(env.personaId, env.chatId);
|
|
56652
56686
|
activity.delete(env.chatId);
|
|
56653
|
-
queues.
|
|
56654
|
-
|
|
56655
|
-
|
|
56687
|
+
for (const key2 of [...queues.keys()]) {
|
|
56688
|
+
if (isChatOf(key2, env.chatId)) queues.delete(key2);
|
|
56689
|
+
}
|
|
56690
|
+
for (const [key2, p2] of [...pending.entries()]) {
|
|
56691
|
+
if (!isChatOf(key2, env.chatId)) continue;
|
|
56656
56692
|
clearTimeout(p2.timer);
|
|
56657
|
-
pending.delete(
|
|
56693
|
+
pending.delete(key2);
|
|
56658
56694
|
}
|
|
56659
56695
|
deps.logger?.info(`larkBot removed from chat ${env.chatId} (persona ${env.personaId})`);
|
|
56660
56696
|
return;
|
|
@@ -65428,7 +65464,7 @@ function computeMethodAccess(args) {
|
|
|
65428
65464
|
}
|
|
65429
65465
|
|
|
65430
65466
|
// src/version.ts
|
|
65431
|
-
var version = "0.2.
|
|
65467
|
+
var version = "0.2.489".length > 0 ? "0.2.489" : "dev";
|
|
65432
65468
|
|
|
65433
65469
|
// src/cli-probe/probe.ts
|
|
65434
65470
|
var fs72 = __toESM(require("fs"), 1);
|