Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/crates/aien-switchboard/src/account.rs # aien-sovereign-core-mv AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / crates / aien-switchboard / src / account.rs` 98 lines ยท 2921 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 //! Accounts. An account names where its program keeps its own login, never 17 //! the login itself. 18 19 use serde::Deserialize; 20 use std::fmt; 21 use std::path::PathBuf; 22 23 /// Short operator-chosen name such as `anthropic-1`. 24 #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize)] 25 #[serde(transparent)] 26 pub struct AccountId(pub String); 27 28 impl AccountId { 29 pub fn new(s: impl Into) -> Self { 30 AccountId(s.into()) 31 } 32 pub fn as_str(&self) -> &str { 33 &self.0 34 } 35 } 36 37 impl fmt::Display for AccountId { 38 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 39 f.write_str(&self.0) 40 } 41 } 42 43 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Deserialize)] 44 #[serde(rename_all = "lowercase")] 45 pub enum Provider { 46 Anthropic, 47 #[serde(rename = "openai")] 48 OpenAI, 49 Google, 50 Xai, 51 #[serde(rename = "openrouter")] 52 OpenRouter, 53 Local, 54 } 55 56 impl Provider { 57 pub fn as_str(self) -> &'static str { 58 match self { 59 Provider::Anthropic => "anthropic", 60 Provider::OpenAI => "openai", 61 Provider::Google => "google", 62 Provider::Xai => "xai", 63 Provider::OpenRouter => "openrouter", 64 Provider::Local => "local", 65 } 66 } 67 } 68 69 /// How an account proves who it is. Both variants hold a pointer, never a 70 /// secret value. 71 #[derive(Debug, Clone, PartialEq, Eq)] 72 pub enum Credential { 73 /// The company's own program keeps its login in this settings folder 74 /// (one folder per account). The router never opens it. 75 SettingsFolder(PathBuf), 76 /// Name of a key held in the vault (for example an OpenRouter key). The 77 /// value is resolved elsewhere, in process memory only. 78 KeyRef(String), 79 /// Nothing needed (the local model). 80 None, 81 } 82 83 #[derive(Debug, Clone, PartialEq, Eq)] 84 pub struct Account { 85 pub id: AccountId, 86 pub provider: Provider, 87 /// Name of the program that serves this account, such as `claude`. 88 /// UNKNOWN for `agy` and `grok`: how a second login is kept side by side 89 /// is not confirmed (see ADR 0030, open UNKNOWNs). 90 pub program: String, 91 pub credential: Credential, 92 } 93 94 impl Account { 95 pub fn is_local(&self) -> bool { 96 self.provider == Provider::Local 97 } 98 }