Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:1ay1 Agentty Credential Vault Descriptors

From Leeroopedia
Knowledge Sources
Domains Auth, Provider_Abstraction
Last Updated 2026-10-28 12:00 GMT

Overview

Table-driven descriptor per credential store, answering every auth question agentty asks about a provider through one function-pointer value type.

Description

The agentty::auth::vault module provides one `Desc` descriptor per credential store, replacing five independent per-provider if-ladders spread over four files (where the blob lives, how to clear it, what's the registry id, is something saved, what header goes on the wire). `vault::of(provider_id)` returns the one descriptor — a small value type of function pointers + data, table-driven like provider registry rows — and the five call sites become one-liners.

Adding a provider's auth story is adding ONE `VaultDesc` row. The compiler doesn't let a row be partial (aggregate init with designated initializers, every question answered or explicitly defaulted). Identity is agentty's provider id; custom hosts fall through to a synthesized SettingsKey descriptor, so `of()` is total: every string yields a usable vault.

Questions are separated from POLICY: the vault knows how to clear a store; whether sign-out should fall back to another provider stays in the reducer, where policy belongs.

Usage

Import this when you need to: check if a provider is signed in, sign out a provider, resolve a provider's wire auth header, or get the current credential's display label.

Code Reference

Source Location

Signature

namespace agentty::auth::vault {

enum class Kind : std::uint8_t {
    AnthropicFile,   // credentials.json (OAuth or x-api-key), sealed
    OAuthFile,       // provider-owned token file (ChatGPT/Copilot/Kimi)
    SettingsKey,     // Settings.provider_keys[id] — hosted keys + custom hosts
    None,            // local/no-auth backends (Ollama): nothing to store
};

struct Desc {
    std::string_view id;
    Kind             kind = Kind::SettingsKey;
    bool     (*is_signed_in)(Io, const std::string& provider);
    void     (*clear)(Io, const maya::unlocked&, const std::string& provider);
    auth::AuthHeader (*resolve)(Io, const std::string& provider);
    std::string (*current_label)(Io, const std::string& provider);
    void     (*after_activate)(Io, const maya::below<maya::leaf>&, const std::string& provider);
};

// Total lookup: registry providers get their row; custom hosts get
// a synthesized SettingsKey descriptor. Never fails.
[[nodiscard]] const Desc& of(std::string_view provider_id);

// Convenience passthroughs
[[nodiscard]] inline bool signed_in(Io, const std::string& p);
inline void sign_out(Io, const maya::unlocked&, const std::string& p);
[[nodiscard]] inline auth::AuthHeader resolve(Io, const std::string& p);
}

Import

#include "agentty/auth/vault.hpp"

I/O Contract

Inputs

Name Type Required Description
provider_id std::string_view Yes Agentty provider id or custom-host spec

Outputs

Name Type Description
of() const Desc& The credential store descriptor (total — never null)
signed_in() bool Whether the provider has a saved credential
resolve() AuthHeader The wire auth header for the provider

Usage Examples

Check Sign-In Status

#include "agentty/auth/vault.hpp"

// One-liner replacing a 5-case if-ladder
if (agentty::auth::vault::signed_in(io, "anthropic")) {
    // Anthropic has a saved credential
}
if (agentty::auth::vault::signed_in(io, "ollama")) {
    // Ollama (Kind::None) always returns false — nothing to store
}

Sign Out a Provider

// The vault knows HOW to clear the store; the reducer decides WHETHER to
agentty::auth::vault::sign_out(io, unlocked, "openai");
// Clears SettingsKey: removes from provider_keys vault + saves

Resolve Wire Header

auto header = agentty::auth::vault::resolve(io, "anthropic");
// For AnthropicFile: loads + unseals credentials.json → AuthHeader
// For SettingsKey: loads provider-keys.json → ApiKeyHeader

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment