Add interactive setup wizard for first-run configuration

Introduces `near-agent setup` command that guides users through:
- NEAR AI authentication (reuses existing OAuth flow)
- Model selection (fetches from API or shows defaults)
- Channel configuration (HTTP webhook, Telegram)

Features:
- First-run detection: auto-runs wizard if no session exists
- Respects existing settings: shows current model with keep/change option
- Saves channel secrets to ~/.near-agent/secrets/ with 0600 permissions
- Validates Telegram bot tokens via API before saving

Also fixes default NEARAI_BASE_URL to use cloud-api.near.ai (api.near.ai
returns 410 Gone).

Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
Illia Polosukhin
2026-02-04 09:42:41 -08:00
co-authored by Claude Opus 4.5
parent 1605939e2a
commit c7f0e8014d
9 changed files with 1093 additions and 4 deletions
+16
View File
@@ -2,6 +2,7 @@
//!
//! Provides subcommands for:
//! - Running the agent (`run`)
//! - Interactive setup wizard (`setup`)
//! - Managing WASM tools (`tool install`, `tool list`, `tool remove`)
//! - Managing secrets (`secret set`, `secret list`, `secret remove`)
@@ -38,6 +39,10 @@ pub struct Cli {
/// Configuration file path (optional, uses env vars by default)
#[arg(short, long, global = true)]
pub config: Option<std::path::PathBuf>,
/// Skip first-run setup check
#[arg(long, global = true)]
pub no_setup: bool,
}
#[derive(Subcommand, Debug)]
@@ -45,6 +50,17 @@ pub enum Command {
/// Run the agent (default if no subcommand given)
Run,
/// Interactive setup wizard
Setup {
/// Skip authentication (use existing session)
#[arg(long)]
skip_auth: bool,
/// Reconfigure channels only
#[arg(long)]
channels_only: bool,
},
/// Manage WASM tools
#[command(subcommand)]
Tool(ToolCommand),