"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useToolset = useToolset;
const react_1 = require("react");
const toolset_1 = require("../utils/toolset/index.js");
/**
 * Wire a toolset into the chat: returns a `MessageRendererRegistry` that
 * renders tool parts via the toolset and a `handleToolResult` callback
 * that merges results into history. To react to tool completion (e.g.
 * forward to the model), pair with `useToolResultContinuation`.
 *
 * Pass the same `toolset` reference across renders (e.g. via `useMemo` or
 * `createToolset`) so the registry stays stable.
 */
function useToolset(options) {
    const { toolset, setMessages, registry } = options;
    const handleToolResult = (0, react_1.useCallback)((event) => {
        setMessages((prev) => (0, toolset_1.applyToolResult)(prev, event));
    }, [setMessages]);
    const messageRendererRegistry = (0, react_1.useMemo)(() => (0, toolset_1.createToolsetRenderer)(toolset, {
        onToolResult: handleToolResult,
        registry,
    }), [toolset, handleToolResult, registry]);
    return { messageRendererRegistry, handleToolResult };
}
//# sourceMappingURL=useToolset.js.map
