adp-openclaw 0.0.65 → 0.0.67
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/package.json +1 -1
- package/src/monitor.ts +38 -2
package/package.json
CHANGED
package/src/monitor.ts
CHANGED
|
@@ -388,8 +388,29 @@ async function connectAndHandle(params: ConnectParams): Promise<void> {
|
|
|
388
388
|
envelope: envelopeOptions,
|
|
389
389
|
});
|
|
390
390
|
|
|
391
|
+
// Build delivery target for cron jobs
|
|
392
|
+
// Format: adp-openclaw:{userId} for direct delivery via this channel
|
|
393
|
+
const cronDeliveryTarget = `${userIdentifier}`;
|
|
394
|
+
const nowMs = Date.now();
|
|
395
|
+
|
|
396
|
+
// Build BodyForAgent with context info for cron jobs (like QQBot does)
|
|
397
|
+
// This tells AI how to set up cron job delivery parameters
|
|
398
|
+
const contextInfo = `你正在通过 ADP-OpenClaw 与用户对话。
|
|
399
|
+
|
|
400
|
+
【会话上下文】
|
|
401
|
+
- 用户: ${inMsg.user?.username || inMsg.from} (${userIdentifier})
|
|
402
|
+
- 场景: 私聊
|
|
403
|
+
- 当前时间戳(ms): ${nowMs}
|
|
404
|
+
- 定时提醒投递地址: channel=adp-openclaw, to=${cronDeliveryTarget}`;
|
|
405
|
+
|
|
406
|
+
// If message is a command (starts with /), don't inject context
|
|
407
|
+
const agentBody = inMsg.text.startsWith("/")
|
|
408
|
+
? inMsg.text
|
|
409
|
+
: `${contextInfo}\n\n${inMsg.text}`;
|
|
410
|
+
|
|
391
411
|
const ctx = runtime.channel.reply.finalizeInboundContext({
|
|
392
412
|
Body: formattedBody,
|
|
413
|
+
BodyForAgent: agentBody, // AI sees this context with cron delivery info
|
|
393
414
|
RawBody: inMsg.text,
|
|
394
415
|
CommandBody: inMsg.text,
|
|
395
416
|
// User identity: format as "adp-openclaw:{tenantId}:{userId}" for multi-tenant support
|
|
@@ -770,8 +791,23 @@ async function connectAndHandle(params: ConnectParams): Promise<void> {
|
|
|
770
791
|
|
|
771
792
|
let result: ChatHistoryResponse;
|
|
772
793
|
|
|
773
|
-
if
|
|
774
|
-
|
|
794
|
+
// Check if sessionKey is in old format: agent:main:direct:{id}
|
|
795
|
+
// We need to extract the id and merge old + new format histories
|
|
796
|
+
const oldFormatMatch = historyPayload.sessionKey?.match(/^agent:main:direct:(.+)$/);
|
|
797
|
+
|
|
798
|
+
if (oldFormatMatch) {
|
|
799
|
+
// Old format sessionKey detected, need to merge with new format
|
|
800
|
+
// Old: agent:main:direct:{conversationId}
|
|
801
|
+
// New: agent:main:adp-openclaw:direct:{conversationId}
|
|
802
|
+
const extractedId = oldFormatMatch[1];
|
|
803
|
+
log?.info(`[adp-openclaw] Old format sessionKey detected, extracting id: ${extractedId}`);
|
|
804
|
+
log?.info(`[adp-openclaw] Merging old and new session histories for id: ${extractedId}`);
|
|
805
|
+
result = await getMergedChatHistory(extractedId, {
|
|
806
|
+
limit,
|
|
807
|
+
log,
|
|
808
|
+
});
|
|
809
|
+
} else if (historyPayload.sessionKey) {
|
|
810
|
+
// Non-old-format sessionKey, use directly
|
|
775
811
|
log?.info(`[adp-openclaw] Using provided sessionKey: ${historyPayload.sessionKey}`);
|
|
776
812
|
result = await getChatHistory(historyPayload.sessionKey, {
|
|
777
813
|
limit,
|