mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-09-25 14:06:18 +00:00
* feat(plugins): add full-stack contributions and bookmarks example * ci(plugins): provision bookmark gateway for browser tests * fix(plugins): authenticate module downloads through configured backend * fix(plugins): isolate contributions and localize extension UI * fix(plugins): preserve bookmark agent routing and contain async callbacks * fix(plugins): pin durable batch workers to app extension snapshots
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
"use client";
|
|
import { useQuery } from "@tanstack/react-query";
|
|
import { toast } from "sonner";
|
|
|
|
import { useAuth } from "@/core/auth/AuthProvider";
|
|
|
|
import { fetchFrontendExtensions, frontendExtensionsQueryKey } from "./api";
|
|
import { loadFrontendExtensions } from "./registry";
|
|
import { conversationText, latestVisibleAnswer } from "./services";
|
|
|
|
export function useFrontendExtensions() {
|
|
const { user } = useAuth();
|
|
return useQuery({
|
|
queryKey: [...frontendExtensionsQueryKey, user?.id],
|
|
queryFn: async () =>
|
|
loadFrontendExtensions(await fetchFrontendExtensions()),
|
|
enabled: !!user,
|
|
staleTime: Infinity,
|
|
gcTime: Infinity,
|
|
refetchOnMount: false,
|
|
refetchOnWindowFocus: false,
|
|
refetchOnReconnect: false,
|
|
retry: false,
|
|
});
|
|
}
|
|
/** Eagerly capture the page's plugin set, even before its first chat is opened. */
|
|
export function ExtensionPageBootstrap() {
|
|
useFrontendExtensions();
|
|
return null;
|
|
}
|
|
export function useFrontendServices() {
|
|
return {
|
|
conversationText,
|
|
latestVisibleAnswer,
|
|
showMessage: (message: string) => toast.message(message),
|
|
};
|
|
}
|