diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-15 03:11:22 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-15 03:11:22 +0100 |
| commit | 343f2a8a6148b8004d6f4d74fb779b4f30c9686a (patch) | |
| tree | 2ea1ddab346565309da644517c3478d2a9096e55 /src/config.rs | |
| parent | M0: streaming provider, SSE decoder, mock provider, i686 build gate (diff) | |
| download | agent686-343f2a8a6148b8004d6f4d74fb779b4f30c9686a.tar.gz agent686-343f2a8a6148b8004d6f4d74fb779b4f30c9686a.zip | |
M1-M5: sessions, six tools, approvals, prompt, Ctrl-C, target gate
- append-only JSONL sessions with --continue/--session; reasoning stored, stripped on replay
- read/write/edit/grep/glob + bash with timeout and capped output
- diff-preview approval for the first edit of a session, per-call approval for bash
- system prompt frozen per session with AGENTS.md snapshot and change warning
- SIGINT aborts the turn, second Ctrl-C exits
- glibc gate ignores weak symbols; verified in linux/386 debian:12
- acceptance test (calculator in C) passes on both x86-64 and i386
Diffstat (limited to 'src/config.rs')
| -rw-r--r-- | src/config.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/config.rs b/src/config.rs index b781637..a1d7c42 100644 --- a/src/config.rs +++ b/src/config.rs | |||
| @@ -8,7 +8,10 @@ pub struct Config { | |||
| 8 | pub base_url: String, | 8 | pub base_url: String, |
| 9 | pub api_key: String, | 9 | pub api_key: String, |
| 10 | pub model: String, | 10 | pub model: String, |
| 11 | /// Session id, sent to the provider as `x-opencode-session`. Filled in once | ||
| 12 | /// the session exists. | ||
| 11 | pub session: String, | 13 | pub session: String, |
| 14 | pub yolo: bool, | ||
| 12 | } | 15 | } |
| 13 | 16 | ||
| 14 | impl Config { | 17 | impl Config { |
| @@ -16,7 +19,7 @@ impl Config { | |||
| 16 | pub fn resolve( | 19 | pub fn resolve( |
| 17 | model: Option<String>, | 20 | model: Option<String>, |
| 18 | base_url: Option<String>, | 21 | base_url: Option<String>, |
| 19 | session: Option<String>, | 22 | yolo: bool, |
| 20 | ) -> Result<Config, String> { | 23 | ) -> Result<Config, String> { |
| 21 | Ok(Config { | 24 | Ok(Config { |
| 22 | api_key: api_key()?, | 25 | api_key: api_key()?, |
| @@ -26,7 +29,8 @@ impl Config { | |||
| 26 | model: model | 29 | model: model |
| 27 | .or_else(|| env_nonempty("AGENT686_MODEL")) | 30 | .or_else(|| env_nonempty("AGENT686_MODEL")) |
| 28 | .unwrap_or_else(|| DEFAULT_MODEL.to_string()), | 31 | .unwrap_or_else(|| DEFAULT_MODEL.to_string()), |
| 29 | session: session.unwrap_or_else(crate::session::new_id), | 32 | session: String::new(), |
| 33 | yolo, | ||
| 30 | }) | 34 | }) |
| 31 | } | 35 | } |
| 32 | 36 | ||
| @@ -40,7 +44,7 @@ fn env_nonempty(key: &str) -> Option<String> { | |||
| 40 | } | 44 | } |
| 41 | 45 | ||
| 42 | /// The key comes from the environment first, then from a file, so a key never | 46 | /// The key comes from the environment first, then from a file, so a key never |
| 43 | /// has to live in shell history or in a process listing. | 47 | /// has to live in shell history. |
| 44 | fn api_key() -> Result<String, String> { | 48 | fn api_key() -> Result<String, String> { |
| 45 | if let Some(k) = env_nonempty("OPENCODE_API_KEY") { | 49 | if let Some(k) = env_nonempty("OPENCODE_API_KEY") { |
| 46 | return Ok(k.trim().to_string()); | 50 | return Ok(k.trim().to_string()); |
