- 在 Gateway 运行逻辑中增加重启循环,可根据重启信号自动重启服务 - 添加取消管理器功能,支持取消所有运行中的 Agent 以便平滑重启 - 在 HTTP API 新增 /api/restart 接口,实现基于任务活动检测的安全重启 - GatewayState 增加重启信号通道,支持异步触发重启流程 - 修改主运行逻辑支持重启等待机制,实现优雅关闭或重启 - 日志初始化修复防止重复初始化导致的问题 - 技能和子代理加载支持自定义绝对路径来源,增加灵活性和扩展性 - 调整技能与子代理来源枚举,增加 Custom 选项支持动态路径 - 优化工具与任务运行时代码,完善路径处理和克隆逻辑 - 前端配置页增加时区选择下拉菜单,提供常用时区选项 - 新增来源路径编辑组件,支持启用/禁用已知来源及添加自定义绝对路径 - 配置页新增保存配置后重启提示,支持用户确认立即重启网关 - 实现重启操作的前端调用及重启状态展示,包括任务冲突提示与重启轮询恢复 - 频道绑定 Agent 字段由输入框改为下拉选择,提升配置体验和正确性
70 lines
2.0 KiB
Rust
70 lines
2.0 KiB
Rust
use clap::{CommandFactory, Parser};
|
|
|
|
#[derive(Parser)]
|
|
#[command(name = "picobot")]
|
|
#[command(about = "A CLI chatbot", long_about = None)]
|
|
enum Command {
|
|
/// Interactive configuration wizard
|
|
Init {
|
|
/// Force overwrite existing config
|
|
#[arg(short, long)]
|
|
force: bool,
|
|
/// Only configure provider, skip channels
|
|
#[arg(long)]
|
|
skip_channels: bool,
|
|
},
|
|
/// Connect to gateway
|
|
Agent {
|
|
/// Gateway WebSocket URL (e.g., ws://127.0.0.1:19876/ws)
|
|
#[arg(long)]
|
|
gateway_url: Option<String>,
|
|
},
|
|
/// Start gateway server
|
|
Gateway {
|
|
/// Host to bind to
|
|
#[arg(long)]
|
|
host: Option<String>,
|
|
/// Port to listen on
|
|
#[arg(long)]
|
|
port: Option<u16>,
|
|
},
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
picobot::bootstrap::initialize_process_runtime();
|
|
|
|
let mut cmd = Command::command();
|
|
|
|
// If no arguments, print help
|
|
if std::env::args().len() <= 1 {
|
|
cmd.print_help()?;
|
|
println!();
|
|
return Ok(())
|
|
}
|
|
|
|
match Command::parse() {
|
|
Command::Init { force, skip_channels } => {
|
|
let mut wizard = picobot::cli::InitWizard::new();
|
|
wizard.run(force, skip_channels).await?;
|
|
}
|
|
Command::Agent { gateway_url } => {
|
|
let config = picobot::config::Config::load_default().ok();
|
|
let url = gateway_url
|
|
.or_else(|| config.as_ref().map(|c| c.client.gateway_url.clone()))
|
|
.unwrap_or_else(|| "ws://127.0.0.1:19876/ws".to_string());
|
|
picobot::client::run(&url).await?;
|
|
}
|
|
Command::Gateway { host, port } => {
|
|
loop {
|
|
let should_restart = picobot::gateway::run(host.clone(), port).await?;
|
|
if !should_restart {
|
|
break;
|
|
}
|
|
tracing::info!("Gateway restarting...");
|
|
}
|
|
}
|
|
}
|
|
Ok(())
|
|
}
|