Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(wrapper): forward provider env vars from the PowerShell Docker helper
kevin93276ac9af916b4a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 08a74e62..2092edbd 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]+### Fixed+- The Windows Docker wrapper (`bin/ai-memory.ps1`) now forwards the same+ provider credentials and host-config env vars as the POSIX wrapper into the+ helper container. A host-exported `GEMINI_API_KEY` / `GOOGLE_API_KEY`,+ Copilot token, `OPENCODE_API_KEY`, `CLAUDE_CONFIG_DIR`, or+ `AI_MEMORY_WORKSTREAM_ID` previously never reached `Config::load`, so+ `llm-test`, Copilot auth, OpenCode, and a relocated Claude config all+ reported "not configured" on native Windows Docker Desktop even though the+ same export worked through `bin/ai-memory`. The POSIX wrapper also now+ forwards `OPENCODE_API_KEY`.+## [2.3.2] - 2026-09-20### Changeddiff --git a/bin/ai-memory b/bin/ai-memoryindex 84a4e1c4..18b6dcc1 100755--- a/bin/ai-memory+++ b/bin/ai-memory@@ -604,6 +604,7 @@ for var in \VOYAGE_API_KEY \LLM_API_KEY \EMBEDDING_API_KEY \+ OPENCODE_API_KEY \RUST_LOGdoif [ -n "${!var:-}" ]; thendiff --git a/bin/ai-memory.ps1 b/bin/ai-memory.ps1index abd25adc..34f9cbc4 100644--- a/bin/ai-memory.ps1+++ b/bin/ai-memory.ps1@@ -145,19 +145,28 @@ foreach ($Name in @("AI_MEMORY_LLM_PROVIDER","AI_MEMORY_LLM_MODEL","AI_MEMORY_LLM_BASE_URL",+ "AI_MEMORY_COPILOT_CLIENT_ID","AI_MEMORY_EMBEDDING_PROVIDER","AI_MEMORY_EMBEDDING_MODEL","AI_MEMORY_EMBEDDING_BASE_URL","AI_MEMORY_EMBEDDING_DIM","AI_MEMORY_ALLOWED_HOSTS",+ "AI_MEMORY_WORKSTREAM_ID",+ "CLAUDE_CONFIG_DIR","CLAUDE_CODE_SESSION_ID","ANTHROPIC_API_KEY","ANTHROPIC_OAUTH_TOKEN","CLAUDE_CODE_OAUTH_TOKEN","OPENAI_API_KEY",+ "GEMINI_API_KEY",+ "GOOGLE_API_KEY",+ "COPILOT_GITHUB_TOKEN",+ "GITHUB_COPILOT_API_TOKEN",+ "COPILOT_API_URL","VOYAGE_API_KEY","LLM_API_KEY","EMBEDDING_API_KEY",+ "OPENCODE_API_KEY","RUST_LOG")) {if (-not [string]::IsNullOrEmpty([Environment]::GetEnvironmentVariable($Name))) {diff --git a/crates/ai-memory-cli/tests/suite/packaging.rs b/crates/ai-memory-cli/tests/suite/packaging.rsindex 6668154c..d8c97e31 100644--- a/crates/ai-memory-cli/tests/suite/packaging.rs+++ b/crates/ai-memory-cli/tests/suite/packaging.rs@@ -488,6 +488,21 @@ fn posix_wrapper_auto_selects_podman_when_docker_is_unavailable() {);}+const WRAPPER_FORWARDED_PROVIDER_KEYS: &[&str] = &[+ "ANTHROPIC_API_KEY",+ "ANTHROPIC_OAUTH_TOKEN",+ "OPENAI_API_KEY",+ "GEMINI_API_KEY",+ "GOOGLE_API_KEY",+ "VOYAGE_API_KEY",+ "COPILOT_GITHUB_TOKEN",+ "GITHUB_COPILOT_API_TOKEN",+ "COPILOT_API_URL",+ "LLM_API_KEY",+ "EMBEDDING_API_KEY",+ "OPENCODE_API_KEY",+];+#[test]fn wrapper_forwards_every_supported_provider_api_key() {// The wrapper runs the server in a container, so any provider credential@@ -496,17 +511,7 @@ fn wrapper_forwards_every_supported_provider_api_key() {// Gemini/Google were missing while every other provider key was// forwarded (#698), so the guard names each key the config layer reads.let wrapper = read_repo("bin/ai-memory");- for key in [- "ANTHROPIC_API_KEY",- "ANTHROPIC_OAUTH_TOKEN",- "OPENAI_API_KEY",- "GEMINI_API_KEY",- "GOOGLE_API_KEY",- "VOYAGE_API_KEY",- "COPILOT_GITHUB_TOKEN",- "LLM_API_KEY",- "EMBEDDING_API_KEY",- ] {+ for key in WRAPPER_FORWARDED_PROVIDER_KEYS {assert!(wrapper.contains(&format!(" {key} \\")),"wrapper must forward {key} into the container"@@ -514,6 +519,42 @@ fn wrapper_forwards_every_supported_provider_api_key() {}}+#[test]+fn powershell_wrapper_forwards_every_supported_provider_api_key() {+ // Same contract as the POSIX wrapper: Docker Desktop on Windows still+ // runs the CLI inside a Linux helper, so a host-exported Gemini /+ // Copilot / OpenCode key that is not on this allowlist never reaches+ // Config::load and the provider reports "not configured".+ let wrapper = read_repo("bin/ai-memory.ps1");+ let allowlist = wrapper+ .split_once("foreach ($Name in @(")+ .and_then(|(_, rest)| rest.split_once(")) {"))+ .map(|(allowlist, _)| allowlist)+ .expect("PowerShell wrapper env allowlist");+ for key in WRAPPER_FORWARDED_PROVIDER_KEYS {+ assert!(+ allowlist+ .lines()+ .any(|line| line.trim() == format!("\"{key}\",")+ || line.trim() == format!("\"{key}\"")),+ "PowerShell wrapper must list {key} in the helper env allowlist"+ );+ }+ for key in [+ "AI_MEMORY_COPILOT_CLIENT_ID",+ "AI_MEMORY_WORKSTREAM_ID",+ "CLAUDE_CONFIG_DIR",+ ] {+ assert!(+ allowlist+ .lines()+ .any(|line| line.trim() == format!("\"{key}\",")+ || line.trim() == format!("\"{key}\"")),+ "PowerShell wrapper must list {key} in the helper env allowlist"+ );+ }+}+#[test]fn wrapper_updates_and_install_docs_use_verified_release_assets() {let wrapper = read_repo("bin/ai-memory");