@honor-claw/yoyo 1.6.1-beta.3 → 1.6.1-beta.4

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.
@@ -22,15 +22,21 @@ function c(e) {
22
22
  }
23
23
  function l(e) {
24
24
  e.on("after_tool_call", async (t) => {
25
- if (!(t.toolName !== "read" || t.error || !u(t.params))) try {
25
+ if (!(t.toolName !== "read" || t.error || !d(t.params))) try {
26
26
  await r(o, "after_tool_call:read_yoyo_control_skill"), e.logger.info("[yoyoclaw-skill-refresh] yoyo-control skill read marker updated");
27
27
  } catch (t) {
28
28
  e.logger.warn(`[yoyoclaw-skill-refresh] failed to update skill read marker: ${String(t)}`);
29
29
  }
30
30
  });
31
31
  }
32
- function u(e) {
33
- return n(e.path) || n(e.file_path);
32
+ var u = [
33
+ "path",
34
+ "file_path",
35
+ "filePath",
36
+ "file"
37
+ ];
38
+ function d(e) {
39
+ return u.some((t) => n(e[t]));
34
40
  }
35
41
  //#endregion
36
42
  export { s as registerHooks };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honor-claw/yoyo",
3
- "version": "1.6.1-beta.3",
3
+ "version": "1.6.1-beta.4",
4
4
  "description": "OpenClaw Honor Yoyo connection plugin",
5
5
  "keywords": [
6
6
  "ai",
@@ -140,8 +140,6 @@ metadata: { "openclaw": { "emoji": "📱", "always": true } }
140
140
  | `flashlight` | `references/flashlight.md` | 手电筒控制 |
141
141
  | `airplane-mode` | `references/airplane-mode.md` | 飞行模式管理 |
142
142
  | `clean-dirty` | `references/clean-dirty.md` | 扬声器清理 |
143
- | `flight-monitor` | `references/flight-monitor-create.md` | 创建机票价格监控 |
144
- | `flight-monitor` | `references/flight-monitor-search.md` | 查询机票监控任务 |
145
143
  | `express` | `references/express-logistics-search.md` | 快递查询 |
146
144
  | `countdown-timer` | `references/countdown-timer.md` | 倒计时计时器管理 |
147
145
  | `desktop` | `references/desktop.md` | 手机桌面管理,支持查询桌面布局、打开桌面设置页,并对风格、应用角标、桌面图标、快捷方式、搜索入口、应用名称、通透模式与布局等进行配置。 |
@@ -1,233 +0,0 @@
1
- ---
2
- name: flight-monitor.create
3
- description: >
4
- 创建机票价格监控任务。支持设置目的地、出发地、监控时间段与目标价格,缺省或低于最低监控价时给出价格区间与建议价。
5
- 只支持飞机票价的监控任务创建,其余票务类型(如酒店、机票联程、火车票等)暂不支持。
6
- ---
7
-
8
- # Create Flight Monitor Task 创建机票监控任务
9
-
10
- ## Tool Provider
11
- ```bash
12
- com.hihonor.magicvoice
13
- ```
14
-
15
- ## Tool Command
16
- ```bash
17
- create_flight_monitor_task
18
- ```
19
-
20
- ## 3. 业务规则
21
-
22
- ### 适用场景及操作流程
23
- 1. 解析并提取目的地城市、出发地城市、监控时间段与目标价格
24
- 2. 未提供出发地时,默认使用用户当前位置城市
25
- 3. 未提供目的地时,提醒用户指定目的地
26
- 4. 对价格进行币种识别与人民币换算,并向下取整
27
- 5. 当未指定监控价格或设定价格低于最低可监控价时,工具返回可监控价格区间与建议价
28
- 6. 创建机票价格监控任务并开始持续监控
29
-
30
- ### 特定交互
31
- - 币种默认人民币;如检测到外币(如 USD、美元),按实时汇率换算为人民币后取整
32
- - 城市名必须为具体城市中文名,不支持省份或国家级地名
33
- - 监控时间段使用用户原始的自然语言日期表述(如“下周二到下周三”“10月1日-10月7日”),不做改写
34
- - 价格仅提取数值部分,取整为不大于该值的整数;“以内/不高于/低于”等等价于上限价
35
-
36
- ## 4. 集成工作流
37
-
38
- ### Step 1: 意图解析与参数组装
39
- ```
40
- ┌─────────────────────────────────────────────────────────────┐
41
- │ 意图识别与参数提取 │
42
- │ - 识别操作意图: 创建 + 机票价格监控任务 │
43
- │ - 提取目的地城市: 城市中文名(不含省/国家) │
44
- │ - 提取出发地城市: 城市中文名(缺省为当前位置) │
45
- │ - 提取监控时间段: 自然语言日期描述(直接保留) │
46
- │ - 提取目标价格: 数字,币种识别与换算,向下取整 │
47
- │ - 特殊处理: "飞/去/到" 等同义词统一识别为目的地 │
48
- └─────────────────────────────────────────────────────────────┘
49
-
50
- ┌─────────────────────────────────────────────────────────────┐
51
- │ 消歧与槽位填充 │
52
- │ - 未指定出发地时,默认为用户当前位置城市 │
53
- │ - 未指定监控价格时,返回价格区间与建议价 │
54
- │ - 价格低于最低可监控价时,提示范围并给出建议价 │
55
- │ - date_time 仅当 query 含时间表述时填写 │
56
- │ - 验证规则: 目的地与出发地不能相同 │
57
- │ - "从/出发地" → 映射为出发地槽位 │
58
- └─────────────────────────────────────────────────────────────┘
59
-
60
- ┌─────────────────────────────────────────────────────────────┐
61
- │ 生成工具调用 │
62
- │ - 组装 destination_city 及可选参数(departure_city, │
63
- │ date_time, price) │
64
- │ - 生成平台特定的命令格式 │
65
- └─────────────────────────────────────────────────────────────┘
66
- ```
67
-
68
- ### Step 2: 执行调用
69
- - 根据操作系统选择对应的命令格式
70
- - Windows: Cmd 格式(双引号需转义)
71
- - Linux: Bash 格式(单引号包裹)
72
-
73
- ## 5. 参数定义
74
- ### 工具输入参数说明
75
- ```json
76
- {
77
- "destination_city": {
78
- "type": "string",
79
- "description": "必填参数,机票监控的目的地城市中文名称,不支持省份或国家。如:深圳、北京。"
80
- },
81
- "departure_city": {
82
- "type": "string",
83
- "description": "机票监控的出发地城市中文名称,默认为用户当前位置所在城市,不支持省份或国家。如:深圳、北京。"
84
- },
85
- "date_time": {
86
- "type": "string",
87
- "description": "监控时间段的自然语言描述,直接提取用户输入中日期的描述。如:下周、下周二到下周三、周一下午。"
88
- },
89
- "price": {
90
- "type": "integer",
91
- "description": "用户设定的监控目标最高价格。直接提取价格数字,向下取整。默认币种人民币,其他币种需换算人民币。如果没有指定币种,按照人民币处理。"
92
- }
93
- }
94
- ```
95
-
96
- ### 工具输出参数说明
97
- ```json
98
- {
99
- "result_code": {
100
- "type": "integer",
101
- "description": "结果状态码。100:执行成功。201:用户没有指定价格时返回,追问用户需要设置的监控价格,同时返回价格区间(suggested_price_range)与推荐价格(suggested_price)。202:追问,没有出发地城市,同时当前城市查询失败时追问。304:未授权三方账号,用户拒绝授权三方。406:授权三方失败。500:出发地不在支持列表范围内。501:目的地不在支持列表范围内。502:监控日期超出监控范围。503:查询监控价格失败,当前航线未查询到直飞航班报价。504:用户设置的监控价格过低,低于最低可监控价格,同时返回价格区间(suggested_price_range)与推荐价格(suggested_price)。505:监控任务创建失败。506:已存在重复监控任务。507:监控任务已达上限。"
102
- },
103
- "result_content": {
104
- "type": "string",
105
- "description": "针对不同状态码场景下,详细的执行结果,包含错误原因等。"
106
- },
107
- "suggested_price_range": {
108
- "type": "string",
109
- "description": "工具根据历史数据建议的价格区间,货币单位为人民币,格式为最低可监控价格-最高监控价格,如:500-1000。"
110
- },
111
- "suggested_price": {
112
- "type": "integer",
113
- "description": "工具建议的监控目标价格,货币单位为人民币。"
114
- },
115
- "departure_city": {
116
- "type": "string",
117
- "description": "出发地城市中文名称。如:深圳、北京。"
118
- },
119
- "destination_city": {
120
- "type": "string",
121
- "description": "目的地城市中文名称。如:深圳、北京。"
122
- },
123
- "date_range": {
124
- "type": "string",
125
- "description": "监控的日期范围,格式为 YYYY-MM-DD~YYYY-MM-DD。"
126
- },
127
- "price": {
128
- "type": "integer",
129
- "description": "用户设置的监控价格,货币单位为人民币,未提供或小于最低可监控价格则设为0。"
130
- }
131
- }
132
- ```
133
-
134
-
135
- ### 参数注意事项
136
- 1. **默认值或缺省行为**: 未提供`departure_city`时默认取用户当前位置城市;未提供`price`时由工具返回可监控价格区间与建议价;未标明币种时按人民币处理。
137
- 2. **参数间关联/验证**: `destination_city`为必填且不得与`departure_city`相同;外币价格需先换算为人民币后再对`price`进行向下取整。
138
- 3. **可选参数填写条件**: `date_time`仅在用户明确提及时间/日期时填写,不做推断;`departure_city`仅在用户未使用默认定位或明确指定时填写。
139
-
140
- ### date_time 参数格式转换
141
- 1. 当用户输入包含时间表述时,工具会直接保留原始的自然语言日期表述,然后调用`scripts/time_infer.py`时间推理模型进行转换。具体执行指令如下:
142
- ```bash
143
- python3 scripts/time_infer.py --query <date_time>
144
- ```
145
- 2. 拿到json-string格式的转换结果,重新改写`date_time`参数,并调用`openclaw nodes invoke`命令执行工具。
146
- 3. 注意:time_infer模型返回的结果格式如下:`{"data_time": {...}}`,用`{...}`JSONstring的完整内容重写`date_time`参数。**不能拆解{...}的内容**
147
-
148
- ## 6. Query 示例及输出
149
-
150
- ### 示例 1: 指定出发地、时间段与人民币价格上限
151
- **用户输入**: "帮我监控一下去上海的机票,出发地是北京,时间是十月一号到十月七号,价格设为1000元以内"
152
-
153
- **工具**: "create_flight_monitor_task"
154
-
155
- **JSON 参数**:
156
- ```json
157
- {
158
- "destination_city": "上海",
159
- "departure_city": "北京",
160
- "date_time": "十月一号到十月七号",
161
- "price": 1000
162
- }
163
- ```
164
- **调用时间推理模型**:
165
- ```bash
166
- python3 scripts/time_infer.py --query "十月一号到十月七号"
167
- ```
168
- 返回结果: {"data_time": <json-string-data>} (注意字符串转义的问题!!!)
169
-
170
- **Windows (Cmd) 执行命令**:
171
- ```bash
172
- cmd /c 'openclaw nodes invoke --node <ID> --command mcp.tool.call --params "{\"name\":\"create_flight_monitor_task\",\"appPkg\":\"com.hihonor.magicvoice\",\"arguments\":{\"destination_city\":\"上海\",\"departure_city\":\"北京\",\"date_time\":\"<json-string-data>\",\"price\":1000}}"'
173
- ```
174
-
175
- **Linux (Bash) 执行命令**:
176
- ```bash
177
- openclaw nodes invoke --node <ID> --command mcp.tool.call --params '{"name":"create_flight_monitor_task","appPkg":"com.hihonor.magicvoice","arguments":{"destination_city":"上海","departure_city":"北京","date_time":"<json-string-data>","price":1000}}'
178
- ```
179
-
180
- ---
181
-
182
- ### 示例 2: 仅目的地与美元价格(自动换算为人民币)
183
- **用户输入**: "帮我监控飞广州的机票,价格低于200美元就提醒"
184
-
185
- **工具**: "create_flight_monitor_task"
186
-
187
- **JSON 参数**:
188
- ```json
189
- {
190
- "destination_city": "广州",
191
- "price": 1440
192
- }
193
- ```
194
-
195
- **Windows (Cmd) 执行命令**:
196
- ```bash
197
- cmd /c 'openclaw nodes invoke --node <ID> --command mcp.tool.call --params "{\"name\":\"create_flight_monitor_task\",\"appPkg\":\"com.hihonor.magicvoice\",\"arguments\":{\"destination_city\":\"广州\",\"price\":1440}}"'
198
- ```
199
-
200
- **Linux (Bash) 执行命令**:
201
- ```bash
202
- openclaw nodes invoke --node <ID> --command mcp.tool.call --params '{"name":"create_flight_monitor_task","appPkg":"com.hihonor.magicvoice","arguments":{"destination_city":"广州","price":1440}}'
203
- ```
204
-
205
- ---
206
-
207
- ### 示例 3: 指定目的地与出发时段,不设价格(工具返回建议价)
208
- **用户输入**: "帮我关注去杭州的机票,下周三下午出发"
209
-
210
- **工具**: "create_flight_monitor_task"
211
-
212
- **JSON 参数**:
213
- ```json
214
- {
215
- "destination_city": "杭州",
216
- "date_time": "下周三下午"
217
- }
218
- ```
219
- **调用时间推理模型**:
220
- ```bash
221
- python3 scripts/time_infer.py --query "下周三下午"
222
- ```
223
- 返回结果: {"data_time": <json-string-data>} (注意字符串转义的问题!!!)
224
-
225
- **Windows (Cmd) 执行命令**:
226
- ```bash
227
- cmd /c 'openclaw nodes invoke --node <ID> --command mcp.tool.call --params "{\"name\":\"create_flight_monitor_task\",\"appPkg\":\"com.hihonor.magicvoice\",\"arguments\":{\"destination_city\":\"杭州\",\"date_time\":\"<json-string-data>\"}}"'
228
- ```
229
-
230
- **Linux (Bash) 执行命令**:
231
- ```bash
232
- openclaw nodes invoke --node <ID> --command mcp.tool.call --params '{"name":"create_flight_monitor_task","appPkg":"com.hihonor.magicvoice","arguments":{"destination_city":"杭州","date_time":"<json-string-data>"}}'
233
- ```
@@ -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()