aKode: integrazione della memoria di imeAI (plugin memoria)
- nuovo crate ext/memoria: aggiunge le istruzioni del plugin (instructions.md) come developer policy solo se il plugin memoria è abilitato e il suo server MCP è pronto; nessuna modifica alle istruzioni di base, [features] memories resta spento - pollutes_memory configurabile per server MCP (predefinito true) - project_header per i server HTTP: progetto ricavato dalla cartella della sessione (origin come host/owner/repo, altrimenti la cartella), connessioni separate per progetto - token Bearer dei server MCP anche dal portachiavi di aKode, solo sotto mcp:<server> (mai le chiavi dei provider dei modelli) - tool namespace (MCP, multi-agente) appiattiti in <namespace>__<tool> per i server compatibili OpenAI che accettano solo function tool (llama.cpp, ik_llama.cpp, vLLM li scartavano); capacità del provider tool_namespaces - prove: parsing e propagazione, intestazione del progetto, iniezione solo se attivo e connesso, appiattimento e mappatura delle chiamate, chiavi dei provider mai consegnate ai server MCP Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -57,3 +57,50 @@ fn configured_credentials_retain_host_environment_resolution() {
|
||||
expected,
|
||||
);
|
||||
}
|
||||
|
||||
/// In-memory key store for the fallback test (no key material in `Debug`).
|
||||
struct MemoryKeyStore(std::collections::HashMap<String, String>);
|
||||
|
||||
impl std::fmt::Debug for MemoryKeyStore {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str("MemoryKeyStore")
|
||||
}
|
||||
}
|
||||
|
||||
impl akode_model_provider_info::ProviderApiKeyStore for MemoryKeyStore {
|
||||
fn load(&self, provider_id: &str) -> Result<Option<String>, String> {
|
||||
Ok(self.0.get(provider_id).cloned())
|
||||
}
|
||||
fn save(&self, _: &str, _: &str) -> Result<akode_model_provider_info::ProviderApiKeyLocation, String> {
|
||||
Err("read-only".to_string())
|
||||
}
|
||||
fn delete(&self, _: &str) -> Result<bool, String> {
|
||||
Ok(false)
|
||||
}
|
||||
fn locate(&self, _: &str) -> Result<Option<akode_model_provider_info::ProviderApiKeyLocation>, String> {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn key_store_fallback_never_hands_out_model_provider_keys() {
|
||||
let store = MemoryKeyStore(
|
||||
[
|
||||
("openrouter".to_string(), "provider-secret".to_string()),
|
||||
("mcp:memoria".to_string(), "memoria-token".to_string()),
|
||||
]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
);
|
||||
akode_model_provider_info::set_provider_api_key_store(std::sync::Arc::new(store));
|
||||
let unset = "AKODE_TEST_SURELY_UNSET_MCP_TOKEN_VAR";
|
||||
// A server that reuses a provider's name (e.g. from a plugin) must not get that provider's key.
|
||||
let error = resolve_bearer_token("openrouter", Some(unset), McpCredentialPolicy::HostFallbackAllowed)
|
||||
.expect_err("provider keys are not MCP tokens");
|
||||
assert!(!error.to_string().contains("provider-secret"));
|
||||
assert_eq!(
|
||||
resolve_bearer_token("memoria", Some(unset), McpCredentialPolicy::HostFallbackAllowed)
|
||||
.expect("token stored under mcp:memoria"),
|
||||
Some("memoria-token".to_string()),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user