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 pub mod provider_v0_1 {
93 pub use greentic_interfaces::secrets_provider_v0_1::*;
94 }
95
96 pub mod generators_v0_1 {
98 pub use greentic_interfaces::secrets_generators_v0_1::*;
99 }
100
101 pub mod audit_exporter_v0_1 {
103 pub use greentic_interfaces::secrets_audit_exporter_v0_1::*;
104 }
105
106 pub mod policy_validator_v0_1 {
108 pub use greentic_interfaces::secrets_policy_validator_v0_1::*;
109 }
110}
111
112pub mod provider_common {
114 pub use greentic_interfaces::bindings::provider_common_0_0_2_common::exports::provider::common::capabilities::*;
115 pub use greentic_interfaces::bindings::provider_common_0_0_2_common::exports::provider::common::render::*;
116}
117
118pub mod state {
120 pub use greentic_interfaces::state_store_v1::*;
121}
122
123pub mod messaging_session {
125 pub use greentic_interfaces::messaging_session_v1::*;
126}
127
128pub mod events_broker {
130 pub use greentic_interfaces::events_broker_v1::*;
131}
132
133pub mod events_source {
135 pub use greentic_interfaces::events_source_v1::*;
136}
137
138pub mod events_sink {
140 pub use greentic_interfaces::events_sink_v1::*;
141}
142
143pub mod events_bridge {
145 pub use greentic_interfaces::events_bridge_event_to_message_v1::EventToMessageBridge;
146 pub use greentic_interfaces::events_bridge_message_to_event_v1::MessageToEventBridge;
147
148 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;
149 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;
150}
151
152pub mod http_client {
154 pub use greentic_interfaces::http_client_v1::*;
156
157 pub mod v1_1 {
159 pub use greentic_interfaces::http_client_v1_1::*;
160 }
161}
162
163pub mod telemetry {
165 pub use greentic_interfaces::telemetry_logger_v1::*;
166}
167
168#[cfg(feature = "oauth-broker-v1")]
170pub mod oauth_broker {
171 pub use greentic_interfaces::oauth_broker_v1::*;
172}
173
174#[cfg(feature = "oauth-broker-v1")]
176pub mod oauth_broker_client {
177 pub use greentic_interfaces::oauth_broker_client_v1::*;
178}
179
180#[cfg(feature = "worker-v1")]
182pub mod worker {
183 use greentic_interfaces::bindings::greentic::interfaces_types::types as interfaces_types;
184 use greentic_interfaces::worker_v1::exports::greentic::worker::worker_api::{
185 TenantCtx as WitWorkerTenantCtx, WorkerMessage as WitWorkerMessage,
186 WorkerRequest as WitWorkerRequest, WorkerResponse as WitWorkerResponse,
187 };
188 use greentic_interfaces::worker_v1::greentic::types_core::types::{
189 Cloud, DeploymentCtx, Platform,
190 };
191 use greentic_types::{ErrorCode, GreenticError, TenantCtx};
192 use serde::{Deserialize, Serialize};
193 use serde_json::Value;
194
195 pub use greentic_interfaces::worker_v1::*;
196
197 type MapperResult<T> = Result<T, GreenticError>;
198
199 fn to_worker_tenant(ctx: TenantCtx) -> MapperResult<WitWorkerTenantCtx> {
200 let base = crate::mappers::tenant_ctx_to_wit(ctx)?;
201 Ok(WitWorkerTenantCtx {
202 tenant: base.tenant,
203 team: base.team,
204 user: base.user,
205 deployment: DeploymentCtx {
206 cloud: Cloud::Other,
207 region: None,
208 platform: Platform::Other,
209 runtime: None,
210 },
211 trace_id: base.trace_id,
212 session_id: base.session_id,
213 flow_id: base.flow_id,
214 node_id: base.node_id,
215 provider_id: base.provider_id,
216 })
217 }
218
219 fn from_worker_tenant(ctx: WitWorkerTenantCtx) -> MapperResult<TenantCtx> {
220 let base = interfaces_types::TenantCtx {
221 env: "unknown".to_string(),
222 tenant: ctx.tenant.clone(),
223 tenant_id: ctx.tenant,
224 team: ctx.team.clone(),
225 team_id: ctx.team,
226 user: ctx.user.clone(),
227 user_id: ctx.user,
228 trace_id: ctx.trace_id,
229 correlation_id: None,
230 session_id: ctx.session_id,
231 flow_id: ctx.flow_id,
232 node_id: ctx.node_id,
233 provider_id: ctx.provider_id,
234 deadline_ms: None,
235 attempt: 0,
236 idempotency_key: None,
237 impersonation: None,
238 attributes: Vec::new(),
239 };
240 crate::mappers::tenant_ctx_from_wit(base)
241 }
242
243 #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
245 pub struct HostWorkerRequest {
246 pub version: String,
248 pub tenant: TenantCtx,
250 pub worker_id: String,
252 pub payload: Value,
254 pub timestamp_utc: String,
256 pub correlation_id: Option<String>,
258 pub session_id: Option<String>,
260 pub thread_id: Option<String>,
262 }
263
264 #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
266 pub struct HostWorkerMessage {
267 pub kind: String,
269 pub payload: Value,
271 }
272
273 #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
275 pub struct HostWorkerResponse {
276 pub version: String,
278 pub tenant: TenantCtx,
280 pub worker_id: String,
282 pub timestamp_utc: String,
284 pub messages: Vec<HostWorkerMessage>,
286 pub correlation_id: Option<String>,
288 pub session_id: Option<String>,
290 pub thread_id: Option<String>,
292 }
293
294 impl TryFrom<HostWorkerMessage> for WitWorkerMessage {
295 type Error = GreenticError;
296
297 fn try_from(value: HostWorkerMessage) -> MapperResult<Self> {
298 let payload_json = serde_json::to_string(&value.payload)
299 .map_err(|err| GreenticError::new(ErrorCode::InvalidInput, err.to_string()))?;
300 Ok(Self {
301 kind: value.kind,
302 payload_json,
303 })
304 }
305 }
306
307 impl TryFrom<WitWorkerMessage> for HostWorkerMessage {
308 type Error = GreenticError;
309
310 fn try_from(value: WitWorkerMessage) -> MapperResult<Self> {
311 let payload = serde_json::from_str(&value.payload_json).map_err(|err| {
312 GreenticError::new(
313 ErrorCode::InvalidInput,
314 format!("invalid worker payload: {err}"),
315 )
316 })?;
317 Ok(Self {
318 kind: value.kind,
319 payload,
320 })
321 }
322 }
323
324 impl TryFrom<HostWorkerRequest> for WitWorkerRequest {
325 type Error = GreenticError;
326
327 fn try_from(value: HostWorkerRequest) -> MapperResult<Self> {
328 let payload_json = serde_json::to_string(&value.payload)
329 .map_err(|err| GreenticError::new(ErrorCode::InvalidInput, err.to_string()))?;
330 Ok(Self {
331 version: value.version,
332 tenant: to_worker_tenant(value.tenant)?,
333 worker_id: value.worker_id,
334 correlation_id: value.correlation_id,
335 session_id: value.session_id,
336 thread_id: value.thread_id,
337 payload_json,
338 timestamp_utc: value.timestamp_utc,
339 })
340 }
341 }
342
343 impl TryFrom<WitWorkerRequest> for HostWorkerRequest {
344 type Error = GreenticError;
345
346 fn try_from(value: WitWorkerRequest) -> MapperResult<Self> {
347 let payload: Value = serde_json::from_str(&value.payload_json).map_err(|err| {
348 GreenticError::new(
349 ErrorCode::InvalidInput,
350 format!("invalid worker payload: {err}"),
351 )
352 })?;
353 Ok(Self {
354 version: value.version,
355 tenant: from_worker_tenant(value.tenant)?,
356 worker_id: value.worker_id,
357 correlation_id: value.correlation_id,
358 session_id: value.session_id,
359 thread_id: value.thread_id,
360 payload,
361 timestamp_utc: value.timestamp_utc,
362 })
363 }
364 }
365
366 impl TryFrom<HostWorkerResponse> for WitWorkerResponse {
367 type Error = GreenticError;
368
369 fn try_from(value: HostWorkerResponse) -> MapperResult<Self> {
370 let messages = value
371 .messages
372 .into_iter()
373 .map(WitWorkerMessage::try_from)
374 .collect::<MapperResult<Vec<_>>>()?;
375 Ok(Self {
376 version: value.version,
377 tenant: to_worker_tenant(value.tenant)?,
378 worker_id: value.worker_id,
379 correlation_id: value.correlation_id,
380 session_id: value.session_id,
381 thread_id: value.thread_id,
382 messages,
383 timestamp_utc: value.timestamp_utc,
384 })
385 }
386 }
387
388 impl TryFrom<WitWorkerResponse> for HostWorkerResponse {
389 type Error = GreenticError;
390
391 fn try_from(value: WitWorkerResponse) -> MapperResult<Self> {
392 let messages = value
393 .messages
394 .into_iter()
395 .map(HostWorkerMessage::try_from)
396 .collect::<MapperResult<Vec<_>>>()?;
397 Ok(Self {
398 version: value.version,
399 tenant: from_worker_tenant(value.tenant)?,
400 worker_id: value.worker_id,
401 correlation_id: value.correlation_id,
402 session_id: value.session_id,
403 thread_id: value.thread_id,
404 messages,
405 timestamp_utc: value.timestamp_utc,
406 })
407 }
408 }
409}
410
411#[cfg(feature = "gui-fragment")]
413pub mod gui_fragment {
414 pub use greentic_interfaces::bindings::greentic_gui_1_0_0_gui_fragment::exports::greentic::gui::fragment_api as bindings;
415 pub use bindings::FragmentContext;
416 pub use bindings::Guest as GuiFragment;
417}
418
419pub mod supply_chain {
421 pub mod source {
423 pub use greentic_interfaces::bindings::greentic_source_1_0_0_source_sync::exports::greentic::source::source_api::*;
424 }
425 pub mod build {
427 pub use greentic_interfaces::bindings::greentic_build_1_0_0_builder::exports::greentic::build::builder_api::*;
428 }
429 pub mod scan {
431 pub use greentic_interfaces::bindings::greentic_scan_1_0_0_scanner::exports::greentic::scan::scanner_api::*;
432 }
433 pub mod signing {
435 pub use greentic_interfaces::bindings::greentic_signing_1_0_0_signer::exports::greentic::signing::signer_api::*;
436 }
437 pub mod attestation {
439 pub use greentic_interfaces::bindings::greentic_attestation_1_0_0_attester::exports::greentic::attestation::attester_api::*;
440 }
441 pub mod policy {
443 pub use greentic_interfaces::bindings::greentic_policy_1_0_0_policy_evaluator::exports::greentic::policy::policy_api::*;
444 }
445 pub mod metadata {
447 pub use greentic_interfaces::bindings::greentic_metadata_1_0_0_metadata_store::exports::greentic::metadata::metadata_api::*;
448 }
449 pub mod oci {
451 pub use greentic_interfaces::bindings::greentic_oci_1_0_0_oci_distribution::exports::greentic::oci::oci_api::*;
452 }
453}
454
455pub mod distribution {
457 pub mod v1 {
459 pub use greentic_interfaces::bindings::greentic_distribution_1_0_0_distribution::exports::greentic::distribution::distribution_api::*;
460 }
461}
462
463pub mod distributor_api {
465 pub mod v1 {
467 pub use greentic_interfaces::bindings::greentic_distributor_api_1_0_0_distributor_api::exports::greentic::distributor_api::distributor::*;
468 }
469}
470
471pub mod messaging {
473 pub use super::messaging_session::*;
474}
475
476pub mod http {
478 pub use super::http_client::*;
479}
480
481#[cfg(feature = "oauth-broker-v1")]
483pub mod oauth {
484 pub use super::oauth_broker::*;
485}
486
487pub mod mcp {
489 #[cfg(feature = "wasix-mcp-24-11-05-host")]
491 pub mod v24_11_05 {
492 pub use greentic_interfaces::wasix_mcp_24_11_05::*;
493 }
494
495 #[cfg(feature = "wasix-mcp-25-03-26-host")]
497 pub mod v25_03_26 {
498 pub use greentic_interfaces::wasix_mcp_25_03_26::*;
499 }
500
501 #[cfg(feature = "wasix-mcp-25-06-18-host")]
503 pub mod v25_06_18 {
504 pub use greentic_interfaces::wasix_mcp_25_06_18::*;
505 }
506}
507
508pub mod ui_actions {
510 pub mod repo_ui_worker {
512 pub use greentic_interfaces::bindings::greentic_repo_ui_actions_1_0_0_repo_ui_worker::exports::greentic::repo_ui_actions::ui_action_api::*;
513 }
514}