openhands / src /hooks /query /use-local-plugins.ts
SaylorTwift's picture
SaylorTwift HF Staff
Add files using upload-large-folder tool
9b906ea verified
Raw
History Blame Contribute Delete
864 Bytes
import { useQuery } from "@tanstack/react-query";
import { useActiveBackend } from "#/contexts/active-backend-context";
import PluginsService, { type LocalPlugin } from "#/api/plugins-service";
import { PLUGINS_QUERY_KEYS } from "./query-keys";
/**
* Query hook for the locally-discovered ("ambient") plugins on the local
* agent-server (e.g. `~/.agents/plugins`). Read-only and local-backend only — a
* cloud backend yields an empty list. Rendered as the read-only "Local" group on
* the Plugins page. Mirrors `usePlugins`.
*/
export const useLocalPlugins = () => {
const { backend, orgId } = useActiveBackend();
return useQuery<LocalPlugin[]>({
queryKey: [...PLUGINS_QUERY_KEYS.local, backend.id, orgId],
queryFn: () => PluginsService.getLocalPlugins(),
staleTime: 1000 * 60 * 10, // 10 minutes
refetchOnWindowFocus: false,
});
};