@@ -26,6 +26,7 @@ fn run(p: &Project, id: u32) -> Result<String, String> {
2626 note("booting VM");
2727 let vm = Vm::up(&name, 8192)?;
2828 give_agent_config(&vm)?;
29+ let keys = give_secrets(&vm)?;
2930 vm.sh("mkdir -p ~/.local/bin ~/.conveyor && cat > ~/.local/bin/conveyor && chmod +x ~/.local/bin/conveyor",
3031 // /proc/self/exe still reads after cargo replaces the binary; current_exe() would not.
3132 &std::fs::read("/proc/self/exe").map_err(|e| e.to_string())?)?;
@@ -51,13 +52,13 @@ fn run(p: &Project, id: u32) -> Result<String, String> {
5152 let stream = File::create(store::dir(&p.slug, id).join("stream.jsonl")).map_err(|e| e.to_string())?;
5253 let mut agent = vm.ssh()
5354 .args(["-o", "StreamLocalBindUnlink=yes", "-R", &format!("{remote}:{}", local.display())])
54- .arg(format!("cd ~/work && CONVEYOR_SOCK={remote} CARGO_TARGET_DIR=$HOME/.cache/conveyor-target PATH=$HOME/.local/bin:$PATH \
55+ .arg(format!("cd ~/work && set -a && . ~/.conveyor/env && set +a && CONVEYOR_SOCK={remote} CARGO_TARGET_DIR=$HOME/.cache/conveyor-target PATH=$HOME/.local/bin:$PATH \
5556 claude -p --output-format stream-json --verbose --dangerously-skip-permissions \
5657 --disallowedTools=AskUserQuestion --append-system-prompt \"$(cat ~/.conveyor/rules.md)\""))
5758 .stdin(Stdio::piped()).stdout(stream).stderr(Stdio::piped())
5859 .spawn().map_err(|e| e.to_string())?;
5960 let before = if resumed { stopped(&p.slug, id) } else { String::new() };
60- agent.stdin.take().unwrap().write_all(format!("# #{id} {}\n\n{}{files}{before}", t.title, t.body).as_bytes()).map_err(|e| e.to_string())?;
61+ agent.stdin.take().unwrap().write_all(format!("# #{id} {}\n\n{}{files}{keys}{before}", t.title, t.body).as_bytes()).map_err(|e| e.to_string())?;
6162 let out = agent.wait_with_output().map_err(|e| e.to_string())?;
6263 let outcome = verbs.finish();
6364 if let Some(reply) = reply(&store::dir(&p.slug, id).join("stream.jsonl")) {
@@ -116,6 +117,23 @@ fn reply(stream: &Path) -> Option<String> {
116117 .find(|v| v["type"] == "result")?["result"].as_str().map(String::from)
117118 }
118119
120+/// Writes the user's keychain to ~/.conveyor/env (0600) as `NAME='value'` lines; the agent's
121+/// shell exports them. A secret `openrouter` is `$OPENROUTER`. What the prompt says of them.
122+fn give_secrets(vm: &Vm) -> Result<String, String> {
123+ let mut env = String::new();
124+ let mut names = Vec::new();
125+ for e in std::fs::read_dir(crate::paths::secrets()).into_iter().flatten().flatten() {
126+ let Ok(value) = std::fs::read_to_string(e.path()) else { continue };
127+ let name: String = e.file_name().to_string_lossy().chars()
128+ .map(|c| if c.is_ascii_alphanumeric() { c.to_ascii_uppercase() } else { '_' }).collect();
129+ if value.is_empty() || name.starts_with(|c: char| c.is_ascii_digit()) { continue; }
130+ env += &format!("{name}='{}'\n", value.trim().replace('\'', "'\\''"));
131+ names.push(format!("`${name}`"));
132+ }
133+ vm.sh("mkdir -p ~/.conveyor && umask 077 && cat > ~/.conveyor/env", env.as_bytes())?;
134+ Ok(if names.is_empty() { String::new() } else { format!("\n\nThe user's keys, in your environment: {}.", names.join(", ")) })
135+}
136+
119137 fn give_agent_config(vm: &Vm) -> Result<(), String> {
120138 let home = std::env::var("HOME").map_err(|e| e.to_string())?;
121139 let files: Vec<&str> = AGENT_FILES.into_iter().filter(|f| Path::new(&home).join(f).exists()).collect();