ToolCall. IR. Type
(ToolCall v0.4.0)
Copy Markdown
A node in the value-domain tree.
kind: :any means "the library could not determine a domain" — usually an
unknown remote type. kind: :unsupported means "the domain is known but
JSON cannot express it" (functions, pids, refs). Emitters render both as
%{}; only :unsupported triggers a compile-time warning.
format is the JSON Schema format string and transform is the
{module, function} that runs after the wire value has been coerced. Both
are populated by a ToolCall.TypeProvider; a hand-built calendar node must
set them explicitly. pattern is the JSON Schema regex string and
pattern_regex is its compiled form, required by coercion. Use
ToolCall.Typespec.validate_type!/1 to build a validated copy of a
hand-written type. source is an atom for the string sub-kinds
(:charlist, :char, :binary, :bitstring, :nonempty_binary,
:nonempty_string, :path), which dispatch and result validation read, and for a few
diagnostics. A non-atom source is compile-time provenance and is dropped from
the embedded IR.
kind: :ref names an entry in the tool's defs map; emitters render it as
{"$ref": "#/$defs/<name>"} and never resolve it.
validator is the value-domain counterpart of transform: a provider type
describes its wire form in kind, and validator answers whether a value
the function returns belongs to the declared type (for example a %Date{}
for Date.t()). Result validation uses it; a nil validator on a node with a
transform means "not checkable" and is accepted.
Summary
Types
@type kind() ::
:integer
| :float
| :number
| :string
| :boolean
| :atom
| :array
| :object
| :tuple
| :enum
| :union
| :ref
| :struct
| :null
| :any
| :unsupported
@type t() :: %ToolCall.IR.Type{ additional: t() | nil, fields: [ToolCall.IR.Field.t()] | nil, format: String.t() | nil, items: t() | [t()] | nil, kind: kind(), maximum: number() | nil, minimum: number() | nil, nullable: boolean(), pattern: String.t() | nil, pattern_regex: Regex.t() | nil, ref: String.t() | nil, source: term(), struct: module() | nil, transform: {module(), atom()} | nil, validator: {module(), atom()} | nil, values: [term()] | nil, variants: [t()] | nil }