Skip to content

Commit a0641f9

Browse files
committed
feat: OAuth access/refresh token flow for CLI login
- Add CredentialStore for persisting tokens to ~/.config/indra/credentials.json - CLI login now polls API and auto-saves tokens (no manual copy needed) - API supports both legacy API keys and access tokens - Add /auth/cli/poll/:state and /auth/refresh endpoints - Token auto-refresh on expiry - Include viz feature in default build
1 parent a73764c commit a0641f9

11 files changed

Lines changed: 3062 additions & 34 deletions

File tree

Cargo.lock

Lines changed: 448 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,16 @@ candle-transformers = { version = "0.8", optional = true }
5454
hf-hub = { version = "0.4", optional = true, features = ["tokio"] }
5555
tokenizers = { version = "0.21", optional = true }
5656
tokio = { version = "1.42", optional = true, features = ["full"] }
57-
reqwest = { version = "0.12", optional = true, features = ["json"] }
57+
reqwest = { version = "0.12", optional = true, features = ["json", "blocking"] }
58+
59+
# Directories for config storage
60+
dirs = "5.0"
61+
62+
# Open browser for login
63+
open = "5.0"
64+
linfa = { version = "0.8.1", optional = true }
65+
linfa-reduction = { version = "0.8.1", optional = true }
66+
ndarray = { version = "0.16", optional = true }
5867

5968
[dev-dependencies]
6069
tempfile = "3.10"
@@ -65,6 +74,13 @@ lto = true
6574
codegen-units = 1
6675

6776
[features]
68-
default = []
77+
default = ["hf-embeddings", "sync", "viz"]
6978
hf-embeddings = ["candle-core", "candle-nn", "candle-transformers", "hf-hub", "tokenizers", "tokio"]
7079
api-embeddings = ["reqwest", "tokio"]
80+
sync = ["reqwest", "tokio"]
81+
viz = ["linfa", "linfa-reduction", "ndarray"]
82+
linfa = ["dep:linfa"]
83+
linfa-reduction = ["dep:linfa-reduction"]
84+
ndarray = ["dep:ndarray"]
85+
# For testing without heavy deps
86+
mock-embeddings = []

src/error.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,13 @@ pub enum Error {
4646

4747
#[error("Version mismatch: expected {expected}, found {found}")]
4848
VersionMismatch { expected: u32, found: u32 },
49+
50+
#[error("Remote error: {0}")]
51+
Remote(String),
52+
53+
#[error("HTTP error: {0}")]
54+
Http(String),
55+
56+
#[error("Config error: {0}")]
57+
Config(String),
4958
}

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ pub mod embedding;
2727
pub mod graph;
2828
pub mod model;
2929
pub mod ops;
30+
pub mod remote;
3031
pub mod search;
3132
pub mod store;
3233
pub mod trie;
34+
pub mod viz;
3335

3436
mod database;
3537
mod error;
@@ -39,8 +41,15 @@ pub use embedding::{Embedder, MockEmbedder};
3941
pub use error::{Error, Result};
4042
pub use graph::TraversalDirection;
4143
pub use model::{Commit, Edge, EdgeType, Hash, Thought, ThoughtId};
44+
pub use remote::{Remote, RemoteConfig, SyncClient, SyncConfig, SyncState, PullResult, Auth, CredentialStore, Credentials, UserInfo, DEFAULT_API_URL};
45+
#[cfg(feature = "sync")]
46+
pub use remote::refresh_access_token;
4247
pub use search::SearchResult;
4348
pub use store::ObjectStore;
49+
pub use viz::{VizExport, VizMeta, VizThought};
50+
51+
#[cfg(feature = "viz")]
52+
pub use viz::project_to_3d;
4453

4554
/// Database version for format compatibility
4655
pub const VERSION: u32 = 1;

0 commit comments

Comments
 (0)