openclaw-glance-plugin 0.1.0 → 0.1.1
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 +10 -3
- package/package.json +1 -1
- package/src/OpenClawPluginAdapter.js +24 -2
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ OpenClaw 集成引导请看:[docs/openclaw-install-guide.md](./docs/openclaw-i
|
|
|
24
24
|
|
|
25
25
|
- 与 `openclaw-bridge` 建立 WebSocket 长连接
|
|
26
26
|
- 支持请求:`watch.create` / `watch.activate` / `watch.pause` / `watch.delete` / `ping`
|
|
27
|
+
- 支持渠道:`openclaw` / `email` / `call`
|
|
27
28
|
- 订阅推送:`watch.triggered`
|
|
28
29
|
- 自动重连 + 心跳
|
|
29
30
|
- 断线请求排队(可配置),重连后自动冲刷
|
|
@@ -44,7 +45,6 @@ npm test
|
|
|
44
45
|
## 运行示例
|
|
45
46
|
|
|
46
47
|
```bash
|
|
47
|
-
OPENCLAW_BRIDGE_WS_BASE=ws://glanceup-pre.100credit.cn \
|
|
48
48
|
OPENCLAW_WS_TOKEN=your_ws_token \
|
|
49
49
|
npm start
|
|
50
50
|
```
|
|
@@ -100,8 +100,15 @@ await adapter.submitWatchDemand({
|
|
|
100
100
|
productType: 'hk_stock',
|
|
101
101
|
condition: 'price >= threshold',
|
|
102
102
|
variables: { threshold: 8.97 },
|
|
103
|
-
channels: ['openclaw'],
|
|
104
|
-
|
|
103
|
+
channels: ['openclaw', 'email', 'call'], // openclaw 必传,email/call 可选
|
|
104
|
+
emailConfig: {
|
|
105
|
+
to_address: 'demo@example.com',
|
|
106
|
+
template_id: 4
|
|
107
|
+
},
|
|
108
|
+
callConfig: {
|
|
109
|
+
phone: '13800138000',
|
|
110
|
+
customer_name: 'Demo'
|
|
111
|
+
}
|
|
105
112
|
});
|
|
106
113
|
```
|
|
107
114
|
|
package/package.json
CHANGED
|
@@ -75,6 +75,28 @@ export class OpenClawPluginAdapter {
|
|
|
75
75
|
* 统一创建盯盘需求接口(适配 OpenClaw 侧参数)。
|
|
76
76
|
*/
|
|
77
77
|
async submitWatchDemand(demand) {
|
|
78
|
+
const channels = Array.isArray(demand.channels)
|
|
79
|
+
? demand.channels
|
|
80
|
+
.filter((x) => typeof x === 'string' && x.trim())
|
|
81
|
+
.map((x) => x.trim().toLowerCase())
|
|
82
|
+
: [];
|
|
83
|
+
const channelConfigs = { ...(demand.channelConfigs || {}) };
|
|
84
|
+
|
|
85
|
+
if (demand.openclawConfig) {
|
|
86
|
+
channelConfigs.openclaw = demand.openclawConfig;
|
|
87
|
+
if (!channels.includes('openclaw')) channels.push('openclaw');
|
|
88
|
+
}
|
|
89
|
+
if (demand.emailConfig) {
|
|
90
|
+
channelConfigs.email = demand.emailConfig;
|
|
91
|
+
if (!channels.includes('email')) channels.push('email');
|
|
92
|
+
}
|
|
93
|
+
if (demand.callConfig) {
|
|
94
|
+
channelConfigs.call = demand.callConfig;
|
|
95
|
+
if (!channels.includes('call')) channels.push('call');
|
|
96
|
+
}
|
|
97
|
+
if (!channels.includes('openclaw')) channels.unshift('openclaw');
|
|
98
|
+
if (!channelConfigs.openclaw) channelConfigs.openclaw = {};
|
|
99
|
+
|
|
78
100
|
const payload = {
|
|
79
101
|
product_code: demand.productCode,
|
|
80
102
|
product_type: demand.productType || 'stock',
|
|
@@ -84,8 +106,8 @@ export class OpenClawPluginAdapter {
|
|
|
84
106
|
variables: demand.variables || {},
|
|
85
107
|
message_template: demand.messageTemplate
|
|
86
108
|
},
|
|
87
|
-
channels
|
|
88
|
-
channel_configs:
|
|
109
|
+
channels,
|
|
110
|
+
channel_configs: channelConfigs
|
|
89
111
|
};
|
|
90
112
|
return this.client.createWatch(payload);
|
|
91
113
|
}
|