@cuebot/skill 1.0.5 → 1.0.6
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 +1 -1
- package/config/modes.json +32 -0
- package/index.js +1 -1
- package/package.json +1 -1
- package/src/api/cuecueClient.js +54 -13
- package/src/core/backgroundExecutor.js +8 -8
- package/src/core/monitorManager.js +14 -0
- package/src/cron/monitor-daemon.js +36 -24
- package/src/index.js +4 -4
- package/src/notifier/index.js +43 -3
- package/src/utils/dataSource.js +145 -20
- package/src/utils/envAdapter.js +233 -0
- package/src/utils/envUtils.js +57 -11
- package/src/utils/fileUtils.js +10 -3
- package/src/utils/notificationQueue.js +134 -246
- package/src/utils/openclawUtils.js +28 -1
- package/src/utils/subagentScheduler.js +147 -0
- package/src/utils/validators.js +0 -122
package/src/utils/validators.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 验证工具
|
|
3
|
-
* 提供输入验证和格式检查
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 验证 API Key 格式
|
|
8
|
-
* @param {string} apiKey - API Key
|
|
9
|
-
* @returns {{valid: boolean, error?: string}}
|
|
10
|
-
*/
|
|
11
|
-
export function validateApiKey(apiKey) {
|
|
12
|
-
if (!apiKey) {
|
|
13
|
-
return { valid: false, error: 'API Key 不能为空' };
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (apiKey.length < 10) {
|
|
17
|
-
return { valid: false, error: 'API Key 长度至少 10 个字符' };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// 检查格式
|
|
21
|
-
const patterns = [
|
|
22
|
-
{ name: 'Tavily', pattern: /^tvly-/ },
|
|
23
|
-
{ name: 'CueCue', pattern: /^skb/ },
|
|
24
|
-
{ name: 'CueCue/QVeris', pattern: /^sk-/ }
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
for (const { name, pattern } of patterns) {
|
|
28
|
-
if (pattern.test(apiKey)) {
|
|
29
|
-
return { valid: true };
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
valid: false,
|
|
35
|
-
error: '无法识别 API Key 格式,请检查是否为 tvly-xxx, skb-xxx 或 sk-xxx 格式'
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 验证主题格式
|
|
41
|
-
* @param {string} topic - 研究主题
|
|
42
|
-
* @returns {{valid: boolean, error?: string}}
|
|
43
|
-
*/
|
|
44
|
-
export function validateTopic(topic) {
|
|
45
|
-
if (!topic || topic.trim().length === 0) {
|
|
46
|
-
return { valid: false, error: '研究主题不能为空' };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (topic.length < 2) {
|
|
50
|
-
return { valid: false, error: '研究主题太短' };
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (topic.length > 500) {
|
|
54
|
-
return { valid: false, error: '研究主题太长(最多 500 字符)' };
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return { valid: true };
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* 验证监控 ID 格式
|
|
62
|
-
* @param {string} monitorId - 监控 ID
|
|
63
|
-
* @returns {boolean}
|
|
64
|
-
*/
|
|
65
|
-
export function isValidMonitorId(monitorId) {
|
|
66
|
-
return /^[a-zA-Z0-9_-]+$/.test(monitorId);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* 验证任务 ID 格式
|
|
71
|
-
* @param {string} taskId - 任务 ID
|
|
72
|
-
* @returns {boolean}
|
|
73
|
-
*/
|
|
74
|
-
export function isValidTaskId(taskId) {
|
|
75
|
-
return /^cuecue_\d+$/.test(taskId);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* 验证天数参数
|
|
80
|
-
* @param {string|number} days - 天数
|
|
81
|
-
* @returns {{valid: boolean, value?: number, error?: string}}
|
|
82
|
-
*/
|
|
83
|
-
export function validateDays(days) {
|
|
84
|
-
const num = parseInt(days, 10);
|
|
85
|
-
|
|
86
|
-
if (isNaN(num)) {
|
|
87
|
-
return { valid: false, error: '天数必须是数字' };
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (num < 1 || num > 365) {
|
|
91
|
-
return { valid: false, error: '天数必须在 1-365 之间' };
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return { valid: true, value: num };
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* 验证模式参数
|
|
99
|
-
* @param {string} mode - 模式
|
|
100
|
-
* @returns {{valid: boolean, normalized?: string}}
|
|
101
|
-
*/
|
|
102
|
-
export function validateMode(mode) {
|
|
103
|
-
const modeMap = {
|
|
104
|
-
'trader': 'trader',
|
|
105
|
-
'短线': 'trader',
|
|
106
|
-
'短线交易': 'trader',
|
|
107
|
-
'fund-manager': 'fund-manager',
|
|
108
|
-
'基金经理': 'fund-manager',
|
|
109
|
-
'researcher': 'researcher',
|
|
110
|
-
'研究员': 'researcher',
|
|
111
|
-
'advisor': 'advisor',
|
|
112
|
-
'理财顾问': 'advisor'
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const normalized = modeMap[mode?.toLowerCase()];
|
|
116
|
-
|
|
117
|
-
if (normalized) {
|
|
118
|
-
return { valid: true, normalized };
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return { valid: false };
|
|
122
|
-
}
|