mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 02:12:44 +00:00
Memory: fix QMD scope channel parsing
This commit is contained in:
committed by
Vignesh
parent
3e82cbd55b
commit
b7f4755020
@@ -12,6 +12,7 @@ import {
|
|||||||
buildSessionEntry,
|
buildSessionEntry,
|
||||||
type SessionFileEntry,
|
type SessionFileEntry,
|
||||||
} from "./session-files.js";
|
} from "./session-files.js";
|
||||||
|
import { parseAgentSessionKey } from "../sessions/session-key-utils.js";
|
||||||
import { requireNodeSqlite } from "./sqlite.js";
|
import { requireNodeSqlite } from "./sqlite.js";
|
||||||
import type {
|
import type {
|
||||||
MemoryEmbeddingProbeResult,
|
MemoryEmbeddingProbeResult,
|
||||||
@@ -561,8 +562,13 @@ export class QmdMemoryManager implements MemorySearchManager {
|
|||||||
|
|
||||||
private deriveChannelFromKey(key?: string) {
|
private deriveChannelFromKey(key?: string) {
|
||||||
if (!key) return undefined;
|
if (!key) return undefined;
|
||||||
const parts = key.split(":").filter(Boolean);
|
const normalized = this.normalizeSessionKey(key);
|
||||||
if (parts.length >= 3 && (parts[1] === "group" || parts[1] === "channel")) {
|
if (!normalized) return undefined;
|
||||||
|
const parts = normalized.split(":").filter(Boolean);
|
||||||
|
if (
|
||||||
|
parts.length >= 2 &&
|
||||||
|
(parts[1] === "group" || parts[1] === "channel" || parts[1] === "dm")
|
||||||
|
) {
|
||||||
return parts[0]?.toLowerCase();
|
return parts[0]?.toLowerCase();
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -570,11 +576,22 @@ export class QmdMemoryManager implements MemorySearchManager {
|
|||||||
|
|
||||||
private deriveChatTypeFromKey(key?: string) {
|
private deriveChatTypeFromKey(key?: string) {
|
||||||
if (!key) return undefined;
|
if (!key) return undefined;
|
||||||
if (key.includes(":group:")) return "group";
|
const normalized = this.normalizeSessionKey(key);
|
||||||
if (key.includes(":channel:")) return "channel";
|
if (!normalized) return undefined;
|
||||||
|
if (normalized.includes(":group:")) return "group";
|
||||||
|
if (normalized.includes(":channel:")) return "channel";
|
||||||
return "direct";
|
return "direct";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private normalizeSessionKey(key: string): string | undefined {
|
||||||
|
const trimmed = key.trim();
|
||||||
|
if (!trimmed) return undefined;
|
||||||
|
const parsed = parseAgentSessionKey(trimmed);
|
||||||
|
const normalized = (parsed?.rest ?? trimmed).toLowerCase();
|
||||||
|
if (normalized.startsWith("subagent:")) return undefined;
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
private toDocLocation(
|
private toDocLocation(
|
||||||
collection: string,
|
collection: string,
|
||||||
collectionRelativePath: string,
|
collectionRelativePath: string,
|
||||||
|
|||||||
Reference in New Issue
Block a user