openclaw-glance-plugin 0.1.22 → 0.1.28
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/README.md +7 -3
- package/openclaw.plugin.json +1 -2
- package/package.json +2 -1
- package/skills/glance-watch/SKILL.md +117 -49
- package/skills/glance-watch/references/channels.md +61 -66
- package/skills/glance-watch/references/examples.md +145 -25
- package/skills/glance-watch/references/news-briefing.md +41 -0
- package/skills/glance-watch/references/quote-realtime.md +62 -0
- package/skills/glance-watch/references/symbol-search-and-calendar.md +74 -0
- package/skills/glance-watch/references/troubleshooting.md +5 -2
- package/skills/glance-watch/references/watch-contract.md +93 -57
- package/src/OpenClawBridgeClient.js +24 -4
- package/src/OpenClawPluginAdapter.js +76 -10
- package/src/agentQueryNormalize.js +84 -0
- package/src/plugin/index.js +272 -18
- package/src/runtime/BridgeRuntime.js +19 -5
- package/skills/glance-watch/references/markets.md +0 -56
- package/skills/glance-watch/references/query-and-symbol.md +0 -69
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
本项目当前以 OpenClaw 插件模式运行(`index.js` + `openclaw.plugin.json`),保持长连接并接收 `watch.triggered`,并对同一 `baseWsUrl + token` 启用严格单活锁,防止重复实例。
|
|
12
12
|
|
|
13
|
+
**网络边界**:插件进程**只通过 WebSocket 连接 `openclaw-bridge`**(盯盘、行情 `ticker.query`、基金估值 `fund.estimates`、直连通知等),**不直连 MySQL** 或其它后端;库表/日终类数据若需暴露,应由 bridge 代理 **financial-data-gateway** 后再接工具(当前未内置 `finance_*` 工具)。
|
|
14
|
+
|
|
13
15
|
## OpenClaw 调用时机(插件模式)
|
|
14
16
|
|
|
15
17
|
- 用户新建盯盘:调用 `submitWatchDemand` 或 `createWatch`
|
|
@@ -21,7 +23,7 @@
|
|
|
21
23
|
## 功能
|
|
22
24
|
|
|
23
25
|
- 与 `openclaw-bridge` 建立 WebSocket 长连接
|
|
24
|
-
- 支持请求:`watch.create` / `watch.activate` / `watch.pause` / `watch.delete` / `ticker.query` / `notify.send` / `ping`
|
|
26
|
+
- 支持请求:`watch.create` / `watch.activate` / `watch.pause` / `watch.delete` / `ticker.query` / `fund.estimates` / `finance.table`(网关白名单只读表:A 股/港股/指数/基金基础检索、快讯、交易日历)/ `notify.send` / `ping`
|
|
25
27
|
- 支持渠道:`openclaw` / `email` / `call` / `sms` / `dingtalk`
|
|
26
28
|
- 建议在 `channel_configs.openclaw` 中携带路由字段(如 `channel`、`session_key`、`account_id`、`conversation_id`),便于触发后回推到正确会话
|
|
27
29
|
- 订阅推送:`watch.triggered`
|
|
@@ -30,6 +32,7 @@
|
|
|
30
32
|
- 严格单活(同 token 只允许一个活跃进程)
|
|
31
33
|
- 断线请求排队(可配置),重连后自动冲刷
|
|
32
34
|
- 提供业务适配层 `OpenClawPluginAdapter`
|
|
35
|
+
- Agent 友好:行情 `market` 支持中文别名(A股→a 等);检索/新闻统一 `keyword`/`q`;交易日历支持 `startDate`/`endDate`;缺参时抛出明确英文错误便于模型自纠
|
|
33
36
|
|
|
34
37
|
## 安装
|
|
35
38
|
|
|
@@ -37,9 +40,10 @@
|
|
|
37
40
|
npm install
|
|
38
41
|
```
|
|
39
42
|
|
|
40
|
-
##
|
|
43
|
+
## 测试与静态检查
|
|
41
44
|
|
|
42
45
|
```bash
|
|
46
|
+
npm run lint
|
|
43
47
|
npm test
|
|
44
48
|
```
|
|
45
49
|
|
|
@@ -126,7 +130,7 @@ await adapter.submitWatchDemand({
|
|
|
126
130
|
|
|
127
131
|
## 插件工具(OpenClaw 调用)
|
|
128
132
|
|
|
129
|
-
- `watch_query_ticker`
|
|
133
|
+
- `watch_query_ticker`:参数 `market`(`a` / `hk` / `crypto`)、`symbol`、可选 `segment`,与 financial-data-gateway `GET /v1/market/quote` 一致
|
|
130
134
|
- `watch_create`
|
|
131
135
|
- `watch_list`
|
|
132
136
|
- `watch_pause`
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openclaw-glance-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.28",
|
|
4
4
|
"description": "OpenClaw plugin client for ticker-monitor openclaw-bridge",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"start": "node examples/basic.js",
|
|
25
25
|
"start:adapter": "node examples/adapter.js",
|
|
26
|
+
"lint": "node --check src/agentQueryNormalize.js src/OpenClawBridgeClient.js src/OpenClawPluginAdapter.js src/index.js src/openclawRouting.js src/config/runtime-config.js src/plugin/index.js src/runtime/BridgeRuntime.js src/runtime/lock/ProcessLock.js src/runtime/dispatchers/PluginDispatcher.js",
|
|
26
27
|
"test": "node --test tests/**/*.test.js"
|
|
27
28
|
},
|
|
28
29
|
"engines": {
|
|
@@ -1,39 +1,74 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: glance-watch
|
|
3
|
-
description:
|
|
3
|
+
description: 用于监控A股、港股、比特币等金融市场行情并在条件触发时发送提醒。当用户要求盯盘、监控价格、设置提醒、需要通过邮件/电话/短信/钉钉发起通知、查询A股港股指数加密与基金行情、名称查代码、交易日历、快讯时使用,例如"帮我盯着比特币"、监控某只股票、涨跌幅提醒、短信通知我、这个月交易日有哪些、有哪些新闻等。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Glance Watch 智能盯盘(主入口)
|
|
7
7
|
|
|
8
|
-
##
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
8
|
+
## 能力优先级(必须遵循)
|
|
9
|
+
|
|
10
|
+
P0(最高)策略能力:
|
|
11
|
+
- 面向 **A股个股、港股个股、A股/港股指数、比特币** 创建/查询/暂停/恢复/删除盯盘策略。
|
|
12
|
+
- 仅用:`watch_create` / `watch_list` / `watch_pause` / `watch_activate` / `watch_remove`。
|
|
13
|
+
- **禁止**:对基金创建盯盘策略(包括场外基金 `xxxxxx.OF`)。
|
|
14
|
+
|
|
15
|
+
P1 行情能力(为策略创建提供上下文):
|
|
16
|
+
- 个股/指数/比特币实时行情:`watch_query_ticker`
|
|
17
|
+
- 基金当日估值:`watch_query_fund_estimates`
|
|
18
|
+
|
|
19
|
+
P2 标的解析能力(创建策略前补齐参数):
|
|
20
|
+
- 先查本地 CSV(`skills/glance-watch/data/*.csv`)做名称/代码映射。
|
|
21
|
+
- 本地不确定再用网关基础信息检索:
|
|
22
|
+
`watch_search_a_stock_basic` / `watch_search_hk_stock_basic` / `watch_search_index_basic` / `watch_search_fund_basic`
|
|
23
|
+
|
|
24
|
+
P3 辅助能力:
|
|
25
|
+
- 交易日历:`watch_trade_calendar`
|
|
26
|
+
- 财经快讯:`watch_fin_news`
|
|
27
|
+
- 立即发送通知:`notify_sms` / `notify_call` / `notify_email` / `notify_dingtalk`
|
|
28
|
+
|
|
29
|
+
## 工具清单(工具名必须完全一致)
|
|
30
|
+
|
|
31
|
+
- 工具名统一使用下划线形式(如 `watch_query_ticker`),不要写成点号形式(如 `watch.query_ticker`)。
|
|
32
|
+
|
|
33
|
+
- `watch_query_ticker`
|
|
34
|
+
- `watch_query_fund_estimates`
|
|
35
|
+
- `watch_search_a_stock_basic`
|
|
36
|
+
- `watch_search_hk_stock_basic`
|
|
37
|
+
- `watch_search_index_basic`
|
|
38
|
+
- `watch_search_fund_basic`
|
|
39
|
+
- `watch_fin_news`
|
|
40
|
+
- `watch_trade_calendar`
|
|
41
|
+
- `watch_create`
|
|
42
|
+
- `watch_list`
|
|
43
|
+
- `watch_pause`
|
|
44
|
+
- `watch_activate`
|
|
45
|
+
- `watch_remove`
|
|
46
|
+
- `notify_sms`
|
|
47
|
+
- `notify_call`
|
|
48
|
+
- `notify_email`
|
|
49
|
+
- `notify_dingtalk`
|
|
14
50
|
|
|
15
51
|
## 调用契约(硬约束)
|
|
16
52
|
|
|
17
|
-
###
|
|
53
|
+
### Agent 选型(先选工具再填参)
|
|
18
54
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
- `
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- `notify.dingtalk`
|
|
55
|
+
| 用户说法 | 第一步工具 | 下一步 |
|
|
56
|
+
|----------|------------|--------|
|
|
57
|
+
| 现价/涨跌/几块钱(**已有代码**) | `watch_query_ticker` | `market`+`symbol`;`market` 可用 **A股/港股/加密** 等中文别名 |
|
|
58
|
+
| 现价但**只有公司或指数名** | 查询`skills/glance-watch/data/*.csv`或 `watch_search_*_basic` | 从 `data[]` 取 `ts_code` 再 `watch_query_ticker` |
|
|
59
|
+
| 基金**今天估值** | `watch_query_fund_estimates` | `fund_codes`;勿用 `watch_query_ticker` |
|
|
60
|
+
| 基金**档案/是不是这只基** | `watch_search_fund_basic` | `ts_code` 或 `keyword` |
|
|
61
|
+
| 要创建基金盯盘策略 | 不调用 `watch_create` | 明确告知“当前仅支持A股港股的股票/指数或比特币盯盘;基金仅支持估值查询” |
|
|
62
|
+
| **新闻/快讯** | `watch_fin_news` | 必须有关键词 `keyword` 或 `q` |
|
|
63
|
+
| **开不开盘/休市/交易日** | `watch_trade_calendar` | `exchange`(如 SSE/SZSE)+ `start_date`+`end_date`(单日则相同) |
|
|
29
64
|
|
|
30
|
-
###
|
|
65
|
+
### 调用顺序(与上表一致)
|
|
31
66
|
|
|
32
|
-
1.
|
|
33
|
-
2.
|
|
34
|
-
3.
|
|
35
|
-
4.
|
|
36
|
-
5.
|
|
67
|
+
1. **盯盘策略任务**优先:`watch_create/watch_list/watch_pause/watch_activate/watch_remove`
|
|
68
|
+
2. 创建策略若缺代码或市场:先本地 CSV,再 `watch_search_*_basic`
|
|
69
|
+
3. 代码已明确再查实时价:`watch_query_ticker`
|
|
70
|
+
4. 基金只做估值/基础信息:`watch_query_fund_estimates` 或 `watch_search_fund_basic`
|
|
71
|
+
5. 再处理辅助任务:`watch_trade_calendar` / `watch_fin_news` / `notify_*`
|
|
37
72
|
|
|
38
73
|
### 创建策略最小必填
|
|
39
74
|
|
|
@@ -44,56 +79,89 @@ description: 智能盯盘插件,用于监控A股、港股、比特币等金融
|
|
|
44
79
|
- `operator_parameters.variables`
|
|
45
80
|
|
|
46
81
|
缺任一项先追问,不猜测阈值。
|
|
82
|
+
若 `product_type` 为基金(或代码为 `xxxxxx.OF`),拒绝创建并改为提供基金估值查询方案。
|
|
83
|
+
|
|
84
|
+
### 渠道选择规则(`watch_create`)
|
|
85
|
+
|
|
86
|
+
- `channels` 至少包含 1 个渠道。
|
|
87
|
+
- 若用户明确表达“仅/只用某几个渠道”,严格按用户指定,不强制补 `openclaw`。
|
|
88
|
+
- 若用户表达“用某个渠道(如 call)”但未明确“仅限”,默认在用户指定渠道基础上补 `openclaw`。
|
|
89
|
+
- 未经用户要求,不额外附加除 `openclaw` 外的其他渠道。
|
|
90
|
+
|
|
91
|
+
#### “仅限渠道”判定词(小模型必用)
|
|
92
|
+
|
|
93
|
+
- 判定为“仅限”的典型说法:
|
|
94
|
+
- `只用X` / `仅用X` / `只能用X` / `不要其他渠道`
|
|
95
|
+
- `除了X都不要` / `就X就行` / `别发到openclaw`
|
|
96
|
+
- 判定为“非仅限”的典型说法:
|
|
97
|
+
- `用X` / `加上X` / `再加X` / `X也发一下`
|
|
98
|
+
- `帮我走X渠道`(未出现“只/仅/不要其他”)
|
|
99
|
+
- 歧义处理:
|
|
100
|
+
- 若用户表达不清,先追问一句:`是否仅使用这些渠道,不包含 openclaw?`
|
|
101
|
+
- 未得到“仅限”确认前,按“非仅限”处理(可补 `openclaw`)。
|
|
47
102
|
|
|
48
103
|
### 绝对禁止项
|
|
49
104
|
|
|
50
105
|
- `operator_type` 不是 `rule`
|
|
51
106
|
- 把 `condition` 放到顶层(必须在 `operator_parameters.condition`)
|
|
52
107
|
- 把 `channel_configs.*` 传成 JSON 字符串(必须是对象)
|
|
53
|
-
-
|
|
54
|
-
- 通过 `
|
|
108
|
+
- 用户明确“仅/只用某几个渠道”时,仍强行附加其他渠道
|
|
109
|
+
- 通过 `watch_list` 传 `user_id/use_id` 越权查询
|
|
110
|
+
- 用 `watch_query_ticker` 查**场外基金估值**(应使用 `watch_query_fund_estimates`)
|
|
111
|
+
- 对基金调用 `watch_create`
|
|
112
|
+
|
|
113
|
+
### 联系人 CSV(强约束,适用于 `watch_create` 与 `notify_*`)
|
|
114
|
+
|
|
115
|
+
- 联系人真源:`~/.openclaw/workspace/memory/watch-notify-contacts.csv`
|
|
116
|
+
- 只要请求涉及 `call/sms/email/dingtalk`,调用前必须先查 CSV。
|
|
117
|
+
- 取值优先级固定:
|
|
118
|
+
1. 本轮用户明确提供
|
|
119
|
+
2. CSV 历史值补全
|
|
120
|
+
3. 仍缺必填字段 -> 追问
|
|
121
|
+
- 当本轮用户提供了新联系方式,且 `watch_create` 或 `notify_*` 调用成功,必须回写 CSV。
|
|
122
|
+
- 禁止依赖其他联系人文件(如 json)代替该 CSV。
|
|
55
123
|
|
|
56
124
|
## 渐进式披露(按需读取)
|
|
57
125
|
|
|
58
126
|
仅在命中场景时读取对应文档,不要一次性加载全部 references。
|
|
59
127
|
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
128
|
+
- 盯盘策略(创建/管理):`references/watch-contract.md`
|
|
129
|
+
- 直连通知(短信/电话/邮件/钉钉):`references/channels.md`
|
|
130
|
+
- 实时行情(股/指/加密)与基金估值:`references/quote-realtime.md`
|
|
131
|
+
- 标的检索 + 是否交易日:`references/symbol-search-and-calendar.md`
|
|
132
|
+
- 快讯:`references/news-briefing.md`
|
|
63
133
|
- 示例 payload:`references/examples.md`
|
|
64
|
-
-
|
|
65
|
-
- 市场与代码速查:`references/markets.md`
|
|
134
|
+
- 重试与排错:`references/troubleshooting.md`
|
|
66
135
|
|
|
67
136
|
## 决策表(强约束)
|
|
68
137
|
|
|
69
|
-
先判定用户主意图,再只读取最小文档集合:
|
|
70
|
-
|
|
71
138
|
| 用户主意图 | 必读文档(最小集合) |
|
|
72
139
|
|---|---|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
-
|
|
|
77
|
-
|
|
|
78
|
-
|
|
|
79
|
-
| 失败排查/补发说明 | `references/troubleshooting.md` |
|
|
80
|
-
| 市场或代码速查 | `references/markets.md` |
|
|
140
|
+
| 创建/管理盯盘策略 | `references/watch-contract.md` |
|
|
141
|
+
| 查行情(股/指/加密)/ 基金估值 | `references/quote-realtime.md` |
|
|
142
|
+
| 名称→代码 / 交易日判断 | `references/symbol-search-and-calendar.md` |
|
|
143
|
+
| 快讯 | `references/news-briefing.md` |
|
|
144
|
+
| 立即发通知 | `references/channels.md` |
|
|
145
|
+
| 失败排查 | `references/troubleshooting.md` |
|
|
81
146
|
|
|
82
147
|
执行规则:
|
|
83
|
-
1. 一次请求默认只读 1
|
|
148
|
+
1. 一次请求默认只读 1–2 个 references 文件。
|
|
84
149
|
2. 仅当当前文档无法回答时,再追加读取下一个文档。
|
|
85
|
-
3.
|
|
150
|
+
3. 读取顺序遵循上表,不按「完整性」一次加载所有文档。
|
|
86
151
|
|
|
87
152
|
## 小模型执行模板(7B)
|
|
88
153
|
|
|
89
154
|
1. 先按固定字段骨架生成 payload,不自创字段名。
|
|
90
155
|
2. 只替换值:`product_code/product_type/operator_parameters/channels/channel_configs`。
|
|
91
|
-
3.
|
|
92
|
-
4. 若报 `400`
|
|
156
|
+
3. 调用前逐条自检「绝对禁止项」。
|
|
157
|
+
4. 若报 `400` 且提示「未注册的算子类型」,把 `operator_type` 纠正为 `rule` 后重试。
|
|
93
158
|
|
|
94
159
|
## 快速分流
|
|
95
160
|
|
|
96
|
-
-
|
|
97
|
-
-
|
|
98
|
-
-
|
|
99
|
-
-
|
|
161
|
+
- 用户说「帮我盯 BTC 跌 2% 提醒」 -> `references/watch-contract.md` + `references/channels.md`
|
|
162
|
+
- 用户说「腾讯现在多少钱」 -> `references/quote-realtime.md`(如缺代码再读 `references/symbol-search-and-calendar.md`)
|
|
163
|
+
- 用户说「这只基金今天估值多少」 -> `references/quote-realtime.md`(`watch_query_fund_estimates`)
|
|
164
|
+
- 用户说「今天 A 股开不开盘」 -> `references/symbol-search-and-calendar.md`(`watch_trade_calendar`,SSE/SZSE)
|
|
165
|
+
- 用户说「发短信给我」 -> `references/channels.md`
|
|
166
|
+
- 用户说「有什么央行快讯」 -> `references/news-briefing.md`
|
|
167
|
+
- 用户说「为什么没发出来」 -> `references/troubleshooting.md`
|
|
@@ -1,27 +1,58 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 直连通知(notify_*)
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 适用工具
|
|
4
4
|
|
|
5
|
-
- `
|
|
6
|
-
- `
|
|
5
|
+
- `notify_sms`
|
|
6
|
+
- `notify_call`
|
|
7
|
+
- `notify_email`
|
|
8
|
+
- `notify_dingtalk`
|
|
7
9
|
|
|
8
|
-
##
|
|
10
|
+
## 统一规则
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
- 仅在用户明确要求时调用直连通知。
|
|
13
|
+
- 不手动传 `request_id`。
|
|
14
|
+
- 返回 `success === true` 视为成功。
|
|
15
|
+
- 失败时直接反馈 `code/error/hint`,不静默重试。
|
|
16
|
+
- 联系人记忆规则同时适用于:
|
|
17
|
+
- `notify_*`
|
|
18
|
+
- `watch_create`(当渠道含 `call/sms/email/dingtalk`)
|
|
11
19
|
|
|
12
|
-
|
|
13
|
-
- `channel` 或 `source_channel`
|
|
14
|
-
- `account_id`
|
|
15
|
-
- `session_key`
|
|
16
|
-
- `conversation_id` 或 `chat_id`
|
|
20
|
+
## 参数要求
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
22
|
+
### `notify_sms`
|
|
23
|
+
- `receiver`(或 `phone`)
|
|
24
|
+
- `template_id`
|
|
25
|
+
- `content`
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
### `notify_call`
|
|
28
|
+
- `phone`
|
|
29
|
+
- `customer_name`
|
|
30
|
+
- `condition`
|
|
23
31
|
|
|
24
|
-
|
|
32
|
+
### `notify_email`
|
|
33
|
+
- `to_address`
|
|
34
|
+
- `template_id`
|
|
35
|
+
- `title`
|
|
36
|
+
- `content`
|
|
37
|
+
|
|
38
|
+
### `notify_dingtalk`
|
|
39
|
+
- `cas_id`
|
|
40
|
+
- `template_id`
|
|
41
|
+
- `msg_type`(`text` 或 `markdown`)
|
|
42
|
+
- `content`
|
|
43
|
+
|
|
44
|
+
## 联系人记忆(强约束)
|
|
45
|
+
|
|
46
|
+
联系人 CSV:`~/.openclaw/workspace/memory/watch-notify-contacts.csv`
|
|
47
|
+
|
|
48
|
+
执行要求:
|
|
49
|
+
1. 触发条件:`notify_*` 或 `watch_create` 使用 `call/sms/email/dingtalk` 时,调用前必须查 CSV。
|
|
50
|
+
2. 文件初始化:CSV 不存在时,先创建文件并写入标准表头后再查询。
|
|
51
|
+
3. 表头修复:CSV 存在但无表头时,先补表头再继续。
|
|
52
|
+
4. 权限异常:若无权限读/写该 CSV,先向用户申请权限后再执行,不静默降级。
|
|
53
|
+
5. 取值优先级:本轮用户明确提供 > CSV 历史值 > 追问。
|
|
54
|
+
6. 回写条件:调用成功且联系方式有更新时,必须回写 CSV。
|
|
55
|
+
7. 文件唯一性:只认该 CSV,不读取其他联系人文件。
|
|
25
56
|
|
|
26
57
|
建议表头:
|
|
27
58
|
|
|
@@ -29,62 +60,26 @@
|
|
|
29
60
|
channel,sender_id,sender_name,phone,email,dingtalk_cas_id,customer_name,updated_at,notes
|
|
30
61
|
```
|
|
31
62
|
|
|
32
|
-
执行要求:
|
|
33
|
-
1. 凡是 `watch.create` 或 `notify.*` 涉及 `call/sms/email/dingtalk`,调用前必须先查询该 CSV。
|
|
34
|
-
2. 取值优先级固定为:
|
|
35
|
-
- 本轮用户明确提供
|
|
36
|
-
- CSV 历史默认值
|
|
37
|
-
- 仍缺必填字段 -> 追问
|
|
38
|
-
3. 若用户在本轮提供了新的联系方式,且本次 `watch.create` / `notify.*` 成功,必须回写 CSV。
|
|
39
|
-
4. 联系人记忆只认该 CSV;不依赖、不读取、不提及 `watch-notify-contacts.json`。
|
|
40
|
-
5. 若 CSV 不存在,先创建带表头的文件,再写入首条联系人记录。
|
|
41
|
-
|
|
42
63
|
查询示例:
|
|
43
64
|
|
|
44
65
|
```bash
|
|
45
|
-
rg -n '^
|
|
66
|
+
rg -n '^sms,jinguo\.xie,' ~/.openclaw/workspace/memory/watch-notify-contacts.csv
|
|
46
67
|
```
|
|
47
68
|
|
|
48
|
-
|
|
49
|
-
- 已有同一 `(channel, sender_id)
|
|
50
|
-
-
|
|
51
|
-
- `updated_at
|
|
52
|
-
|
|
53
|
-
## `watch.create` 渠道必填
|
|
54
|
-
|
|
55
|
-
- 选 `email` -> `channel_configs.email.to_address/template_id/title/content`
|
|
56
|
-
- 选 `call` -> `channel_configs.call.phone/customer_name/condition`
|
|
57
|
-
- 选 `sms` -> `channel_configs.sms.receiver(或phone)/template_id/content`
|
|
58
|
-
- 选 `dingtalk` -> `channel_configs.dingtalk.cas_id/template_id/msg_type/content`
|
|
69
|
+
回写要求:
|
|
70
|
+
- 已有同一 `(channel, sender_id)`:更新该行,不重复追加
|
|
71
|
+
- 不存在:按表头顺序追加
|
|
72
|
+
- `updated_at`:写 ISO-8601 时间
|
|
59
73
|
|
|
60
|
-
##
|
|
74
|
+
## 常见禁止项
|
|
61
75
|
|
|
62
|
-
-
|
|
63
|
-
- `notify.call`: `phone`、`customer_name`、`condition`
|
|
64
|
-
- `notify.email`: `to_address`、`template_id`、`title`、`content`
|
|
65
|
-
- `notify.dingtalk`: `cas_id`、`template_id`、`msg_type`、`content`
|
|
66
|
-
|
|
67
|
-
固定模板:
|
|
68
|
-
|
|
69
|
-
```javascript
|
|
70
|
-
// notify.sms
|
|
71
|
-
{ receiver: '13800138000', template_id: 90010, content: '测试消息1' }
|
|
72
|
-
|
|
73
|
-
// notify.call
|
|
74
|
-
{ phone: '13800138000', customer_name: 'Demo', condition: '比特币跌幅超过2%' }
|
|
75
|
-
|
|
76
|
-
// notify.email
|
|
77
|
-
{ to_address: 'demo@example.com', template_id: 4, title: '监控提醒', content: '测试消息1' }
|
|
78
|
-
|
|
79
|
-
// notify.dingtalk
|
|
80
|
-
{ cas_id: 'user.dingtalk', template_id: 3, msg_type: 'text', content: '测试消息1' }
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
禁止项:
|
|
84
|
-
- 手机号含空格、`+86-`、中划线等非纯数字
|
|
76
|
+
- 手机号含空格、中划线、`+86-` 等非纯数字
|
|
85
77
|
- `template_id` 传字符串
|
|
86
|
-
- `msg_type`
|
|
87
|
-
|
|
78
|
+
- `msg_type` 不是 `text/markdown`
|
|
79
|
+
|
|
80
|
+
## `watch_create` 渠道必填映射
|
|
88
81
|
|
|
89
|
-
|
|
90
|
-
-
|
|
82
|
+
- 选 `email`:`channel_configs.email.to_address/template_id/title/content`
|
|
83
|
+
- 选 `call`:`channel_configs.call.phone/customer_name/condition`
|
|
84
|
+
- 选 `sms`:`channel_configs.sms.receiver(或phone)/template_id/content`
|
|
85
|
+
- 选 `dingtalk`:`channel_configs.dingtalk.cas_id/template_id/msg_type/content`
|
|
@@ -1,43 +1,163 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 示例模板(按任务类型)
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 1) 盯盘策略(watch_*)
|
|
4
|
+
|
|
5
|
+
### 1.1 创建比特币盯盘(跌破阈值)
|
|
4
6
|
|
|
5
7
|
```javascript
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
await watch_create({
|
|
9
|
+
product_code: 'BTCUSDT',
|
|
10
|
+
product_type: 'crypto',
|
|
11
|
+
operator_type: 'rule',
|
|
12
|
+
operator_parameters: {
|
|
13
|
+
condition: 'price <= threshold and change_percent <= cp_threshold',
|
|
14
|
+
variables: { threshold: 68000, cp_threshold: -0.02, product_name: '比特币' }
|
|
15
|
+
},
|
|
16
|
+
channels: ['openclaw'],
|
|
17
|
+
channel_configs: {
|
|
18
|
+
openclaw: {
|
|
19
|
+
channel: 'dingtalk',
|
|
20
|
+
account_id: 'default',
|
|
21
|
+
session_key: 'agent:main:dingtalk:group:cid_demo',
|
|
22
|
+
conversation_id: 'cid_demo'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
})
|
|
11
26
|
```
|
|
12
27
|
|
|
13
|
-
|
|
28
|
+
### 1.2 创建A股盯盘 + 短信通知(含联系人 CSV 补值)
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
// Step 0: 先查联系人 CSV(若本轮未给手机号)
|
|
32
|
+
// ~/.openclaw/workspace/memory/watch-notify-contacts.csv
|
|
14
33
|
|
|
15
|
-
|
|
34
|
+
await watch_create({
|
|
35
|
+
product_code: '600000.SH',
|
|
36
|
+
product_type: 'stock',
|
|
37
|
+
operator_type: 'rule',
|
|
38
|
+
operator_parameters: {
|
|
39
|
+
condition: 'price >= threshold and turnover_rate >= tr_threshold',
|
|
40
|
+
variables: { threshold: 12.5, tr_threshold: 0.01, product_name: '浦发银行' }
|
|
41
|
+
},
|
|
42
|
+
channels: ['openclaw', 'sms'],
|
|
43
|
+
channel_configs: {
|
|
44
|
+
openclaw: {
|
|
45
|
+
channel: 'dingtalk',
|
|
46
|
+
account_id: 'default',
|
|
47
|
+
session_key: 'agent:main:dingtalk:group:cid_demo',
|
|
48
|
+
conversation_id: 'cid_demo'
|
|
49
|
+
},
|
|
50
|
+
sms: {
|
|
51
|
+
receiver: '13800138000',
|
|
52
|
+
template_id: 90010,
|
|
53
|
+
content: '浦发银行触发盯盘条件,当前价 ${price}'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
// Step 1: 若本轮用了新联系方式且创建成功,回写联系人 CSV
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 1.3 管理策略
|
|
16
62
|
|
|
17
63
|
```javascript
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
64
|
+
await watch_list({ status: 'active' })
|
|
65
|
+
await watch_pause({ strategy_id: 's_123' })
|
|
66
|
+
await watch_activate({ strategy_id: 's_123' })
|
|
67
|
+
await watch_remove({ strategy_id: 's_123' })
|
|
23
68
|
```
|
|
24
69
|
|
|
25
|
-
##
|
|
70
|
+
## 2) 直连通知(notify_*)
|
|
71
|
+
|
|
72
|
+
### 2.1 发送短信(含联系人 CSV 补值)
|
|
26
73
|
|
|
27
74
|
```javascript
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
75
|
+
// Step 0: 先查联系人 CSV,补 receiver/template_id
|
|
76
|
+
await notify_sms({
|
|
77
|
+
receiver: '13800138000',
|
|
78
|
+
template_id: 90010,
|
|
79
|
+
content: '测试短信:比特币跌幅超过2%'
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
// Step 1: 若本轮有新联系方式且发送成功,回写 CSV
|
|
33
83
|
```
|
|
34
84
|
|
|
35
|
-
|
|
85
|
+
### 2.2 发送电话/邮件/钉钉
|
|
36
86
|
|
|
37
87
|
```javascript
|
|
38
|
-
await
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
88
|
+
await notify_call({
|
|
89
|
+
phone: '13800138000',
|
|
90
|
+
customer_name: '张三',
|
|
91
|
+
condition: '比特币跌幅超过2%'
|
|
42
92
|
})
|
|
93
|
+
|
|
94
|
+
await notify_email({
|
|
95
|
+
to_address: 'demo@example.com',
|
|
96
|
+
template_id: 4,
|
|
97
|
+
title: '盯盘提醒',
|
|
98
|
+
content: 'BTCUSDT 触发阈值'
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
await notify_dingtalk({
|
|
102
|
+
cas_id: 'user.dingtalk',
|
|
103
|
+
template_id: 3,
|
|
104
|
+
msg_type: 'text',
|
|
105
|
+
content: '盯盘触发:BTCUSDT'
|
|
106
|
+
})
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## 3) 实时行情查询
|
|
110
|
+
|
|
111
|
+
### 3.1 股票/指数/加密实时行情
|
|
112
|
+
|
|
113
|
+
```javascript
|
|
114
|
+
await watch_query_ticker({ market: 'a', symbol: '600000.SH', segment: 'stock' })
|
|
115
|
+
await watch_query_ticker({ market: 'hk', symbol: '00700', segment: 'stock' })
|
|
116
|
+
await watch_query_ticker({ market: 'crypto', symbol: 'BTCUSDT' })
|
|
43
117
|
```
|
|
118
|
+
|
|
119
|
+
### 3.2 基金当日估值(基金不支持创建盯盘)
|
|
120
|
+
|
|
121
|
+
```javascript
|
|
122
|
+
await watch_query_fund_estimates({ fund_codes: '000006.OF' })
|
|
123
|
+
await watch_query_fund_estimates({ fund_codes: ['000006.OF', '110011.OF'] })
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## 4) 标的检索与是否交易日查询
|
|
127
|
+
|
|
128
|
+
### 4.1 名称 -> 代码
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
await watch_search_a_stock_basic({ keyword: '平安银行', limit: 5 })
|
|
132
|
+
await watch_search_hk_stock_basic({ q: '腾讯', limit: 5 })
|
|
133
|
+
await watch_search_index_basic({ keyword: '沪深300', limit: 5 })
|
|
134
|
+
await watch_search_fund_basic({ keyword: '西部利得量化成长', limit: 5 })
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### 4.2 是否交易日
|
|
138
|
+
|
|
139
|
+
```javascript
|
|
140
|
+
await watch_trade_calendar({
|
|
141
|
+
exchange: 'SSE',
|
|
142
|
+
start_date: '2026-04-10',
|
|
143
|
+
end_date: '2026-04-10'
|
|
144
|
+
})
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## 5) 快讯
|
|
148
|
+
|
|
149
|
+
```javascript
|
|
150
|
+
await watch_fin_news({ keyword: '央行', limit: 10 })
|
|
151
|
+
await watch_fin_news({
|
|
152
|
+
q: '比特币',
|
|
153
|
+
pub_time_start: '2026-04-10 00:00:00',
|
|
154
|
+
pub_time_end: '2026-04-10 23:59:59',
|
|
155
|
+
limit: 20
|
|
156
|
+
})
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## 常见边界提示
|
|
160
|
+
|
|
161
|
+
- 基金(`xxxxxx.OF`)不能用 `watch_create`,只能用 `watch_query_fund_estimates` / `watch_search_fund_basic`。
|
|
162
|
+
- 使用 `call/sms/email/dingtalk` 时,`watch_create` 与 `notify_*` 都要先查联系人 CSV。
|
|
163
|
+
- `operator_type` 固定 `rule`,不要用其他值。
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# 快讯查询
|
|
2
|
+
|
|
3
|
+
## 工具
|
|
4
|
+
|
|
5
|
+
- `watch_fin_news`
|
|
6
|
+
|
|
7
|
+
## 何时使用
|
|
8
|
+
|
|
9
|
+
- 用户询问“有什么快讯/新闻/资讯”
|
|
10
|
+
- 用户给了主题词(如:央行、降息、AI、特斯拉)
|
|
11
|
+
|
|
12
|
+
## 参数
|
|
13
|
+
|
|
14
|
+
必填:
|
|
15
|
+
- `keyword` 或 `q`(二选一)
|
|
16
|
+
|
|
17
|
+
可选:
|
|
18
|
+
- `limit`
|
|
19
|
+
- `pub_time_start`
|
|
20
|
+
- `pub_time_end`
|
|
21
|
+
|
|
22
|
+
## 成功判定
|
|
23
|
+
|
|
24
|
+
- `success === true`
|
|
25
|
+
- `finance.table.result` 的 `data[]` 含快讯行
|
|
26
|
+
|
|
27
|
+
## 示例
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
await watch_fin_news({ keyword: '央行', limit: 10 })
|
|
31
|
+
await watch_fin_news({
|
|
32
|
+
q: '比特币',
|
|
33
|
+
pub_time_start: '2026-04-10 00:00:00',
|
|
34
|
+
pub_time_end: '2026-04-10 23:59:59'
|
|
35
|
+
})
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 失败处理
|
|
39
|
+
|
|
40
|
+
- 没有关键词时先追问,不要空查
|
|
41
|
+
- 返回失败时,直接反馈 `error` 与 `http_status`
|