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
//! Cross-harness sessions (DESIGN §40.50, ledger #429): on an agent's
//! explicit call, and only when this machine's configuration enables it,
//! the stdio MCP server starts one headless run of another installed
//! harness (Claude Code, Codex, OpenCode, Pi, Cursor, Vibe, Muse Code) per
//! turn, follows its output and
//! records the link between the two sessions. Neosian holds no model key,
//! chooses no provider and runs no loop: the child harness does all of it
//! with its own login, model and permissions.
pub mod adapter;
#[cfg(unix)]
mod begin;
#[cfg(unix)]
mod bounded;
#[cfg(unix)]
mod capture;
#[cfg(unix)]
mod child;
mod claude;
mod codex;
mod config;
mod cursor;
#[cfg(unix)]
mod drive;
#[cfg(unix)]
mod ending;
mod events;
#[cfg(unix)]
pub mod file;
#[cfg(unix)]
mod filing;
#[cfg(unix)]
mod home;
mod link;
#[cfg(unix)]
mod memory;
mod muse;
#[cfg(unix)]
mod native;
mod opencode;
mod pi;
mod server;
mod signin;
pub mod text;
mod transport;
mod vibe;
#[cfg(unix)]
pub mod plan;
#[cfg(unix)]
mod probe;
#[cfg(unix)]
mod ready;
#[cfg(unix)]
mod recorder;
#[cfg(unix)]
pub mod registry;
#[cfg(unix)]
mod render;
#[cfg(unix)]
mod sandbox;
#[cfg(unix)]
pub mod selection;
#[cfg(unix)]
mod status;
#[cfg(unix)]
mod tree;
#[cfg(unix)]
mod turn;
#[cfg(unix)]
pub mod watch;
use std::env;
use std::path::Path;
pub use config::{Settings, load};
/// The variable every child carries; a server that sees it is a child.
pub const CHILD_ENV: &str = "NEOSIAN_HARNESS_CHILD";
/// The marker file in a child's private directory, which is Codex's
/// `TMPDIR`: Codex passes MCP servers TMPDIR, never the process environment.
pub const MARKER: &str = ".neosian-harness-child";
/// Whether this process is a harness child (§40.50 item 7): the
/// variable's presence is the marker, whatever its value (#430).
pub fn is_child() -> bool {
if env::var_os(CHILD_ENV).is_some() {
return true;
}
env::var_os("TMPDIR").is_some_and(|dir| Path::new(&dir).join(MARKER).exists())
}
/// The settings when the tool is served by this process: enabled, not a
/// child, on Unix. `warn` receives the reason a broken setting is ignored.
pub fn served(warn: &mut dyn FnMut(&str)) -> Option<Settings> {
if cfg!(not(unix)) || is_child() {
return None;
}
let home = crate::home::home().ok()?;
match load(&home.join("config.toml")) {
Ok(settings) => settings,
Err(message) => {
warn(&message);
None
}
}
}