UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

43 lines (42 loc) 2.14 kB
import { m as resolveAgentWorkspaceDir } from "./agent-scope-config-DcbEhP0R.js"; import { o as resolveSessionStorePathCore } from "./paths-CXdaYWF_.js"; import { _ as resolveSessionAgentId } from "./agent-scope-DbtJyKUL.js"; import { r as logVerbose } from "./globals-CTaGxEqj.js"; import { x as runWithGatewayIndependentRootWorkContinuation } from "./gateway-work-admission-R1IpuDim.js"; import { n as parseSqliteSessionFileMarker } from "./legacy-sqlite-marker-COPKCuIN.js"; import { i as hasInternalHookListeners, n as createInternalHookEvent, u as triggerInternalHook } from "./internal-hooks-Dgwjgwuj.js"; //#region src/hooks/session-auto-reset.ts function isSessionAutoResetReason(reason) { return reason === "daily" || reason === "idle"; } function hasSessionAutoResetListeners() { return hasInternalHookListeners("session", "auto-reset"); } function emitSessionAutoResetHook(params) { if (!isSessionAutoResetReason(params.reason) || !hasSessionAutoResetListeners()) return; const marker = parseSqliteSessionFileMarker(params.sessionFile); const agentId = params.agentId ?? marker?.agentId ?? resolveSessionAgentId({ sessionKey: params.sessionKey, config: params.cfg }); const event = createInternalHookEvent("session", "auto-reset", params.sessionKey, { cfg: params.cfg, agentId, workspaceDir: params.workspaceDir ?? resolveAgentWorkspaceDir(params.cfg, agentId), storePath: params.storePath ?? marker?.storePath ?? resolveSessionStorePathCore(params.cfg.session?.store, { agentId }), sessionEntry: { sessionId: params.sessionId, sessionFile: params.sessionFile }, reason: params.reason, transcriptArchived: params.transcriptArchived, nextSessionId: params.nextSessionId, nextSessionKey: params.nextSessionKey, previousSessionMemory: params.previousSessionMemory }); runWithGatewayIndependentRootWorkContinuation(() => triggerInternalHook(event), "hooks:session-auto-reset").catch((error) => { logVerbose(`session:auto-reset hook failed: ${String(error)}`); }); } //#endregion export { hasSessionAutoResetListeners as n, isSessionAutoResetReason as r, emitSessionAutoResetHook as t };