refactor: compute per-agent mount points for /agents/<name>/ structure
This commit is contained in:
parent
6dd17864ac
commit
ecaa178199
1 changed files with 22 additions and 1 deletions
|
|
@ -742,8 +742,29 @@ fn set_nspawn_flags(
|
|||
|
||||
let path = format!("/etc/nixos-containers/{container}.conf");
|
||||
let original = std::fs::read_to_string(&path).with_context(|| format!("read {path}"))?;
|
||||
|
||||
// Compute mount points: for sub-agents, bind /agents/<name>/ with state+claude inside.
|
||||
// For manager, use the old structure with /root/.claude and /state.
|
||||
let agent_mount_base = if container == MANAGER_NAME {
|
||||
None // Manager has no agent-specific mount
|
||||
} else {
|
||||
// Strip the "h-" prefix from container name to get agent name
|
||||
let agent_name = container.strip_prefix(AGENT_PREFIX).unwrap_or(container);
|
||||
Some(format!("/agents/{agent_name}"))
|
||||
};
|
||||
|
||||
// For sub-agents: bind /agents/<name>/ containing state and claude
|
||||
// For manager: use old /state and /root/.claude mounts
|
||||
let (notes_mount, claude_mount) = if let Some(ref mount_base) = agent_mount_base {
|
||||
// Sub-agent: state at /agents/<name>/state, claude at /agents/<name>/claude
|
||||
(format!("{mount_base}/state"), format!("{mount_base}/claude"))
|
||||
} else {
|
||||
// Manager: keep current structure
|
||||
(CONTAINER_NOTES_MOUNT.to_owned(), CONTAINER_CLAUDE_MOUNT.to_owned())
|
||||
};
|
||||
|
||||
let mut binds = format!(
|
||||
"--bind={runtime}:{CONTAINER_RUNTIME_MOUNT} --bind={claude}:{CONTAINER_CLAUDE_MOUNT} --bind={notes}:{CONTAINER_NOTES_MOUNT} --bind={shared}:{CONTAINER_SHARED_MOUNT}",
|
||||
"--bind={runtime}:{CONTAINER_RUNTIME_MOUNT} --bind={claude}:{claude_mount} --bind={notes}:{notes_mount} --bind={shared}:{CONTAINER_SHARED_MOUNT}",
|
||||
runtime = runtime_dir.display(),
|
||||
claude = claude_dir.display(),
|
||||
notes = notes_dir.display(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue