Raxol. AgentClientProtocol. Schema. Ext. ExtResponse
(Raxol Agent Client Protocol v0.1.0)
Copy Markdown
View Source
The reply to an ExtRequest.
Unlike most ACP types, ExtResponse's wire representation is
transparent: the JSON-RPC result body IS the wrapped data term
verbatim (see to_json/1), not an envelope like %{"data" => ...}. This
mirrors the upstream f1729/agent_client_protocol behavior, since an
extension's response shape is defined entirely by the extension itself —
ACP core has no opinion on it.
Fixed defect
The upstream library's __using__-injected default implementation of
ext_method/1 (in its ACP.Client/ACP.Agent behaviours) constructed
%ACP.ExtResponse{value: nil} — but the struct's only field is :data,
so that default raised KeyError on every un-overridden _ext/* request.
This module fixes its half of that mismatch: the struct field is :data
everywhere (construction, to_json/1, from_json/1), and empty/0 is
the canonical, crash-proof "no extension implemented" response — callers
wiring an ACP behaviour's default ext_method/1 should return
{:ok, ExtResponse.empty()}, never hand-roll the struct.
Ported from the MIT f1729/agent_client_protocol (c) 2025 f1729; see NOTICE.md.
Summary
Functions
The canonical "no extension implemented" response — safe to return from
an un-overridden ext_method/1 callback. Never raises, unlike the
upstream library's %ExtResponse{value: nil} default.
Wrap an already-decoded wire value as an ExtResponse. Total and infallible
by construction — any term is a valid data payload.
Wrap an arbitrary term as an ExtResponse.
The raw wire value for this response: just the wrapped data, unwrapped.
Types
@type t() :: %Raxol.AgentClientProtocol.Schema.Ext.ExtResponse{data: term()}
Functions
@spec empty() :: t()
The canonical "no extension implemented" response — safe to return from
an un-overridden ext_method/1 callback. Never raises, unlike the
upstream library's %ExtResponse{value: nil} default.
Wrap an already-decoded wire value as an ExtResponse. Total and infallible
by construction — any term is a valid data payload.
Wrap an arbitrary term as an ExtResponse.
The raw wire value for this response: just the wrapped data, unwrapped.