Native tools — turn a plain function into a uniform Toolnexus.Tool (SPEC §6).
The execute function's return value becomes the tool output:
- a
Toolnexus.ToolResultpasses through unchanged - a binary is wrapped as a success output
- anything else is JSON-encoded (JS
JSON.stringifyparity) - a raise becomes
%ToolResult{is_error: true, output: <message>}
Summary
Functions
Wrap a function as a Tool.
Functions
@spec define_tool(keyword() | map()) :: Toolnexus.Tool.t()
Wrap a function as a Tool.
Options (keyword list or map):
:name(required) — tool name:description(required) — tool description:input_schema— JSON schema map (default: empty object schema):source— tool source (default"native"):execute(required) —fn args -> ... endorfn args, ctx -> ... end