1use std::path::{Path, PathBuf};
2
3const DEFAULT_AGENT_ID: &str = "default-agent";
4
5#[derive(Debug, Clone)]
7pub struct SecretsPaths {
8 root: PathBuf,
9}
10
11impl SecretsPaths {
12 pub fn new(root: impl AsRef<Path>) -> Self {
14 Self {
15 root: root.as_ref().to_path_buf(),
16 }
17 }
18
19 pub fn root(&self) -> &Path {
21 &self.root
22 }
23
24 pub fn store_dir(&self) -> PathBuf {
26 self.root.join("store")
27 }
28
29 pub fn metadata_dir(&self) -> PathBuf {
31 self.root.join("meta")
32 }
33
34 pub fn pending_file(&self) -> PathBuf {
36 self.root.join("pending.json")
37 }
38
39 pub fn audit_file(&self) -> PathBuf {
41 self.root.join("audit.jsonl")
42 }
43
44 pub fn default_identity_file(&self) -> PathBuf {
46 self.identity_file_for_agent(DEFAULT_AGENT_ID)
47 }
48
49 pub fn identity_file_for_agent(&self, agent_id: &str) -> PathBuf {
51 self.root.join(format!("{agent_id}.agekey"))
52 }
53
54 pub fn default_signing_key_file(&self) -> PathBuf {
56 self.signing_key_file_for_agent(DEFAULT_AGENT_ID)
57 }
58
59 pub fn signing_key_file_for_agent(&self, agent_id: &str) -> PathBuf {
61 self.root.join(format!("{agent_id}.signing.key"))
62 }
63
64 pub fn vaults_dir(&self) -> PathBuf {
66 self.root.join("vaults")
67 }
68
69 pub fn gpg_homes_dir(&self) -> PathBuf {
71 self.root.join("gpg")
72 }
73
74 pub fn gpg_home(&self, agent_id: &str) -> PathBuf {
76 self.gpg_homes_dir().join(agent_id)
77 }
78
79 pub fn vault_sessions_file(&self) -> PathBuf {
81 self.vaults_dir().join("sessions.json")
82 }
83
84 pub fn encrypted_dir(&self) -> PathBuf {
86 self.root.join("encrypted")
87 }
88
89 pub fn mounts_dir(&self) -> PathBuf {
91 self.root.join("mnt")
92 }
93
94 pub fn vault_config_file(&self, vault_name: &str) -> PathBuf {
96 self.vaults_dir().join(format!("{vault_name}.toml"))
97 }
98
99 pub fn vault_cipher_dir(&self, vault_name: &str) -> PathBuf {
101 self.encrypted_dir().join(vault_name)
102 }
103
104 pub fn vault_mountpoint(&self, vault_name: &str) -> PathBuf {
106 self.mounts_dir().join(vault_name)
107 }
108}