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