@agent-webui/ai-desk-daemon
v1.0.66
Published
AI Desk Daemon - CLI tool for managing the AI Desk daemon service
Readme
AI Desk Desktop
一个类似 Docker Desktop 的桌面应用,用于管理本地 AI CLI 工具的守护进程。
✨ 特性
- 🎯 智能启动 - Web 访问时自动检测并尝试启动守护进程
- 🖥️ 图形化管理 - Dashboard 控制面板,便捷管理
- 🔄 实时监控 - 查看守护进程状态、日志和统计信息
- 🚀 智能启动器 - 多种方式自动唤醒守护进程
- 🔒 安全可靠 - 工作目录白名单、认证支持
- 📦 跨平台 - macOS、Windows、Linux 统一体验
- ⚡ 高性能 - Go 原生编译,体积小、内存占用低
📦 安装
方式 1: npm 安装(纯 CLI 工具)
适合场景:开发者、服务器环境、CI/CD、命令行用户
# 全局安装
npm install -g @agent-webui/ai-desk
# 启动 daemon(默认使用已保存模式)
aidesk start
# 切到 Native mode
aidesk start --mode native
# 切到 Bundled CLI-Anything runtime mode
aidesk start --mode cli-anything
# 查看状态
aidesk status包含内容:
- ✅ AI Desk Daemon 后台服务
- ✅ CLI 命令行管理工具
- ✅ 默认 harness 运行时与安装脚本
- ✅ bundled CLI-Anything runtime(随包安装到 AI Desk runtime)
- ✅ 按平台分发的内置 Python runtime
- ✅ HTTP API (http://localhost:9527)
可用命令:
aidesk start- 启动守护进程(后台运行,沿用当前已保存 mode)aidesk start --mode native- 切到 Native mode 并启动aidesk start --mode cli-anything- 切到 Bundled CLI-Anything runtime mode 并启动aidesk start --log- 启动守护进程(前台运行,跟随日志)aidesk stop- 停止守护进程aidesk restart- 重启守护进程aidesk restart --mode cli-anything- 切到 Bundled CLI-Anything runtime mode 并重启aidesk status- 查看状态aidesk logs- 查看日志aidesk logs -f- 实时查看日志(不会停止守护进程)
Mode 说明:
Native mode:检测、模型查询、命令执行走 daemon 原生实现。Bundled CLI-Anything runtime mode:使用 npm 安装时随包准备好的 Python runtime 和cli_anything入口;如果某个功能当前 runtime 不支持,daemon 会按配置回退到 native。
📖 详细使用说明:NPM_CLI.md
方式 2: 脚本安装
macOS
# 手动安装
./scripts/install-macos.shLinux
# Ubuntu/Debian
sudo ./scripts/install-linux.sh
# 启用自动启动
systemctl --user enable ai-desk-daemon
systemctl --user start ai-desk-daemonWindows
# 以管理员身份运行 PowerShell
.\scripts\install-windows.ps1🚀 快速开始
1. Web 应用集成
在你的 Web 应用中集成智能启动器:
// App.tsx
import DaemonInitializer from './components/common/DaemonInitializer';
function App() {
return (
<DaemonInitializer>
<YourMainApp />
</DaemonInitializer>
);
}启动器会自动:
- ✅ 检测守护进程是否运行
- ✅ 如果未运行,通过多种方式尝试启动
- ✅ 等待守护进程就绪
- ✅ 失败时显示友好的错误提示
3. 使用 Daemon API
import { daemonService } from './services/DaemonService';
// 执行 CLI 命令
const result = await daemonService.executeCLI({
command: 'claude',
args: ['--verbose'],
stdin: 'Your prompt here',
cwd: '/path/to/workspace',
timeout: 300000,
});
// 流式执行
await daemonService.executeStreaming(
{ command: 'claude', args: [], stdin: 'Hello!' },
(chunk) => console.log(chunk), // onChunk
(result) => console.log(result), // onComplete
(error) => console.error(error) // onError
);🏗️ 架构
┌─────────────────────────────────────────────────────┐
│ AI Desk Daemon │
│ (Go HTTP Server) │
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Dashboard│ │ Control │ │ Settings │ │
│ │ Web UI │ │ Panel │ │ Panel │ │
│ └──────────┘ └──────────┘ └──────────┘ │
│ │ │ │
│ └────────────────┼──────────────────────────┘
│ ▼
│ ┌──────────────────┐
│ │ Daemon Process │
│ │ HTTP Server :9527│
│ └──────────────────┘
│ │
│ ┌────────────────┼────────────────┐
│ ▼ ▼ ▼
│ ┌────────┐ ┌────────┐ ┌────────┐
│ │ Claude │ │ Gemini │ │ Cursor │
│ └────────┘ └────────┘ └────────┘
│
├─────────────────────────────────────────────────────┤
│ Web Application │
│ (React/TypeScript) │
│ │
│ ┌────────────────────────────────────┐ │
│ │ Smart Daemon Starter │ │
│ │ - Auto-detect & Start │ │
│ │ - URL Scheme / Extension / HTTP │ │
│ └────────────────────────────────────┘ │
└─────────────────────────────────────────────────────┘📚 组件说明
1. Daemon(守护进程)
基于 Go 开发的 HTTP/WebSocket 服务器:
功能:
- CLI 检测(claude、gemini、cursor)
- CLI 执行(同步和流式)
- 并发控制和超时管理
- 安全策略(工作目录白名单)
- 日志记录
API 端点:
GET /health- 健康检查GET /api/v1/clis- 检测 CLIPOST /api/v1/execute- 执行 CLI(REST)WS /api/v1/execute/stream- 执行 CLI(WebSocket)POST /api/v1/execute/{id}/cancel- 取消执行
2. Tauri Desktop(桌面应用)
基于 Tauri(Rust + React)的桌面应用:
功能:
- 系统托盘图标和菜单
- 守护进程生命周期管理
- 实时状态监控
- 日志查看
- 设置管理
- URL Scheme 注册
3. Web Integration(Web 集成)
Smart Daemon Starter(智能启动器):
- 自动检测守护进程
- 多种启动方式(URL Scheme、Extension、HTTP)
- 自动重试机制
- 友好的错误提示
Daemon Service(守护进程服务):
- HTTP/WebSocket 通信
- CLI 执行和流式输出
- 错误处理
⚙️ 配置
Daemon 配置
配置文件位置:~/.aidesktop/daemon-config.json
{
"port": 9527,
"max_concurrent_executions": 10,
"execution_timeout": 300,
"allowed_origins": [
"*"
],
"allowed_working_dirs": [
"*"
],
"require_authentication": false,
"auth_token": "",
"log_level": "INFO"
}说明:9527 是默认端口,实际运行时以 ~/.aidesktop/daemon-config.json 中的 port 为准。
🔧 开发
前置要求
- Node.js 18+
- Go 1.21+ (用于守护进程)
构建
# 克隆仓库
git clone https://github.com/your-repo/ai-desk-desktop.git
cd ai-desk-desktop
# 安装依赖
npm install
# 构建所有组件
./scripts/build.sh
# 或分别构建:
# 1. 构建守护进程
cd daemon && go build -o ai-desk-daemon
# 2. 构建前端
npm run build
开发模式
# 启动守护进程(热重载)
cd daemon
go run .📖 使用示例
在 Web 应用中显示守护进程状态
import { DaemonStatusIndicator } from './components/common/DaemonStatusBanner';
function Layout() {
return (
<div>
<Header />
<Content />
<DaemonStatusIndicator /> {/* 显示在右下角 */}
</div>
);
}条件渲染(守护进程可用时)
import { useDaemon } from './hooks/useDaemon';
function AgentPanel() {
const { isAvailable, isChecking } = useDaemon();
if (isChecking) {
return <div>Checking daemon...</div>;
}
if (!isAvailable) {
return (
<div>
Daemon not available.
<button onClick={() => window.location.href = 'aidesktop://start'}>
Launch Now
</button>
</div>
);
}
return <YourAgentInterface />;
}🐛 故障排查
守护进程未启动
检查日志:
aidesk logs -f手动启动测试:
/usr/local/bin/ai-desk-daemon --config ~/.aidesktop/daemon-config.jsonWeb 应用无法连接
检查守护进程是否运行:
curl http://localhost:<port>/health检查防火墙设置
确认配置文件中的端口未被占用
📄 许可证
MIT License
🤝 贡献
欢迎提交 Issues 和 Pull Requests!
📧 支持
- GitHub Issues: https://github.com/your-repo/ai-desk-desktop/issues
- 文档: https://docs.aidesktop.com
Version: 1.0.0
Maintained by: AI Desk Team
