ahp_types/errors.rs
1// Generated from types/*.ts — do not edit.
2//
3// Regenerate with: npm run generate:rust
4
5#![allow(missing_docs)]
6
7#[allow(unused_imports)]
8use crate::common::{AnyValue, JsonObject, StringOrMarkdown, Uri};
9#[allow(unused_imports)]
10use serde::{Deserialize, Serialize};
11#[allow(unused_imports)]
12use serde_repr::{Deserialize_repr, Serialize_repr};
13
14use crate::commands::ResourceRequestParams;
15use crate::state::ProtectedResourceMetadata;
16
17// ─── Standard JSON-RPC Error Codes ─────────────────────────────────────────
18
19/// Standard JSON-RPC 2.0 error codes.
20pub mod json_rpc_error_codes {
21 /// Invalid JSON.
22 pub const PARSE_ERROR: i32 = -32700;
23 /// Not a valid JSON-RPC request.
24 pub const INVALID_REQUEST: i32 = -32600;
25 /// Unknown method name.
26 pub const METHOD_NOT_FOUND: i32 = -32601;
27 /// Invalid method parameters.
28 pub const INVALID_PARAMS: i32 = -32602;
29 /// Unspecified server error.
30 pub const INTERNAL_ERROR: i32 = -32603;
31}
32
33/// AHP application-specific error codes.
34pub mod ahp_error_codes {
35 /// The referenced session URI does not exist.
36 pub const SESSION_NOT_FOUND: i32 = -32001;
37 /// The requested agent provider is not registered.
38 pub const PROVIDER_NOT_FOUND: i32 = -32002;
39 /// A session with the given URI already exists.
40 pub const SESSION_ALREADY_EXISTS: i32 = -32003;
41 /// The operation requires no active turn, but one is in progress.
42 pub const TURN_IN_PROGRESS: i32 = -32004;
43 /// The server cannot speak any of the protocol versions offered by the
44 /// client in `InitializeParams.protocolVersions`.
45 pub const UNSUPPORTED_PROTOCOL_VERSION: i32 = -32005;
46 /// The requested content URI does not exist.
47 pub const CONTENT_NOT_FOUND: i32 = -32006;
48 /// Authentication required for a protected resource.
49 pub const AUTH_REQUIRED: i32 = -32007;
50 /// The requested file, folder, or URI does not exist.
51 pub const NOT_FOUND: i32 = -32008;
52 /// The client is not permitted to access the requested resource.
53 pub const PERMISSION_DENIED: i32 = -32009;
54 /// The target resource already exists and the operation does not allow overwriting.
55 pub const ALREADY_EXISTS: i32 = -32010;
56}
57
58/// Type alias: AHP application error code.
59pub type AhpErrorCode = i32;
60/// Type alias: JSON-RPC 2.0 error code.
61pub type JsonRpcErrorCode = i32;
62
63// ─── Error Detail Payloads ────────────────────────────────────────────────
64
65/// Details carried in the `data` field of an `AuthRequired` (-32007) error.
66#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
67#[serde(rename_all = "camelCase")]
68pub struct AuthRequiredErrorData {
69 /// Protected resources that require authentication.
70 pub resources: Vec<ProtectedResourceMetadata>,
71}
72
73/// Details carried in the `data` field of a `PermissionDenied` (-32009) error.
74#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
75#[serde(rename_all = "camelCase")]
76pub struct PermissionDeniedErrorData {
77 /// The resource access that, if granted via `resourceRequest`, would
78 /// unlock the operation. Omitted when no specific access grant would
79 /// resolve the denial.
80 #[serde(default, skip_serializing_if = "Option::is_none")]
81 pub request: Option<ResourceRequestParams>,
82}
83
84/// Details carried in the `data` field of an `UnsupportedProtocolVersion`
85/// (-32005) error.
86#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
87#[serde(rename_all = "camelCase")]
88pub struct UnsupportedProtocolVersionErrorData {
89 /// Protocol versions the server is willing to speak. Each entry is
90 /// either a SemVer `MAJOR.MINOR.PATCH` string (e.g. `"0.1.0"`) or a
91 /// SemVer range constraint (e.g. `">=0.1.0 <0.3.0"` or `"^0.2.0"`).
92 pub supported_versions: Vec<String>,
93}