mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-03 20:51:40 +00:00
* feat(plugin-sdk): support removing pairing requests * refactor(reef): centralize peer trust in SQLite * chore: defer Reef release note * fix(reef): share runtime state across module instances * refactor(reef): narrow trust store boundary * test(reef): pass config to account description
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import type { PluginRuntime } from "openclaw/plugin-sdk/core";
|
|
import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
|
|
import type { ReefMessageFlow } from "./flow.js";
|
|
import type { ReefFriendManager } from "./friends.js";
|
|
import type { ReviewApprovalStore } from "./state.js";
|
|
|
|
type ActiveReef =
|
|
| { flow: ReefMessageFlow; friends: ReefFriendManager; reviews: ReviewApprovalStore }
|
|
| undefined;
|
|
|
|
const {
|
|
setRuntime: setReefRuntime,
|
|
tryGetRuntime: getOptionalReefRuntime,
|
|
getRuntime: getReefRuntime,
|
|
} = createPluginRuntimeStore<PluginRuntime>({
|
|
pluginId: "reef",
|
|
errorMessage: "Reef runtime unavailable",
|
|
});
|
|
|
|
// Keep the live channel handle in a second named slot: duplicate bundled-plugin
|
|
// module instances must observe the same running Reef instance for outbound sends.
|
|
const activeReefStore = createPluginRuntimeStore<Exclude<ActiveReef, undefined>>({
|
|
key: "plugin-runtime:reef:active",
|
|
errorMessage: "Reef channel is not running",
|
|
});
|
|
|
|
export { getOptionalReefRuntime, getReefRuntime, setReefRuntime };
|
|
|
|
export function setActiveReef(value: ActiveReef): void {
|
|
if (value) {
|
|
activeReefStore.setRuntime(value);
|
|
} else {
|
|
activeReefStore.clearRuntime();
|
|
}
|
|
}
|
|
|
|
export const getActiveReef = activeReefStore.getRuntime;
|