File size: 864 Bytes
9b906ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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,
  });
};