mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 18:58:26 +00:00
refactor: dedupe plugin runtime stores
This commit is contained in:
@@ -194,6 +194,7 @@ export { buildOauthProviderAuthResult } from "./provider-auth-result.js";
|
||||
export { formatResolvedUnresolvedNote } from "./resolution-notes.js";
|
||||
export { buildChannelSendResult } from "./channel-send-result.js";
|
||||
export type { ChannelSendRawResult } from "./channel-send-result.js";
|
||||
export { createPluginRuntimeStore } from "./runtime-store.js";
|
||||
export type { ChannelDock } from "../channels/dock.js";
|
||||
export { getChatChannelMeta } from "../channels/registry.js";
|
||||
export { resolveAllowlistMatchByCandidates } from "../channels/allowlist-match.js";
|
||||
|
||||
26
src/plugin-sdk/runtime-store.ts
Normal file
26
src/plugin-sdk/runtime-store.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
export function createPluginRuntimeStore<T>(errorMessage: string): {
|
||||
setRuntime: (next: T) => void;
|
||||
clearRuntime: () => void;
|
||||
tryGetRuntime: () => T | null;
|
||||
getRuntime: () => T;
|
||||
} {
|
||||
let runtime: T | null = null;
|
||||
|
||||
return {
|
||||
setRuntime(next: T) {
|
||||
runtime = next;
|
||||
},
|
||||
clearRuntime() {
|
||||
runtime = null;
|
||||
},
|
||||
tryGetRuntime() {
|
||||
return runtime;
|
||||
},
|
||||
getRuntime() {
|
||||
if (!runtime) {
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
return runtime;
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user