openclaw-glance-plugin 0.1.12 → 0.1.13

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-glance-plugin",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "OpenClaw plugin client for ticker-monitor openclaw-bridge",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -12,14 +12,15 @@ description: 智能盯盘插件,用于监控A股、港股、比特币等金融
12
12
  - 宿主已启动插件运行时(长连接由插件后台维护)
13
13
 
14
14
  2. **用户请求盯盘时**,解析用户需求提取:
15
- - `productCode`: 产品代码
16
- - `productType`: 市场类型 (stock/index/hk_stock/crypto)
17
- - `condition`: 条件表达式
18
- - `variables`: 变量值
15
+ - `product_code`: 产品代码
16
+ - `product_type`: 市场类型 (stock/index/hk_stock/crypto)
17
+ - `operator_type`: 固定为 `rule`
18
+ - `operator_parameters.condition`: 条件表达式
19
+ - `operator_parameters.variables`: 变量值
19
20
 
20
21
  3. **通过已安装运行时提交盯盘请求**(长连接由宿主运行时维护)
21
22
  4. **用户要求“查行情/看当前价格/报价”时**,优先调用 `queryTickerData` 获取实时数据,再决定是否创建盯盘策略。
22
- 5. **用户要求“发短信/打电话/发邮件”时**。
23
+ 5. **用户要求“发短信/打电话/发邮件/发钉钉”时**,调用对应 `notify.*` 动作直接发送。
23
24
 
24
25
  ## 调用契约(必须遵循)
25
26
 
@@ -65,20 +66,59 @@ description: 智能盯盘插件,用于监控A股、港股、比特币等金融
65
66
  #### `watch.create`
66
67
 
67
68
  参数(最少):
68
- - `productCode`
69
- - `productType`
70
- - `condition`
71
- - `variables`
69
+ - `product_code`
70
+ - `product_type`
71
+ - `operator_type`
72
+ - `operator_parameters`
72
73
 
73
74
  建议附加:
74
75
  - `channels`(默认至少包含 `openclaw`)
75
- - 对应渠道配置(`emailConfig/callConfig/smsConfig`)
76
+ - 对应渠道配置(`channel_configs.email/call/sms/dingtalk`)
77
+
78
+ 固定模板(必须按此结构构造,字段名不要改):
79
+
80
+ ```javascript
81
+ {
82
+ product_code: 'BTCUSDT',
83
+ product_type: 'crypto',
84
+ operator_type: 'rule', // 必须是 rule,不可改成条件表达式
85
+ operator_parameters: {
86
+ condition: 'change_percent <= cp_threshold',
87
+ variables: {
88
+ cp_threshold: -0.02,
89
+ product_name: '比特币'
90
+ }
91
+ },
92
+ channels: ['openclaw', 'dingtalk', 'sms'],
93
+ // 注意:必须是对象,不要传 JSON 字符串
94
+ channel_configs: {
95
+ openclaw: {},
96
+ dingtalk: {
97
+ cas_id: 'jinguo.xie',
98
+ template_id: 3,
99
+ msg_type: 'text',
100
+ content: '比特币跌幅超2%!当前价格 ${price},跌幅 ${change_percent}%。建议卖出!'
101
+ },
102
+ sms: {
103
+ receiver: '18616726853',
104
+ template_id: 90010,
105
+ content: '比特币跌幅超2%!当前价格 ${price},建议卖出!'
106
+ }
107
+ }
108
+ }
109
+ ```
110
+
111
+ 禁止项(任何一条命中都必须先修正再调用):
112
+ - `operator_type` 不是 `rule`(例如写成 `change_percent <=`)
113
+ - 把 `condition` 放在顶层,而不是 `operator_parameters.condition`
114
+ - 把 `channel_configs` 下的渠道配置传成 JSON 字符串
115
+ - 用户未要求某渠道,却默认附加该渠道配置
76
116
 
77
117
  渠道参数要求(必须):
78
- - 只要 `channels` 包含 `email`,必须提供 `emailConfig.to_address/template_id/title/content`
79
- - 只要 `channels` 包含 `call`,必须提供 `callConfig.phone/customer_name/condition`
80
- - 只要 `channels` 包含 `sms`,必须提供 `smsConfig.receiver(或phone)/template_id/content`
81
- - 只要 `channels` 包含 `dingtalk`,必须提供 `dingtalkConfig.cas_id/template_id/msg_type/content`
118
+ - 只要 `channels` 包含 `email`,必须提供 `channel_configs.email.to_address/template_id/title/content`
119
+ - 只要 `channels` 包含 `call`,必须提供 `channel_configs.call.phone/customer_name/condition`
120
+ - 只要 `channels` 包含 `sms`,必须提供 `channel_configs.sms.receiver(或phone)/template_id/content`
121
+ - 只要 `channels` 包含 `dingtalk`,必须提供 `channel_configs.dingtalk.cas_id/template_id/msg_type/content`
82
122
 
83
123
  成功判定:
84
124
  - 返回 `success = true`
@@ -89,6 +129,12 @@ description: 智能盯盘插件,用于监控A股、港股、比特币等金融
89
129
  - 若是超时/网络波动导致的重试,必须使用同一组创建参数再次调用 `watch.create`(不要改字段和值),避免重复创建策略
90
130
  - `request_id` 由插件运行时自动生成并在同 payload 重试时自动复用;大模型无需手动设置 `request_id`
91
131
 
132
+ 小模型(7B)执行策略(强约束):
133
+ 1. 先用固定模板生成 payload 骨架,不要自由发挥字段名
134
+ 2. 仅替换值:`product_code/product_type/operator_parameters/channels/channel_configs`
135
+ 3. 发送前逐条自检“禁止项”
136
+ 4. 若失败返回 `400` 且提示“未注册的算子类型”,立即把 `operator_type` 纠正为 `rule` 并重试
137
+
92
138
  #### `watch.pause` / `watch.activate` / `watch.remove`
93
139
 
94
140
  参数:
@@ -108,6 +154,28 @@ description: 智能盯盘插件,用于监控A股、港股、比特币等金融
108
154
  - `notify.email`:必须提供 `to_address`、`template_id`、`title`、`content`
109
155
  - `notify.dingtalk`:必须提供 `cas_id`、`template_id`、`msg_type`、`content`
110
156
 
157
+ 固定模板(必须按此结构,不要增删字段名):
158
+
159
+ ```javascript
160
+ // notify.sms
161
+ { receiver: '13800138000', template_id: 90010, content: '测试消息1' }
162
+
163
+ // notify.call
164
+ { phone: '13800138000', customer_name: 'Demo', condition: '比特币跌幅超过2%' }
165
+
166
+ // notify.email
167
+ { to_address: 'demo@example.com', template_id: 4, title: '监控提醒', content: '测试消息1' }
168
+
169
+ // notify.dingtalk
170
+ { cas_id: 'user.dingtalk', template_id: 3, msg_type: 'text', content: '测试消息1' }
171
+ ```
172
+
173
+ 禁止项(任何一条命中都必须先修正再调用):
174
+ - 把手机号写成非数字字符串(空格、`+86-`、中划线等)
175
+ - 把 `template_id` 写成字符串(应传数字)
176
+ - `msg_type` 传非 `text/markdown`
177
+ - 传入 `request_id`(通知请求由插件运行时自动生成并复用)
178
+
111
179
  成功判定:
112
180
  - 返回 `success = true`
113
181
 
@@ -115,6 +183,7 @@ description: 智能盯盘插件,用于监控A股、港股、比特币等金融
115
183
  - 明确返回失败原因,不要静默重试
116
184
  - 若是超时/网络波动导致的重试,必须使用同一组通知参数再次调用(不要改字段和值)
117
185
  - `request_id` 由插件运行时自动生成并在同 payload 重试时自动复用;大模型无需手动设置 `request_id`
186
+ - 若返回缺字段错误(如 `MISSING_REQUIRED_FIELD`),只补缺失字段,其他字段保持不变再重试
118
187
 
119
188
  回执说明:
120
189
  - 直连通知发送完成后,客户端会收到 `notify.sent` 事件(`overall_status/success_count/failed_count/deliveries`)
@@ -127,13 +196,23 @@ description: 智能盯盘插件,用于监控A股、港股、比特币等金融
127
196
  - “达到某个涨跌幅提醒我”
128
197
 
129
198
  调用前必须确认:
130
- - `productCode`(标的代码)
131
- - `productType`(`stock/index/hk_stock/crypto`)
132
- - `condition`(规则表达式)
133
- - `variables`(阈值变量)
199
+ - `product_code`(标的代码)
200
+ - `product_type`(`stock/index/hk_stock/crypto`)
201
+ - `operator_parameters.condition`(规则表达式)
202
+ - `operator_parameters.variables`(阈值变量)
134
203
 
135
204
  缺任一项时先追问,不要猜测阈值。
136
205
 
206
+ ### 调用前最终检查(小尺寸模型 必做)
207
+
208
+ 在实际调用工具前,逐条检查:
209
+ 1. `watch.create` 是否使用 `snake_case`:`product_code/product_type/operator_type/operator_parameters/channel_configs`
210
+ 2. `operator_type` 是否固定为 `rule`
211
+ 3. `operator_parameters.condition` 与 `operator_parameters.variables` 是否都存在
212
+ 4. `channels` 是否与 `channel_configs` 一一对应(选了哪个渠道就必须有哪个配置)
213
+ 5. 所有配置是否为对象而非 JSON 字符串
214
+ 6. 是否未手动传 `request_id`(由插件自动生成与复用)
215
+
137
216
  ### 买卖意图与条件方向
138
217
 
139
218
  用户设置价格提醒时,往往不会说"大于等于"或"小于等于",而是说"到了XX提醒我"。此时需要判断用户的**买卖意图**来决定条件方向:
@@ -160,7 +239,7 @@ description: 智能盯盘插件,用于监控A股、港股、比特币等金融
160
239
 
161
240
  ## 标的检索规则(必须遵循)
162
241
 
163
- 当不能直接确定 `productCode`/`productType` 时,必须先在本地标的数据中检索,再和用户确认。
242
+ 当不能直接确定 `product_code`/`product_type` 时,必须先在本地标的数据中检索,再和用户确认。
164
243
 
165
244
  数据文件(CSV,字段为 `类型,代码,名称,完整代码,市场`):
166
245
  - `data/stock_a.csv`:A股个股列表(`productType=stock`)
@@ -225,23 +304,22 @@ await runtime.queryTickerData({
225
304
  `openclaw` 渠道必传,`email` / `call` / `sms` / `dingtalk` 可选。如用户没明确说明使用邮件(email)、电话/外呼(call)、短信(sms)、钉钉(dingtalk)通知提醒,则只需要传入`openclaw`渠道。
226
305
 
227
306
  但一旦用户选择了某个通知渠道,其配置参数必须完整填写:
228
- - 选择 `email` 必须提供 `emailConfig.to_address/template_id/title/content`
229
- - 选择 `call` 必须提供 `callConfig.phone/customer_name/condition`
230
- - 选择 `sms` 必须提供 `smsConfig.receiver(或phone)/template_id/content`
231
- - 选择 `dingtalk` 必须提供 `dingtalkConfig.cas_id/template_id/msg_type/content`
307
+ - 选择 `email` 必须提供 `channel_configs.email.to_address/template_id/title/content`
308
+ - 选择 `call` 必须提供 `channel_configs.call.phone/customer_name/condition`
309
+ - 选择 `sms` 必须提供 `channel_configs.sms.receiver(或phone)/template_id/content`
310
+ - 选择 `dingtalk` 必须提供 `channel_configs.dingtalk.cas_id/template_id/msg_type/content`
232
311
 
233
- ### email 参数(emailConfig
312
+ ### email 参数(channel_configs.email
234
313
  - `to_address`:收件人邮箱(必填,缺失不可创建/不可发送)
235
314
  - `template_id`:邮件模板 ID(必填,默认为4,不需要修改)
236
- - `template_params`:模板变量
237
315
  - `title`: 收到邮件的标题(必填)
238
316
  - `content`: 消息内容(必填)
239
317
  示例:
240
318
  ```javascript
241
- emailConfig: {
242
- to_address: 'demo@example.com',
243
- template_id: 4,
244
- template_params: {
319
+ channel_configs: {
320
+ email: {
321
+ to_address: 'demo@example.com',
322
+ template_id: 4,
245
323
  title: '监控提醒',
246
324
  content: '测试消息1'
247
325
  }
@@ -249,39 +327,43 @@ emailConfig: {
249
327
  ```
250
328
  用户收到的是一封title为"监控提醒",内容为"测试消息1"的一封邮件
251
329
 
252
- ### call 参数(callConfig
330
+ ### call 参数(channel_configs.call
253
331
  - `phone`:手机号(必填,缺失不可创建/不可发送)
254
332
  - `customer_name`:客户名称(必填)
255
333
  - `condition`:外呼内容(必填)
256
334
 
257
335
  示例:
258
336
  ```javascript
259
- callConfig: {
260
- phone: '13800138000',
261
- customer_name: 'Demo',
262
- condition: '比特币价格突破阈值'
337
+ channel_configs: {
338
+ call: {
339
+ phone: '13800138000',
340
+ customer_name: 'Demo',
341
+ condition: '比特币价格突破阈值'
342
+ }
263
343
  }
264
344
  ```
265
345
  用户收到的是一通打给手机号码为13800138000的电话,电话内容为'比特币价格突破阈值'
266
346
 
267
347
 
268
- ### sms 参数(smsConfig
348
+ ### sms 参数(channel_configs.sms
269
349
  - `receiver`:手机号(必填,必须是纯数字;缺失不可创建/不可发送)
270
350
  - `template_id`:短信模板 ID(必填,默认 90010,不需要修改)
271
351
  - `content`:短信变量内容(必填)
272
352
 
273
353
  示例:
274
354
  ```javascript
275
- smsConfig: {
276
- receiver: '13800138000',
277
- template_id: 90010,
278
- content: '测试消息1'
355
+ channel_configs: {
356
+ sms: {
357
+ receiver: '13800138000',
358
+ template_id: 90010,
359
+ content: '测试消息1'
360
+ }
279
361
  }
280
362
  ```
281
363
  用户收到的是一封发送给手机号码为13800138000的短信,短信内容为'测试消息1'
282
364
 
283
365
 
284
- ### 钉钉 参数(dingtalkConfig
366
+ ### 钉钉 参数(channel_configs.dingtalk
285
367
  - `cas_id`:钉钉用户ID(必填,缺失不可创建/不可发送)
286
368
  - `template_id`:钉钉模板 ID(必填,默认 3,不需要修改)
287
369
  - `msg_type`: 消息类型(必填):`text`/`markdown`
@@ -289,11 +371,13 @@ smsConfig: {
289
371
 
290
372
  示例:
291
373
  ```javascript
292
- dingtalkConfig: {
293
- cas_id: 'user.dingtalk',
294
- template_id: 3,
295
- msg_type: "text",
296
- content: "测试消息1"
374
+ channel_configs: {
375
+ dingtalk: {
376
+ cas_id: 'user.dingtalk',
377
+ template_id: 3,
378
+ msg_type: 'text',
379
+ content: '测试消息1'
380
+ }
297
381
  }
298
382
  ```
299
383
  用户收到的是一条发送给钉钉号为user.dingtalk的单聊消息,消息内容为'测试消息1'
@@ -321,24 +405,33 @@ dingtalkConfig: {
321
405
 
322
406
  ### 比特币监控
323
407
  ```javascript
324
- // 条件: 价格 >= 73000 且涨幅 >= 1%
325
- condition: 'price >= threshold and change_percent >= cp_threshold'
326
- variables: { threshold: 73000, cp_threshold: 0.01, product_name: 'Bitcoin' }
408
+ // 条件: 价格 >= 73000 且涨幅 >= 1%(放在 operator_parameters 内)
409
+ operator_type: 'rule'
410
+ operator_parameters: {
411
+ condition: 'price >= threshold and change_percent >= cp_threshold',
412
+ variables: { threshold: 73000, cp_threshold: 0.01, product_name: 'Bitcoin' }
413
+ }
327
414
  // 注意: crypto 不支持 turnover_rate
328
415
  ```
329
416
 
330
417
  ### A股监控
331
418
  ```javascript
332
- // 条件: 价格 >= 12.5 且换手率 >= 1%
333
- condition: 'price >= threshold and turnover_rate >= tr_threshold'
334
- variables: { threshold: 12.5, tr_threshold: 0.01, product_name: '平安银行' }
419
+ // 条件: 价格 >= 12.5 且换手率 >= 1%(放在 operator_parameters 内)
420
+ operator_type: 'rule'
421
+ operator_parameters: {
422
+ condition: 'price >= threshold and turnover_rate >= tr_threshold',
423
+ variables: { threshold: 12.5, tr_threshold: 0.01, product_name: '平安银行' }
424
+ }
335
425
  ```
336
426
 
337
427
  ### 港股监控
338
428
  ```javascript
339
- // 条件: 价格 >= 420
340
- condition: 'price >= threshold'
341
- variables: { threshold: 420, product_name: '腾讯控股' }
429
+ // 条件: 价格 >= 420(放在 operator_parameters 内)
430
+ operator_type: 'rule'
431
+ operator_parameters: {
432
+ condition: 'price >= threshold',
433
+ variables: { threshold: 420, product_name: '腾讯控股' }
434
+ }
342
435
  ```
343
436
 
344
437
  ## 触发后操作