-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Expand file tree
/
Copy pathcustom_requests.rs
More file actions
142 lines (122 loc) · 4.18 KB
/
custom_requests.rs
File metadata and controls
142 lines (122 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
/// Schema descriptor for a single custom method, produced by the
/// `#[custom_methods]` macro's generated `custom_method_schemas()` function.
///
/// `params_schema` / `response_schema` hold `$ref` pointers or inline schemas
/// produced by `SchemaGenerator::subschema_for`. All referenced types are
/// collected in the generator's `$defs` map.
///
/// `params_type_name` / `response_type_name` carry the Rust struct name so the
/// binary can key `$defs` entries and annotate them with `x-method` / `x-side`.
#[derive(Debug, Serialize)]
pub struct CustomMethodSchema {
pub method: String,
pub params_schema: Option<schemars::Schema>,
pub params_type_name: Option<String>,
pub response_schema: Option<schemars::Schema>,
pub response_type_name: Option<String>,
}
/// Add an extension to an active session.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct AddExtensionRequest {
pub session_id: String,
/// Extension configuration (see ExtensionConfig variants: Stdio, StreamableHttp, Builtin, Platform).
pub config: serde_json::Value,
}
/// Remove an extension from an active session.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct RemoveExtensionRequest {
pub session_id: String,
pub name: String,
}
/// List all tools available in a session.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct GetToolsRequest {
pub session_id: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct GetToolsResponse {
/// Array of tool info objects with `name`, `description`, `parameters`, and optional `permission`.
pub tools: Vec<serde_json::Value>,
}
/// Read a resource from an extension.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct ReadResourceRequest {
pub session_id: String,
pub uri: String,
pub extension_name: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct ReadResourceResponse {
/// The resource result from the extension (MCP ReadResourceResult).
pub result: serde_json::Value,
}
/// Update the working directory for a session.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct UpdateWorkingDirRequest {
pub session_id: String,
pub working_dir: String,
}
/// Get a session by ID.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct GetSessionRequest {
pub session_id: String,
#[serde(default)]
pub include_messages: bool,
}
/// Get a session response.
#[derive(Debug, Serialize, JsonSchema)]
pub struct GetSessionResponse {
/// The session object with id, name, working_dir, timestamps, tokens, etc.
pub session: serde_json::Value,
}
/// Delete a session.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct DeleteSessionRequest {
pub session_id: String,
}
/// Export a session as a JSON string.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct ExportSessionRequest {
pub session_id: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct ExportSessionResponse {
pub data: String,
}
/// Import a session from a JSON string.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct ImportSessionRequest {
pub data: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct ImportSessionResponse {
/// The imported session object.
pub session: serde_json::Value,
}
/// List configured extensions and any warnings.
#[derive(Debug, Serialize, JsonSchema)]
pub struct GetExtensionsResponse {
/// Array of ExtensionEntry objects with `enabled` flag and config details.
pub extensions: Vec<serde_json::Value>,
pub warnings: Vec<String>,
}
/// Apply system prompt instructions to an active session.
/// Equivalent to POST /agent/update_from_session in the HTTP API.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct SetSessionInstructionsRequest {
pub session_id: String,
/// Instructions to prepend to the agent's system prompt (e.g. channel context, persona).
pub instructions: String,
}
/// Health check.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct HealthRequest {}
#[derive(Debug, Serialize, JsonSchema)]
pub struct HealthResponse {
pub status: String,
}
/// Empty success response for operations that return no data.
#[derive(Debug, Serialize, JsonSchema)]
pub struct EmptyResponse {}