


























@@ -20,10 +20,6 @@ import {
2020import { definePluginEntry, type OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry";
2121import { parseAgentSessionKey, parseThreadSessionSuffix } from "openclaw/plugin-sdk/routing";
2222import { isPathInside, replaceFileAtomic } from "openclaw/plugin-sdk/security-runtime";
23-import {
24-resolveSessionStoreEntry,
25-updateSessionStore,
26-} from "openclaw/plugin-sdk/session-store-runtime";
2723import { tempWorkspace, resolvePreferredOpenClawTmpDir } from "openclaw/plugin-sdk/temp-path";
28242925const DEFAULT_TIMEOUT_MS = 15_000;
@@ -542,20 +538,15 @@ function resolveCanonicalSessionKeyFromSessionId(params: {
542538return undefined;
543539}
544540try {
545-const storePath = params.api.runtime.agent.session.resolveStorePath(
546-params.api.config.session?.store,
547-{
548-agentId: params.agentId,
549-},
550-);
551-const store = params.api.runtime.agent.session.loadSessionStore(storePath, { clone: false });
552541let bestMatch:
553542| {
554543sessionKey: string;
555544updatedAt: number;
556545}
557546| undefined;
558-for (const [sessionKey, entry] of Object.entries(store)) {
547+for (const { sessionKey, entry } of params.api.runtime.agent.session.listSessionEntries({
548+agentId: params.agentId,
549+})) {
559550if (!entry || typeof entry !== "object") {
560551continue;
561552}
@@ -673,17 +664,10 @@ function resolveRecallRunChannelContext(params: {
673664}
674665675666try {
676-const storePath = params.api.runtime.agent.session.resolveStorePath(
677-params.api.config.session?.store,
678-{
679-agentId: params.agentId,
680-},
681-);
682-const store = params.api.runtime.agent.session.loadSessionStore(storePath, { clone: false });
683-const sessionEntry = resolveSessionStoreEntry({
684- store,
667+const sessionEntry = params.api.runtime.agent.session.getSessionEntry({
668+agentId: params.agentId,
685669sessionKey: resolvedSessionKey,
686-}).existing;
670+});
687671const rawStrongEntryChannel =
688672normalizeOptionalString(sessionEntry?.lastChannel) ??
689673normalizeOptionalString(sessionEntry?.channel);
@@ -1594,53 +1578,50 @@ async function persistPluginStatusLines(params: {
15941578return;
15951579}
15961580try {
1597-const storePath = params.api.runtime.agent.session.resolveStorePath(
1598-params.api.config.session?.store,
1599-agentId ? { agentId } : undefined,
1600-);
16011581if (!params.statusLine && !debugLine) {
1602-const store = params.api.runtime.agent.session.loadSessionStore(storePath, { clone: false });
1603-const existingEntry = resolveSessionStoreEntry({ store, sessionKey }).existing;
1582+const existingEntry = params.api.runtime.agent.session.getSessionEntry({
1583+ agentId,
1584+ sessionKey,
1585+});
16041586const hasActiveMemoryEntry = Array.isArray(existingEntry?.pluginDebugEntries)
16051587 ? existingEntry.pluginDebugEntries.some((entry) => entry?.pluginId === "active-memory")
16061588 : false;
16071589if (!hasActiveMemoryEntry) {
16081590return;
16091591}
16101592}
1611-await updateSessionStore(storePath, (store) => {
1612-const resolved = resolveSessionStoreEntry({ store, sessionKey });
1613-const existing = resolved.existing;
1614-if (!existing) {
1615-return;
1616-}
1617-const previousEntries = Array.isArray(existing.pluginDebugEntries)
1618- ? existing.pluginDebugEntries
1619- : [];
1620-const nextEntries = previousEntries.filter(
1621-(entry): entry is PluginDebugEntry =>
1622-Boolean(entry) &&
1623-typeof entry === "object" &&
1624-typeof entry.pluginId === "string" &&
1625-entry.pluginId !== "active-memory",
1626-);
1627-const nextLines: string[] = [];
1628-if (params.statusLine) {
1629-nextLines.push(params.statusLine);
1630-}
1631-if (debugLine) {
1632-nextLines.push(debugLine);
1633-}
1634-if (nextLines.length > 0) {
1635-nextEntries.push({
1636-pluginId: "active-memory",
1637-lines: nextLines,
1638-});
1639-}
1640-store[resolved.normalizedKey] = {
1641- ...existing,
1642-pluginDebugEntries: nextEntries.length > 0 ? nextEntries : undefined,
1643-};
1593+await params.api.runtime.agent.session.patchSessionEntry({
1594+ agentId,
1595+ sessionKey,
1596+preserveActivity: true,
1597+update: (existing) => {
1598+const previousEntries = Array.isArray(existing.pluginDebugEntries)
1599+ ? existing.pluginDebugEntries
1600+ : [];
1601+const nextEntries = previousEntries.filter(
1602+(entry): entry is PluginDebugEntry =>
1603+Boolean(entry) &&
1604+typeof entry === "object" &&
1605+typeof entry.pluginId === "string" &&
1606+entry.pluginId !== "active-memory",
1607+);
1608+const nextLines: string[] = [];
1609+if (params.statusLine) {
1610+nextLines.push(params.statusLine);
1611+}
1612+if (debugLine) {
1613+nextLines.push(debugLine);
1614+}
1615+if (nextLines.length > 0) {
1616+nextEntries.push({
1617+pluginId: "active-memory",
1618+lines: nextLines,
1619+});
1620+}
1621+return {
1622+pluginDebugEntries: nextEntries.length > 0 ? nextEntries : undefined,
1623+};
1624+},
16441625});
16451626} catch (error) {
16461627params.api.logger.debug?.(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。