import type { ResourceClient } from "./resource-client.js"; import type { AgentStore } from "./store.js"; import type { AgentStoreSnapshot, ConnectionStatus, ResourceClientSnapshot } from "./types.js"; /** * Subscribe to an {@link AgentStore} and re-render whenever state changes. * * Uses `useSyncExternalStore` internally for concurrent-mode safety. The * returned snapshot is the same object reference until the next state change, * so destructuring is stable across renders. * * @param store - The store to subscribe to. * @returns Current immutable state snapshot. * * @example * ```tsx * function ChatPanel({ store }: { store: AgentStore }) { * const { messages, streamingText, phase } = useAgentStore(store) * // ... * } * ``` * @docLink packages/store/concepts#react-hooks */ export declare function useAgentStore(store: AgentStore): AgentStoreSnapshot; /** * Return stable action dispatchers bound to an {@link AgentStore}. * * The returned object is referentially stable across renders (memoised on * `store` identity), so it is safe to pass as a dependency to `useCallback` * or `useMemo` without causing unnecessary re-computations. * * @param store - The store to bind actions to. * @returns Object with `prompt`, `reply`, `cancel`, `loadPreviousMessages`, * and `setStatus` action functions. * * @example * ```tsx * function ChatInput({ store }: { store: AgentStore }) { * const { prompt, cancel } = useAgentStoreActions(store) * return * } * ``` * @docLink packages/store/concepts#react-hooks */ export declare function useAgentStoreActions(store: AgentStore): { /** Send a user prompt to the agent. */ prompt: (text: string) => void; /** * Send a reply to the agent's pending question. Pass `question` verbatim * from the `question` event being answered when the UI can surface * several at once — see {@link AgentStore.reply}. */ reply: (answer: string, question?: string, requestId?: string) => void; /** Cancel the current agent turn. */ cancel: () => void; /** Load the previous page of messages. */ loadPreviousMessages: () => Promise; /** Programmatically update the connection status. */ setStatus: (status: ConnectionStatus) => void; }; /** * Subscribe to a {@link ResourceClient} and re-render when resources change. * * Uses `useSyncExternalStore` for concurrent-mode safety. Re-renders only * when the agent emits a `resources_available` event (typically once on connect). * * @param client - The resource client to subscribe to. * @returns Current immutable resource snapshot (mounts + connectors). * * @example * ```tsx * function ResourcePanel({ client }: { client: ResourceClient }) { * const { mounts, connectors } = useResourceClient(client) * // ... * } * ``` * @docLink packages/store/concepts#react-hooks */ export declare function useResourceClient(client: ResourceClient): ResourceClientSnapshot; //# sourceMappingURL=react.d.ts.map