mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-02 16:00:21 +00:00
34 lines
963 B
TypeScript
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);
|
|
}
|
|
}
|