interplane.Get Omega
Read in your language

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

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
19use serde::Deserialize;
20use std::fmt;
21use 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)]
26pub struct AccountId(pub String);
27
28impl AccountId {
29 pub fn new(s: impl Into<String>) -> Self {
30 AccountId(s.into())
31 }
32 pub fn as_str(&self) -> &str {
33 &self.0
34 }
35}
36
37impl 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")]
45pub enum Provider {
46 Anthropic,
47 #[serde(rename = "openai")]
48 OpenAI,
49 Google,
50 Xai,
51 #[serde(rename = "openrouter")]
52 OpenRouter,
53 Local,
54}
55
56impl 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)]
72pub 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)]
84pub 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
94impl Account {
95 pub fn is_local(&self) -> bool {
96 self.provider == Provider::Local
97 }
98}