Messages
Category: Jsonrpc
Source: messages.dart
JSON-RPC 2.0 message types, shared between the ACP and MCP servers.
Pure data — no I/O, no transport. See codec.dart for serialization and transport/stdio.dart for line-delimited framing.
Classes
sealed JsonRpcMessage
Sealed type for all JSON-RPC messages flowing in either direction.
Constructor
dart
const JsonRpcMessage()JsonRpcRequest
A JSON-RPC request — has an [id] and expects a [JsonRpcResponse].
Constructor
dart
const JsonRpcRequest({required this.id, required this.method, this.params})Properties
| Property | Type | Description |
|---|---|---|
id | Object | Either an int or a String per JSON-RPC 2.0 §3. |
method | String | |
params | Map<String, Object?>? |
JsonRpcNotification
A JSON-RPC notification — no [id], no response expected.
Constructor
dart
const JsonRpcNotification({required this.method, this.params})Properties
| Property | Type | Description |
|---|---|---|
method | String | |
params | Map<String, Object?>? |
JsonRpcResponse
A successful response.
Constructor
dart
const JsonRpcResponse({required this.id, required this.result})Properties
| Property | Type | Description |
|---|---|---|
id | Object | |
result | Object? |
JsonRpcError
An error response.
Constructor
dart
const JsonRpcError({
required this.id,
required this.code,
required this.message,
this.data,
})Properties
| Property | Type | Description |
|---|---|---|
id | Object? | Null only for parse errors that arrive before we can read the id. |
code | int | |
message | String | |
data | Object? |
abstract JsonRpcErrorCode
Standard JSON-RPC 2.0 error codes (§5.1) plus a Glue-reserved range.
Properties
| Property | Type | Description |
|---|---|---|
parseError | const int | Invalid JSON received by the server. |
invalidRequest | const int | The JSON sent is not a valid Request object. |
methodNotFound | const int | The method does not exist or is not available. |
invalidParams | const int | Invalid method parameter(s). |
internalError | const int | Internal JSON-RPC error. |
permissionDenied | const int | Glue-reserved: the user denied a permission request that gated this method. ACP/MCP both surface permission denial through this code. |
sessionNotFound | const int | Glue-reserved: the requested session ID is unknown or has been closed. |
cancelled | const int | Glue-reserved: the agent's prompt loop was cancelled (matching session/cancel). |