import crypto from "node:crypto"; import type { MsgContext } from "../../auto-reply/templating.js"; import {
normalizeThinkLevel,
normalizeVerboseLevel,
type ThinkLevel,
type VerboseLevel,
} from "../../auto-reply/thinking.js"; import {
resolveAgentIdFromSessionKey,
resolveExplicitAgentSessionKey,
} from "../../config/sessions/main-session.js"; import { resolveStorePath } from "../../config/sessions/paths.js"; import {
evaluateSessionFreshness,
resolveSessionResetPolicy,
} from "../../config/sessions/reset-policy.js"; import { resolveChannelResetConfig, resolveSessionResetType } from "../../config/sessions/reset.js"; import { resolveSessionKey } from "../../config/sessions/session-key.js"; import { loadSessionStore } from "../../config/sessions/store-load.js"; import type { SessionEntry } from "../../config/sessions/types.js"; import type { OpenClawConfig } from "../../config/types.openclaw.js"; import { normalizeAgentId, normalizeMainKey } from "../../routing/session-key.js"; import { resolveSessionIdMatchSelection } from "../../sessions/session-id-resolution.js"; import { listAgentIds } from "../agent-scope.js"; import { clearBootstrapSnapshotOnSessionRollover } from "../bootstrap-cache.js";
// If a session id was provided, prefer to re-use its existing entry (by id) even when no key was // derived. When duplicates exist across agent stores, pick the same deterministic best match used // by the shared gateway/session resolver helpers instead of whichever store happens to be scanned // first. if (
requestedSessionId &&
!explicitSessionKey &&
(!sessionKey || sessionStore[sessionKey]?.sessionId !== requestedSessionId)
) { const { matches, primaryStoreMatches, storeByKey } = collectSessionIdMatchesForRequest({
cfg: opts.cfg,
sessionStore,
storePath,
storeAgentId,
sessionId: requestedSessionId,
searchOtherAgentStores: requestedAgentId === undefined,
}); const preferredSelection = resolveSessionIdMatchSelection(matches, requestedSessionId); const currentStoreSelection =
preferredSelection.kind === "selected"
? preferredSelection
: resolveSessionIdMatchSelection(primaryStoreMatches, requestedSessionId); if (currentStoreSelection.kind === "selected") { const preferred = storeByKey.get(currentStoreSelection.sessionKey); if (preferred) { return preferred;
}
sessionKey = currentStoreSelection.sessionKey;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.