Expand description
The credential broker — the mandatory boundary between runtimes and
provider secrets (Checkpoint 1 decision, docs/decisions/credential-broker-checkpoint-1.md).
§Invariants (enforced by construction and tests)
- Runtime/TUI code talks to a
CredentialBrokerand never readsauth.json, provider-key config, or credential environment variables. All of that discovery lives insideLocalBroker— behind the boundary. - OAuth responses vend access token + expiry only (
AccessTokenhas no refresh field to put one in). Refresh tokens stay broker-owned. - Static API keys are never vended, locally or remotely. They are applied
broker-side via the typed request proxy (
ProxyRequest): the broker pins the destination URL from its ownstatic_providerstable and attaches the bearer key itself. - Capability/status queries (
ProviderStatus) expose configured-ness only — never key material. - Fail closed: a missing credential is an error, never a fallback to a direct read at the call site.
Structs§
- Access
Token - An OAuth access token vended by the broker.
- Cloud
Catalog Entry - Normalized dynamic cloud model returned across local/remote broker boundaries.
- Local
Broker - In-process credential broker. This module is the ONLY place runtime-serving
code may read
auth.json,provider.<key>config values, or credential environment variables. - Provider
Status - Non-secret capability/status row for one provider.
- Proxy
Request - A typed, credential-free request the broker executes on the caller’s behalf against an OpenAI-compatible provider endpoint.
- Proxy
Response - Buffered (non-streaming) proxy result: upstream status + body text.
- Remote
Broker - Client for a remote
synaps auth-broker. Presents the machine’s own bearer token; receives access tokens (OAuth) and proxied responses (static-key providers). Never receives refresh tokens or raw keys.
Enums§
- Broker
Error - Broker failures. Messages never contain credential values.
- Cloud
Event - Credential-free normalized cloud invocation event.
- Credential
Kind - What kind of credential a provider uses. Never carries key material.
- Proxy
Method - HTTP method subset the proxy protocol supports.
- Static
KeyStatus - Non-secret display status for one static key (settings UI).
Constants§
- GOOGLE_
GEMINI_ CODE_ ASSIST_ BASE_ URL - Pinned Code Assist host for the broker-only Google Gemini proxy runtime.
The service is treated as experimental and only the exact
v1internalmethod paths reviewed in the spec are permitted (setup + streaming). - MAX_
PROXY_ REQUEST_ BYTES - Maximum serialized size of a proxy request body.
- MAX_
PROXY_ RESPONSE_ BYTES - Maximum buffered (non-streaming) response body size.
- MAX_
UPSTREAM_ ERROR_ BYTES - Historical cap for upstream error-body snippets. Upstream/broker error
bodies are no longer read at all (spec §5.1: they may echo the request);
the constant remains only because it is re-exported from
auth::mod. - OPENAI_
CODEX_ BACKEND_ BASE_ URL - Pinned ChatGPT backend host for OpenAI Codex catalog traffic.
- PROXY_
REQUEST_ TIMEOUT - Total time budget for a buffered (non-streaming) broker-executed request.
Traits§
- Cloud
Backend - Credential
Broker - The typed credential broker protocol. One implementation runs in-process
(
LocalBroker) so normal local use needs no daemon; the other talks to a remotesynaps auth-brokerover authenticated HTTP(S) (RemoteBroker).
Functions§
- anthropic_
credential_ available - True if any Anthropic credential is available through the broker
(OAuth login or
ANTHROPIC_API_KEY). Non-secret answer for first-run UX. - broker_
access_ token - Legacy signature bridge: resolve an access token via the appropriate
broker for
source. Kept for CLI paths (synaps status). - broker_
from_ source - remote transport. There is no third option — and no direct-read fallback.
- configured_
static_ provider_ keys - The set of static providers with an available credential. Non-secret.
- global_
broker - The process-wide broker. Defaults to the in-process
LocalBrokerso normal local use never requires a separately launched daemon. - local_
endpoint_ config - The explicitly-configured local endpoint, if any (None → default in use).
- local_
endpoint_ url - The local endpoint URL (non-secret configuration:
provider.local.urlconfig →LOCAL_ENDPOINTenv → default). - local_
model_ ids - Comma-separated local model ids from non-secret config (
provider.local.models). - oauth_
provider_ logged_ in - True if the OAuth provider has stored refreshable credentials. This is a non-secret availability query for UI surfaces; an expired access token is still a valid login when the broker can refresh it on first use.
- preflight_
cloud_ capability - Build the right broker for a credential source. Local sources get the in-process broker (no daemon needed); remote sources get the authenticated Pre-flight capability check for a cloud route (spec §5.5). Pure function: callers MUST run it before constructing a broker, looking up credentials, or opening any connection. The invoke-time guard inside the broker remains in place as defense in depth.
- set_
global_ broker - Install the process-wide broker (called once from runtime configuration).
- static_
key_ configured - True if a static key is available through the broker (storage, login config, or env). Never returns the key.
- static_
key_ status - Non-secret display status for a static key: configured (with masked preview), from-env, or not set. The mask keeps at most the first 4 and last 4 characters and is safe to render.
- static_
key_ status_ map - Non-secret map of static key display statuses for every provider, plus the local endpoint. For settings UI snapshots.
Type Aliases§
- Cloud
Event Stream - Proxy
Byte Stream - Streaming proxy result: raw upstream bytes (SSE), post-authorization.