greentic_types/
bindings.rs

1//! Resource binding hints shared across Greentic tooling.
2//! This module codifies the canonical host binding invariants (network allowlists, secrets,
3//! environment passthrough, and MCP server stubs) so packs, hints generators, and runtime hosts
4//! agree on the same schema.
5
6extern crate alloc;
7
8/// Shared binding hints emitted by pack generators and consumed by the runner host.
9pub mod hints {
10    use crate::SecretRequirement;
11    use alloc::{string::String, vec::Vec};
12
13    #[cfg(feature = "schemars")]
14    use schemars::JsonSchema;
15    #[cfg(feature = "serde")]
16    use serde::{Deserialize, Serialize};
17
18    #[derive(Debug, Clone, Default, PartialEq, Eq)]
19    #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
20    #[cfg_attr(feature = "schemars", derive(JsonSchema))]
21    /// Hints that describe the binding requirements a pack emits for the runner.
22    pub struct BindingsHints {
23        /// Explicit network endpoints that the pack plans to call. Default is deny-all.
24        #[cfg_attr(feature = "serde", serde(default))]
25        pub network: NetworkHints,
26        /// Secrets referenced by the pack. Only listed secrets are allowed; others are denied.
27        #[cfg_attr(feature = "serde", serde(default))]
28        pub secrets: SecretsHints,
29        /// Environment variables the pack needs surfaced. Each listed key is forwarded through
30        /// the runner; unspecified keys are not available to the host.
31        #[cfg_attr(feature = "serde", serde(default))]
32        pub env: EnvHints,
33        /// MCP servers (name + endpoint) referenced by the flows. These entries let the runner
34        /// prepare tool bindings before execution.
35        #[cfg_attr(feature = "serde", serde(default))]
36        pub mcp: McpHints,
37    }
38
39    #[derive(Debug, Clone, Default, PartialEq, Eq)]
40    #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
41    #[cfg_attr(feature = "schemars", derive(JsonSchema))]
42    /// Network-specific allowlists declared by a pack.
43    pub struct NetworkHints {
44        /// Allowlisted host:port entries required by the flows.
45        #[cfg_attr(feature = "serde", serde(default))]
46        pub allow: Vec<String>,
47    }
48
49    #[derive(Debug, Clone, Default, PartialEq, Eq)]
50    #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
51    #[cfg_attr(feature = "schemars", derive(JsonSchema))]
52    /// Secrets referenced by the pack that the runner must provide.
53    pub struct SecretsHints {
54        /// Secrets that flows declare as required. The host must supply these keys.
55        #[cfg_attr(feature = "serde", serde(default))]
56        pub required: Vec<SecretRequirement>,
57    }
58
59    #[derive(Debug, Clone, Default, PartialEq, Eq)]
60    #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
61    #[cfg_attr(feature = "schemars", derive(JsonSchema))]
62    /// Environment variables that need to be forwarded to the pack.
63    pub struct EnvHints {
64        /// Environment variables the pack expects the host to forward.
65        #[cfg_attr(feature = "serde", serde(default))]
66        pub passthrough: Vec<String>,
67    }
68
69    #[derive(Debug, Clone, Default, PartialEq, Eq)]
70    #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
71    #[cfg_attr(feature = "schemars", derive(JsonSchema))]
72    /// Metadata for MCP servers that will be bound into the runtime toolkit.
73    pub struct McpHints {
74        /// Stubbed MCP tool servers referenced by the flows.
75        #[cfg_attr(feature = "serde", serde(default))]
76        pub servers: Vec<McpServer>,
77    }
78
79    #[derive(Debug, Clone, PartialEq, Eq)]
80    #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
81    #[cfg_attr(feature = "schemars", derive(JsonSchema))]
82    /// Descriptor for a single MCP server the host must expose.
83    pub struct McpServer {
84        /// Logical name referenced by flows.
85        pub name: String,
86        /// Transport mechanism (e.g. `http`, `grpc`, etc.).
87        pub transport: String,
88        /// Endpoint exposed by the host for this MCP server.
89        pub endpoint: String,
90        /// Optional capability tags; useful when the runner enforces tool-specific policies.
91        #[cfg_attr(feature = "serde", serde(default))]
92        pub caps: Vec<String>,
93    }
94}