botmux 2.53.0 → 2.54.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/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +42 -22
- package/dist/cli.js.map +1 -1
- package/dist/core/pending-response.d.ts +31 -0
- package/dist/core/pending-response.d.ts.map +1 -0
- package/dist/core/pending-response.js +87 -0
- package/dist/core/pending-response.js.map +1 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +16 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/types.d.ts +3 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/worker-pool.d.ts +1 -1
- package/dist/core/worker-pool.d.ts.map +1 -1
- package/dist/core/worker-pool.js +67 -6
- package/dist/core/worker-pool.js.map +1 -1
- package/dist/core/zellij-adopt-discovery.d.ts.map +1 -1
- package/dist/core/zellij-adopt-discovery.js +53 -32
- package/dist/core/zellij-adopt-discovery.js.map +1 -1
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +63 -1
- package/dist/daemon.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +4 -0
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +4 -0
- package/dist/i18n/zh.js.map +1 -1
- package/dist/im/lark/card-builder.d.ts +3 -0
- package/dist/im/lark/card-builder.d.ts.map +1 -1
- package/dist/im/lark/card-builder.js +33 -0
- package/dist/im/lark/card-builder.js.map +1 -1
- package/dist/im/lark/card-handler.d.ts.map +1 -1
- package/dist/im/lark/card-handler.js +13 -1
- package/dist/im/lark/card-handler.js.map +1 -1
- package/dist/im/lark/event-dispatcher.d.ts +8 -1
- package/dist/im/lark/event-dispatcher.d.ts.map +1 -1
- package/dist/im/lark/event-dispatcher.js +28 -0
- package/dist/im/lark/event-dispatcher.js.map +1 -1
- package/dist/services/pending-response-transaction-store.d.ts +12 -0
- package/dist/services/pending-response-transaction-store.d.ts.map +1 -0
- package/dist/services/pending-response-transaction-store.js +52 -0
- package/dist/services/pending-response-transaction-store.js.map +1 -0
- package/dist/services/session-store.d.ts.map +1 -1
- package/dist/services/session-store.js +15 -1
- package/dist/services/session-store.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/worker.js +114 -5
- package/dist/worker.js.map +1 -1
- package/dist/workflows/events/payloads.d.ts +20 -20
- package/dist/workflows/events/schema.d.ts +48 -48
- package/package.json +1 -1
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AA64HA;;;;;;;;;;;GAWG;AACH,wBAAsB,OAAO,CAC3B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EACvC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,qBAAqB,EAAE,SAAS,CAAC,EAC9F,KAAK,EAAE,MAAM,EACb,mBAAmB,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,2BAA2B,EAAE,UAAU,GAAG,IAAI,CAAC,GACzF,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CA+F7B"}
|
package/dist/cli.js
CHANGED
|
@@ -1510,6 +1510,9 @@ function loadSessions() {
|
|
|
1510
1510
|
return sessions;
|
|
1511
1511
|
}
|
|
1512
1512
|
/** Save a single session back to its appropriate file based on larkAppId. */
|
|
1513
|
+
function loadSessionFresh(session) {
|
|
1514
|
+
return loadSessions().get(session.sessionId);
|
|
1515
|
+
}
|
|
1513
1516
|
function saveSession(session) {
|
|
1514
1517
|
const dataDir = resolveDataDir();
|
|
1515
1518
|
const fileName = session.larkAppId ? `sessions-${session.larkAppId}.json` : 'sessions.json';
|
|
@@ -1522,7 +1525,7 @@ function saveSession(session) {
|
|
|
1522
1525
|
}
|
|
1523
1526
|
catch { /* start fresh */ }
|
|
1524
1527
|
}
|
|
1525
|
-
data[session.sessionId] = session;
|
|
1528
|
+
data[session.sessionId] = mergePendingResponseState(session, data[session.sessionId]);
|
|
1526
1529
|
// Clean up entries where file key doesn't match the entry's sessionId (data corruption)
|
|
1527
1530
|
for (const [key, val] of Object.entries(data)) {
|
|
1528
1531
|
if (val && typeof val === 'object' && 'sessionId' in val && val.sessionId !== key) {
|
|
@@ -2638,6 +2641,7 @@ function argValues(args, ...flags) {
|
|
|
2638
2641
|
// daemon's bridge fallback path can produce identical cards. cmdSend
|
|
2639
2642
|
// keeps using `buildCardBodyElements` and `hasMarkdown` from there.
|
|
2640
2643
|
import { buildCardBodyElements, hasMarkdown, brandFooterSegment } from './im/lark/md-card.js';
|
|
2644
|
+
import { claimPendingResponseCard, isPendingResponseCardOpen, markPendingResponseCardPatchedIfCurrent, mergePendingResponseState, shouldUseCardForSend } from './core/pending-response.js';
|
|
2641
2645
|
import { resolveBrandLabel } from './bot-registry.js';
|
|
2642
2646
|
import { config } from './config.js';
|
|
2643
2647
|
import { resolveQuoteTarget, validateMentionDecision } from './services/send-policy.js';
|
|
@@ -2763,7 +2767,7 @@ async function cmdSend(rest) {
|
|
|
2763
2767
|
registerBot(cfg);
|
|
2764
2768
|
}
|
|
2765
2769
|
catch { /* */ }
|
|
2766
|
-
const { sendMessage, replyMessage, uploadImage, uploadFile, MessageWithdrawnError } = await import('./im/lark/client.js');
|
|
2770
|
+
const { sendMessage, replyMessage, uploadImage, uploadFile, deleteMessage, MessageWithdrawnError } = await import('./im/lark/client.js');
|
|
2767
2771
|
const appId = s.larkAppId;
|
|
2768
2772
|
// Effective target chat for top-level mode (defaults to session's chat)
|
|
2769
2773
|
const targetChatId = overrideChatId ?? s.chatId;
|
|
@@ -2824,6 +2828,28 @@ async function cmdSend(rest) {
|
|
|
2824
2828
|
const dispatch = (content, msgType) => (sendTopLevel || isChatScope)
|
|
2825
2829
|
? sendMessage(appId, targetChatId, content, msgType)
|
|
2826
2830
|
: replyMessage(appId, s.rootMessageId, content, msgType, true);
|
|
2831
|
+
const recordBridgeSendMarker = (sentAtMs, messageId) => {
|
|
2832
|
+
try {
|
|
2833
|
+
const markerDir = join(resolveDataDir(), 'turn-sends');
|
|
2834
|
+
if (!existsSync(markerDir))
|
|
2835
|
+
mkdirSync(markerDir, { recursive: true });
|
|
2836
|
+
const line = JSON.stringify({ sentAtMs, messageId }) + '\n';
|
|
2837
|
+
appendFileSync(join(markerDir, `${sid}.jsonl`), line);
|
|
2838
|
+
}
|
|
2839
|
+
catch { /* best-effort: marker miss only causes a redundant fallback message */ }
|
|
2840
|
+
};
|
|
2841
|
+
const shouldRecordBridgeMarker = !sendTopLevel && !overrideChatId;
|
|
2842
|
+
const dispatchOrPatchPending = async (content, msgType) => {
|
|
2843
|
+
const pendingCardId = msgType === 'interactive' ? claimPendingResponseCard(s) : undefined;
|
|
2844
|
+
const sentId = await dispatchPrimary(content, msgType);
|
|
2845
|
+
const latest = pendingCardId ? loadSessionFresh(s) : undefined;
|
|
2846
|
+
if (pendingCardId && latest?.pendingResponseCardId === pendingCardId) {
|
|
2847
|
+
deleteMessage(appId, pendingCardId)
|
|
2848
|
+
.then(() => { markPendingResponseCardPatchedIfCurrent(latest, pendingCardId); saveSession(latest); })
|
|
2849
|
+
.catch((err) => logger.warn(`[send:${sid.substring(0, 8)}] failed to withdraw pending card after explicit send: ${err?.message ?? err}`));
|
|
2850
|
+
}
|
|
2851
|
+
return sentId;
|
|
2852
|
+
};
|
|
2827
2853
|
// Quote chain (普通群): the primary message replies to the turn's target so
|
|
2828
2854
|
// Lark renders a 引用 chain. --quote overrides, --no-quote opts out. Thread
|
|
2829
2855
|
// scope and --top-level never quote. Withdrawn target → fall back to plain.
|
|
@@ -2984,8 +3010,14 @@ async function cmdSend(rest) {
|
|
|
2984
3010
|
knownBotOpenIds,
|
|
2985
3011
|
});
|
|
2986
3012
|
// Decide: interactive card (renders markdown) vs. post (plain text).
|
|
2987
|
-
//
|
|
2988
|
-
|
|
3013
|
+
// An open pending response card takes precedence over --text so the
|
|
3014
|
+
// placeholder can close cleanly; otherwise explicit --card / --text wins.
|
|
3015
|
+
const useCard = shouldUseCardForSend({
|
|
3016
|
+
forceCard,
|
|
3017
|
+
forceText,
|
|
3018
|
+
hasMarkdown: hasMarkdown(text),
|
|
3019
|
+
hasOpenPendingResponseCard: isPendingResponseCardOpen(s),
|
|
3020
|
+
});
|
|
2989
3021
|
const mentionMap = new Map();
|
|
2990
3022
|
for (const m of mentions)
|
|
2991
3023
|
if (m.name)
|
|
@@ -3079,7 +3111,7 @@ async function cmdSend(rest) {
|
|
|
3079
3111
|
config: { update_multi: true },
|
|
3080
3112
|
body: { direction: 'vertical', elements },
|
|
3081
3113
|
});
|
|
3082
|
-
messageId = await
|
|
3114
|
+
messageId = await dispatchOrPatchPending(cardJson, 'interactive');
|
|
3083
3115
|
}
|
|
3084
3116
|
else {
|
|
3085
3117
|
// Plain-text path: build post content, paragraph per line.
|
|
@@ -3129,23 +3161,11 @@ async function cmdSend(rest) {
|
|
|
3129
3161
|
const postJson = JSON.stringify({ zh_cn: { title: '', content: postContent } });
|
|
3130
3162
|
messageId = await dispatchPrimary(postJson, 'post');
|
|
3131
3163
|
}
|
|
3132
|
-
// Bridge fallback marker — append-only jsonl per session.
|
|
3133
|
-
//
|
|
3134
|
-
//
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
if (!sendTopLevel && !overrideChatId) {
|
|
3138
|
-
try {
|
|
3139
|
-
const markerDir = join(resolveDataDir(), 'turn-sends');
|
|
3140
|
-
if (!existsSync(markerDir))
|
|
3141
|
-
mkdirSync(markerDir, { recursive: true });
|
|
3142
|
-
// sentAtMs was captured pre-dispatch (see above). messageId is the
|
|
3143
|
-
// confirmed Lark message id from the now-successful dispatch.
|
|
3144
|
-
const line = JSON.stringify({ sentAtMs, messageId }) + '\n';
|
|
3145
|
-
appendFileSync(join(markerDir, `${sid}.jsonl`), line);
|
|
3146
|
-
}
|
|
3147
|
-
catch { /* best-effort: marker miss only causes a redundant fallback message */ }
|
|
3148
|
-
}
|
|
3164
|
+
// Bridge fallback marker — append-only jsonl per session. Same-thread
|
|
3165
|
+
// sends always suppress transcript fallback; detoured sends suppress only
|
|
3166
|
+
// when they closed a pending response card for this turn.
|
|
3167
|
+
if (shouldRecordBridgeMarker)
|
|
3168
|
+
recordBridgeSendMarker(sentAtMs, messageId);
|
|
3149
3169
|
// Send file attachments as separate messages
|
|
3150
3170
|
const fileIds = [];
|
|
3151
3171
|
for (const fp of files) {
|