greentic_interfaces_host/
lib.rs1#![deny(unsafe_code)]
2#![warn(missing_docs, clippy::unwrap_used, clippy::expect_used)]
3#[cfg(target_arch = "wasm32")]
6compile_error!("greentic-interfaces-host is intended for native host targets.");
7
8pub use greentic_interfaces::{bindings, mappers, validate};
9
10pub mod component {
12 pub mod v0_5 {
14 pub use greentic_interfaces::component_v0_5::*;
15 }
16 pub mod v0_5_configurable {
18 pub use greentic_interfaces::component_configurable_v0_5::*;
19 }
20 pub mod v0_4 {
22 pub use greentic_interfaces::component_v0_4::*;
23 }
24 pub mod v1 {
26 pub use greentic_interfaces::component_v1::*;
27 pub use greentic_interfaces::mappers::ComponentOutcome;
28 pub use greentic_interfaces::mappers::ComponentOutcomeStatus;
29 }
30 pub mod describe_v1 {
32 pub use greentic_interfaces::component_describe_v1::*;
33 }
34 pub mod lifecycle_v1 {
36 pub use greentic_interfaces::component_lifecycle_v1::*;
37 }
38}
39
40pub mod runner_host_v1 {
42 pub use greentic_interfaces::runner_host_v1::*;
43}
44
45pub mod pack_exports {
47 pub mod v0_2 {
49 pub use greentic_interfaces::pack_export_v0_2::*;
50 }
51 pub mod v0_4 {
53 pub use greentic_interfaces::pack_export_v0_4::*;
54 }
55 pub mod v1 {
57 pub use greentic_interfaces::mappers::{
58 FlowDescriptor as HostFlowDescriptor, PackDescriptor as HostPackDescriptor,
59 };
60 pub use greentic_interfaces::pack_export_v1::*;
61 }
62}
63
64pub mod types {
66 pub mod common_v0_1 {
68 pub use greentic_interfaces::common_types_v0_1::*;
69 }
70 pub mod events_v1 {
72 pub use greentic_interfaces::events_v1::*;
73 }
74 pub mod types_core_v0_2 {
76 pub use greentic_interfaces::types_core_v0_2::*;
77 }
78 pub mod types_core_v0_4 {
80 pub use greentic_interfaces::types_core_v0_4::*;
81 }
82}
83
84pub mod secrets {
86 pub mod store_v1 {
88 pub use greentic_interfaces::secrets_store_v1::*;
89 }
90}
91
92pub mod state {
94 pub use greentic_interfaces::state_store_v1::*;
95}
96
97pub mod messaging_session {
99 pub use greentic_interfaces::messaging_session_v1::*;
100}
101
102pub mod events_broker {
104 pub use greentic_interfaces::events_broker_v1::*;
105}
106
107pub mod events_source {
109 pub use greentic_interfaces::events_source_v1::*;
110}
111
112pub mod events_sink {
114 pub use greentic_interfaces::events_sink_v1::*;
115}
116
117pub mod events_bridge {
119 pub use greentic_interfaces::events_bridge_event_to_message_v1::EventToMessageBridge;
120 pub use greentic_interfaces::events_bridge_message_to_event_v1::MessageToEventBridge;
121
122 pub use greentic_interfaces::bindings::greentic_events_bridge_1_0_0_event_to_message_bridge::exports::greentic::events_bridge::bridge_api as event_to_message_bridge;
123 pub use greentic_interfaces::bindings::greentic_events_bridge_1_0_0_message_to_event_bridge::exports::greentic::events_bridge::bridge_api as message_to_event_bridge;
124}
125
126pub mod http_client {
128 pub use greentic_interfaces::http_client_v1::*;
129}
130
131pub mod telemetry {
133 pub use greentic_interfaces::telemetry_logger_v1::*;
134}
135
136#[cfg(feature = "oauth-broker-v1")]
138pub mod oauth_broker {
139 pub use greentic_interfaces::oauth_broker_v1::*;
140}
141
142#[cfg(feature = "oauth-broker-v1")]
144pub mod oauth_broker_client {
145 pub use greentic_interfaces::oauth_broker_client_v1::*;
146}
147
148#[cfg(feature = "worker-v1")]
150pub mod worker {
151 use greentic_interfaces::bindings::greentic::interfaces_types::types as interfaces_types;
152 use greentic_interfaces::worker_v1::exports::greentic::worker::worker_api::{
153 TenantCtx as WitWorkerTenantCtx, WorkerMessage as WitWorkerMessage,
154 WorkerRequest as WitWorkerRequest, WorkerResponse as WitWorkerResponse,
155 };
156 use greentic_interfaces::worker_v1::greentic::types_core::types::{
157 Cloud, DeploymentCtx, Platform,
158 };
159 use greentic_types::{ErrorCode, GreenticError, TenantCtx};
160 use serde::{Deserialize, Serialize};
161 use serde_json::Value;
162
163 pub use greentic_interfaces::worker_v1::*;
164
165 type MapperResult<T> = Result<T, GreenticError>;
166
167 fn to_worker_tenant(ctx: TenantCtx) -> MapperResult<WitWorkerTenantCtx> {
168 let base = crate::mappers::tenant_ctx_to_wit(ctx)?;
169 Ok(WitWorkerTenantCtx {
170 tenant: base.tenant,
171 team: base.team,
172 user: base.user,
173 deployment: DeploymentCtx {
174 cloud: Cloud::Other,
175 region: None,
176 platform: Platform::Other,
177 runtime: None,
178 },
179 trace_id: base.trace_id,
180 session_id: base.session_id,
181 flow_id: base.flow_id,
182 node_id: base.node_id,
183 provider_id: base.provider_id,
184 })
185 }
186
187 fn from_worker_tenant(ctx: WitWorkerTenantCtx) -> MapperResult<TenantCtx> {
188 let base = interfaces_types::TenantCtx {
189 env: "unknown".to_string(),
190 tenant: ctx.tenant.clone(),
191 tenant_id: ctx.tenant,
192 team: ctx.team.clone(),
193 team_id: ctx.team,
194 user: ctx.user.clone(),
195 user_id: ctx.user,
196 trace_id: ctx.trace_id,
197 correlation_id: None,
198 session_id: ctx.session_id,
199 flow_id: ctx.flow_id,
200 node_id: ctx.node_id,
201 provider_id: ctx.provider_id,
202 deadline_ms: None,
203 attempt: 0,
204 idempotency_key: None,
205 impersonation: None,
206 attributes: Vec::new(),
207 };
208 crate::mappers::tenant_ctx_from_wit(base)
209 }
210
211 #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
213 pub struct HostWorkerRequest {
214 pub version: String,
216 pub tenant: TenantCtx,
218 pub worker_id: String,
220 pub payload: Value,
222 pub timestamp_utc: String,
224 pub correlation_id: Option<String>,
226 pub session_id: Option<String>,
228 pub thread_id: Option<String>,
230 }
231
232 #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
234 pub struct HostWorkerMessage {
235 pub kind: String,
237 pub payload: Value,
239 }
240
241 #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
243 pub struct HostWorkerResponse {
244 pub version: String,
246 pub tenant: TenantCtx,
248 pub worker_id: String,
250 pub timestamp_utc: String,
252 pub messages: Vec<HostWorkerMessage>,
254 pub correlation_id: Option<String>,
256 pub session_id: Option<String>,
258 pub thread_id: Option<String>,
260 }
261
262 impl TryFrom<HostWorkerMessage> for WitWorkerMessage {
263 type Error = GreenticError;
264
265 fn try_from(value: HostWorkerMessage) -> MapperResult<Self> {
266 let payload_json = serde_json::to_string(&value.payload)
267 .map_err(|err| GreenticError::new(ErrorCode::InvalidInput, err.to_string()))?;
268 Ok(Self {
269 kind: value.kind,
270 payload_json,
271 })
272 }
273 }
274
275 impl TryFrom<WitWorkerMessage> for HostWorkerMessage {
276 type Error = GreenticError;
277
278 fn try_from(value: WitWorkerMessage) -> MapperResult<Self> {
279 let payload = serde_json::from_str(&value.payload_json).map_err(|err| {
280 GreenticError::new(
281 ErrorCode::InvalidInput,
282 format!("invalid worker payload: {err}"),
283 )
284 })?;
285 Ok(Self {
286 kind: value.kind,
287 payload,
288 })
289 }
290 }
291
292 impl TryFrom<HostWorkerRequest> for WitWorkerRequest {
293 type Error = GreenticError;
294
295 fn try_from(value: HostWorkerRequest) -> MapperResult<Self> {
296 let payload_json = serde_json::to_string(&value.payload)
297 .map_err(|err| GreenticError::new(ErrorCode::InvalidInput, err.to_string()))?;
298 Ok(Self {
299 version: value.version,
300 tenant: to_worker_tenant(value.tenant)?,
301 worker_id: value.worker_id,
302 correlation_id: value.correlation_id,
303 session_id: value.session_id,
304 thread_id: value.thread_id,
305 payload_json,
306 timestamp_utc: value.timestamp_utc,
307 })
308 }
309 }
310
311 impl TryFrom<WitWorkerRequest> for HostWorkerRequest {
312 type Error = GreenticError;
313
314 fn try_from(value: WitWorkerRequest) -> MapperResult<Self> {
315 let payload: Value = serde_json::from_str(&value.payload_json).map_err(|err| {
316 GreenticError::new(
317 ErrorCode::InvalidInput,
318 format!("invalid worker payload: {err}"),
319 )
320 })?;
321 Ok(Self {
322 version: value.version,
323 tenant: from_worker_tenant(value.tenant)?,
324 worker_id: value.worker_id,
325 correlation_id: value.correlation_id,
326 session_id: value.session_id,
327 thread_id: value.thread_id,
328 payload,
329 timestamp_utc: value.timestamp_utc,
330 })
331 }
332 }
333
334 impl TryFrom<HostWorkerResponse> for WitWorkerResponse {
335 type Error = GreenticError;
336
337 fn try_from(value: HostWorkerResponse) -> MapperResult<Self> {
338 let messages = value
339 .messages
340 .into_iter()
341 .map(WitWorkerMessage::try_from)
342 .collect::<MapperResult<Vec<_>>>()?;
343 Ok(Self {
344 version: value.version,
345 tenant: to_worker_tenant(value.tenant)?,
346 worker_id: value.worker_id,
347 correlation_id: value.correlation_id,
348 session_id: value.session_id,
349 thread_id: value.thread_id,
350 messages,
351 timestamp_utc: value.timestamp_utc,
352 })
353 }
354 }
355
356 impl TryFrom<WitWorkerResponse> for HostWorkerResponse {
357 type Error = GreenticError;
358
359 fn try_from(value: WitWorkerResponse) -> MapperResult<Self> {
360 let messages = value
361 .messages
362 .into_iter()
363 .map(HostWorkerMessage::try_from)
364 .collect::<MapperResult<Vec<_>>>()?;
365 Ok(Self {
366 version: value.version,
367 tenant: from_worker_tenant(value.tenant)?,
368 worker_id: value.worker_id,
369 correlation_id: value.correlation_id,
370 session_id: value.session_id,
371 thread_id: value.thread_id,
372 messages,
373 timestamp_utc: value.timestamp_utc,
374 })
375 }
376 }
377}
378
379#[cfg(feature = "gui-fragment")]
381pub mod gui_fragment {
382 pub use greentic_interfaces::bindings::greentic_gui_1_0_0_gui_fragment::exports::greentic::gui::fragment_api as bindings;
383 pub use bindings::FragmentContext;
384 pub use bindings::Guest as GuiFragment;
385}
386
387pub mod supply_chain {
389 pub mod source {
391 pub use greentic_interfaces::bindings::greentic_source_1_0_0_source_sync::exports::greentic::source::source_api::*;
392 }
393 pub mod build {
395 pub use greentic_interfaces::bindings::greentic_build_1_0_0_builder::exports::greentic::build::builder_api::*;
396 }
397 pub mod scan {
399 pub use greentic_interfaces::bindings::greentic_scan_1_0_0_scanner::exports::greentic::scan::scanner_api::*;
400 }
401 pub mod signing {
403 pub use greentic_interfaces::bindings::greentic_signing_1_0_0_signer::exports::greentic::signing::signer_api::*;
404 }
405 pub mod attestation {
407 pub use greentic_interfaces::bindings::greentic_attestation_1_0_0_attester::exports::greentic::attestation::attester_api::*;
408 }
409 pub mod policy {
411 pub use greentic_interfaces::bindings::greentic_policy_1_0_0_policy_evaluator::exports::greentic::policy::policy_api::*;
412 }
413 pub mod metadata {
415 pub use greentic_interfaces::bindings::greentic_metadata_1_0_0_metadata_store::exports::greentic::metadata::metadata_api::*;
416 }
417 pub mod oci {
419 pub use greentic_interfaces::bindings::greentic_oci_1_0_0_oci_distribution::exports::greentic::oci::oci_api::*;
420 }
421}
422
423pub mod distribution {
425 pub mod v1 {
427 pub use greentic_interfaces::bindings::greentic_distribution_1_0_0_distribution::exports::greentic::distribution::distribution_api::*;
428 }
429}
430
431pub mod distributor_api {
433 pub mod v1 {
435 pub use greentic_interfaces::bindings::greentic_distributor_api_1_0_0_distributor_api::exports::greentic::distributor_api::distributor::*;
436 }
437}
438
439pub mod messaging {
441 pub use super::messaging_session::*;
442}
443
444pub mod http {
446 pub use super::http_client::*;
447}
448
449#[cfg(feature = "oauth-broker-v1")]
451pub mod oauth {
452 pub use super::oauth_broker::*;
453}
454
455pub mod mcp {
457 #[cfg(feature = "wasix-mcp-24-11-05-host")]
459 pub mod v24_11_05 {
460 pub use greentic_interfaces::wasix_mcp_24_11_05::*;
461 }
462
463 #[cfg(feature = "wasix-mcp-25-03-26-host")]
465 pub mod v25_03_26 {
466 pub use greentic_interfaces::wasix_mcp_25_03_26::*;
467 }
468
469 #[cfg(feature = "wasix-mcp-25-06-18-host")]
471 pub mod v25_06_18 {
472 pub use greentic_interfaces::wasix_mcp_25_06_18::*;
473 }
474}
475
476pub mod ui_actions {
478 pub mod repo_ui_worker {
480 pub use greentic_interfaces::bindings::greentic_repo_ui_actions_1_0_0_repo_ui_worker::exports::greentic::repo_ui_actions::ui_action_api::*;
481 }
482}