inject HYPERHIVE_STATE_DIR into container env + extra MCP server envs
This commit is contained in:
parent
9cbb05bb86
commit
f21ae1ff98
2 changed files with 19 additions and 1 deletions
|
|
@ -1383,13 +1383,20 @@ pub fn render_claude_config(agent_binary: &str, socket: &std::path::Path) -> Str
|
||||||
"env": {}
|
"env": {}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
for (name, spec) in load_extra_mcp() {
|
// Auto-inject HYPERHIVE_STATE_DIR so extra MCP servers can resolve the
|
||||||
|
// agent's durable state dir without the agent author hard-coding it.
|
||||||
|
// User-supplied env takes precedence — we only fill in the missing key.
|
||||||
|
let state_dir = crate::paths::state_dir();
|
||||||
|
for (name, mut spec) in load_extra_mcp() {
|
||||||
if name == SERVER_NAME {
|
if name == SERVER_NAME {
|
||||||
tracing::warn!(
|
tracing::warn!(
|
||||||
"extra MCP server name `{SERVER_NAME}` collides with the built-in surface; ignoring",
|
"extra MCP server name `{SERVER_NAME}` collides with the built-in surface; ignoring",
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
spec.env
|
||||||
|
.entry("HYPERHIVE_STATE_DIR".to_owned())
|
||||||
|
.or_insert_with(|| state_dir.display().to_string());
|
||||||
servers.insert(
|
servers.insert(
|
||||||
name,
|
name,
|
||||||
serde_json::json!({
|
serde_json::json!({
|
||||||
|
|
|
||||||
|
|
@ -273,11 +273,22 @@ fn render_flake(
|
||||||
name = name;
|
name = name;
|
||||||
email = "${name}@hyperhive";
|
email = "${name}@hyperhive";
|
||||||
};
|
};
|
||||||
|
# Container-wide env: every service + co-process daemon can
|
||||||
|
# resolve the agent's durable state dir without hard-coding it.
|
||||||
|
environment.variables = {
|
||||||
|
HIVE_LABEL = name;
|
||||||
|
HYPERHIVE_STATE_DIR =
|
||||||
|
if isManager then "/state"
|
||||||
|
else "/agents/${name}/state";
|
||||||
|
};
|
||||||
systemd.services.${service}.environment = {
|
systemd.services.${service}.environment = {
|
||||||
HIVE_PORT = toString port;
|
HIVE_PORT = toString port;
|
||||||
HIVE_LABEL = name;
|
HIVE_LABEL = name;
|
||||||
HIVE_DASHBOARD_PORT = toString dashboardPort;
|
HIVE_DASHBOARD_PORT = toString dashboardPort;
|
||||||
HIVE_OPERATOR_PRONOUNS = operatorPronouns;
|
HIVE_OPERATOR_PRONOUNS = operatorPronouns;
|
||||||
|
HYPERHIVE_STATE_DIR =
|
||||||
|
if isManager then "/state"
|
||||||
|
else "/agents/${name}/state";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue