1mod bundle_catalog;
4pub mod auto_permit;
5pub mod pty_resume;
6pub mod session_meta;
7
8mod context_pack;
9
10mod harness_mcp_proxy;
11
12mod bundle_provider;
13
14mod git_worktree;
15pub mod plugins;
16pub mod provider_inventory;
17pub mod provider_limits;
18pub mod git_watch;
19pub mod provider_error;
20pub mod session_signals;
21
22mod host_directory_browser;
23
24mod environment_profiles;
25
26mod session_environment;
27
28mod worktree_service;
29
30pub(crate) use gate4agent_node_core::session_registry;
31
32mod standalone_workspace;
33
34#[cfg(windows)]
35mod workspace_file_windows;
36
37#[cfg(unix)]
38mod workspace_file_unix;
39
40#[cfg(feature = "dig2-station-probe")]
41mod dig2_station_lease;
42#[cfg(feature = "dig2-station-probe")]
43mod dig2_station_probe;
44pub mod kit;
45pub mod local_infra;
46pub mod node_control;
47#[cfg(feature = "wireguard")]
48pub(crate) use gate4agent_node_core::kit_wireguard;
49mod network_allowlist_catalog;
50pub(crate) use gate4agent_node_core::platform;
51pub mod enroll_client;
52pub mod uplink_journal;
53pub mod restream_session;
54pub mod uplink_calls;
55pub mod machine_env;
56pub use machine_env::collect as collect_machine_environment;
57pub mod restream_g4a_bridge;
58#[cfg(feature = "d2b")]
59pub mod browser_capture;
60pub mod grok_leader;
61pub mod m4a_accounts;
62pub mod m4a_adopt;
63pub mod m4a_wake;
64pub mod windows_process;
65pub mod service;
66pub mod m4a_attach;
67#[cfg(unix)]
68pub mod keystore_proxy;
69#[cfg(unix)]
71pub mod m4a_signer_proxy {
72 pub use super::keystore_proxy::*;
73}
74pub mod door;
75#[cfg(feature = "local-server")]
76pub mod local_server;
77pub mod wake_pipeline;
78#[cfg(unix)]
79pub mod isolation;
80pub use kit::{force_link, linked_core_names};
81#[cfg(feature = "m4a")]
82pub use kit::start_mailbox;
83#[cfg(feature = "m4a")]
84pub use kit::MailboxHandle;
85#[cfg(feature = "wireguard")]
86pub use kit_wireguard::{
87 bring_up_node_wireguard, node_wg_from_env, spawn_linux_wireguard_retry, NodeWgPeerConfig,
88 NodeWgPeerError, WgStatus, LINK_TAG as WIREGUARD_LINK_TAG, WG_ADDRESS_ENV, WG_INTERFACE_ENV,
89 WG_KEEPALIVE_ENV, WG_KERNEL_ENV, WG_LISTEN_PORT_ENV, WG_PEER_ADDRESS_ENV, WG_PEER_ENDPOINT_ENV,
90 WG_PEER_KEY_ENV, WG_PRIVATE_KEY_ENV,
91};
92pub use gate4agent_node_core::{node_log, wg_status};
93mod provider_runtime;
94mod server;
95pub(crate) use gate4agent_node_core::spawn_spec;
96
97#[cfg(feature = "fixture")]
98pub use bundle_catalog::protect_bundle_source_tree_fixture;
99pub use bundle_catalog::{
100 BundleCatalog, BundleCatalogError, NodeBundle, NodeBundleError, NodeBundleFile,
101 MAX_BUNDLE_CATALOG_ENTRIES, MAX_BUNDLE_FILES, MAX_BUNDLE_FILE_BYTES, MAX_BUNDLE_PATH_BYTES,
102 MAX_BUNDLE_TOTAL_BYTES,
103};
104pub use environment_profiles::{
105 NodeEnvironmentProfile, NodeEnvironmentProfileError, MAX_NODE_ENVIRONMENT_PROFILES,
106};
107pub use gate4agent_node_protocol::WorktreeServiceMode;
108pub use gate4agent_runtime_native::{
109 orca_home_roots, HistorySourceLayout, NativeHistoryConfig, NativeHistoryRoot,
110};
111pub use network_allowlist_catalog::{
112 claude_allowed_domains_from_permits, claude_bash_sandbox_network_os_supported,
113 claude_settings_network_overlay_args, claude_station_network_settings_json,
114 codex_network_access_config_overlay, load_network_allowlist_catalog_file,
115 parse_network_allowlist_catalog_text, permit_peer_to_allowed_domain,
116 provider_native_mapping_supported, resolve_network_allowlist_catalog,
117 resolve_provider_native_launch_overlay, NetworkAllowlistCatalog, NetworkAllowlistCatalogError,
118 NetworkAllowlistEntry, NetworkPermitProtocol, NetworkPermitSketch, ProviderNativeNetworkSketch,
119 CLAUDE_STATION_NETWORK_SETTINGS_FILE, MAX_NETWORK_ALLOWLIST_CATALOG_ENTRIES,
120 MAX_NETWORK_PERMITS_PER_ENTRY, NETWORK_ALLOWLIST_CATALOG_ENV,
121 NETWORK_ALLOWLIST_CATALOG_SCHEMA_VERSION,
122};
123#[cfg(feature = "fixture")]
124pub use server::SpawnManagedWorktreeV2FailureProbe;
125pub use server::node_wake::{NodeLetter, NodeWake};
126pub use server::{
127 default_node_endpoint, default_state_path, NodeServer, NodeServerConfig, NodeServerError,
128 NodeShutdownHandle, WorkspaceConfig,
129};
130pub use session_environment::{
131 NodeSecretReference, NodeSecretResolveError, NodeSecretResolver, NodeSecretValue,
132 NodeSecretValueError, NodeSessionEnvironmentMutation, NodeSessionFile,
133 NodeSessionMaterializationProfile, NodeSessionMaterializationProfileError,
134 NodeSessionPathBinding, NodeSessionPathClass, MAX_NODE_SECRET_REFERENCE_BYTES,
135 MAX_NODE_SECRET_VALUE_BYTES, MAX_SESSION_ENVIRONMENT_ENTRIES,
136 MAX_SESSION_MATERIALIZATION_FILES, MAX_SESSION_MATERIALIZATION_FILE_BYTES,
137 MAX_SESSION_MATERIALIZATION_RELATIVE_PATH_BYTES,
138};
139pub use spawn_spec::{
140 SpawnProfileRegistry, SpawnProfileRegistryError, DEFAULT_SPAWN_PROFILE_ID, MAX_SPAWN_PROFILES,
141};
142pub use worktree_service::ManagedWorktreeProfile;
143
144#[cfg(windows)]
145pub use server::DEFAULT_NODE_ENDPOINT;
146
147pub use gate4agent_node_protocol as protocol;
148
149#[cfg(test)]
150mod kit_manifest {
151 #[test]
152 fn default_features_are_the_full_kit() {
153 let manifest = include_str!("../Cargo.toml");
154 let features = manifest
155 .split("[features]")
156 .nth(1)
157 .expect("features section")
158 .split("\n[")
159 .next()
160 .expect("features body");
161 assert!(
162 features.contains("default = [\"kit\"]"),
163 "default build must include the kit"
164 );
165 let kit = feature_array(features, "kit");
166 for core in ["m4a", "d2b", "session-restore", "wireguard", "memory"] {
167 assert!(
168 kit.iter().any(|item| item == core),
169 "kit feature missing {core}: {kit:?}"
170 );
171 }
172 assert!(
173 !features.contains("bare = "),
174 "there is no light mode"
175 );
176 let m4a = feature_array(features, "m4a");
177 assert_eq!(m4a, ["dep:mail4agent"]);
178 let d2b = feature_array(features, "d2b");
179 assert_eq!(d2b, ["dep:dig2browser", "dep:tokio-tungstenite", "dep:futures-util", "dep:image"]);
181 let wg = feature_array(features, "wireguard");
182 assert_eq!(wg, ["gate4agent-node-core/wireguard"]);
183 let code = manifest
184 .lines()
185 .map(|line| line.split('#').next().unwrap_or(""))
186 .collect::<Vec<_>>()
187 .join("\n");
188 assert!(
189 !code.contains("hatchery-tui") && !code.contains("hatchery_tui"),
190 "node must not depend on the hatchery TUI"
191 );
192 assert!(manifest.contains("dig2browser = { version = \"0.5.3\""));
193 assert!(manifest.contains("mail4agent = { version = \"0.4.17\""));
194 assert!(!manifest.contains("[patch.crates-io]"), "published state has no patch table");
195 assert!(!manifest.contains("../../../"), "no path dependency leaves the workspace");
196 assert!(manifest.contains("claude-session-restore = { version = \"0.1.3\""));
197 assert!(manifest.contains("codex-session-restore = { version = \"0.1.3\""));
198 assert!(manifest.contains("grok-session-restore"));
199 assert!(manifest.contains("kimi-session-restore"));
200 }
201
202 fn feature_array(features: &str, name: &str) -> Vec<String> {
203 let line_start = features
204 .find(&format!("{name} = "))
205 .unwrap_or_else(|| panic!("missing feature {name}"));
206 let rest = &features[line_start + name.len() + 3..];
207 if rest.starts_with("[]") {
208 return Vec::new();
209 }
210 assert!(rest.starts_with("["), "{name} must be an array");
211 let end = rest.find(']').unwrap_or_else(|| panic!("{name} array"));
212 rest[1..end]
213 .split(',')
214 .map(|item| item.trim().trim_matches('"').to_owned())
215 .filter(|item| !item.is_empty())
216 .collect()
217 }
218}
219
220
221#[cfg(test)]
222mod deploy_artifacts {
223 #[test]
228 fn service_unit_is_mode1_kit_entry() {
229 let unit = include_str!("../deploy/node/gate4agent-node.service");
230 assert!(unit.contains("ExecStart=/usr/local/bin/gate4agent-node"));
231 assert!(unit.contains("gate4agent node (standard kit)"));
232 assert!(
233 !unit.contains("INSTALL_PROVIDER_CLIS"),
234 "mode 1 unit must not install provider CLIs"
235 );
236 assert!(
237 unit.contains("GATE4AGENT_WG_INTERFACE") || unit.contains("WireGuard"),
238 "unit must document optional WG env"
239 );
240 }
241
242 #[test]
243 fn dockerfile_and_build_script_are_mode2() {
244 let dockerfile = include_str!("../deploy/node/Dockerfile");
245 assert!(dockerfile.contains("cargo build --locked --release -p hatchery-node"));
246 assert!(dockerfile.contains("ENTRYPOINT [\"gate4agent-node\"]"));
247 assert!(!dockerfile.contains("COPY mail4agent"));
248 assert!(!dockerfile.contains("COPY gate4agent"), "crates.io only: no sibling checkouts");
249 assert!(
250 !dockerfile.contains("GATE4AGENT_NODE_TOKEN"),
251 "image must not bake a node token"
252 );
253 let build = include_str!("../deploy/node/docker-build.sh");
254 assert!(build.contains("docker build"));
255 assert!(build.contains("gate4agent-node:kit"));
256 assert!(!build.contains("copy_tree \"$WS/mail4agent\""));
257 }
258
259 #[test]
260 fn qemu_guest_script_is_mode3_underlay_only() {
261 let script = include_str!("../deploy/node/qemu-guest.sh");
262 assert!(script.contains("Mode 3"));
263 assert!(script.contains("QEMU_NET"));
264 assert!(script.contains("tap") && script.contains("user"));
265 assert!(
266 script.contains("Kernel WireGuard is not a QEMU network"),
267 "script must keep WG out of the QEMU NIC story"
268 );
269 assert!(script.contains("GATE4AGENT_WG_"));
270 assert!(script.contains("gate4agent-node"));
271 assert!(
273 !script.contains("cargo test"),
274 "qemu guest script must not be wired into cargo test"
275 );
276 }
277
278 #[test]
279 fn deploy_readme_names_three_modes() {
280 let readme = include_str!("../deploy/node/README.md");
281 assert!(readme.contains("Mode 1 — service"));
282 assert!(readme.contains("Mode 2 — container"));
283 assert!(readme.contains("Mode 3 — QEMU guest"));
284 assert!(readme.contains("no light mode"));
285 }
286}