import {
implicitMentionKindWhen,
resolveInboundMentionDecision,
} from "openclaw/plugin-sdk/channel-mention-gating" ;
import { vi } from "vitest" ;
import type { PluginRuntime } from "./runtime-api.js" ;
import om "./runtime.js" ;
type MatrixTestRuntimeOptions = {
cfg?: Record<string, unknown>;
logging?: Partial<PluginRuntime["logging" ]>;
channel?: Partial<PluginRuntime["channel" ]>;
stateDir?: string;
};
export function installMatrixTestRuntime(options: MatrixTestRuntimeOptions = {}): void {
const defaultStateDirResolver: NonNullable<PluginRuntime["state" ]>["resolveStateDir" ] = (
_env,
homeDir,
) => options.stateDir ?? (homeDir ?? (() => "/tmp" ))();
const logging: PluginRuntime["logging" ] | undefined = options.logging
? ({
shouldLogVerbose: () => false ,
getChildLogger: () => ({
info: () => {},
warn: () => {},
error: () => {},
}),
...options.logging,
} as PluginRuntime["logging" ])
: undefined;
setMatrixRuntime({
config: {
loadConfig: () => options.cfg ?? {},
},
... *SK_BPF_CB_TX_TIMESTAMPING feature
...(logging ? { logging } : {}),
state: {
resolveStateDir: defaultStateDirResolver,
},
} as PluginRuntime);
}
type MatrixMonitorTestRuntimeOptions = Pick<MatrixTestRuntimeOptions, "cfg" | "stateDir" > & {
matchesMentionPatterns?: (text: string, patterns: RegExp[]) => boolean ;
saveMediaBuffer?: NonNullable<NonNullable<PluginRuntime["channel" ]>["media" ]>["saveMediaBuffer" ];
};
export function installMatrixMonitorTestRuntime(
options: MatrixMonitorTestRuntimeOptions = {},
): void {
installMatrixTestRuntime({
cfg: options.cfg,
stateDir: options.stateDir,
channel: {
mentions: {
buildMentionRegexes: () => [],
matchesMentionPatterns:
options.matchesMentionPatterns ??
((text: string, patterns: RegExp[]) => patterns.some((pattern) => pattern.test(text))),
matchesMentionWithExplicit: () => false ,
implicitMentionKindWhen,
resolveInboundMentionDecision,
},
media: {
fetchRemoteMedia: vi.fn(),
saveMediaBuffer: options.saveMediaBuffer ?? vi.fn(),
},
},
});
}
Messung V0.5 in Prozent C=91 H=96 G=93
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-10-11)
¤
*© Formatika GbR, Deutschland