Files
openclaw/src/channels/session-meta.ts
2026-03-29 22:42:06 +01:00

34 lines
963 B
TypeScript

import type { MsgContext } from "../auto-reply/templating.js";
import type { OpenClawConfig } from "../config/config.js";
let inboundSessionRuntimePromise: Promise<
typeof import("../config/sessions/inbound.runtime.js")
> | null = null;
function loadInboundSessionRuntime() {
inboundSessionRuntimePromise ??= import("../config/sessions/inbound.runtime.js");
return inboundSessionRuntimePromise;
}
export async function recordInboundSessionMetaSafe(params: {
cfg: OpenClawConfig;
agentId: string;
sessionKey: string;
ctx: MsgContext;
onError?: (error: unknown) => void;
}): Promise<void> {
const runtime = await loadInboundSessionRuntime();
const storePath = runtime.resolveStorePath(params.cfg.session?.store, {
agentId: params.agentId,
});
try {
await runtime.recordSessionMetaFromInbound({
storePath,
sessionKey: params.sessionKey,
ctx: params.ctx,
});
} catch (err) {
params.onError?.(err);
}
}