Skip to main content

persist_oauth_direct_account

Function persist_oauth_direct_account 

Source
fn persist_oauth_direct_account(
    mstore: &Arc<Store>,
    identity_store: &Arc<Store>,
    broker: &Arc<Broker>,
    account_id: &str,
    provider_id: &str,
    dir: Option<&str>,
    _session_id: &str,
    email: Option<&str>,
) -> Option<String>
Expand description

Upserts the IdentityAccount (SecretRef::OAuthConfigDir, status “valid”) on a successful OAuth handshake (CLI exited 0 + authCheckCommand confirmed). The actual agent_identity_link write happens later, once the agent exists (the launch-flow write-through reconcile) — this function only makes sure the account itself exists and is ready to be linked.

Publishes identityaccounts:changed (the same broad event account.key.verify/upsertidentityaccount already use) rather than a bundle-scoped event, since there’s no bundle id to scope to.

Returns None on any persistence failure (dir never resolved, or the account upsert itself failed) — same “log + skip, session still succeeds” contract as the bundle path, just without a synthetic placeholder to fall back to (direct-account mode has no “ambient” concept to fall back to; the caller surfaces account_id: None on the wire and the frontend treats that as “nothing to select”).