
























@@ -7,6 +7,7 @@ import { deliveryContextFromSession } from "../../utils/delivery-context.shared.
77import { getRuntimeConfig } from "../io.js";
88import type { OpenClawConfig } from "../types.openclaw.js";
99import { resolveStorePath } from "./paths.js";
10+import { normalizeStoreSessionKey } from "./store-entry.js";
1011import { loadSessionStore } from "./store.js";
1112import { resolveAllAgentSessionStoreTargetsSync } from "./targets.js";
1213import { parseSessionThreadInfo } from "./thread-info.js";
@@ -104,14 +105,24 @@ function findSessionEntryInStore(
104105};
105106for (const key of keys) {
106107const trimmed = key.trim();
107-const normalized = normalizeLowercaseStringOrEmpty(key);
108+const normalized = normalizeStoreSessionKey(key);
109+const foldedLegacyKey = normalizeLowercaseStringOrEmpty(normalized);
108110let foundRoutableCandidate = false;
109111if (Object.prototype.hasOwnProperty.call(store, normalized)) {
110112foundRoutableCandidate ||= hasRoutableDeliveryContext(
111113deliveryContextFromSession(store[normalized]),
112114);
113115acceptCandidate(store[normalized]);
114116}
117+if (
118+foldedLegacyKey !== normalized &&
119+Object.prototype.hasOwnProperty.call(store, foldedLegacyKey)
120+) {
121+foundRoutableCandidate ||= hasRoutableDeliveryContext(
122+deliveryContextFromSession(store[foldedLegacyKey]),
123+);
124+acceptCandidate(store[foldedLegacyKey]);
125+}
115126if (trimmed !== normalized && Object.prototype.hasOwnProperty.call(store, trimmed)) {
116127foundRoutableCandidate ||= hasRoutableDeliveryContext(
117128deliveryContextFromSession(store[trimmed]),
@@ -122,6 +133,9 @@ function findSessionEntryInStore(
122133normalizedIndex ??= buildFreshestSessionEntryIndex(store);
123134const freshest = normalizedIndex.get(normalized);
124135acceptCandidate(freshest);
136+if (foldedLegacyKey !== normalized) {
137+acceptCandidate(normalizedIndex.get(foldedLegacyKey));
138+}
125139}
126140}
127141return bestEntry;
@@ -132,7 +146,7 @@ function buildFreshestSessionEntryIndex(
132146): Map<string, SessionEntry> {
133147const index = new Map<string, SessionEntry>();
134148for (const [key, entry] of Object.entries(store)) {
135-const normalized = normalizeLowercaseStringOrEmpty(key);
149+const normalized = normalizeStoreSessionKey(key);
136150const existing = index.get(normalized);
137151const entryRoutable = hasRoutableDeliveryContext(deliveryContextFromSession(entry));
138152const existingRoutable = hasRoutableDeliveryContext(deliveryContextFromSession(existing));
@@ -143,6 +157,22 @@ function buildFreshestSessionEntryIndex(
143157) {
144158index.set(normalized, entry);
145159}
160+const foldedLegacyKey = normalizeLowercaseStringOrEmpty(normalized);
161+if (foldedLegacyKey === normalized) {
162+continue;
163+}
164+const foldedExisting = index.get(foldedLegacyKey);
165+const foldedExistingRoutable = hasRoutableDeliveryContext(
166+deliveryContextFromSession(foldedExisting),
167+);
168+if (
169+!foldedExisting ||
170+(entryRoutable && !foldedExistingRoutable) ||
171+(entryRoutable === foldedExistingRoutable &&
172+(entry.updatedAt ?? 0) > (foldedExisting.updatedAt ?? 0))
173+) {
174+index.set(foldedLegacyKey, entry);
175+}
146176}
147177return index;
148178}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。