greentic-interfaces-guest 0.5.0

Guest-facing bindings for Greentic components targeting wasm32-wasip2
Documentation
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
#![deny(unsafe_code)]
#![warn(missing_docs, clippy::unwrap_used, clippy::expect_used)]
//! Guest-facing bindings and mappers without host-world leakage.

pub mod bindings;

#[cfg(all(not(target_arch = "wasm32"), feature = "host-bridge"))]
pub mod host_bridge;

#[cfg(feature = "distributor-api-imports")]
mod distributor_api_imports;
#[cfg(feature = "distributor-api-v1-1-imports")]
mod distributor_api_imports_v1_1;

/// Component exports for `greentic:component/component@0.6.0` plus the
/// canonical `component-qa` and `component-i18n` guest exports.
///
/// Enable feature `component-v0-6` and export your implementation:
///
/// ```rust
/// # use greentic_interfaces_guest::component_v0_6::node;
/// # use greentic_interfaces_guest::component_v0_6::{component_i18n, component_qa};
/// # struct MyImpl;
/// # impl node::Guest for MyImpl {
/// #     fn describe() -> node::ComponentDescriptor {
/// #         node::ComponentDescriptor {
/// #             name: "demo".into(),
/// #             version: "0.1.0".into(),
/// #             summary: None,
/// #             capabilities: vec![],
/// #             ops: vec![],
/// #             schemas: vec![],
/// #             setup: None,
/// #         }
/// #     }
/// #     fn invoke(_op: String, _envelope: node::InvocationEnvelope) -> Result<node::InvocationResult, node::NodeError> {
/// #         Ok(node::InvocationResult {
/// #             ok: true,
/// #             output_cbor: vec![],
/// #             output_metadata_cbor: None,
/// #         })
/// #     }
/// # }
/// # impl component_qa::Guest for MyImpl {
/// #     fn qa_spec(_mode: component_qa::QaMode) -> Vec<u8> {
/// #         vec![]
/// #     }
/// #     fn apply_answers(
/// #         _mode: component_qa::QaMode,
/// #         _current_config: Vec<u8>,
/// #         _answers: Vec<u8>,
/// #     ) -> Vec<u8> {
/// #         vec![]
/// #     }
/// # }
/// # impl component_i18n::Guest for MyImpl {
/// #     fn i18n_keys() -> Vec<String> {
/// #         vec!["demo.title".into()]
/// #     }
/// # }
/// greentic_interfaces_guest::export_component_v060!(
///     MyImpl,
///     component_qa: MyImpl,
///     component_i18n: MyImpl,
/// );
/// ```
#[cfg(feature = "component-v0-6")]
pub mod component_v0_6 {
    pub use crate::bindings::greentic_component_0_6_0_component::exports::greentic::component::*;
    pub use crate::bindings::greentic_component_0_6_0_component_i18n_support::exports::greentic::component::component_i18n;
    pub use crate::bindings::greentic_component_0_6_0_component_qa_support::exports::greentic::component::component_qa;
}

/// Exports a `greentic:component/node@0.6.0` guest implementation, and can
/// optionally also export `greentic:component/component-qa@0.6.0` and
/// `greentic:component/component-i18n@0.6.0` from crate-owned canonical
/// bindings.
///
/// `export_component_v060!(MyNode)` preserves the existing node-only behavior.
/// To add the optional exports without local WIT files:
///
/// ```rust
/// # use greentic_interfaces_guest::component_v0_6::{component_i18n, component_qa, node};
/// # struct Component;
/// # impl node::Guest for Component {
/// #     fn describe() -> node::ComponentDescriptor {
/// #         node::ComponentDescriptor {
/// #             name: "demo".into(),
/// #             version: "0.1.0".into(),
/// #             summary: None,
/// #             capabilities: vec![],
/// #             ops: vec![],
/// #             schemas: vec![],
/// #             setup: None,
/// #         }
/// #     }
/// #     fn invoke(
/// #         _op: String,
/// #         _envelope: node::InvocationEnvelope,
/// #     ) -> Result<node::InvocationResult, node::NodeError> {
/// #         Ok(node::InvocationResult {
/// #             ok: true,
/// #             output_cbor: vec![],
/// #             output_metadata_cbor: None,
/// #         })
/// #     }
/// # }
/// # impl component_qa::Guest for Component {
/// #     fn qa_spec(_mode: component_qa::QaMode) -> Vec<u8> { vec![] }
/// #     fn apply_answers(
/// #         _mode: component_qa::QaMode,
/// #         _current_config: Vec<u8>,
/// #         _answers: Vec<u8>,
/// #     ) -> Vec<u8> { vec![] }
/// # }
/// # impl component_i18n::Guest for Component {
/// #     fn i18n_keys() -> Vec<String> { vec![] }
/// # }
/// greentic_interfaces_guest::export_component_v060!(
///     Component,
///     component_qa: Component,
///     component_i18n: Component,
/// );
/// ```
#[cfg(feature = "component-v0-6")]
#[macro_export]
macro_rules! export_component_v060 {
    ($node_ty:ty $(, component_qa: $qa_ty:ty)? $(, component_i18n: $i18n_ty:ty)? $(,)?) => {
        const _: () = {
            use $crate::bindings::greentic_component_0_6_0_component::exports::greentic::component::node;

            #[unsafe(export_name = "greentic:component/node@0.6.0#describe")]
            unsafe extern "C" fn export_component_v060_describe() -> *mut u8 {
                unsafe { node::_export_describe_cabi::<$node_ty>() }
            }

            #[unsafe(export_name = "cabi_post_greentic:component/node@0.6.0#describe")]
            unsafe extern "C" fn export_component_v060_post_describe(arg0: *mut u8) {
                unsafe { node::__post_return_describe::<$node_ty>(arg0) }
            }

            #[unsafe(export_name = "greentic:component/node@0.6.0#invoke")]
            unsafe extern "C" fn export_component_v060_invoke(arg0: *mut u8) -> *mut u8 {
                unsafe { node::_export_invoke_cabi::<$node_ty>(arg0) }
            }

            #[unsafe(export_name = "cabi_post_greentic:component/node@0.6.0#invoke")]
            unsafe extern "C" fn export_component_v060_post_invoke(arg0: *mut u8) {
                unsafe { node::__post_return_invoke::<$node_ty>(arg0) }
            }

            $(
                use $crate::bindings::greentic_component_0_6_0_component_qa_support::exports::greentic::component::component_qa;

                #[unsafe(export_name = "greentic:component/component-qa@0.6.0#qa-spec")]
                unsafe extern "C" fn export_component_v060_qa_spec(arg0: i32) -> *mut u8 {
                    unsafe { component_qa::_export_qa_spec_cabi::<$qa_ty>(arg0) }
                }

                #[unsafe(export_name = "cabi_post_greentic:component/component-qa@0.6.0#qa-spec")]
                unsafe extern "C" fn export_component_v060_post_qa_spec(arg0: *mut u8) {
                    unsafe { component_qa::__post_return_qa_spec::<$qa_ty>(arg0) }
                }

                #[unsafe(export_name = "greentic:component/component-qa@0.6.0#apply-answers")]
                unsafe extern "C" fn export_component_v060_apply_answers(
                    arg0: i32,
                    arg1: *mut u8,
                    arg2: usize,
                    arg3: *mut u8,
                    arg4: usize,
                ) -> *mut u8 {
                    unsafe {
                        component_qa::_export_apply_answers_cabi::<$qa_ty>(
                            arg0, arg1, arg2, arg3, arg4,
                        )
                    }
                }

                #[unsafe(export_name = "cabi_post_greentic:component/component-qa@0.6.0#apply-answers")]
                unsafe extern "C" fn export_component_v060_post_apply_answers(arg0: *mut u8) {
                    unsafe { component_qa::__post_return_apply_answers::<$qa_ty>(arg0) }
                }
            )?

            $(
                use $crate::bindings::greentic_component_0_6_0_component_i18n_support::exports::greentic::component::component_i18n;

                #[unsafe(export_name = "greentic:component/component-i18n@0.6.0#i18n-keys")]
                unsafe extern "C" fn export_component_v060_i18n_keys() -> *mut u8 {
                    unsafe { component_i18n::_export_i18n_keys_cabi::<$i18n_ty>() }
                }

                #[unsafe(export_name = "cabi_post_greentic:component/component-i18n@0.6.0#i18n-keys")]
                unsafe extern "C" fn export_component_v060_post_i18n_keys(arg0: *mut u8) {
                    unsafe { component_i18n::__post_return_i18n_keys::<$i18n_ty>(arg0) }
                }
            )?
        };
    };
}

/// Generic component host ABI `greentic:component-v1/component-host@0.1.0`.
#[cfg(feature = "component-v1")]
pub mod component_v1 {
    pub use crate::bindings::greentic_component_v1_0_1_0_component_host::exports::greentic::component_v1::*;
    #[cfg(not(target_arch = "wasm32"))]
    pub use greentic_interfaces::mappers::{ComponentOutcome, ComponentOutcomeStatus};
}

/// Lifecycle hooks for `greentic:lifecycle/component-lifecycle@1.0.0`.
#[cfg(feature = "lifecycle")]
pub mod lifecycle {
    pub use crate::bindings::greentic_lifecycle_1_0_0_component_lifecycle::exports::greentic::lifecycle::*;
}

/// Secret store imports for `greentic:secrets-store/store@1.0.0`.
#[cfg(feature = "secrets")]
pub mod secrets_store {
    pub use crate::bindings::greentic_secrets_store_1_0_0_store::greentic::secrets_store::secrets_store::*;
}

// Legacy secrets provider protocol removed; use provider-core instead.

/// Provider core schema exports for `greentic:provider-schema-core@1.0.0`.
#[cfg(feature = "provider-core-v1")]
pub mod provider_core {
    pub use crate::bindings::greentic_provider_schema_core_1_0_0_schema_core::exports::greentic::provider_schema_core::schema_core_api::*;
}

/// Operator hook-provider exports for `greentic:operator/hook-provider@1.0.0`.
#[cfg(feature = "operator-hooks-v1")]
pub mod operator_hooks {
    pub use crate::bindings::greentic_operator_1_0_0_hook_provider::exports::greentic::operator::hook_api::*;
}

/// Shared messaging provider metadata/render helpers `provider:common/common@0.0.2`.
#[cfg(feature = "provider-common")]
pub mod provider_common {
    pub use crate::bindings::provider_common_0_0_2_common::exports::provider::common::capabilities::*;
    pub use crate::bindings::provider_common_0_0_2_common::exports::provider::common::render::*;
}

/// State store imports for `greentic:state/store@1.0.0`.
#[cfg(feature = "state-store")]
pub mod state_store {
    pub use crate::bindings::greentic_state_1_0_0_store::greentic::state::state_store::*;
}

/// HTTP client imports for `greentic:http/client@1.0.0`.
#[cfg(feature = "http-client")]
pub mod http_client {
    pub use crate::bindings::greentic_http_1_0_0_client::greentic::http::http_client::*;
}

/// HTTP client imports for `greentic:http/client@1.1.0`.
#[cfg(feature = "http-client-v1-1")]
pub mod http_client_v1_1 {
    pub use crate::bindings::greentic_http_1_1_0_client::greentic::http::http_client::*;
}

/// Telemetry logger imports for `greentic:telemetry/logger@1.0.0`.
#[cfg(feature = "telemetry")]
pub mod telemetry_logger {
    pub use crate::bindings::greentic_telemetry_1_0_0_logger::greentic::telemetry::logger_api::*;
}

/// OAuth broker imports for `greentic:oauth-broker/broker@1.0.0`.
#[cfg(feature = "oauth-broker")]
pub mod oauth_broker {
    pub use crate::bindings::greentic_oauth_broker_1_0_0_broker::exports::greentic::oauth_broker::broker_v1::*;
}

/// OAuth broker client imports for `greentic:oauth-broker/broker-client@1.0.0`.
#[cfg(feature = "oauth-broker")]
pub mod oauth_broker_client {
    pub use crate::bindings::greentic_oauth_broker_1_0_0_broker_client::greentic::oauth_broker::broker_v1::*;
}

/// Generic worker world `greentic:worker/worker@1.0.0`.
#[cfg(feature = "worker")]
pub mod worker {
    pub use crate::bindings::greentic_worker_1_0_0_worker::exports::greentic::worker::worker_api::*;
}

/// GUI fragment world `greentic:gui/gui-fragment@1.0.0`.
#[cfg(feature = "gui-fragment")]
pub mod gui_fragment {
    pub use crate::bindings::greentic_gui_1_0_0_gui_fragment::exports::greentic::gui::fragment_api::*;
}

/// Pack validator world `greentic:pack-validate/pack-validator@0.1.0`.
#[cfg(feature = "pack-validate")]
pub mod pack_validate {
    pub use crate::bindings::greentic_pack_validate_0_1_0_pack_validator::exports::greentic::pack_validate::validator::*;
}

/// Provisioning world `greentic:provision/provision-runner@0.1.0`.
#[cfg(feature = "provision")]
pub mod provision {
    pub use crate::bindings::greentic_provision_0_1_0_provision_runner::exports::greentic::provision::provisioner::*;
}

/// Pack metadata/flow discovery worlds.
#[cfg(feature = "pack-export-v1")]
pub mod pack_exports {
    /// Pack host metadata world `greentic:pack-export-v1/pack-host@0.1.0`.
    #[cfg(feature = "pack-export-v1")]
    pub mod v1 {
        pub use crate::bindings::greentic_pack_export_v1_0_1_0_pack_host::exports::greentic::pack_export_v1::*;
        #[cfg(not(target_arch = "wasm32"))]
        pub use greentic_interfaces::mappers::{
            FlowDescriptor as GuestFlowDescriptor, PackDescriptor as GuestPackDescriptor,
        };
    }
}

/// Supply-chain provider contracts implemented by components.
#[cfg(any(
    feature = "repo",
    feature = "build",
    feature = "scan",
    feature = "signing",
    feature = "attestation",
    feature = "policy",
    feature = "metadata",
    feature = "oci"
))]
pub mod supply_chain {
    /// Source provider world `greentic:source/source-sync@1.0.0`.
    #[cfg(feature = "repo")]
    pub mod source {
        pub use crate::bindings::greentic_source_1_0_0_source_sync::exports::greentic::source::source_api::*;
    }
    /// Build provider world `greentic:build/builder@1.0.0`.
    #[cfg(feature = "build")]
    pub mod build {
        pub use crate::bindings::greentic_build_1_0_0_builder::exports::greentic::build::builder_api::*;
    }
    /// Scanner world `greentic:scan/scanner@1.0.0`.
    #[cfg(feature = "scan")]
    pub mod scan {
        pub use crate::bindings::greentic_scan_1_0_0_scanner::exports::greentic::scan::scanner_api::*;
    }
    /// Signing world `greentic:signing/signer@1.0.0`.
    #[cfg(feature = "signing")]
    pub mod signing {
        pub use crate::bindings::greentic_signing_1_0_0_signer::exports::greentic::signing::signer_api::*;
    }
    /// Attestation world `greentic:attestation/attester@1.0.0`.
    #[cfg(feature = "attestation")]
    pub mod attestation {
        pub use crate::bindings::greentic_attestation_1_0_0_attester::exports::greentic::attestation::attester_api::*;
    }
    /// Policy evaluation world `greentic:policy/policy-evaluator@1.0.0`.
    #[cfg(feature = "policy")]
    pub mod policy {
        pub use crate::bindings::greentic_policy_1_0_0_policy_evaluator::exports::greentic::policy::policy_api::*;
    }
    /// Metadata store world `greentic:metadata/metadata-store@1.0.0`.
    #[cfg(feature = "metadata")]
    pub mod metadata {
        pub use crate::bindings::greentic_metadata_1_0_0_metadata_store::exports::greentic::metadata::metadata_api::*;
    }
    /// OCI distribution world `greentic:oci/oci-distribution@1.0.0`.
    #[cfg(feature = "oci")]
    pub mod oci {
        pub use crate::bindings::greentic_oci_1_0_0_oci_distribution::exports::greentic::oci::oci_api::*;
    }
}

/// Desired state distribution API (experimental).
#[cfg(feature = "distribution")]
pub mod distribution {
    pub use crate::bindings::greentic_distribution_1_0_0_distribution::exports::greentic::distribution::distribution_api::*;
}

/// Distributor API for resolving pack components (active).
#[cfg(any(feature = "distributor-api", feature = "distributor-api-imports"))]
pub mod distributor_api {
    #[cfg(feature = "distributor-api")]
    pub use crate::bindings::greentic_distributor_api_1_0_0_distributor_api::exports::greentic::distributor_api::distributor::*;

    /// Raw imports generated from `greentic:distributor-api@1.0.0`.
    #[cfg(feature = "distributor-api-imports")]
    pub mod imports {
        pub use crate::bindings::greentic_distributor_api_1_0_0_distributor_api_imports::greentic::distributor_api::distributor::*;
    }

    /// Convenience wrapper around the distributor imports.
    #[cfg(feature = "distributor-api-imports")]
    pub use crate::distributor_api_imports::DistributorApiImports;
}

/// Distributor API for resolving pack components (ref-based v1.1).
#[cfg(any(
    feature = "distributor-api-v1-1",
    feature = "distributor-api-v1-1-imports"
))]
pub mod distributor_api_v1_1 {
    #[cfg(feature = "distributor-api-v1-1")]
    pub use crate::bindings::greentic_distributor_api_1_1_0_distributor_api::exports::greentic::distributor_api::distributor::*;

    /// Raw imports generated from `greentic:distributor-api@1.1.0`.
    #[cfg(feature = "distributor-api-v1-1-imports")]
    pub mod imports {
        pub use crate::bindings::greentic_distributor_api_1_1_0_distributor_api_imports::greentic::distributor_api::distributor::*;
    }

    /// Convenience wrapper around the distributor imports.
    #[cfg(feature = "distributor-api-v1-1-imports")]
    pub use crate::distributor_api_imports_v1_1::DistributorApiImportsV1_1;
}

/// MCP router exports for multiple protocol snapshots.
#[cfg(any(
    feature = "wasix-mcp-24-11-05-guest",
    feature = "wasix-mcp-25-03-26-guest",
    feature = "wasix-mcp-25-06-18-guest"
))]
pub mod mcp {
    /// `wasix:mcp@24.11.5` snapshot (2024-11-05 spec).
    #[cfg(feature = "wasix-mcp-24-11-05-guest")]
    pub mod v24_11_05 {
        pub use crate::bindings::wasix_mcp_24_11_5_mcp_router::exports::wasix::mcp::router::*;
    }

    /// `wasix:mcp@25.3.26` snapshot with annotations/audio/completions/progress.
    #[cfg(feature = "wasix-mcp-25-03-26-guest")]
    pub mod v25_03_26 {
        pub use crate::bindings::wasix_mcp_25_3_26_mcp_router::exports::wasix::mcp::router::*;
    }

    /// `wasix:mcp@25.6.18` snapshot with structured output/resources/elicitation.
    #[cfg(feature = "wasix-mcp-25-06-18-guest")]
    pub mod v25_06_18 {
        pub use crate::bindings::wasix_mcp_25_6_18_mcp_router::exports::wasix::mcp::router::*;
    }
}

/// UI action handler world `greentic:repo-ui-actions/repo-ui-worker@1.0.0`.
#[cfg(feature = "repo-ui-actions")]
pub mod repo_ui_actions {
    pub use crate::bindings::greentic_repo_ui_actions_1_0_0_repo_ui_worker::exports::greentic::repo_ui_actions::ui_action_api::*;
}

/// Stable alias for OAuth broker imports.
#[cfg(feature = "oauth-broker")]
pub mod oauth {
    pub use super::oauth_broker::*;
}