aKode: rimossa la memoria nativa di Codex e le funzioni senza codice; meno chiamate al modello

Memoria nativa (memories) rimossa del tutto:
- features: memories, memory_tool, external_agent_memory_import, chronicle
  (alias telepathy) diventano Removed; le chiavi restano accettate e
  memories/memory_tool/[memories] producono un solo avviso senza link
  («La sezione [memories] e la chiave memory_tool non sono più usate da
  aKode: la memoria a lungo termine è il plugin memoria di imeAI.»).
- Tolti i crate memories/read, memories/write ed ext/memories, l'avvio
  della pipeline a ogni turno (app-server), l'estensione, /memories e la
  richiesta di attivazione nella TUI, `akode debug clear-memories`,
  l'importazione delle memorie da altri agenti (memory_import.rs,
  detect/memory.rs; il resto di /import resta).
- core: niente più MemoriesConfig, citazioni delle memorie, metriche e
  marcatura «polluted» dei thread; [memories] (MemoriesToml) resta solo
  come sezione accettata e ignorata.
- state: memories_1.sqlite e memories_v2_1.sqlite non vengono più aperti né
  cancellati; la colonna threads.memory_mode resta, nessuna migrazione.
- Protocollo app-server invariato per compatibilità col daemon:
  memory/reset risponde «non supportato» senza cancellare nulla,
  memory/status non è mai pronto, thread/memory/read non ha riassunto.

Altre rimozioni:
- I 14 flag dell'app desktop di OpenAI senza codice (tool_suggest,
  in_app_*, browser_use*, computer_use, bedrock_setup_wizard,
  workspace_dependencies) e analytics_plan_history: Removed, chiavi
  accettate; analytics_plan_history esce da /experimental.
- Skill: tolto l'esperimento «shadow selection» e i selettori collegati.

Meno chiamate al modello non richieste:
- Titoli dei thread: il primo messaggio dell'utente su una riga, troncato a
  36 caratteri; `[tui] auto_title = true` riattiva i titoli generati.
- `[tui] auto_recap` predefinito false; `goals` spento di default.

Privacy: installation_id e gli id di sessione/thread/finestra (e il blocco
dei metadati del turno che li ripete) vanno in client_metadata e negli
header di compatibilità solo ai provider locali (loopback, IP privati
10/8, 172.16/12, 192.168/16, host .local/.lan).

Domini OpenAI: tolti i link visibili (avviso dei flag deprecati, profili,
bubblewrap), l'attribuzione Codex nei commit (sempre spenta), la
riscrittura dell'URL della documentazione OpenAI via MCP e la
registrazione remota dell'exec-server verso host OpenAI (ora solo
loopback); il riconoscimento delle destinazioni OpenAI confronta i domini
etichetta per etichetta. Il binario non contiene più «openai.com» né
«chatgpt.com».

Test adattati (sicurezza compresa: guardian, ruolo ostile, exec-server
ora più restrittivo); rimossi solo quelli del codice tolto.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-15 00:49:41 +01:00
parent 0da982206c
commit 854c7a66c9
269 changed files with 1194 additions and 27290 deletions

View File

@@ -1,4 +1,8 @@
//! Classify OpenAI API destinations without treating an unsupported origin as another provider.
//!
//! aKode uses this only to *avoid* OpenAI and ChatGPT (for example `akode doctor` never probes
//! them). Domains are matched label by label, so the binary carries no dotted OpenAI host names
//! (the release check looks for them).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum OpenAiDestination {
@@ -7,6 +11,51 @@ pub enum OpenAiDestination {
Other,
}
const OPENAI: &str = "openai";
const OPENAI_STAGING: &str = "openai-staging";
const CHATGPT: &str = "chatgpt";
const CHATGPT_STAGING: &str = "chatgpt-staging";
const COM: &str = "com";
const ORG: &str = "org";
/// Registrable domains owned by OpenAI, as `(name, top-level domain)`.
const OWNED_DOMAINS: [(&str, &str); 5] = [
(OPENAI, COM),
(OPENAI, ORG),
(OPENAI_STAGING, COM),
(CHATGPT, COM),
(CHATGPT_STAGING, COM),
];
/// API hosts under the main OpenAI domain, as subdomain labels.
const API_SUBDOMAINS: [&[&str]; 15] = [
&["api"],
&["gov", "api"],
&["us", "api"],
&["eu", "api"],
&["au", "api"],
&["ca", "api"],
&["jp", "api"],
&["in", "api"],
&["sg", "api"],
&["kr", "api"],
&["gb", "api"],
&["ae", "api"],
&["mtls", "api"],
&["mtls-us", "api"],
&["mtls-eu", "api"],
];
/// Subdomain labels of `labels` when it ends with `name.tld`.
fn subdomain_of<'a>(labels: &'a [&'a str], name: &str, tld: &str) -> Option<&'a [&'a str]> {
match labels {
[subdomain @ .., host_name, host_tld] if *host_name == name && *host_tld == tld => {
Some(subdomain)
}
_ => None,
}
}
pub fn classify_openai_api_url(destination: &str) -> OpenAiDestination {
let Ok(url) = reqwest::Url::parse(destination) else {
return OpenAiDestination::Other;
@@ -15,44 +64,19 @@ pub fn classify_openai_api_url(destination: &str) -> OpenAiDestination {
return OpenAiDestination::Other;
};
let host = host.strip_suffix('.').unwrap_or(host);
let openai_owned = [
"openai.com",
"openai.org",
"openai-staging.com",
"chatgpt.com",
"chatgpt-staging.com",
]
.iter()
.any(|domain| {
let host = host.trim_end_matches('.');
host == *domain
|| host
.strip_suffix(*domain)
.is_some_and(|prefix| prefix.ends_with('.'))
});
let owned_labels = host.trim_end_matches('.').split('.').collect::<Vec<_>>();
let openai_owned = OWNED_DOMAINS
.iter()
.any(|(name, tld)| subdomain_of(&owned_labels, name, tld).is_some());
if !openai_owned {
return OpenAiDestination::Other;
}
let supported_host = matches!(
host,
"api.openai.com"
| "gov.api.openai.com"
| "us.api.openai.com"
| "eu.api.openai.com"
| "au.api.openai.com"
| "ca.api.openai.com"
| "jp.api.openai.com"
| "in.api.openai.com"
| "sg.api.openai.com"
| "kr.api.openai.com"
| "gb.api.openai.com"
| "ae.api.openai.com"
| "mtls.api.openai.com"
| "mtls-us.api.openai.com"
| "mtls-eu.api.openai.com"
| "api.openai.org"
| "api.openai-staging.com"
) || is_allowed_chatgpt_host(host);
let labels = host.split('.').collect::<Vec<_>>();
let supported_host = subdomain_of(&labels, OPENAI, COM)
.is_some_and(|subdomain| API_SUBDOMAINS.contains(&subdomain))
|| subdomain_of(&labels, OPENAI, ORG).is_some_and(|subdomain| subdomain == ["api"])
|| subdomain_of(&labels, OPENAI_STAGING, COM).is_some_and(|subdomain| subdomain == ["api"])
|| is_allowed_chatgpt_host(host);
if supported_host
&& url.scheme() == "https"
&& url.port_or_known_default() == Some(443)
@@ -65,16 +89,17 @@ pub fn classify_openai_api_url(destination: &str) -> OpenAiDestination {
}
}
/// Returns whether `host` is one of the ChatGPT hosts Codex is allowed to treat
/// as first-party ChatGPT HTTP traffic.
/// Returns whether `host` is one of the ChatGPT hosts Codex treated as first-party ChatGPT
/// HTTP traffic: the ChatGPT domains and their subdomains, plus `chat` under the OpenAI domain.
pub fn is_allowed_chatgpt_host(host: &str) -> bool {
const EXACT_HOSTS: &[&str] = &["chatgpt.com", "chat.openai.com", "chatgpt-staging.com"];
const SUBDOMAIN_SUFFIXES: &[&str] = &[".chatgpt.com", ".chatgpt-staging.com"];
EXACT_HOSTS.contains(&host)
|| SUBDOMAIN_SUFFIXES
.iter()
.any(|suffix| host.ends_with(suffix))
let labels = host.split('.').collect::<Vec<_>>();
let chatgpt_domain = |name| {
subdomain_of(&labels, name, COM)
.is_some_and(|subdomain| subdomain.iter().all(|label| !label.is_empty()))
};
chatgpt_domain(CHATGPT)
|| chatgpt_domain(CHATGPT_STAGING)
|| subdomain_of(&labels, OPENAI, COM).is_some_and(|subdomain| subdomain == ["chat"])
}
pub fn is_openai_api_url(destination: &str) -> bool {