adp-openclaw 0.0.68 → 0.0.69

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adp-openclaw",
3
- "version": "0.0.68",
3
+ "version": "0.0.69",
4
4
  "description": "ADP-OpenClaw demo channel plugin (Go WebSocket backend)",
5
5
  "type": "module",
6
6
  "dependencies": {
@@ -498,9 +498,10 @@ export async function getMergedChatHistory(
498
498
  options?: {
499
499
  limit?: number;
500
500
  log?: PluginLogger;
501
+ filterAfterNewSession?: boolean; // Default true: filter out messages before last /new
501
502
  },
502
503
  ): Promise<ChatHistoryResponse> {
503
- const { limit = 200, log } = options ?? {};
504
+ const { limit = 200, log, filterAfterNewSession = true } = options ?? {};
504
505
 
505
506
  // Build both old and new session key formats
506
507
  const oldSessionKey = `agent:main:direct:${conversationId}`;
@@ -511,6 +512,7 @@ export async function getMergedChatHistory(
511
512
  log?.info?.(`[session-history] New sessionKey: ${newSessionKey}`);
512
513
 
513
514
  // Fetch history from both session keys in parallel
515
+ // Note: getChatHistory already applies filterAfterNewSession for each session individually
514
516
  const [oldResult, newResult] = await Promise.all([
515
517
  getChatHistory(oldSessionKey, { limit, log }).catch((err) => {
516
518
  log?.debug?.(`[session-history] Failed to fetch old session history: ${err}`);
@@ -537,7 +539,7 @@ export async function getMergedChatHistory(
537
539
 
538
540
  // Deduplicate by message id (if available) or content+timestamp
539
541
  const seen = new Set<string>();
540
- const dedupedMessages = allMessages.filter((msg) => {
542
+ let dedupedMessages = allMessages.filter((msg) => {
541
543
  // Create a unique key for deduplication
542
544
  const key = msg.id || `${msg.role}:${msg.timestamp}:${msg.content.slice(0, 100)}`;
543
545
  if (seen.has(key)) {
@@ -547,6 +549,13 @@ export async function getMergedChatHistory(
547
549
  return true;
548
550
  });
549
551
 
552
+ // Filter out messages before the last /new session on the MERGED result
553
+ // This is important because the /new might be in the old sessionKey but we still
554
+ // want to filter the combined history based on the latest /new across both sessions
555
+ if (filterAfterNewSession) {
556
+ dedupedMessages = filterMessagesAfterLastNewSession(dedupedMessages, log);
557
+ }
558
+
550
559
  // Apply limit (return last N messages if exceeds limit)
551
560
  const limitedMessages = dedupedMessages.length > limit
552
561
  ? dedupedMessages.slice(-limit)