Spaces:
Paused
Paused
Download src/plugins/runtime.ts from amos-fernandes/melbot: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/spaces/amos-fernandes/melbot/resolve/main/src/plugins/runtime.ts
- Command line
-
hf download hf://spaces/amos-fernandes/melbot/src/plugins/runtime.ts
-
curl -L -o runtime.ts https://huggingface.co/spaces/amos-fernandes/melbot/resolve/main/src/plugins/runtime.ts
1.33 kB
| import type { PluginRegistry } from "./registry.js"; | |
| const createEmptyRegistry = (): PluginRegistry => ({ | |
| plugins: [], | |
| tools: [], | |
| hooks: [], | |
| typedHooks: [], | |
| channels: [], | |
| providers: [], | |
| gatewayHandlers: {}, | |
| httpHandlers: [], | |
| httpRoutes: [], | |
| cliRegistrars: [], | |
| services: [], | |
| commands: [], | |
| diagnostics: [], | |
| }); | |
| const REGISTRY_STATE = Symbol.for("moltbot.pluginRegistryState"); | |
| type RegistryState = { | |
| registry: PluginRegistry | null; | |
| key: string | null; | |
| }; | |
| const state: RegistryState = (() => { | |
| const globalState = globalThis as typeof globalThis & { | |
| [REGISTRY_STATE]?: RegistryState; | |
| }; | |
| if (!globalState[REGISTRY_STATE]) { | |
| globalState[REGISTRY_STATE] = { | |
| registry: createEmptyRegistry(), | |
| key: null, | |
| }; | |
| } | |
| return globalState[REGISTRY_STATE] as RegistryState; | |
| })(); | |
| export function setActivePluginRegistry(registry: PluginRegistry, cacheKey?: string) { | |
| state.registry = registry; | |
| state.key = cacheKey ?? null; | |
| } | |
| export function getActivePluginRegistry(): PluginRegistry | null { | |
| return state.registry; | |
| } | |
| export function requireActivePluginRegistry(): PluginRegistry { | |
| if (!state.registry) { | |
| state.registry = createEmptyRegistry(); | |
| } | |
| return state.registry; | |
| } | |
| export function getActivePluginRegistryKey(): string | null { | |
| return state.key; | |
| } | |