Implementation:ARCANGEL0 EVA CredentialStore
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Configuration, Security, Credential_Management |
| Last Updated | 2026-10-29 14:00 GMT |
Overview
Concrete tool for persisting provider credentials, API keys, and search engine settings with atomic writes and restrictive permissions, provided by the Mitsu config storage module.
Description
The CredentialStore class manages credentials in `~/.config/mitsu/credentials.json` with 0o600 permissions. It provides:
- Profile management: `save_profile(profile)` stores a provider profile (base_url, model, api_key, protocol, reasoning settings) keyed by provider_id. When saving without an API key, the previous key is retained.
- Active profile: `active()` returns the currently active provider profile; `profile_for(provider_id)` returns a specific profile.
- Configuration validation: `ready()` checks if the active profile has all required fields (base_url, model, api_key if required).
- Configured profiles list: `configured_profiles()` returns all profiles that have valid base_urls and API keys.
- Search engine settings: `search_engines()` and `save_search_engines()` manage search engine configuration stored in the same credentials file.
All writes use atomic file operations (temp file + fsync + os.replace) to prevent corruption.
Usage
- Onboarding wizard: Used to save the operator's provider configuration during first-run setup.
- Session open: Used to load the active provider profile and check readiness.
- Provider reconfiguration: Used to update API keys, base URLs, or models.
Code Reference
Source Location
- Repository: Mitsu
- File: config/storage.py
Signature
class CredentialStore:
def __init__(self) -> None: ...
def load(self) -> dict[str, Any]: ...
def active(self) -> dict[str, Any] | None: ...
def profile_for(self, provider_id: str) -> dict[str, Any] | None: ...
def configured_profiles(self) -> list[dict[str, Any]]: ...
def ready(self) -> bool: ...
def save_profile(self, profile: dict[str, Any]) -> None: ...
def search_engines(self) -> dict[str, dict[str, Any]]: ...
def save_search_engines(self, engines: dict[str, dict[str, Any]]) -> None: ...
Import
from mitsu.config.storage import CredentialStore
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| profile | dict[str, Any] | Yes (save_profile) | Provider profile with provider_id, base_url, model, api_key, protocol |
| engines | dict[str, dict] | Yes (save_search_engines) | Search engine settings keyed by engine ID |
Outputs
| Name | Type | Description |
|---|---|---|
| active() returns | None | Active provider profile or None |
| ready() returns | bool | Whether the active profile is complete |
| search_engines() returns | dict[str, dict] | Saved search engine settings |
Usage Examples
Save a Provider Profile
from mitsu.config.storage import CredentialStore
store = CredentialStore()
store.save_profile({
"provider_id": "openai",
"base_url": "https://api.openai.com/v1",
"model": "gpt-4o",
"api_key": "sk-...",
"protocol": "openai",
"reasoning_enabled": False,
"reasoning_parameter": "",
"reasoning_effort": "medium",
})
Check if Ready
store = CredentialStore()
if not store.ready():
print("Provider not configured. Run onboarding.")
else:
profile = store.active()
print(f"Using {profile['model']} on {profile['base_url']}")
Update API Key Without Clearing
# Save with a new model but no api_key — the old key is retained
store.save_profile({
"provider_id": "openai",
"base_url": "https://api.openai.com/v1",
"model": "gpt-4o-mini",
"api_key": "", # Will retain the previously saved key
"protocol": "openai",
})
Related Pages
Implements Principle
- Principle:ARCANGEL0_EVA_Configuration_Persistence
- Principle:ARCANGEL0_EVA_Session_Lifecycle_Management
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment