@lobehub/lobehub 2.0.0-next.94 → 2.0.0-next.96

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.
Files changed (63) hide show
  1. package/.github/workflows/issue-auto-comments.yml +0 -19
  2. package/CHANGELOG.md +50 -0
  3. package/changelog/v1.json +18 -0
  4. package/locales/ar/common.json +21 -0
  5. package/locales/ar/hotkey.json +4 -0
  6. package/locales/bg-BG/common.json +21 -0
  7. package/locales/bg-BG/hotkey.json +4 -0
  8. package/locales/de-DE/common.json +21 -0
  9. package/locales/de-DE/hotkey.json +4 -0
  10. package/locales/en-US/common.json +21 -0
  11. package/locales/en-US/hotkey.json +4 -0
  12. package/locales/es-ES/common.json +21 -0
  13. package/locales/es-ES/hotkey.json +4 -0
  14. package/locales/fa-IR/common.json +21 -0
  15. package/locales/fa-IR/hotkey.json +4 -0
  16. package/locales/fr-FR/common.json +21 -0
  17. package/locales/fr-FR/hotkey.json +4 -0
  18. package/locales/it-IT/common.json +21 -0
  19. package/locales/it-IT/hotkey.json +4 -0
  20. package/locales/ja-JP/common.json +21 -0
  21. package/locales/ja-JP/hotkey.json +4 -0
  22. package/locales/ko-KR/common.json +21 -0
  23. package/locales/ko-KR/hotkey.json +4 -0
  24. package/locales/nl-NL/common.json +21 -0
  25. package/locales/nl-NL/hotkey.json +4 -0
  26. package/locales/pl-PL/common.json +21 -0
  27. package/locales/pl-PL/hotkey.json +4 -0
  28. package/locales/pt-BR/common.json +21 -0
  29. package/locales/pt-BR/hotkey.json +4 -0
  30. package/locales/ru-RU/common.json +21 -0
  31. package/locales/ru-RU/hotkey.json +4 -0
  32. package/locales/tr-TR/common.json +21 -0
  33. package/locales/tr-TR/hotkey.json +4 -0
  34. package/locales/vi-VN/common.json +21 -0
  35. package/locales/vi-VN/hotkey.json +4 -0
  36. package/locales/zh-CN/common.json +21 -0
  37. package/locales/zh-CN/hotkey.json +4 -0
  38. package/locales/zh-TW/common.json +21 -0
  39. package/locales/zh-TW/hotkey.json +4 -0
  40. package/package.json +3 -1
  41. package/packages/agent-runtime/src/core/InterventionChecker.ts +85 -0
  42. package/packages/agent-runtime/src/core/__tests__/InterventionChecker.test.ts +492 -22
  43. package/packages/agent-runtime/src/core/defaultSecurityBlacklist.ts +335 -0
  44. package/packages/agent-runtime/src/core/index.ts +1 -0
  45. package/packages/agent-runtime/src/types/state.ts +10 -1
  46. package/packages/const/src/hotkeys.ts +6 -0
  47. package/packages/conversation-flow/src/__tests__/indexing.test.ts +513 -0
  48. package/packages/conversation-flow/src/__tests__/structuring.test.ts +600 -0
  49. package/packages/types/src/hotkey.ts +1 -0
  50. package/packages/types/src/tool/intervention.ts +38 -0
  51. package/src/app/[variants]/(main)/settings/_layout/Desktop/index.tsx +41 -8
  52. package/src/app/[variants]/(main)/settings/provider/(list)/ProviderGrid/Card.tsx +6 -4
  53. package/src/app/[variants]/(main)/settings/provider/(list)/ProviderGrid/index.tsx +16 -4
  54. package/src/app/[variants]/(main)/settings/provider/(list)/index.tsx +15 -3
  55. package/src/app/[variants]/(main)/settings/provider/detail/index.tsx +23 -15
  56. package/src/features/Conversation/MarkdownElements/remarkPlugins/createRemarkSelfClosingTagPlugin.test.ts +25 -0
  57. package/src/features/Conversation/MarkdownElements/remarkPlugins/createRemarkSelfClosingTagPlugin.ts +28 -0
  58. package/src/layout/GlobalProvider/Cmdk.tsx +470 -0
  59. package/src/layout/GlobalProvider/CmdkLazy.tsx +17 -0
  60. package/src/layout/GlobalProvider/index.tsx +2 -0
  61. package/src/locales/default/common.ts +21 -0
  62. package/src/locales/default/hotkey.ts +4 -0
  63. package/src/store/chat/agents/GeneralChatAgent.ts +22 -8
@@ -0,0 +1,335 @@
1
+ import type { SecurityBlacklistConfig } from '@lobechat/types';
2
+
3
+ /**
4
+ * Default Security Blacklist
5
+ * These rules will ALWAYS block execution and require human intervention,
6
+ * regardless of user settings (even in auto-run mode)
7
+ *
8
+ * This is the last line of defense against dangerous operations
9
+ */
10
+ export const DEFAULT_SECURITY_BLACKLIST: SecurityBlacklistConfig = [
11
+ // ==================== File System Dangers ====================
12
+ {
13
+ description: 'Recursive deletion of home directory is extremely dangerous',
14
+ match: {
15
+ command: {
16
+ pattern: 'rm.*-r.*(~|\\$HOME|/Users/[^/]+|/home/[^/]+)/?\\s*$',
17
+ type: 'regex',
18
+ },
19
+ },
20
+ },
21
+ {
22
+ description: 'Recursive deletion of root directory will destroy the system',
23
+ match: {
24
+ command: {
25
+ pattern: 'rm.*-r.*/\\s*$',
26
+ type: 'regex',
27
+ },
28
+ },
29
+ },
30
+ {
31
+ description: 'Force recursive deletion without specific target is too dangerous',
32
+ match: {
33
+ command: {
34
+ pattern: 'rm\\s+-rf\\s+[~./]\\s*$',
35
+ type: 'regex',
36
+ },
37
+ },
38
+ },
39
+
40
+ // ==================== System Configuration Dangers ====================
41
+ {
42
+ description: 'Modifying /etc/passwd could lock you out of the system',
43
+ match: {
44
+ command: {
45
+ pattern: '.*(/etc/passwd|/etc/shadow).*',
46
+ type: 'regex',
47
+ },
48
+ },
49
+ },
50
+ {
51
+ description: 'Modifying sudoers file without proper validation is dangerous',
52
+ match: {
53
+ command: {
54
+ pattern: '.*/etc/sudoers.*',
55
+ type: 'regex',
56
+ },
57
+ },
58
+ },
59
+
60
+ // ==================== Dangerous Commands ====================
61
+ {
62
+ description: 'Fork bomb can crash the system',
63
+ match: {
64
+ command: {
65
+ pattern: '.*:\\(\\).*\\{.*\\|.*&.*\\};.*:.*',
66
+ type: 'regex',
67
+ },
68
+ },
69
+ },
70
+ {
71
+ description: 'Writing random data to disk devices can destroy data',
72
+ match: {
73
+ command: {
74
+ pattern: 'dd.*of=/dev/(sd|hd|nvme).*',
75
+ type: 'regex',
76
+ },
77
+ },
78
+ },
79
+ {
80
+ description: 'Formatting system partitions will destroy data',
81
+ match: {
82
+ command: {
83
+ pattern: '(mkfs|fdisk|parted).*(/dev/(sd|hd|nvme)|/)',
84
+ type: 'regex',
85
+ },
86
+ },
87
+ },
88
+
89
+ // ==================== Network & Remote Access Dangers ====================
90
+ {
91
+ description: 'Disabling firewall exposes system to attacks',
92
+ match: {
93
+ command: {
94
+ pattern: '(ufw\\s+disable|iptables\\s+-F|systemctl\\s+stop\\s+firewalld)',
95
+ type: 'regex',
96
+ },
97
+ },
98
+ },
99
+ {
100
+ description: 'Changing SSH configuration could lock you out',
101
+ match: {
102
+ command: {
103
+ pattern: '.*(/etc/ssh/sshd_config).*',
104
+ type: 'regex',
105
+ },
106
+ },
107
+ },
108
+
109
+ // ==================== Package Manager Dangers ====================
110
+ {
111
+ description: 'Removing essential system packages can break the system',
112
+ match: {
113
+ command: {
114
+ pattern: '(apt|yum|dnf|pacman)\\s+(remove|purge|erase).*(systemd|kernel|glibc|bash|sudo)',
115
+ type: 'regex',
116
+ },
117
+ },
118
+ },
119
+
120
+ // ==================== Kernel & System Core Dangers ====================
121
+ {
122
+ description: 'Modifying kernel parameters without understanding can crash the system',
123
+ match: {
124
+ command: {
125
+ pattern: 'echo.*>/proc/sys/.*',
126
+ type: 'regex',
127
+ },
128
+ },
129
+ },
130
+ {
131
+ description: 'Direct memory access is extremely dangerous',
132
+ match: {
133
+ command: {
134
+ pattern: '.*(/dev/(mem|kmem|port)).*',
135
+ type: 'regex',
136
+ },
137
+ },
138
+ },
139
+
140
+ // ==================== Privilege Escalation Dangers ====================
141
+ {
142
+ description: 'Changing file ownership of system directories is dangerous',
143
+ match: {
144
+ command: {
145
+ pattern: 'chown.*-R.*(/(etc|bin|sbin|usr|var|sys|proc)|~).*',
146
+ type: 'regex',
147
+ },
148
+ },
149
+ },
150
+ {
151
+ description: 'Setting SUID on shells or interpreters is a security risk',
152
+ match: {
153
+ command: {
154
+ pattern: 'chmod.*(4755|u\\+s).*(sh|bash|python|perl|ruby|node)',
155
+ type: 'regex',
156
+ },
157
+ },
158
+ },
159
+
160
+ // ==================== Sensitive Information Leakage ====================
161
+ {
162
+ description: 'Reading .env files may leak sensitive credentials and API keys',
163
+ match: {
164
+ command: {
165
+ pattern: '(cat|less|more|head|tail|vim|nano|vi|emacs|code).*\\.env.*',
166
+ type: 'regex',
167
+ },
168
+ },
169
+ },
170
+ {
171
+ description: 'Reading .env files may leak sensitive credentials and API keys',
172
+ match: {
173
+ path: {
174
+ pattern: '.*\\.env.*',
175
+ type: 'regex',
176
+ },
177
+ },
178
+ },
179
+ {
180
+ description: 'Reading SSH private keys can compromise system security',
181
+ match: {
182
+ command: {
183
+ pattern:
184
+ '(cat|less|more|head|tail|vim|nano|vi|emacs|code).*(id_rsa|id_ed25519|id_ecdsa)(?!\\.pub).*',
185
+ type: 'regex',
186
+ },
187
+ },
188
+ },
189
+ {
190
+ description: 'Reading SSH private keys can compromise system security',
191
+ match: {
192
+ path: {
193
+ pattern: '.*/\\.ssh/(id_rsa|id_ed25519|id_ecdsa)$',
194
+ type: 'regex',
195
+ },
196
+ },
197
+ },
198
+ {
199
+ description: 'Accessing AWS credentials can leak cloud access keys',
200
+ match: {
201
+ command: {
202
+ pattern: '(cat|less|more|head|tail|vim|nano|vi|emacs|code).*/\\.aws/credentials.*',
203
+ type: 'regex',
204
+ },
205
+ },
206
+ },
207
+ {
208
+ description: 'Accessing AWS credentials can leak cloud access keys',
209
+ match: {
210
+ path: {
211
+ pattern: '.*/\\.aws/credentials.*',
212
+ type: 'regex',
213
+ },
214
+ },
215
+ },
216
+ {
217
+ description: 'Reading Docker config may expose registry credentials',
218
+ match: {
219
+ command: {
220
+ pattern: '(cat|less|more|head|tail|vim|nano|vi|emacs|code).*/\\.docker/config\\.json.*',
221
+ type: 'regex',
222
+ },
223
+ },
224
+ },
225
+ {
226
+ description: 'Reading Docker config may expose registry credentials',
227
+ match: {
228
+ path: {
229
+ pattern: '.*/\\.docker/config\\.json$',
230
+ type: 'regex',
231
+ },
232
+ },
233
+ },
234
+ {
235
+ description: 'Reading Kubernetes config may expose cluster credentials',
236
+ match: {
237
+ command: {
238
+ pattern: '(cat|less|more|head|tail|vim|nano|vi|emacs|code).*/\\.kube/config.*',
239
+ type: 'regex',
240
+ },
241
+ },
242
+ },
243
+ {
244
+ description: 'Reading Kubernetes config may expose cluster credentials',
245
+ match: {
246
+ path: {
247
+ pattern: '.*/\\.kube/config$',
248
+ type: 'regex',
249
+ },
250
+ },
251
+ },
252
+ {
253
+ description: 'Reading Git credentials file may leak access tokens',
254
+ match: {
255
+ command: {
256
+ pattern: '(cat|less|more|head|tail|vim|nano|vi|emacs|code).*/\\.git-credentials.*',
257
+ type: 'regex',
258
+ },
259
+ },
260
+ },
261
+ {
262
+ description: 'Reading Git credentials file may leak access tokens',
263
+ match: {
264
+ path: {
265
+ pattern: '.*/\\.git-credentials$',
266
+ type: 'regex',
267
+ },
268
+ },
269
+ },
270
+ {
271
+ description: 'Reading npm token file may expose package registry credentials',
272
+ match: {
273
+ command: {
274
+ pattern: '(cat|less|more|head|tail|vim|nano|vi|emacs|code).*/\\.npmrc.*',
275
+ type: 'regex',
276
+ },
277
+ },
278
+ },
279
+ {
280
+ description: 'Reading npm token file may expose package registry credentials',
281
+ match: {
282
+ path: {
283
+ pattern: '.*/\\.npmrc$',
284
+ type: 'regex',
285
+ },
286
+ },
287
+ },
288
+ {
289
+ description: 'Reading history files may expose sensitive commands and credentials',
290
+ match: {
291
+ command: {
292
+ pattern:
293
+ '(cat|less|more|head|tail|vim|nano|vi|emacs|code).*/\\.(bash_history|zsh_history|history).*',
294
+ type: 'regex',
295
+ },
296
+ },
297
+ },
298
+ {
299
+ description: 'Reading history files may expose sensitive commands and credentials',
300
+ match: {
301
+ path: {
302
+ pattern: '.*/\\.(bash_history|zsh_history|history)$',
303
+ type: 'regex',
304
+ },
305
+ },
306
+ },
307
+ {
308
+ description: 'Accessing browser credential storage may leak passwords',
309
+ match: {
310
+ command: {
311
+ pattern:
312
+ '(cat|less|more|head|tail|vim|nano|vi|emacs|code).*(Cookies|Login Data|Web Data).*',
313
+ type: 'regex',
314
+ },
315
+ },
316
+ },
317
+ {
318
+ description: 'Reading GCP credentials may leak cloud service account keys',
319
+ match: {
320
+ command: {
321
+ pattern: '(cat|less|more|head|tail|vim|nano|vi|emacs|code).*/\\.config/gcloud/.*\\.json.*',
322
+ type: 'regex',
323
+ },
324
+ },
325
+ },
326
+ {
327
+ description: 'Reading GCP credentials may leak cloud service account keys',
328
+ match: {
329
+ path: {
330
+ pattern: '.*/\\.config/gcloud/.*\\.json$',
331
+ type: 'regex',
332
+ },
333
+ },
334
+ },
335
+ ];
@@ -1,3 +1,4 @@
1
+ export * from './defaultSecurityBlacklist';
1
2
  export * from './InterventionChecker';
2
3
  export * from './runtime';
3
4
  export * from './UsageCounter';
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable sort-keys-fix/sort-keys-fix, typescript-sort-keys/interface */
2
- import { ChatToolPayload, UserInterventionConfig } from '@lobechat/types';
2
+ import { ChatToolPayload, SecurityBlacklistConfig, UserInterventionConfig } from '@lobechat/types';
3
3
 
4
4
  import type { Cost, CostLimit, Usage } from './usage';
5
5
 
@@ -23,6 +23,15 @@ export interface AgentState {
23
23
  * Controls how tools requiring approval are handled
24
24
  */
25
25
  userInterventionConfig?: UserInterventionConfig;
26
+
27
+ /**
28
+ * Security blacklist configuration
29
+ * These rules will ALWAYS block execution and require human intervention,
30
+ * regardless of user settings (even in auto-run mode).
31
+ * If not provided, DEFAULT_SECURITY_BLACKLIST will be used.
32
+ */
33
+ securityBlacklist?: SecurityBlacklistConfig;
34
+
26
35
  // --- Execution Tracking ---
27
36
  /**
28
37
  * Number of execution steps in this session.
@@ -15,6 +15,12 @@ export type HotkeyRegistration = HotkeyItem[];
15
15
  // mod is the command key on Mac, alt is the ctrl key on Windows
16
16
  export const HOTKEYS_REGISTRATION: HotkeyRegistration = [
17
17
  // basic
18
+ {
19
+ group: HotkeyGroupEnum.Essential,
20
+ id: HotkeyEnum.CommandPalette,
21
+ keys: combineKeys([KeyEnum.Mod, 'j']),
22
+ scopes: [HotkeyScopeEnum.Global],
23
+ },
18
24
  {
19
25
  group: HotkeyGroupEnum.Essential,
20
26
  id: HotkeyEnum.Search,