fix(chat): 聊天定时功能断链接通 — NlScheduleParser + _reminder Hand
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
接通"写了没接"的定时功能断链: - NlScheduleParser has_schedule_intent/parse_nl_schedule 接入 agent_chat_stream - 新增 _reminder 系统 Hand 作为定时触发器桥接 - TriggerManager hand_id 验证对 _ 前缀系统 Hand 放行 - 聊天消息含定时意图时自动拦截,创建触发器并返回确认消息 验证:cargo check 0 error, 49 tests passed, Tauri MCP "每天早上9点提醒我查房" → cron 0 9 * * * 确认正确显示
This commit is contained in:
@@ -35,6 +35,7 @@ tags: [module, hands, skills, mcp]
|
||||
| Slideshow | 幻灯片生成 | — | 13 | `hands/slideshow.HAND.toml` |
|
||||
| Speech | 语音合成 | Browser TTS | — | `hands/speech.HAND.toml` |
|
||||
| Quiz | 测验生成 | — | — | `hands/quiz.HAND.toml` |
|
||||
| _reminder | 定时提醒 (系统内部) | — | — | 无 TOML(代码注册) |
|
||||
|
||||
Hands 测试分布(前 5): Clip(30), Twitter(25), Researcher(22), Slideshow(13), Browser(8)
|
||||
|
||||
@@ -56,6 +57,32 @@ UI 触发 → handStore.trigger(handName, params)
|
||||
→ handStore 更新状态 + 记录日志
|
||||
```
|
||||
|
||||
### 定时提醒链路(NlScheduleParser → _reminder Hand)
|
||||
|
||||
用户在聊天中输入包含定时意图的消息(如"每天早上9点提醒我查房"),系统自动拦截并创建定时触发器:
|
||||
|
||||
```
|
||||
用户消息 "每天早上9点提醒我查房"
|
||||
→ agent_chat_stream (chat.rs)
|
||||
→ has_schedule_intent() 检测关键词(提醒我/定时/每天/每周等)
|
||||
→ parse_nl_schedule() 解析为 cron 表达式
|
||||
→ ScheduleParseResult::Exact (confidence >= 0.8)
|
||||
→ TriggerConfig { hand_id: "_reminder", trigger_type: Schedule { cron: "0 9 * * *" } }
|
||||
→ kernel.create_trigger() → TriggerManager 存储
|
||||
→ LoopEvent::Delta(确认消息) → 前端流式显示
|
||||
→ 跳过 LLM 调用(省 token)
|
||||
→ SchedulerService 每60秒轮询
|
||||
→ should_fire_cron() 匹配 → execute_hand_with_source("_reminder")
|
||||
→ ReminderHand.execute() → 记录日志
|
||||
```
|
||||
|
||||
关键组件:
|
||||
- `crates/zclaw-runtime/src/nl_schedule.rs` — 中文时间→cron 转换(支持6种模式)
|
||||
- `crates/zclaw-hands/src/hands/reminder.rs` — 系统内部 Hand(id=`_reminder`)
|
||||
- `crates/zclaw-kernel/src/trigger_manager.rs` — 触发器 CRUD(`_` 前缀 hand_id 免验证)
|
||||
- `crates/zclaw-kernel/src/scheduler.rs` — 60秒轮询 + cron 匹配
|
||||
- `desktop/src-tauri/src/kernel_commands/chat.rs` — 定时意图拦截入口
|
||||
|
||||
Hand 相关 Tauri 命令 (8 个):
|
||||
`hand_list, hand_execute, hand_approve, hand_cancel, hand_get, hand_run_status, hand_run_list, hand_run_cancel`
|
||||
|
||||
@@ -167,7 +194,8 @@ MCP 工具在 ToolRegistry 中使用限定名 `service_name.tool_name` 避免冲
|
||||
|
||||
| 文件 | 职责 |
|
||||
|------|------|
|
||||
| `crates/zclaw-hands/src/hands/` | 9 个 Hand 实现 |
|
||||
| `crates/zclaw-hands/src/hands/` | 10 个 Hand 实现 (含 _reminder) |
|
||||
| `crates/zclaw-runtime/src/nl_schedule.rs` | 中文时间→cron 解析器 |
|
||||
| `crates/zclaw-skills/src/semantic_router.rs` | TF-IDF 语义路由 |
|
||||
| `crates/zclaw-skills/src/` | 技能解析和索引 |
|
||||
| `skills/*/SKILL.md` | 75 个技能定义 |
|
||||
|
||||
Reference in New Issue
Block a user