Skip to main content

Module store

Module store 

Source
Expand description

App-owned credential storage: modify is the only write path.

Ported from pi-mono packages/ai/src/auth/types.ts (CredentialStore) and packages/ai/src/auth/credential-store.ts (InMemoryCredentialStore), MIT, Copyright (c) 2025 Mario Zechner — full notice in the parent module. Several doc comments below are adapted closely from pi’s.

pi’s rule, kept verbatim in spirit: every mutation is a serialized read-modify-write whose closure sees the current credential, so a refresh and a concurrent login cannot clobber each other.

CodeWhale already serializes the xAI OAuth refresh that way, but not through this store: xai_oauth holds with_xai_oauth_lifecycle_lock across the token-file read, the refresh request, and the write-back, so two concurrent near-expiry observers share one rotated epoch rather than overwriting each other’s refresh token. That lock is process- and file-level, not this registry’s per-provider mutex, and the xAI flow is not rewritten onto CredentialStore::modify here. This trait is the shape that would put API-key slots and that OAuth flow on one write path.

Structs§

CredentialInfo
Non-secret credential metadata for account/status enumeration.
SecretStoreCredentials
Adapter over CodeWhale’s existing durable secret store.

Traits§

CredentialStore
App-owned credential storage, keyed by provider id, one credential per provider.

Functions§

with_provider_write_lock
Run body holding this provider’s write lock.
with_provider_write_locks
Run body holding every listed provider’s write lock.