@honor-claw/yoyo 1.6.0-beta.4 → 1.6.0

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,229 +0,0 @@
1
- ---
2
- name: flight-monitor.query
3
- description: >
4
- 查询用户已创建的机票价格监控任务,支持按出发地、目的地、监控日期与任务状态筛选。
5
- 只支持飞机票价的监控任务创建,其余票务类型(如酒店、机票联程、火车票等)暂不支持。
6
- ---
7
-
8
- # Query Flight Monitor Task 机票监控任务查询
9
-
10
- ## Tool Provider
11
- ```bash
12
- com.hihonor.magicvoice
13
- ```
14
-
15
- ## Tool Command
16
- ```bash
17
- query_flight_monitor_task
18
- ```
19
-
20
- ## 集成工作流
21
-
22
- ### Step 1: 意图解析与参数组装
23
- ```
24
- ┌─────────────────────────────────────────────────────────────┐
25
- │ 意图识别与参数提取 │
26
- │ - 识别操作意图: 查询 + 机票价格监控任务 │
27
- │ - 提取目的地: 城市名/机场名/别称 │
28
- │ - 提取出发地: 城市名/机场名/别称 │
29
- │ - 提取监控日期: 具体日期/日期范围/自然语言时间 │
30
- │ - 提取任务状态: 已过期/监控中/监控成功 │
31
- │ - 特殊处理: "监控中的/正在监控" → 映射为监控中 │
32
- │ - 特殊处理: "过期/失效" → 已过期;"成功/达成" → 监控成功 │
33
- └─────────────────────────────────────────────────────────────┘
34
-
35
- ┌─────────────────────────────────────────────────────────────┐
36
- │ 消歧与槽位填充 │
37
- │ - 未指定任何筛选条件时,默认查询全部监控任务 │
38
- │ - destination_city/departure_city/date_time/status 缺失时, │
39
- │ 不对该项筛选 │
40
- │ - date_time 仅当 query 含时间表述时填写 │
41
- │ - "监控中的/进行中/在监控" → 映射为监控中 │
42
- │ - "已失效/过期的" → 已过期;"已触发/成功了" → 监控成功 │
43
- │ - 城市名需为有效地名,避免与机场简称冲突 │
44
- └─────────────────────────────────────────────────────────────┘
45
-
46
- ┌─────────────────────────────────────────────────────────────┐
47
- │ 生成工具调用 │
48
- │ - 组装 status 及可选参数(destination_city、departure_city、 │
49
- │ date_time) │
50
- │ - 生成平台特定的命令格式 │
51
- └─────────────────────────────────────────────────────────────┘
52
- ```
53
-
54
- ### Step 2: 执行调用
55
- - 根据操作系统选择对应的命令格式
56
- - Windows: Cmd 格式(双引号需转义)
57
- - Linux: Bash 格式(单引号包裹)
58
-
59
- ## 参数定义
60
- ### 工具输入参数说明
61
- ```json
62
- {
63
- "destination_city": {
64
- "type": "string",
65
- "description": "监控任务的目的地城市名称。"
66
- },
67
- "departure_city": {
68
- "type": "string",
69
- "description": "监控任务的出发地城市名称。"
70
- },
71
- "date_time": {
72
- "type": "string",
73
- "description": "监控时间段的自然语言描述,直接提取用户输入中日期的描述。如:下周、下周二到下周三、周一下午。"
74
- },
75
- "status": {
76
- "type": "string",
77
- "enum": ["已过期", "监控中", "监控成功"],
78
- "description": "监控任务的当前生效状态。"
79
- }
80
- }
81
- ```
82
-
83
- ### 工具输出参数说明
84
- ```json
85
- {
86
- "result_code":{
87
- "type":"integer",
88
- "description":"结果状态码,100:执行成功。304:未授权三方账号,用户拒绝授权三方。402:三方接口调用出错。406:授权三方失败。500:无监控任务。"
89
- },
90
- "result_content":{
91
- "type":"string",
92
- "description":"针对不同状态码场景下,详细的执行结果,包含错误原因等。"
93
- },
94
- "task_count":{
95
- "type":"integer",
96
- "description":"查询到的监控任务总数量。"
97
- },
98
- "task_list":{
99
- "type":"string",
100
- "description":"监控任务的详细列表数据。每条数据包含序号、出发地、目的地、监控日期段、监控状态。查询失败或无监控任务(500)时返回空字符串。",
101
- "examples":[
102
- "{\"监控任务列表\":[{\"序号\":1,\"出发地\":\"北京\",\"目的地\":\"上海\",\"开始日期\":\"2023-12-01\",\"结束日期\":\"2023-12-03\",\"状态\":\"监控中\"},{\"序号\":2,\"出发地\":\"上海\",\"目的地\":\"广州\",\"开始日期\":\"2023-12-05\",\"状态\":\"监控成功\"}]}"
103
- ]
104
- }
105
- }
106
- ```
107
-
108
- ### 参数注意事项
109
- 1. **默认值或缺省行为**: 未提供任一筛选条件时,默认返回全部监控任务;某参数未提供则不作为筛选条件参与过滤。
110
- 2. **可选参数填写条件**: `date_time` 仅在用户输入包含时间表述时填写;`destination_city`、`departure_city` 仅在出现明确城市名时填写;`status` 仅在用户明确提及时填写。
111
- 3. **格式/原样保留要求**: `date_time` 必须保留用户的自然语言原始表述,不做标准化或改写。
112
-
113
- ### date_time 参数格式转换
114
- 1. 当用户输入包含时间表述时,工具会直接保留原始的自然语言日期表述,然后调用`scripts/time_infer.py`时间推理模型进行转换。具体执行指令如下:
115
- ```bash
116
- python3 scripts/time_infer.py --query <date_time>
117
- ```
118
- 2. 拿到json-string格式的转换结果,重新改写`date_time`参数,并调用`openclaw nodes invoke`命令执行工具。
119
- 3. 注意:time_infer模型返回的结果格式如下:`{"data_time": {...}}`,用`{...}`JSONstring的完整内容重写`date_time`参数。**不能拆解{...}的内容**
120
-
121
- ## Query 示例及输出
122
-
123
- ### 示例 1: 按目的地筛选
124
- **用户输入**: "帮我查一下去上海的监控任务"
125
-
126
- **工具**: "query_flight_monitor_task"
127
-
128
- **JSON 参数**:
129
- ```json
130
- {
131
- "destination_city": "上海"
132
- }
133
- ```
134
-
135
- **Windows (Cmd) 执行命令**:
136
- ```bash
137
- cmd /c 'openclaw nodes invoke --node <ID> --command mcp.tool.call --params "{\"name\":\"query_flight_monitor_task\",\"appPkg\":\"com.hihonor.magicvoice\",\"arguments\":{\"destination_city\":\"上海\"}}"'
138
- ```
139
-
140
- **Linux (Bash) 执行命令**:
141
- ```bash
142
- openclaw nodes invoke --node <ID> --command mcp.tool.call --params '{"name":"query_flight_monitor_task","appPkg":"com.hihonor.magicvoice","arguments":{"destination_city":"上海"}}'
143
- ```
144
-
145
- ---
146
-
147
- ### 示例 2: 按任务状态筛选
148
- **用户输入**: "查询所有监控中的任务"
149
-
150
- **工具**: "query_flight_monitor_task"
151
-
152
- **JSON 参数**:
153
- ```json
154
- {
155
- "status": "监控中"
156
- }
157
- ```
158
-
159
- **Windows (Cmd) 执行命令**:
160
- ```bash
161
- cmd /c 'openclaw nodes invoke --node <ID> --command mcp.tool.call --params "{\"name\":\"query_flight_monitor_task\",\"appPkg\":\"com.hihonor.magicvoice\",\"arguments\":{\"status\":\"监控中\"}}"'
162
- ```
163
-
164
- **Linux (Bash) 执行命令**:
165
- ```bash
166
- openclaw nodes invoke --node <ID> --command mcp.tool.call --params '{"name":"query_flight_monitor_task","appPkg":"com.hihonor.magicvoice","arguments":{"status":"监控中"}}'
167
- ```
168
-
169
- ---
170
-
171
- ### 示例 3: 按时间与状态组合筛选(自然语言时间)
172
- **用户输入**: "查询下周监控中的任务"
173
-
174
- **工具**: "query_flight_monitor_task"
175
-
176
- **JSON 参数**:
177
- ```json
178
- {
179
- "date_time": "下周",
180
- "status": "监控中"
181
- }
182
- ```
183
- **调用时间推理模型**:
184
- ```bash
185
- python3 scripts/time_infer.py --query "下周"
186
- ```
187
- 返回结果:{"data_time": <json-string-data>} (注意字符串转义的问题!!!)
188
-
189
- **Windows (Cmd) 执行命令**:
190
- ```bash
191
- cmd /c 'openclaw nodes invoke --node <ID> --command mcp.tool.call --params "{\"name\":\"query_flight_monitor_task\",\"appPkg\":\"com.hihonor.magicvoice\",\"arguments\":{\"date_time\":\"<json-string-data>\",\"status\":\"监控中\"}}"'
192
- ```
193
-
194
- **Linux (Bash) 执行命令**:
195
- ```bash
196
- openclaw nodes invoke --node <ID> --command mcp.tool.call --params '{"name":"query_flight_monitor_task","appPkg":"com.hihonor.magicvoice","arguments":{"date_time":"<json-string-data>","status":"监控中"}}'
197
- ```
198
-
199
- ---
200
-
201
- ### 示例 4: 按时间范围与状态组合筛选
202
- **用户输入**: "查询十月一号到十月七号监控中的任务"
203
-
204
- **工具**: "query_flight_monitor_task"
205
-
206
- **JSON 参数**:
207
- ```json
208
- {
209
- "date_time": "十月一号到十月七号",
210
- "status": "监控中"
211
- }
212
- ```
213
- **调用时间推理模型**:
214
- ```bash
215
- python3 scripts/time_infer.py --query "十月一号到十月七号"
216
- ```
217
- 返回结果:{"data_time": <json-string-data>} (注意字符串转义的问题!!!)
218
-
219
- **Windows (Cmd) 执行命令**:
220
- ```bash
221
- cmd /c 'openclaw nodes invoke --node <ID> --command mcp.tool.call --params "{\"name\":\"query_flight_monitor_task\",\"appPkg\":\"com.hihonor.magicvoice\",\"arguments\":{\"date_time\":\"<json-string-data>\",\"status\":\"监控中\"}}"'
222
- ```
223
-
224
- **Linux (Bash) 执行命令**:
225
- ```bash
226
- openclaw nodes invoke --node <ID> --command mcp.tool.call --params '{"name":"query_flight_monitor_task","appPkg":"com.hihonor.magicvoice","arguments":{date_time":"<json-string-data>","status":"监控中"}}'
227
- ```
228
-
229
- ---
@@ -1,99 +0,0 @@
1
- import time
2
- import hmac
3
- import hashlib
4
- import base64
5
- import json
6
- import requests
7
- from datetime import datetime
8
- import argparse
9
-
10
-
11
- def gen_headers():
12
- # ak / sk 建议线上不要写死在代码里,放到环境变量或配置文件中
13
- ak = "DB1178355DDE4CD2"
14
- sk = "4764F7B34264E8F4343AC7363AA6D4"
15
-
16
- # 对应:var ts = Math.floor(Date.now()).toString();
17
- # Date.now() 是毫秒,这里同样用毫秒时间戳
18
- ts = str(int(time.time() * 1000))
19
-
20
- # 对应:CryptoJS.HmacSHA256(ts + ak, sk).toString().toUpperCase()
21
- msg = (ts + ak).encode("utf-8")
22
- key = sk.encode("utf-8")
23
- digest = hmac.new(key, msg, hashlib.sha256).hexdigest().upper()
24
-
25
- # 对应:new Buffer(...).toString('base64');
26
- # 即对十六进制字符串做 base64 编码
27
- sign = base64.b64encode(digest.encode("utf-8")).decode("utf-8")
28
-
29
- headers = {
30
- "accessKey": ak,
31
- "ts": ts,
32
- "sign": sign,
33
- "Content-Type": "application/json",
34
- }
35
- return headers
36
-
37
-
38
- def get_current_local_time_str():
39
- """
40
- 生成形如:2025-12-23 12:48:00.000 的时间字符串
41
- 使用当前系统时间
42
- """
43
- now = datetime.now()
44
- # %f 是微秒,取前 3 位当毫秒
45
- return now.strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
46
-
47
-
48
- def parse_args():
49
- parser = argparse.ArgumentParser(
50
- description="调用 time-agent 接口的命令行工具"
51
- )
52
- parser.add_argument(
53
- "--query",
54
- # required=True,
55
- default="大小周下周六休息7点",
56
- help="语义查询内容(必填)",
57
- )
58
- parser.add_argument(
59
- "--type",
60
- dest="req_type",
61
- default="time",
62
- help="payload.data.type,默认值为 'time'",
63
- )
64
- parser.add_argument(
65
- "--timeZone",
66
- dest="time_zone",
67
- default="+0800",
68
- help="payload.data.timeZone,默认值为 '+0800'",
69
- )
70
- return parser.parse_args()
71
-
72
-
73
- def main():
74
- url = "https://ai-model-access-drcn.rnd.honor.com/time-agent/v1/models/model/predict"
75
- args = parse_args()
76
-
77
- payload = {
78
- "data": {
79
- "type": args.req_type,
80
- "timeZone": args.time_zone,
81
- "query": args.query,
82
- "localTime": get_current_local_time_str()
83
- }
84
- }
85
-
86
- headers = gen_headers()
87
-
88
- resp = requests.post(url, headers=headers, data=json.dumps(payload))
89
- print("Status code:", resp.status_code)
90
- try:
91
- datas = resp.json()
92
- res = json.dumps(datas.get("data", {}), separators=(",", ":"), ensure_ascii=False)
93
- print({"data_time": res})
94
- except Exception:
95
- print("Response text:", resp.text)
96
-
97
-
98
- if __name__ == "__main__":
99
- main()