daemon: use CLAUDE_CONFIG_DIR for OAuth credential separation, fix shutdown

Replace agent_api_key (which didn't work — claude CLI uses OAuth, not
API keys) with agent_config_dir. When configured, sets CLAUDE_CONFIG_DIR
on claude subprocesses so daemon agent work authenticates with separate
OAuth credentials from the interactive session.

Fix daemon not shutting down on SIGTERM: use process::exit(0) after
cleanup so PR_SET_PDEATHSIG kills child claude processes immediately.
Previously the daemon hung waiting for choir threads/subprocesses to
finish. Restart now takes ~20ms instead of timing out.

Also: main.rs now uses `use poc_memory::*` since lib.rs exists.
This commit is contained in:
ProofOfConcept 2026-03-05 22:43:50 -05:00
parent 2f3ac1ecb6
commit e33fd4ffbc
4 changed files with 15 additions and 40 deletions

View file

@ -49,9 +49,10 @@ pub struct Config {
pub journal_max: usize,
/// Ordered context groups for session-start loading.
pub context_groups: Vec<ContextGroup>,
/// Separate API key for background agent work (daemon jobs).
/// If set, passed as ANTHROPIC_API_KEY to model calls.
pub agent_api_key: Option<String>,
/// Separate Claude config dir for background agent work (daemon jobs).
/// If set, passed as CLAUDE_CONFIG_DIR so the daemon authenticates
/// with different OAuth credentials than the interactive session.
pub agent_config_dir: Option<PathBuf>,
}
impl Default for Config {
@ -72,7 +73,7 @@ impl Default for Config {
source: ContextSource::Store,
},
],
agent_api_key: None,
agent_config_dir: None,
}
}
}
@ -126,8 +127,8 @@ impl Config {
if let Some(m) = cfg.get("journal_max").and_then(|v| v.as_u64()) {
config.journal_max = m as usize;
}
if let Some(s) = cfg.get("agent_api_key").and_then(|v| v.as_str()) {
config.agent_api_key = Some(s.to_string());
if let Some(s) = cfg.get("agent_config_dir").and_then(|v| v.as_str()) {
config.agent_config_dir = Some(expand_home(s));
}
continue;
}