mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 03:30:43 +00:00
29 lines
964 B
TypeScript
29 lines
964 B
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 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);
|
|
}
|