Toolnexus.Native (toolnexus v0.9.4)

Copy Markdown View Source

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.ToolResult passes through unchanged
  • a binary is wrapped as a success output
  • anything else is JSON-encoded (JS JSON.stringify parity)
  • a raise becomes %ToolResult{is_error: true, output: <message>}

Summary

Functions

Wrap a function as a Tool.

Functions

define_tool(opts)

@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 -> ... end or fn args, ctx -> ... end