A protocol-neutral handler result shaped later by the selected dialect.
error/2 builds a successful tools/call response carrying
isError: true. That is what a failed upstream call, a rejected domain
precondition, or any other outcome the tool itself understands should
return. It is not the same as returning {:error, %Snodo.Error{}} from a
handler, which makes the whole JSON-RPC request fail. See Snodo.Tool for
which to reach for.
Values handed to structured/2 and to the content builders must be JSON
values, meaning string keys and no atoms. Snodo.JSONValue.encodable!/1
converts an atom-keyed domain value into one.
Summary
Functions
Builds a ranked completion result with optional cardinality hints.
Builds a tools/call result that reports a failure.
Requests another round trip from an ordinary tool, resource, or prompt.
Converts a tool's {:ok, value} payload into a result.
Builds a prompts/get result.
Builds a prompts/list result from Snodo.Prompt.Definition structs.
Wraps a map that is already in wire shape.
Builds a tools/call result from content blocks.
Builds a resources/read result.
Builds a resources/templates/list result from Snodo.Resource.Definition
structs.
Builds a resources/list result from Snodo.Resource.Definition structs.
Builds a structured result from a JSON value.
Builds a text result.
Builds a tools/list result from Snodo.Tool.Definition structs.
Marks a JSON object as an already dialect-shaped result.
Types
@type kind() ::
:text
| :structured
| :resource
| :tools
| :resources
| :resource_templates
| :resource_read
| :prompts
| :prompt_get
| :completion
| :subscription
| :input_required
| :error
| :raw
| :wire
@type t() :: %Snodo.Result{ error: Snodo.Error.t() | nil, kind: kind(), metadata: map(), value: term() }
Functions
Builds a ranked completion result with optional cardinality hints.
Builds a tools/call result that reports a failure.
message becomes one "text" content block and "isError" is true. The
JSON-RPC request itself succeeds. Output schema validation is skipped.
Options:
:error- anSnodo.Errorkept in the result'serrorfield. It is not sent to the client. Defaults toSnodo.Error.execution(message).:metadata- as fortext/2.
Requests another round trip from an ordinary tool, resource, or prompt.
Provide :input_requests (a map of server-assigned IDs to bare input
requests), :request_state (an opaque string), or both. For example:
Result.input_required(input_requests: %{"approval" => request})The current request ends when this result is sent. The client may retry with
a fresh ID and new Snodo.Context.input_responses / request_state values, or
never retry. Keep side effects explicit and defer them until inputs are ready.
Use Snodo.MRTR.State when state influences business logic; a plain string is
not integrity protection. The dialect validates placement and peer support.
Prefer a nonempty input map or a state-only continuation. The pinned official
TypeScript client rejects an empty inputRequests without state, even though
the protocol schema permits that field to be an empty map.
Converts a tool's {:ok, value} payload into a result.
A Snodo.Result is returned unchanged, a binary becomes text/1, and any
other value becomes structured/1.
Builds a prompts/get result.
messages is one message or a list of them, built with
Snodo.Prompt.message/2.
Options:
:description- a string sent as the result's"description".:metadata- as fortext/2.
Builds a prompts/list result from Snodo.Prompt.Definition structs.
Snodo.Router.dispatch/5 returns this for :prompts_list.
Wraps a map that is already in wire shape.
As a tools/call result, the map is sent as the result, with "content"
defaulting to [] and "isError" to false. When the tool declares an
output schema, the map must carry "structuredContent", which is validated.
Extensions also return raw/1 from Snodo.Extension.dispatch/3 and shape
the value in Snodo.Extension.shape_result/3.
Builds a tools/call result from content blocks.
contents is one content block map, such as an "image" or embedded
"resource" block, or a list of them. It becomes the result's "content"
unchanged, with "isError" => false.
Options:
:metadata- as fortext/2.
Builds a resources/read result.
contents is one resource-content map or a list of them, built with
Snodo.Resource.text/3, Snodo.Resource.json/3, or Snodo.Resource.blob/3.
Options:
:metadata- a map. String keys are added to the result's"_meta". The atom keys:ttl_ms(a non-negative integer) and:cache_scope("public"or"private") override the runtime'sresources_cachepolicy for this read.
Builds a resources/templates/list result from Snodo.Resource.Definition
structs.
Snodo.Router.dispatch/5 returns this for :resource_templates_list.
Builds a resources/list result from Snodo.Resource.Definition structs.
Snodo.Router.dispatch/5 returns this for :resources_list.
Builds a structured result from a JSON value.
As a tools/call result, value becomes "structuredContent" and is also
encoded as JSON into one "text" content block. When the tool declares an
output schema, the runtime's schema validator checks value against it.
Options:
:metadata- as fortext/2.
Builds a text result.
As a tools/call result it becomes one "text" content block with
"isError" => false.
Options:
:metadata- a map. String keys are added to the result's"_meta"; atom keys are not sent.
Builds a tools/list result from Snodo.Tool.Definition structs.
Snodo.Router.dispatch/5 returns this for :tools_list. The server then
pages it and adds cache hints.
Marks a JSON object as an already dialect-shaped result.
This escape hatch is intended for protocol dialects and negotiated extensions that add a polymorphic result shape to an existing core method. The selected dialect still stamps response metadata and the server still validates that the final JSON-RPC response is JSON-compatible.