import { ɵThread } from "@copilotkitnext/core"; //#region src/hooks/use-threads.d.ts /** * A conversation thread managed by the Intelligence platform. * * Each thread has a unique `id`, an optional human-readable `name`, and * timestamp fields tracking creation and update times. */ interface Thread extends ɵThread {} /** * Configuration for the {@link useThreads} hook. * * Thread operations are scoped to the runtime-authenticated user and the * provided agent on the Intelligence platform. */ interface UseThreadsInput { /** The ID of the agent whose threads to list and manage. */ agentId: string; /** When `true`, archived threads are included in the list. Defaults to `false`. */ includeArchived?: boolean; /** Maximum number of threads to fetch per page. When set, enables cursor-based pagination. */ limit?: number; } /** * Return value of the {@link useThreads} hook. * * The `threads` array is kept in sync with the platform via a realtime * WebSocket subscription (when available) and is sorted most-recently-updated * first. Mutations reject with an `Error` if the platform request fails. */ interface UseThreadsResult { /** * Threads for the current user/agent pair, sorted by most recently * updated first. Updated in realtime when the platform pushes metadata * events. Includes archived threads only when `includeArchived` is set. */ threads: Thread[]; /** * `true` while the initial thread list is being fetched from the platform. * Subsequent realtime updates do not re-enter the loading state. */ isLoading: boolean; /** * The most recent error from fetching threads or executing a mutation, * or `null` when there is no error. Reset to `null` on the next * successful fetch. */ error: Error | null; /** * `true` when there are more threads available to fetch via * {@link fetchNextPage}. Only meaningful when `limit` is set. */ hasNextPage: boolean; /** * `true` while a subsequent page of threads is being fetched. */ isFetchingNextPage: boolean; /** * Fetch the next page of threads. No-op when {@link hasNextPage} is * `false` or a page fetch is already in progress. */ fetchNextPage: () => void; /** * Rename a thread on the platform. * Resolves when the server confirms the update; rejects on failure. */ renameThread: (threadId: string, name: string) => Promise; /** * Archive a thread on the platform. * Archived threads are excluded from subsequent list results. * Resolves when the server confirms the update; rejects on failure. */ archiveThread: (threadId: string) => Promise; /** * Permanently delete a thread from the platform. * This is irreversible. Resolves when the server confirms deletion; * rejects on failure. */ deleteThread: (threadId: string) => Promise; } /** * React hook for listing and managing Intelligence platform threads. * * On mount the hook fetches the thread list for the runtime-authenticated user * and the given `agentId`. When the Intelligence platform exposes a WebSocket * URL, it also opens a realtime subscription so the `threads` array stays * current without polling — thread creates, renames, archives, and deletes * from any client are reflected immediately. * * Mutation methods (`renameThread`, `archiveThread`, `deleteThread`) return * promises that resolve once the platform confirms the operation and reject * with an `Error` on failure. * * @param input - Agent identifier and optional list controls. * @returns Thread list state and stable mutation callbacks. * * @example * ```tsx * import { useThreads } from "@copilotkitnext/react"; * * function ThreadList() { * const { threads, isLoading, renameThread, deleteThread } = useThreads({ * agentId: "agent-1", * }); * * if (isLoading) return

Loading…

; * * return ( *
    * {threads.map((t) => ( *
  • * {t.name ?? "Untitled"} * * *
  • * ))} *
* ); * } * ``` */ declare function useThreads({ agentId, includeArchived, limit }: UseThreadsInput): UseThreadsResult; //#endregion export { Thread, UseThreadsInput, UseThreadsResult, useThreads }; //# sourceMappingURL=use-threads.d.cts.map