Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
Merge remote-tracking branch 'upstream/main' into feat/llm-reasoning-effort
Matheus Cardosobafa7c964e9a
diff --cc CHANGELOG.mdindex 098b90ac,26fea0ec..6a96078e--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -262,17 -396,18 +396,29 @@@ and this project adheres to [Semantic Vproject, or worktree reads as absent rather than renamable. The Dockerwrapper routes the command through its native host client, since repositoryidentity is a host resource.+ - Human password login, web sessions, and native `aim_` API credentials, so the+ console can use short-lived human sessions instead of a Bearer pasted into+ the browser. `POST /auth/login` issues an `HttpOnly` `ai_memory_session`+ cookie plus CSRF; `/mcp`, hooks, and workstreams stay Bearer-only. Greenfield+ bootstrap consumes `AI_MEMORY_AUTH__INITIAL_ROOT_PASSWORD` once; break-glass+ recovery uses `AI_MEMORY_AUTH__RECOVERY_TOKEN` and never opens a session.+ `ai-memory user add-human|list|reset-password|disable|enable|patch` manages+ people, while `ai-memory api-key add|list|rotate|revoke` manages machine+ secrets. Existing 32-byte `users.token_hash` values copy losslessly into+ `api_credentials`. The mirror triggers remain load-bearing for the deprecated+ 1.x `user add|expire|revive|rotate-token` shims and may be removed only when+ those shims are removed in 2.0. (#533)+- `llm_reasoning_effort` / `AI_MEMORY_LLM_REASONING_EFFORT` is a typed+ enum (`none`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`,+ `ultra`, `persistent`); unknown values fail at config load. Unset keeps+ the model default. Each chat provider maps the value to its native+ field: OpenAI `reasoning_effort`, OpenRouter `reasoning.effort`,+ xAI Grok `reasoning_effort`, Anthropic `output_config.effort` (plus+ adaptive/disabled thinking on models that accept it), and Codex+ Responses `reasoning.effort`. Gemini and Copilot ignore the key.+ Host-unsupported values are clamped (`ultra`/`persistent` → `max` on+ OpenAI/OpenRouter/Codex; Anthropic `xhigh`/`max` per model; `none`+ does not send `thinking: disabled` on always-on Claude models).## [1.38.0] - 2026-08-30diff --cc crates/ai-memory-cli/src/config.rsindex c3f24257,c99afd66..94cbe63b--- a/crates/ai-memory-cli/src/config.rs+++ b/crates/ai-memory-cli/src/config.rs@@@ -1001,6 -1015,9 +1024,8 @@@ impl Configconfig.llm_timeout_secs);}-+ validate_auth_secrets(&config.auth)?;+Ok(config)}@@@ -1359,9 -1504,84 +1513,85 @@@ fn normalize_home_dir(home: &str) -> Op#[cfg(test)]mod tests {++ /// #552: the bearer used to travel on every hook's command line, readable+ /// through `/proc/<pid>/cmdline` by any local user. It now lives in the+ /// data dir instead — which is only an improvement if the files are not+ /// world-readable, so the mode is asserted rather than assumed.+ #[test]+ fn a_persisted_hook_token_is_owner_only_and_round_trips() {+ let tmp = TempDir::new().unwrap();+ let dd = tmp.path().join("data");++ store_hook_auth_token(&dd, "s3cret-bearer").unwrap();++ assert_eq!(read_hook_auth_token(&dd).as_deref(), Some("s3cret-bearer"));+ assert_eq!(+ std::fs::read_to_string(hook_auth_header_path_in(&dd)).unwrap(),+ "Authorization: Bearer s3cret-bearer\n",+ "the header file is what curl reads with -H @file"+ );++ #[cfg(unix)]+ {+ use std::os::unix::fs::PermissionsExt as _;+ for path in [hook_auth_token_path_in(&dd), hook_auth_header_path_in(&dd)] {+ let mode = std::fs::metadata(&path).unwrap().permissions().mode() & 0o777;+ assert_eq!(+ mode,+ 0o600,+ "{} must be owner-only, got {mode:o}",+ path.display()+ );+ }+ }+ }++ /// Re-running `install-hooks --apply` after `user rotate-token` must leave+ /// the new bearer, not both.+ #[test]+ fn storing_a_second_token_replaces_the_first() {+ let tmp = TempDir::new().unwrap();+ let dd = tmp.path().join("data");+ store_hook_auth_token(&dd, "old-token").unwrap();+ store_hook_auth_token(&dd, "new-token").unwrap();++ assert_eq!(read_hook_auth_token(&dd).as_deref(), Some("new-token"));+ assert!(+ !std::fs::read_to_string(hook_auth_header_path_in(&dd))+ .unwrap()+ .contains("old-token"),+ "a rotated token must not leave the previous one behind"+ );+ }++ /// Absent, empty, and whitespace-only files all read as "no token" rather+ /// than as an empty bearer, which would send `Authorization: Bearer `.+ #[test]+ fn an_absent_or_blank_token_file_reads_as_none() {+ let tmp = TempDir::new().unwrap();+ let dd = tmp.path().join("data");+ assert!(read_hook_auth_token(&dd).is_none(), "absent");++ std::fs::create_dir_all(&dd).unwrap();+ std::fs::write(hook_auth_token_path_in(&dd), "").unwrap();+ assert!(read_hook_auth_token(&dd).is_none(), "empty");+ std::fs::write(hook_auth_token_path_in(&dd), " \n ").unwrap();+ assert!(read_hook_auth_token(&dd).is_none(), "whitespace only");+ }++ #[test]+ fn clearing_a_token_is_idempotent() {+ let tmp = TempDir::new().unwrap();+ let dd = tmp.path().join("data");+ store_hook_auth_token(&dd, "tok").unwrap();+ clear_hook_auth_token(&dd).unwrap();+ assert!(read_hook_auth_token(&dd).is_none());+ clear_hook_auth_token(&dd).expect("clearing twice must not error");+ }use super::*;+ use rstest::rstest;- use secrecy::ExposeSecret;+ use secrecy::{ExposeSecret, SecretString};use tempfile::TempDir;#[test]