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