import { useQuery } from "@tanstack/react-query"; import { getMemoryTask } from "@/services/memory"; import { queryKeys } from "@/lib/query-keys"; import { useRuntimeContext } from "@/providers/runtime-context-provider"; import type { MemoryScope } from "@/types/memory"; export function useMemoryTask( memoryStoreName: string, requestId: string | undefined, scope?: MemoryScope, ) { const { context, ready } = useRuntimeContext(); return useQuery({ queryKey: queryKeys.memoryTask( context.dataScopeKey, memoryStoreName, requestId, scope, ), queryFn: () => getMemoryTask(memoryStoreName, requestId!, scope), enabled: ready && !!memoryStoreName && !!requestId, }); }