(execute-native t args)(execute-native t args ctx)Call a Tool's :execute directly, with §0.8's throw-becomes-isError rule
applied. Equivalent to toolnexus.tool/execute on a one-tool toolkit.
Call a Tool's :execute directly, with §0.8's throw-becomes-isError rule applied. Equivalent to `toolnexus.tool/execute` on a one-tool toolkit.
(native-tool m)(native-tool tool-name description input-schema run)Build a native Tool from a plain function.
Map form (preferred):
(native-tool {:name "upper" :description "Uppercase"
:input-schema {:type "object"}
:run (fn [args] (str/upper-case (:text args)))})
:run receives ONE argument — the args map. A tool that needs the §1
Context declares :ctx? true and receives two:
(native-tool {:name "ask" :run (fn [args ctx] …) :ctx? true})
PORTABILITY NOTE — why the flag exists. JS/Python/Go can hand run both
values and let the callee ignore the extra one; Clojure cannot. Arity
introspection is java.lang.reflect on the JVM and absent on cljgo, so there
is no portable way to ask a fn how many arguments it takes. The flag is the
honest version of what the other ports get for free. It costs a keyword and
never guesses wrong.
Build a native Tool from a plain function.
Map form (preferred):
(native-tool {:name "upper" :description "Uppercase"
:input-schema {:type "object"}
:run (fn [args] (str/upper-case (:text args)))})
`:run` receives ONE argument — the args map. A tool that needs the §1
Context declares `:ctx? true` and receives two:
(native-tool {:name "ask" :run (fn [args ctx] …) :ctx? true})
PORTABILITY NOTE — why the flag exists. JS/Python/Go can hand `run` both
values and let the callee ignore the extra one; Clojure cannot. Arity
introspection is `java.lang.reflect` on the JVM and absent on cljgo, so there
is no portable way to ask a fn how many arguments it takes. The flag is the
honest version of what the other ports get for free. It costs a keyword and
never guesses wrong.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |