toolmark-monorepo / @toolmark/react / useTool
Function: useTool()
useTool<
I,O>(def):void
Defined in: packages/react/src/use-tool.ts:51
Registers def as a tool in the current scope (spec §9) while the component is mounted.
Registration happens in an effect and is StrictMode-safe (a double mount/unmount leaves exactly one live registration). run, summary and state always call the latest def through a ref updated on every render, so a fresh def object each render never needs a re-registration by itself. The tool re-registers only when name, description, title, hints (compared shallowly) or the input/output/jsonSchema identities change.
Type Parameters
I
I
O
O
Parameters
def
ToolDefinition<I, O>
The tool declaration.
Returns
void