AgentWireProtocol class
The pure event/command mapping and version negotiation for protocol v1.
Constructors
- AgentWireProtocol({int version = wireProtocolVersion})
-
Creates a protocol speaking
version. Unsupported versions are a construction-time WireVersionError — a host cannot half-configure the mapping.
Properties
Methods
-
decodeCommand(
Map< String, dynamic> frame) → WireCommand - Decodes a command frame. Unknown kinds return WireUnknownCommand; malformed known frames and unsupported versions throw WireProtocolException/WireVersionError — declared types are the only escapes.
-
decodeEvent(
Map< String, dynamic> frame) → DecodedWireEvent -
Decodes an event frame. Unknown kinds (and
unknown_eventitself) return UnknownWireEvent; malformed known frames and unsupported versions throw WireProtocolException/WireVersionError — declared types are the only escapes (a malformed field must not surface as a raw TypeError from a nestedfromJson). -
encodeApprovalRequest(
{required String id, required ApprovalRequest request}) → Map< String, dynamic> -
Encodes an in-process ApprovalRequest as an
approval_requestframe. -
encodeAskRequest(
{required String id, required List< AskQuestion> questions}) → Map<String, dynamic> -
Encodes an in-process
askcallback's questions as anask_request. -
encodeAssistantEvent(
AssistantMessageEvent event) → Map< String, dynamic> -
Encodes the nested provider-event discriminator of a
message_updateframe.partialis never duplicated here — the frame'smessagefield IS the live partial. -
encodeCommand(
WireCommand command) → Map< String, dynamic> -
Encodes a typed
commandinto its canonical frame. -
encodeEvent(
AgentEvent event) → Map< String, dynamic> -
Encodes
eventinto a canonical frame at this protocol's version. -
encodeSecretRequest(
{required String id, required String name, required String reason}) → Map< String, dynamic> -
Encodes an in-process
request_secretcallback inputs as asecret_request. -
encodeUnknownEvent(
{required String originalKind, Map< String, dynamic> ? payload}) → Map<String, dynamic> -
Builds the documented
unknown_eventpassthrough frame — what a host emits when it must forward a frame it does not understand. -
hello(
{List< int> versions = const [wireProtocolVersion], List<String> caps = const []}) → Map<String, dynamic> -
Builds the client
helloframe. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
welcome(
{int negotiated = wireProtocolVersion, List< String> caps = const []}) → Map<String, dynamic> -
Builds the server
welcomeframe fornegotiated.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
acceptHello(
Map< String, dynamic> helloFrame, {List<String> caps = const []}) → ({AgentWireProtocol protocol, Map<String, dynamic> welcome}) -
Validates a client
helloand negotiates the highest mutually supported version. The hello frame's ownvparticipates in negotiation alongside the frame'sversionsarray; negotiation is max-overlap and throws WireVersionError when there is no overlap (the loud unsupported-version error). WireProtocolException is thrown when the frame itself is malformed. -
frameLine(
Map< String, dynamic> frame) → String -
Frames one message as a single NDJSON line (UTF-8 JSON object plus
\n). One object per line — NOT JSONP. -
isSecretField(
String kind, String field) → bool -
Whether
fieldof frame kindkindis SECRET-class (E4). The anywhere-rule is NOT dead for registry kinds: arawBodyundersecret_responsemust still be marked, so the registry check and the anywhere-rule OR together (?? would fall through onfalse). -
negotiate(
List< int> clientVersions) → int -
The highest version from
clientVersionsthis library supports. -
parseLine(
String line) → Map< String, dynamic> ? -
Parses one NDJSON line. Blank lines return
null; garbage throws FormatException; a line whose JSON is not an object throws WireProtocolException. -
redactForLog(
Map< String, dynamic> frame) → Map<String, dynamic> -
Deep-copies
framewith every SECRET-class field replaced by the repo-standard[REDACTED:<kind>]marker — the layered redaction pipeline keys on the kind label, so nested maps inherit the frame's kind (unknown-kind frames mark as[REDACTED:unknown]). Use for LOGGING and PERSISTENCE copies only — the live frame keeps its values so the engine can work.