mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 16:40:42 +00:00
Merged via squash.
Prepared head SHA: e8d6738fd0
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
|
|
import type { PluginRuntime } from "./runtime-api.js";
|
|
|
|
const runtimeStore = createPluginRuntimeStore<PluginRuntime>({
|
|
pluginId: "bluebubbles",
|
|
errorMessage: "BlueBubbles runtime not initialized",
|
|
});
|
|
type LegacyRuntimeLogShape = { log?: (message: string) => void };
|
|
export const setBlueBubblesRuntime = runtimeStore.setRuntime;
|
|
|
|
export function clearBlueBubblesRuntime(): void {
|
|
runtimeStore.clearRuntime();
|
|
}
|
|
|
|
export function tryGetBlueBubblesRuntime(): PluginRuntime | null {
|
|
return runtimeStore.tryGetRuntime();
|
|
}
|
|
|
|
export function getBlueBubblesRuntime(): PluginRuntime {
|
|
return runtimeStore.getRuntime();
|
|
}
|
|
|
|
export function warnBlueBubbles(message: string): void {
|
|
const formatted = `[bluebubbles] ${message}`;
|
|
// Backward-compatible with tests/legacy injections that pass { log }.
|
|
const log = (runtimeStore.tryGetRuntime() as unknown as LegacyRuntimeLogShape | null)?.log;
|
|
if (typeof log === "function") {
|
|
log(formatted);
|
|
return;
|
|
}
|
|
console.warn(formatted);
|
|
}
|