soma_application/types.rs
1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3use soma_provider_core::ProviderCatalog;
4
5/// Request to execute a named action with free-form JSON parameters.
6#[derive(Debug, Clone, Deserialize, Serialize)]
7pub struct ExecuteActionRequest {
8 /// Name of the action to execute.
9 pub action: String,
10 /// JSON parameters passed to the action (defaults to `null` when absent).
11 #[serde(default)]
12 pub params: Value,
13}
14
15/// Result of executing an action, pairing its output with a correlation id.
16#[derive(Debug, Clone, PartialEq, Serialize)]
17pub struct ExecuteActionResponse {
18 /// JSON output produced by the action.
19 pub output: Value,
20 /// Unique id correlating this response with its originating request.
21 pub request_id: String,
22}
23
24/// Outcome of an MCP elicitation prompt asking the client for a name.
25#[derive(Debug, Clone, PartialEq, Eq)]
26pub enum ElicitedName {
27 /// The user supplied a name.
28 Accepted(String),
29 /// The user accepted the prompt but left the name empty.
30 NoInput,
31 /// The user declined to provide a name.
32 Declined,
33 /// The user cancelled the elicitation.
34 Cancelled,
35 /// The client does not support elicitation.
36 Unsupported,
37}
38
39/// Parameters collected by the scaffold-intent wizard to generate a new server.
40#[derive(Debug, Clone, Deserialize, Serialize)]
41pub struct ScaffoldIntentRequest {
42 /// Human-readable display name for the scaffolded server.
43 pub display_name: String,
44 /// Cargo crate name for the generated project.
45 pub crate_name: String,
46 /// Name of the produced binary.
47 pub binary_name: String,
48 /// Category classifying the kind of server.
49 pub server_category: String,
50 /// Environment variable prefix for the server's configuration.
51 pub env_prefix: String,
52 /// Authentication scheme to wire in (e.g. bearer, oauth).
53 pub auth_kind: String,
54 /// Default bind host.
55 pub host: String,
56 /// Default bind port.
57 pub port: u16,
58 /// MCP transport(s) to enable (e.g. http, stdio).
59 pub mcp_transport: String,
60 /// MCP primitives to include (tools, resources, prompts).
61 pub mcp_primitives: String,
62 /// Deployment target/model for the scaffolded server.
63 pub deployment: String,
64 /// Plugin surfaces to generate (Claude/Codex/Gemini).
65 pub plugins: String,
66 /// Whether to publish MCP registry metadata.
67 pub publish_mcp: bool,
68 /// Seed URLs to crawl for the knowledge base.
69 pub crawl_urls: String,
70 /// Seed repositories to ingest for the knowledge base.
71 pub crawl_repos: String,
72 /// Seed search topics for automated web crawling.
73 pub crawl_search_topics: String,
74}
75
76/// Request to reload the gateway with an optional replacement config.
77#[derive(Debug, Clone, Deserialize, Serialize)]
78pub struct GatewayReloadRequest {
79 /// New gateway configuration to apply (defaults to `null` when absent).
80 #[serde(default)]
81 pub config: Value,
82}
83
84/// Request to execute a gateway action with free-form JSON parameters.
85#[derive(Debug, Clone, Deserialize, Serialize)]
86pub struct GatewayExecuteRequest {
87 /// Name of the gateway action to execute.
88 pub action: String,
89 /// JSON parameters passed to the action (defaults to `null` when absent).
90 #[serde(default)]
91 pub params: Value,
92}
93
94/// Scope constraining which gateway upstreams and services a route may reach.
95#[derive(Debug, Clone, Default, PartialEq, Eq)]
96pub struct GatewayRouteScope {
97 /// Allowed upstream identifiers.
98 pub upstreams: Vec<String>,
99 /// Allowed service identifiers.
100 pub services: Vec<String>,
101 /// Whether the code-mode surface is exposed to this route.
102 pub expose_code_mode: bool,
103}
104
105/// A tool advertised through the gateway routing layer.
106#[derive(Debug, Clone, PartialEq, Serialize)]
107pub struct GatewayToolRoute {
108 /// Tool name as exposed by the gateway.
109 pub name: String,
110 /// Optional human-readable description.
111 pub description: Option<String>,
112 /// Optional JSON schema for the tool's input.
113 pub input_schema: Option<Value>,
114 /// Optional JSON schema for the tool's output.
115 pub output_schema: Option<Value>,
116 /// Whether invoking the tool may have destructive effects.
117 pub destructive: bool,
118}
119
120/// A resource advertised through the gateway routing layer.
121#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
122pub struct GatewayResourceRoute {
123 /// Gateway-facing URI for the resource.
124 pub uri: String,
125 /// Native upstream URI the gateway URI maps to.
126 pub native_uri: String,
127 /// Optional human-readable resource name.
128 pub name: Option<String>,
129}
130
131/// A prompt advertised through the gateway routing layer.
132#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
133pub struct GatewayPromptRoute {
134 /// Prompt name as exposed by the gateway.
135 pub name: String,
136 /// Optional human-readable description.
137 pub description: Option<String>,
138}
139
140/// Request to execute a code-mode script with optional JSON input.
141#[derive(Debug, Clone, Deserialize, Serialize)]
142pub struct CodeModeExecuteRequest {
143 /// Source code to execute in the code-mode sandbox.
144 pub source: String,
145 /// JSON input made available to the script (defaults to `null` when absent).
146 #[serde(default)]
147 pub input: Value,
148}
149
150/// Request to invoke an OpenAPI operation with free-form JSON parameters.
151#[derive(Debug, Clone, Deserialize, Serialize)]
152pub struct OpenApiExecuteRequest {
153 /// Identifier of the OpenAPI operation to invoke.
154 pub operation: String,
155 /// JSON parameters passed to the operation (defaults to `null` when absent).
156 #[serde(default)]
157 pub params: Value,
158}
159
160/// Result of an operation, pairing its output with a correlation id.
161#[derive(Debug, Clone, PartialEq, Serialize)]
162pub struct OperationResponse {
163 /// JSON output produced by the operation.
164 pub output: Value,
165 /// Unique id correlating this response with its originating request.
166 pub request_id: String,
167}
168
169/// Request to read a resource identified by URI.
170#[derive(Debug, Clone, Deserialize, Serialize)]
171pub struct ReadResourceRequest {
172 /// URI of the resource to read.
173 pub uri: String,
174}
175
176/// Content returned when reading a resource, either text or binary blob.
177#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
178#[serde(tag = "kind", rename_all = "kebab-case")]
179pub enum ResourceContent {
180 /// Textual resource content.
181 Text {
182 /// The resource text.
183 text: String,
184 /// Optional MIME type of the text.
185 mime_type: Option<String>,
186 },
187 /// Binary resource content encoded as base64.
188 Blob {
189 /// Base64-encoded resource bytes.
190 blob_base64: String,
191 /// Optional MIME type of the blob.
192 mime_type: Option<String>,
193 },
194}
195
196/// Specification of a templated resource with a parameterized URI.
197#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
198pub struct ResourceTemplateSpec {
199 /// RFC 6570 URI template describing the resource address.
200 pub uri_template: String,
201 /// Human-readable name for the resource template.
202 pub name: String,
203 /// Human-readable description of the resource template.
204 pub description: String,
205 /// Optional MIME type of resources produced by the template.
206 pub mime_type: Option<String>,
207}
208
209/// Snapshot of the provider catalogs at a point in time.
210#[derive(Debug, Clone, PartialEq, Serialize)]
211pub struct CatalogSnapshot {
212 /// Identifier of this snapshot.
213 pub id: String,
214 /// Fingerprint of the catalog contents used for change detection.
215 pub fingerprint: String,
216 /// Provider catalogs captured in the snapshot.
217 pub catalogs: Vec<ProviderCatalog>,
218}
219
220/// Result of the `doctor` pre-flight readiness check.
221#[derive(Debug, Clone, PartialEq, Serialize)]
222pub struct DoctorReport {
223 /// Whether the service is ready to serve requests.
224 pub ready: bool,
225 /// Optional status detail captured during the check.
226 pub status: Option<Value>,
227 /// List of problems detected during the check.
228 pub problems: Vec<String>,
229}