feat: 新增技能编排引擎和工作流构建器组件
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
refactor: 统一Hands系统常量到单个源文件 refactor: 更新Hands中文名称和描述 fix: 修复技能市场在连接状态变化时重新加载 fix: 修复身份变更提案的错误处理逻辑 docs: 更新多个功能文档的验证状态和实现位置 docs: 更新Hands系统文档 test: 添加测试文件验证工作区路径
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
> **成熟度**: L4 - 生产
|
||||
> **最后更新**: 2026-03-24
|
||||
> **负责人**: Intelligence Layer Team
|
||||
> **后端实现**: Rust (Phase 2 迁移完成)
|
||||
> **验证状态**: ✅ 代码已验证
|
||||
|
||||
## 概述
|
||||
|
||||
@@ -17,36 +19,45 @@
|
||||
|
||||
### 心跳配置 (HeartbeatConfig)
|
||||
|
||||
```typescript
|
||||
interface HeartbeatConfig {
|
||||
enabled: boolean; // 是否启用心跳
|
||||
interval_minutes: number; // 心跳间隔(分钟)
|
||||
quiet_hours_start: string | null; // 静默时段开始(如 "22:00")
|
||||
quiet_hours_end: string | null; // 静默时段结束(如 "08:00")
|
||||
notify_channel: 'ui' | 'desktop' | 'all'; // 通知渠道
|
||||
proactivity_level: 'silent' | 'light' | 'standard' | 'autonomous'; // 主动级别
|
||||
max_alerts_per_tick: number; // 每次心跳最大提醒数
|
||||
---
|
||||
|
||||
## 核心概念
|
||||
|
||||
### 心跳配置 (HeartbeatConfig)
|
||||
|
||||
```rust
|
||||
// Rust 后端实现 (heartbeat.rs)
|
||||
pub struct HeartbeatConfig {
|
||||
pub enabled: bool,
|
||||
pub interval_minutes: u64, // 默认 30 分钟
|
||||
pub quiet_hours_start: Option<String>, // "22:00" 格式
|
||||
pub quiet_hours_end: Option<String>, // "08:00" 格式
|
||||
pub notify_channel: NotifyChannel, // ui | desktop | all
|
||||
pub proactivity_level: ProactivityLevel, // silent | light | standard | autonomous
|
||||
pub max_alerts_per_tick: usize, // 默认 5
|
||||
}
|
||||
```
|
||||
|
||||
### 心跳提醒 (HeartbeatAlert)
|
||||
|
||||
```typescript
|
||||
interface HeartbeatAlert {
|
||||
title: string; // 提醒标题
|
||||
content: string; // 提醒内容
|
||||
urgency: 'low' | 'medium' | 'high'; // 紧急程度
|
||||
source: string; // 来源模块
|
||||
timestamp: string; // 时间戳
|
||||
```rust
|
||||
pub struct HeartbeatAlert {
|
||||
pub title: String,
|
||||
pub content: String,
|
||||
pub urgency: Urgency, // low | medium | high
|
||||
pub source: String,
|
||||
pub timestamp: String,
|
||||
}
|
||||
```
|
||||
|
||||
### 心跳结果 (HeartbeatResult)
|
||||
|
||||
```typescript
|
||||
interface HeartbeatResult {
|
||||
status: 'ok' | 'alert'; // 状态
|
||||
alerts: HeartbeatAlert[]; // 提醒列表
|
||||
```rust
|
||||
pub struct HeartbeatResult {
|
||||
pub status: HeartbeatStatus, // ok | alert
|
||||
pub alerts: Vec<HeartbeatAlert>,
|
||||
pub checked_items: usize,
|
||||
pub timestamp: String,
|
||||
}
|
||||
```
|
||||
|
||||
@@ -69,11 +80,23 @@ interface HeartbeatResult {
|
||||
|
||||
| 文件 | 用途 |
|
||||
|------|------|
|
||||
| `desktop/src/lib/intelligence-backend.ts` | 心跳后端实现 |
|
||||
| `desktop/src/domains/intelligence/store.ts` | 状态管理 |
|
||||
| `desktop/src/domains/intelligence/types.ts` | 类型定义 |
|
||||
| `desktop/src-tauri/src/intelligence/heartbeat.rs` | **Rust 后端实现** (762 行) |
|
||||
| `desktop/src/lib/intelligence-backend.ts` | TypeScript 命令封装 |
|
||||
| `desktop/src/lib/intelligence-client.ts` | 统一客户端接口 |
|
||||
|
||||
### Store 接口
|
||||
### Tauri 命令
|
||||
|
||||
| 命令 | 说明 |
|
||||
|------|------|
|
||||
| `heartbeat_init` | 初始化心跳引擎 |
|
||||
| `heartbeat_start` | 启动心跳定时器 |
|
||||
| `heartbeat_stop` | 停止心跳 |
|
||||
| `heartbeat_tick` | 手动执行一次巡检 |
|
||||
| `heartbeat_get_config` | 获取当前配置 |
|
||||
| `heartbeat_update_config` | 更新配置 |
|
||||
| `heartbeat_get_history` | 获取历史记录 |
|
||||
|
||||
### Store 接口 (前端)
|
||||
|
||||
```typescript
|
||||
interface IntelligenceStore {
|
||||
@@ -90,21 +113,34 @@ interface IntelligenceStore {
|
||||
}
|
||||
```
|
||||
|
||||
### 后端实现
|
||||
### 后端 API (TypeScript 封装)
|
||||
|
||||
```typescript
|
||||
// intelligence-backend.ts
|
||||
export const heartbeat = {
|
||||
config: {
|
||||
get: async (agentId: string): Promise<HeartbeatConfig> => {...},
|
||||
update: async (agentId: string, config: Partial<HeartbeatConfig>): Promise<HeartbeatConfig> => {...},
|
||||
},
|
||||
init: async (agentId: string, config?: HeartbeatConfig): Promise<void> =>
|
||||
invoke('heartbeat_init', { agentId, config }),
|
||||
|
||||
start: async (agentId: string): Promise<void> => {...},
|
||||
stop: async (agentId: string): Promise<void> => {...},
|
||||
tick: async (agentId: string): Promise<HeartbeatResult> => {...},
|
||||
start: async (agentId: string): Promise<void> =>
|
||||
invoke('heartbeat_start', { agentId }),
|
||||
|
||||
stop: async (agentId: string): Promise<void> =>
|
||||
invoke('heartbeat_stop', { agentId }),
|
||||
|
||||
tick: async (agentId: string): Promise<HeartbeatResult> =>
|
||||
invoke('heartbeat_tick', { agentId }),
|
||||
|
||||
getConfig: async (agentId: string): Promise<HeartbeatConfig> =>
|
||||
invoke('heartbeat_get_config', { agentId }),
|
||||
|
||||
updateConfig: async (agentId: string, config: HeartbeatConfig): Promise<void> =>
|
||||
invoke('heartbeat_update_config', { agentId, config }),
|
||||
|
||||
getHistory: async (agentId: string, limit?: number): Promise<HeartbeatResult[]> =>
|
||||
invoke('heartbeat_get_history', { agentId, limit }),
|
||||
};
|
||||
```
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -255,9 +291,9 @@ export const heartbeat = {
|
||||
|
||||
### 当前限制
|
||||
|
||||
1. **前端定时器依赖** - 心跳依赖页面打开,后台时不运行
|
||||
2. **无持久化调度** - 重启后心跳不自动恢复
|
||||
3. **静默时段实现不完整** - 时区处理可能有问题
|
||||
1. **Rust 后台定时器** - 心跳在 Rust tokio 运行时中执行
|
||||
2. **持久化调度** - 重启后需要重新初始化心跳
|
||||
3. **静默时段** - 已实现,使用本地时区
|
||||
|
||||
### 未来改进
|
||||
|
||||
|
||||
Reference in New Issue
Block a user