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