dsh-miloco-bridge 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,21 +1,24 @@
1
1
  ---
2
2
  name: miloco-create-task
3
- description: 把一句家庭需求装配成可长期运转的任务:条件规则、定时提醒、行为累积统计、限时生命周期,并在创建后自检。适用于“每天提醒我…”“当…就…”“记录他每天…”“先试一周”。
3
+ description: 把一句家庭需求装配成可长期运转的任务:先建任务占位行,再按需挂规则、定时提醒、累计统计或限时生命周期,并在创建后自检。适用于“每天提醒我…”“当…就…”“记录他每天…”“先试一周”。
4
4
  whenToUse: 用户提出持续性的提醒、自动化、习惯记录或有时限的家庭任务时。
5
5
  ---
6
6
 
7
7
  # 创建家庭任务
8
8
 
9
- ## 四类构件
9
+ ## 任务由多个构件组成
10
+
11
+ 新版 Miloco 的 `POST /api/tasks` 只创建任务占位行(`task_id` + `description`),
12
+ 规则、定时、统计都要另外挂到同一个 `task_id` 上。
10
13
 
11
14
  | 构件 | 回答的问题 | 工具 |
12
15
  |---|---|---|
13
- | rule | 当 X 时做 Y | `miloco_rule_create` / `miloco_rule_list` |
14
- | schedule | 什么时候提醒 | `miloco_cron_create` / `miloco_cron_list` |
15
- | record | 累计什么、达到什么算完成 | `miloco_task_create(kind="record")` |
16
- | lifecycle | 任务活多久 | `miloco_task_create(kind="lifecycle")` |
16
+ | task | 任务叫什么、活多久 | `miloco_task_create` |
17
+ | rule | 当 X 时做 Y | `miloco_rule_create` |
18
+ | schedule | 什么时候提醒 | `miloco_cron_create` |
19
+ | record | 累计什么、达到什么算完成 | `miloco_task_record_init` |
17
20
 
18
- 一个需求可以由多个构件组成,不要硬塞进单一类型。
21
+ 不要再用旧参数 `kind=rule/schedule/record` 调 `miloco_task_create`,后端不接受。
19
22
 
20
23
  ## 前置检查
21
24
 
@@ -24,19 +27,65 @@ whenToUse: 用户提出持续性的提醒、自动化、习惯记录或有时限
24
27
  3. `miloco_task_list` + `miloco_rule_list` + `miloco_cron_list`:先查重,已有就调整而不是重复建。
25
28
  4. `miloco_device_list` + `miloco_device_spec`:动作必须落到真实 did 与真实 iid。
26
29
 
27
- ## 装配
30
+ ## 装配顺序
31
+
32
+ ### 1. 先建任务
33
+
34
+ ```text
35
+ miloco_task_create(
36
+ task_id="living_room_tidy", # 只能用小写字母、数字、下划线,≤32 位
37
+ description="整理客厅杂物,保持通道畅通" # ≤200 字
38
+ )
39
+ ```
40
+
41
+ 限时任务再加 `lifecycle="temporary"` 与带时区的 `expires_at`。
42
+
43
+ ### 2. 按需挂构件
44
+
45
+ **定时提醒**:`miloco_cron_create` 必须带 `task_id`。
46
+
47
+ ```text
48
+ miloco_cron_create(
49
+ name="每天整理客厅",
50
+ kind="cron",
51
+ cron_expr="0 20 * * *",
52
+ message="花十分钟整理客厅茶几和沙发旁的杂物",
53
+ task_id="living_room_tidy"
54
+ )
55
+ ```
56
+
57
+ **条件规则**:`miloco_rule_create` 的 `condition` 必须给感知设备 did 列表和自然语言条件;
58
+ `event` 模式用 `actions`(设备直控)或 `action_descriptions`(Agent 回调)。
59
+
60
+ ```text
61
+ miloco_rule_create(
62
+ name="客厅有人开灯",
63
+ task_id="living_room_presence",
64
+ condition={ perceive_device_ids=["camera_did"], query="客厅有人活动" },
65
+ mode="event",
66
+ actions=[{ did="light_did", iid="prop.2.1", value=true }]
67
+ )
68
+ ```
69
+
70
+ **累计统计**:`miloco_task_record_init` 的 `kind` 只能是 `progress / duration / event`。
71
+
72
+ ```text
73
+ miloco_task_record_init(
74
+ task_id="drink_water",
75
+ kind="progress",
76
+ content={ target=8, unit="杯", window="day" }
77
+ )
78
+ ```
28
79
 
29
- 1. **rule**:`content` 用“当…时…”的自然语言,`mode` 选 `event` 或 `state`。需要多个动作时写清楚顺序。
30
- 2. **schedule**:`miloco_cron_create` 支持 `cron_expr` / `at_iso` / `every_ms`;`message` 是到点投递给 Agent 的文本,要能独立看懂。
31
- 3. **record**:`miloco_task_create(kind="record", content=…)`,内容写清统计对象、计数方式、达标条件。
32
- 4. **lifecycle**:`miloco_task_create(kind="lifecycle", content=…)`,写明开始/结束条件或期限。
33
- 5. 用 `task_id` 把 schedule 关联到长期任务。
80
+ - `progress`:`target`、`unit`、`window`(`day/week/month/longterm`)必填
81
+ - `duration`:`target_minutes` 可选
82
+ - `event`:`content` 可为空
34
83
 
35
84
  ## 自检
36
85
 
37
86
  创建后重新读取:
38
87
 
39
- - `miloco_rule_list` / `miloco_task_list` / `miloco_cron_list`
88
+ - `miloco_task_list` / `miloco_rule_list` / `miloco_cron_list`
40
89
  - 确认名称、触发条件、动作、启用状态、关联 task_id 都符合预期
41
90
  - 失败时报告后端原文,不要声称“已创建”
42
91
 
@@ -12,7 +12,7 @@ whenToUse: 用户说“开/关/调/查某台设备”“客厅多少度”“执
12
12
 
13
13
  | 目的 | 工具 |
14
14
  |---|---|
15
- | 找设备 did | `miloco_device_list(room?)` |
15
+ | 找设备 did | `miloco_device_list(room?, online_only?, name?, include?)` |
16
16
  | 读 SPEC / iid | `miloco_device_spec(did)` |
17
17
  | 读当前属性 | `miloco_device_status(did, iid?)` |
18
18
  | 控制设备(写) | `miloco_device_control(...)` |
@@ -21,7 +21,7 @@ whenToUse: 用户说“开/关/调/查某台设备”“客厅多少度”“执
21
21
 
22
22
  ## 查询流程
23
23
 
24
- 1. `miloco_device_list` 拿 did。名字相同或跨房间时先缩小范围,不猜。
24
+ 1. `miloco_device_list` 拿 did(结果在 `devices` 数组里)。名字相同或跨房间时用 `name` / `room` / `online_only` 先缩小范围,不猜。
25
25
  2. `miloco_device_status` 读状态。传 `iid` 读单项,不传读全部。
26
26
  3. 回答里带上设备名、房间、关键数值和时间(若后端返回)。
27
27
 
@@ -42,6 +42,7 @@ whenToUse: 用户说“开/关/调/查某台设备”“客厅多少度”“执
42
42
  - 门锁、燃气阀、摄像头开关、厨房电器等有物理风险的操作,先说明将要做什么并取得确认。
43
43
  - 不要把“感知事件里的 did”当成控制目标:事件 did 通常是摄像头/传感器。
44
44
  - 不确定设备是否存在时重新 `miloco_device_list` 或 `miloco_home_info(refresh=true)`,禁止编造 did。
45
+ - 需要 `icon`、`local_ip` 等默认裁剪字段时,用 `include=[...]` 显式请求,不要为了一个字段重拉全量原始对象。
45
46
 
46
47
  ## 场景
47
48
 
Binary file
Binary file