Implementation:1ay1 Agentty Auth View Value Type
| Knowledge Sources | |
|---|---|
| Domains | Auth, Model_State |
| Last Updated | 2026-10-28 12:00 GMT |
Overview
Domain value type capturing what the Model knows about credentials that live outside the settings record, so reducers and views don't re-stat credential files every frame.
Description
The AuthView value type is the Model's snapshot of external credential state. A provider's sign-in status is spread over `credentials.json`, provider-owned OAuth token files, env vars, and the accounts registry. Reducers and views used to ask the disk directly, making update impure and re-statting those files every frame.
The host reads them into this value (`LoadAuthView` effect, replying `AuthViewLoaded`) at launch and after every effect that changes credentials. Keys pasted into settings are NOT here — those are `m.d.persisted.provider_keys`. `provider::auth_source(p, settings, view)` combines the two.
Usage
Import this when you need the Model's view of external credential state for rendering or decision-making in the reducer or view layers.
Code Reference
Source Location
- Repository: 1ay1_Agentty
- File: include/agentty/domain/auth_view.hpp
- Lines: 1-63
Signature
namespace agentty::auth {
struct ProviderAuth {
bool stored = false;
std::string env_var;
std::vector<std::string> accounts;
std::string active_account;
std::string unregistered_label;
bool operator==(const ProviderAuth&) const = default;
};
struct AuthView {
std::map<std::string, ProviderAuth, std::less<>> providers;
bool loaded = false;
[[nodiscard]] const ProviderAuth* find(std::string_view id) const;
[[nodiscard]] bool stored(std::string_view id) const;
[[nodiscard]] std::string env_var(std::string_view id) const;
[[nodiscard]] std::string active_account(std::string_view id) const;
bool operator==(const AuthView&) const = default;
};
}
Import
#include "agentty/domain/auth_view.hpp"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| providers | std::map<string, ProviderAuth> | Yes | Per-provider auth snapshot |
| loaded | bool | Yes | False until the host has loaded it once |
Outputs
| Name | Type | Description |
|---|---|---|
| find() | const ProviderAuth* | Provider auth state, or null if unknown |
| stored() | bool | Whether the provider has a saved credential |
Usage Examples
Check Provider Sign-In in Reducer
#include "agentty/domain/auth_view.hpp"
if (m.auth_view.stored("anthropic")) {
// Anthropic has a saved credential
}
if (!m.auth_view.env_var("openai").empty()) {
// OPENAI_API_KEY is set in the environment
}
Render Account Picker
const auto* pa = m.auth_view.find("anthropic");
if (pa) {
for (const auto& label : pa->accounts) {
bool active = (label == pa->active_account);
// Render each saved account row
}
}