@lobehub/lobehub 2.0.0-next.50 → 2.0.0-next.51

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 (118) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/apps/desktop/src/main/controllers/ShellCommandCtr.ts +242 -0
  3. package/apps/desktop/src/main/controllers/__tests__/ShellCommandCtr.test.ts +499 -0
  4. package/changelog/v1.json +9 -0
  5. package/locales/ar/chat.json +20 -0
  6. package/locales/ar/common.json +1 -0
  7. package/locales/ar/components.json +6 -0
  8. package/locales/ar/plugin.json +1 -0
  9. package/locales/bg-BG/chat.json +20 -0
  10. package/locales/bg-BG/common.json +1 -0
  11. package/locales/bg-BG/components.json +6 -0
  12. package/locales/bg-BG/plugin.json +1 -0
  13. package/locales/de-DE/chat.json +20 -0
  14. package/locales/de-DE/common.json +1 -0
  15. package/locales/de-DE/components.json +6 -0
  16. package/locales/de-DE/plugin.json +1 -0
  17. package/locales/en-US/chat.json +20 -0
  18. package/locales/en-US/common.json +1 -0
  19. package/locales/en-US/components.json +6 -0
  20. package/locales/en-US/plugin.json +1 -0
  21. package/locales/es-ES/chat.json +20 -0
  22. package/locales/es-ES/common.json +1 -0
  23. package/locales/es-ES/components.json +6 -0
  24. package/locales/es-ES/plugin.json +1 -0
  25. package/locales/fa-IR/chat.json +20 -0
  26. package/locales/fa-IR/common.json +1 -0
  27. package/locales/fa-IR/components.json +6 -0
  28. package/locales/fa-IR/plugin.json +1 -0
  29. package/locales/fr-FR/chat.json +20 -0
  30. package/locales/fr-FR/common.json +1 -0
  31. package/locales/fr-FR/components.json +6 -0
  32. package/locales/fr-FR/plugin.json +1 -0
  33. package/locales/it-IT/chat.json +20 -0
  34. package/locales/it-IT/common.json +1 -0
  35. package/locales/it-IT/components.json +6 -0
  36. package/locales/it-IT/plugin.json +1 -0
  37. package/locales/ja-JP/chat.json +20 -0
  38. package/locales/ja-JP/common.json +1 -0
  39. package/locales/ja-JP/components.json +6 -0
  40. package/locales/ja-JP/plugin.json +1 -0
  41. package/locales/ko-KR/chat.json +20 -0
  42. package/locales/ko-KR/common.json +1 -0
  43. package/locales/ko-KR/components.json +6 -0
  44. package/locales/ko-KR/plugin.json +1 -0
  45. package/locales/nl-NL/chat.json +20 -0
  46. package/locales/nl-NL/common.json +1 -0
  47. package/locales/nl-NL/components.json +6 -0
  48. package/locales/nl-NL/plugin.json +1 -0
  49. package/locales/pl-PL/chat.json +20 -0
  50. package/locales/pl-PL/common.json +1 -0
  51. package/locales/pl-PL/components.json +6 -0
  52. package/locales/pl-PL/plugin.json +1 -0
  53. package/locales/pt-BR/chat.json +20 -0
  54. package/locales/pt-BR/common.json +1 -0
  55. package/locales/pt-BR/components.json +6 -0
  56. package/locales/pt-BR/plugin.json +1 -0
  57. package/locales/ru-RU/chat.json +20 -0
  58. package/locales/ru-RU/common.json +1 -0
  59. package/locales/ru-RU/components.json +6 -0
  60. package/locales/ru-RU/plugin.json +1 -0
  61. package/locales/tr-TR/chat.json +20 -0
  62. package/locales/tr-TR/common.json +1 -0
  63. package/locales/tr-TR/components.json +6 -0
  64. package/locales/tr-TR/plugin.json +1 -0
  65. package/locales/vi-VN/chat.json +20 -0
  66. package/locales/vi-VN/common.json +1 -0
  67. package/locales/vi-VN/components.json +6 -0
  68. package/locales/vi-VN/plugin.json +1 -0
  69. package/locales/zh-CN/chat.json +20 -0
  70. package/locales/zh-CN/common.json +1 -0
  71. package/locales/zh-CN/components.json +6 -0
  72. package/locales/zh-CN/plugin.json +1 -0
  73. package/locales/zh-TW/chat.json +20 -0
  74. package/locales/zh-TW/common.json +1 -0
  75. package/locales/zh-TW/components.json +6 -0
  76. package/locales/zh-TW/plugin.json +1 -0
  77. package/package.json +1 -1
  78. package/packages/agent-runtime/src/core/InterventionChecker.ts +1 -1
  79. package/packages/agent-runtime/src/core/__tests__/InterventionChecker.test.ts +23 -23
  80. package/packages/agent-runtime/src/types/state.ts +7 -1
  81. package/packages/const/src/settings/tool.ts +1 -5
  82. package/packages/file-loaders/src/loaders/docx/index.ts +1 -1
  83. package/packages/model-bank/src/aiModels/wenxin.ts +1348 -291
  84. package/packages/model-runtime/src/providers/wenxin/index.ts +22 -1
  85. package/packages/model-runtime/src/utils/modelParse.ts +6 -0
  86. package/packages/types/src/tool/builtin.ts +9 -0
  87. package/packages/types/src/tool/intervention.ts +32 -2
  88. package/packages/types/src/user/settings/tool.ts +3 -27
  89. package/src/config/modelProviders/wenxin.ts +2 -3
  90. package/src/features/Conversation/MarkdownElements/remarkPlugins/__snapshots__/createRemarkSelfClosingTagPlugin.test.ts.snap +133 -0
  91. package/src/features/Conversation/MarkdownElements/remarkPlugins/createRemarkSelfClosingTagPlugin.test.ts +48 -0
  92. package/src/features/Conversation/MarkdownElements/remarkPlugins/createRemarkSelfClosingTagPlugin.ts +2 -1
  93. package/src/features/Conversation/Messages/Group/Tool/Render/Intervention/Fallback.tsx +98 -0
  94. package/src/features/Conversation/Messages/Group/Tool/Render/Intervention/ModeSelector.tsx +5 -6
  95. package/src/features/Conversation/Messages/Group/Tool/Render/Intervention/index.tsx +40 -36
  96. package/src/features/Conversation/Messages/Group/Tool/Render/index.tsx +25 -18
  97. package/src/features/LocalFile/LocalFile.tsx +55 -5
  98. package/src/locales/default/components.ts +6 -0
  99. package/src/locales/default/plugin.ts +1 -0
  100. package/src/services/electron/localFileService.ts +4 -0
  101. package/src/store/chat/agents/GeneralChatAgent.ts +26 -1
  102. package/src/store/chat/agents/__tests__/GeneralChatAgent.test.ts +173 -0
  103. package/src/store/chat/slices/aiChat/actions/conversationControl.ts +8 -40
  104. package/src/store/chat/slices/aiChat/actions/streamingExecutor.ts +91 -34
  105. package/src/store/user/selectors.ts +1 -0
  106. package/src/store/user/slices/settings/action.ts +12 -0
  107. package/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snap +0 -7
  108. package/src/store/user/slices/settings/selectors/index.ts +1 -0
  109. package/src/store/user/slices/settings/selectors/settings.test.ts +0 -37
  110. package/src/store/user/slices/settings/selectors/settings.ts +0 -5
  111. package/src/store/user/slices/settings/selectors/toolIntervention.ts +17 -0
  112. package/src/tools/interventions.ts +8 -0
  113. package/src/tools/local-system/Intervention/RunCommand/index.tsx +56 -0
  114. package/src/tools/local-system/Intervention/index.tsx +17 -0
  115. package/src/tools/local-system/Render/RunCommand/index.tsx +100 -21
  116. package/src/tools/local-system/Render/index.tsx +2 -0
  117. package/src/tools/local-system/index.ts +180 -0
  118. package/src/tools/local-system/systemRole.ts +61 -7
@@ -135,6 +135,7 @@
135
135
  }
136
136
  },
137
137
  "close": "Закрыть",
138
+ "confirm": "Подтвердить",
138
139
  "contact": "Свяжитесь с нами",
139
140
  "copy": "Копировать",
140
141
  "copyFail": "Не удалось скопировать",
@@ -106,6 +106,12 @@
106
106
  "keyPlaceholder": "Ключ",
107
107
  "valuePlaceholder": "Значение"
108
108
  },
109
+ "LocalFile": {
110
+ "action": {
111
+ "open": "Открыть",
112
+ "showInFolder": "Показать в папке"
113
+ }
114
+ },
109
115
  "MaxTokenSlider": {
110
116
  "unlimited": "Без ограничений"
111
117
  },
@@ -255,6 +255,7 @@
255
255
  "moveLocalFiles": "Перемещение файлов",
256
256
  "readLocalFile": "Чтение содержимого файла",
257
257
  "renameLocalFile": "Переименование",
258
+ "runCommand": "Выполнить код",
258
259
  "searchLocalFiles": "Поиск файлов",
259
260
  "writeLocalFile": "Запись в файл"
260
261
  },
@@ -369,6 +369,26 @@
369
369
  "remained": "Kalan",
370
370
  "used": "Kullanılan"
371
371
  },
372
+ "tool": {
373
+ "intervention": {
374
+ "approve": "Onayla",
375
+ "approveAndRemember": "Onayla ve Hatırla",
376
+ "approveOnce": "Sadece Bu Sefer Onayla",
377
+ "mode": {
378
+ "allowList": "Beyaz Liste",
379
+ "allowListDesc": "Yalnızca onaylanmış araçlar otomatik olarak çalıştırılır",
380
+ "autoRun": "Otomatik Onay",
381
+ "autoRunDesc": "Tüm araçların çalıştırılmasını otomatik olarak onayla",
382
+ "manual": "Manuel",
383
+ "manualDesc": "Her çağrı için manuel onay gerekir"
384
+ },
385
+ "reject": "Reddet",
386
+ "rejectReasonPlaceholder": "Reddetme nedenini girmek, Agent'ın anlamasına ve sonraki eylemleri iyileştirmesine yardımcı olur",
387
+ "rejectTitle": "Bu Araç Çağrısını Reddet",
388
+ "rejectedWithReason": "Bu araç çağrısı şu nedenle reddedildi: {{reason}}",
389
+ "toolRejected": "Bu araç çağrısı kullanıcı tarafından reddedildi"
390
+ }
391
+ },
372
392
  "topic": {
373
393
  "checkOpenNewTopic": "Yeni bir konu açılsın mı?",
374
394
  "checkSaveCurrentMessages": "Mevcut sohbeti konu olarak kaydetmek istiyor musunuz?",
@@ -135,6 +135,7 @@
135
135
  }
136
136
  },
137
137
  "close": "Kapat",
138
+ "confirm": "Onayla",
138
139
  "contact": "Bize Ulaşın",
139
140
  "copy": "Kopyala",
140
141
  "copyFail": "Kopyalama başarısız oldu",
@@ -106,6 +106,12 @@
106
106
  "keyPlaceholder": "Anahtar",
107
107
  "valuePlaceholder": "Değer"
108
108
  },
109
+ "LocalFile": {
110
+ "action": {
111
+ "open": "Aç",
112
+ "showInFolder": "Klasörde Göster"
113
+ }
114
+ },
109
115
  "MaxTokenSlider": {
110
116
  "unlimited": "Sınırsız"
111
117
  },
@@ -255,6 +255,7 @@
255
255
  "moveLocalFiles": "Dosya taşı",
256
256
  "readLocalFile": "Dosya içeriğini oku",
257
257
  "renameLocalFile": "Dosya adını değiştir",
258
+ "runCommand": "Komutu Çalıştır",
258
259
  "searchLocalFiles": "Dosya ara",
259
260
  "writeLocalFile": "Dosyaya yaz"
260
261
  },
@@ -369,6 +369,26 @@
369
369
  "remained": "Còn lại",
370
370
  "used": "Đã sử dụng"
371
371
  },
372
+ "tool": {
373
+ "intervention": {
374
+ "approve": "Phê duyệt",
375
+ "approveAndRemember": "Phê duyệt và ghi nhớ",
376
+ "approveOnce": "Chỉ phê duyệt lần này",
377
+ "mode": {
378
+ "allowList": "Danh sách cho phép",
379
+ "allowListDesc": "Chỉ tự động thực thi các công cụ đã được phê duyệt",
380
+ "autoRun": "Tự động phê duyệt",
381
+ "autoRunDesc": "Tự động phê duyệt tất cả các công cụ thực thi",
382
+ "manual": "Thủ công",
383
+ "manualDesc": "Mỗi lần gọi đều cần phê duyệt thủ công"
384
+ },
385
+ "reject": "Từ chối",
386
+ "rejectReasonPlaceholder": "Nhập lý do từ chối sẽ giúp Agent hiểu và cải thiện hành động sau này",
387
+ "rejectTitle": "Từ chối lần gọi công cụ này",
388
+ "rejectedWithReason": "Lần gọi công cụ này đã bị từ chối: {{reason}}",
389
+ "toolRejected": "Lần gọi công cụ này đã bị từ chối"
390
+ }
391
+ },
372
392
  "topic": {
373
393
  "checkOpenNewTopic": "Có muốn mở chủ đề mới không?",
374
394
  "checkSaveCurrentMessages": "Bạn có muốn lưu cuộc trò chuyện hiện tại thành chủ đề không?",
@@ -135,6 +135,7 @@
135
135
  }
136
136
  },
137
137
  "close": "Đóng",
138
+ "confirm": "Xác nhận",
138
139
  "contact": "Liên hệ chúng tôi",
139
140
  "copy": "Sao chép",
140
141
  "copyFail": "Sao chép thất bại",
@@ -106,6 +106,12 @@
106
106
  "keyPlaceholder": "Khóa",
107
107
  "valuePlaceholder": "Giá trị"
108
108
  },
109
+ "LocalFile": {
110
+ "action": {
111
+ "open": "Mở",
112
+ "showInFolder": "Hiển thị trong thư mục"
113
+ }
114
+ },
109
115
  "MaxTokenSlider": {
110
116
  "unlimited": "Không giới hạn"
111
117
  },
@@ -255,6 +255,7 @@
255
255
  "moveLocalFiles": "Di chuyển tệp",
256
256
  "readLocalFile": "Đọc nội dung tệp",
257
257
  "renameLocalFile": "Đổi tên",
258
+ "runCommand": "Chạy mã",
258
259
  "searchLocalFiles": "Tìm kiếm tệp",
259
260
  "writeLocalFile": "Ghi tệp"
260
261
  },
@@ -369,6 +369,26 @@
369
369
  "remained": "剩余",
370
370
  "used": "使用"
371
371
  },
372
+ "tool": {
373
+ "intervention": {
374
+ "approve": "批准",
375
+ "approveAndRemember": "批准并记住",
376
+ "approveOnce": "仅本次批准",
377
+ "mode": {
378
+ "allowList": "白名单",
379
+ "allowListDesc": "仅自动执行已批准的工具",
380
+ "autoRun": "自动批准",
381
+ "autoRunDesc": "自动批准所有工具执行",
382
+ "manual": "手动",
383
+ "manualDesc": "每次调用都需要手动批准"
384
+ },
385
+ "reject": "拒绝",
386
+ "rejectReasonPlaceholder": "输入拒绝原因将帮助 Agent 理解并优化后续行动",
387
+ "rejectTitle": "拒绝本次工具调用",
388
+ "rejectedWithReason": "本次工具调用被主动拒绝:{{reason}}",
389
+ "toolRejected": "本次工具调用被主动拒绝"
390
+ }
391
+ },
372
392
  "topic": {
373
393
  "checkOpenNewTopic": "是否开启新话题?",
374
394
  "checkSaveCurrentMessages": "是否保存当前会话为话题?",
@@ -135,6 +135,7 @@
135
135
  }
136
136
  },
137
137
  "close": "关闭",
138
+ "confirm": "确认",
138
139
  "contact": "联系我们",
139
140
  "copy": "复制",
140
141
  "copyFail": "复制失败",
@@ -106,6 +106,12 @@
106
106
  "keyPlaceholder": "键",
107
107
  "valuePlaceholder": "值"
108
108
  },
109
+ "LocalFile": {
110
+ "action": {
111
+ "open": "打开",
112
+ "showInFolder": "在文件夹中显示"
113
+ }
114
+ },
109
115
  "MaxTokenSlider": {
110
116
  "unlimited": "无限制"
111
117
  },
@@ -255,6 +255,7 @@
255
255
  "moveLocalFiles": "移动文件",
256
256
  "readLocalFile": "读取文件内容",
257
257
  "renameLocalFile": "重命名",
258
+ "runCommand": "执行代码",
258
259
  "searchLocalFiles": "搜索文件",
259
260
  "writeLocalFile": "写入文件"
260
261
  },
@@ -369,6 +369,26 @@
369
369
  "remained": "剩餘",
370
370
  "used": "使用"
371
371
  },
372
+ "tool": {
373
+ "intervention": {
374
+ "approve": "批准",
375
+ "approveAndRemember": "批准並記住",
376
+ "approveOnce": "僅本次批准",
377
+ "mode": {
378
+ "allowList": "白名單",
379
+ "allowListDesc": "僅自動執行已批准的工具",
380
+ "autoRun": "自動批准",
381
+ "autoRunDesc": "自動批准所有工具執行",
382
+ "manual": "手動",
383
+ "manualDesc": "每次調用都需要手動批准"
384
+ },
385
+ "reject": "拒絕",
386
+ "rejectReasonPlaceholder": "輸入拒絕原因將幫助 Agent 理解並優化後續行動",
387
+ "rejectTitle": "拒絕本次工具調用",
388
+ "rejectedWithReason": "本次工具調用被主動拒絕:{{reason}}",
389
+ "toolRejected": "本次工具調用被主動拒絕"
390
+ }
391
+ },
372
392
  "topic": {
373
393
  "checkOpenNewTopic": "是否開啟新主題?",
374
394
  "checkSaveCurrentMessages": "是否將當前對話保存為話題?",
@@ -135,6 +135,7 @@
135
135
  }
136
136
  },
137
137
  "close": "關閉",
138
+ "confirm": "確認",
138
139
  "contact": "聯繫我們",
139
140
  "copy": "複製",
140
141
  "copyFail": "複製失敗",
@@ -106,6 +106,12 @@
106
106
  "keyPlaceholder": "鍵",
107
107
  "valuePlaceholder": "值"
108
108
  },
109
+ "LocalFile": {
110
+ "action": {
111
+ "open": "開啟",
112
+ "showInFolder": "在資料夾中顯示"
113
+ }
114
+ },
109
115
  "MaxTokenSlider": {
110
116
  "unlimited": "無限制"
111
117
  },
@@ -255,6 +255,7 @@
255
255
  "moveLocalFiles": "移動檔案",
256
256
  "readLocalFile": "讀取檔案內容",
257
257
  "renameLocalFile": "重新命名",
258
+ "runCommand": "執行程式碼",
258
259
  "searchLocalFiles": "搜尋檔案",
259
260
  "writeLocalFile": "寫入檔案"
260
261
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/lobehub",
3
- "version": "2.0.0-next.50",
3
+ "version": "2.0.0-next.51",
4
4
  "description": "LobeHub - an open-source,comprehensive AI Agent framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -35,7 +35,7 @@ export class InterventionChecker {
35
35
  }
36
36
 
37
37
  // No rule matched - default to require for safety
38
- return 'require';
38
+ return 'required';
39
39
  }
40
40
 
41
41
  /**
@@ -12,16 +12,16 @@ describe('InterventionChecker', () => {
12
12
 
13
13
  it('should return the policy when config is a simple string', () => {
14
14
  expect(InterventionChecker.shouldIntervene({ config: 'never', toolArgs: {} })).toBe('never');
15
- expect(InterventionChecker.shouldIntervene({ config: 'require', toolArgs: {} })).toBe(
16
- 'require',
15
+ expect(InterventionChecker.shouldIntervene({ config: 'required', toolArgs: {} })).toBe(
16
+ 'required',
17
17
  );
18
18
  });
19
19
 
20
20
  it('should match rules in order and return first match', () => {
21
21
  const config: HumanInterventionConfig = [
22
22
  { match: { command: 'ls:*' }, policy: 'never' },
23
- { match: { command: 'git commit:*' }, policy: 'require' },
24
- { policy: 'require' }, // Default rule
23
+ { match: { command: 'git commit:*' }, policy: 'required' },
24
+ { policy: 'required' }, // Default rule
25
25
  ];
26
26
 
27
27
  expect(InterventionChecker.shouldIntervene({ config, toolArgs: { command: 'ls:' } })).toBe(
@@ -29,10 +29,10 @@ describe('InterventionChecker', () => {
29
29
  );
30
30
  expect(
31
31
  InterventionChecker.shouldIntervene({ config, toolArgs: { command: 'git commit:' } }),
32
- ).toBe('require');
32
+ ).toBe('required');
33
33
  expect(
34
34
  InterventionChecker.shouldIntervene({ config, toolArgs: { command: 'rm -rf /' } }),
35
- ).toBe('require');
35
+ ).toBe('required');
36
36
  });
37
37
 
38
38
  it('should return require as default when no rule matches', () => {
@@ -42,7 +42,7 @@ describe('InterventionChecker', () => {
42
42
  config,
43
43
  toolArgs: { command: 'rm -rf /' },
44
44
  });
45
- expect(result).toBe('require');
45
+ expect(result).toBe('required');
46
46
  });
47
47
 
48
48
  it('should handle multiple parameter matching', () => {
@@ -54,7 +54,7 @@ describe('InterventionChecker', () => {
54
54
  },
55
55
  policy: 'never',
56
56
  },
57
- { policy: 'require' },
57
+ { policy: 'required' },
58
58
  ];
59
59
 
60
60
  // Both match
@@ -77,20 +77,20 @@ describe('InterventionChecker', () => {
77
77
  path: '/tmp/file.ts',
78
78
  },
79
79
  }),
80
- ).toBe('require');
80
+ ).toBe('required');
81
81
  });
82
82
 
83
83
  it('should handle default rule without match', () => {
84
84
  const config: HumanInterventionConfig = [
85
85
  { match: { command: 'ls:*' }, policy: 'never' },
86
- { policy: 'require' }, // Default rule
86
+ { policy: 'required' }, // Default rule
87
87
  ];
88
88
 
89
89
  const result = InterventionChecker.shouldIntervene({
90
90
  config,
91
91
  toolArgs: { command: 'anything' },
92
92
  });
93
- expect(result).toBe('require');
93
+ expect(result).toBe('required');
94
94
  });
95
95
  });
96
96
 
@@ -222,10 +222,10 @@ describe('InterventionChecker', () => {
222
222
  it('should handle Bash tool scenario', () => {
223
223
  const config: HumanInterventionConfig = [
224
224
  { match: { command: 'ls:*' }, policy: 'never' },
225
- { match: { command: 'git add:*' }, policy: 'require' },
226
- { match: { command: 'git commit:*' }, policy: 'require' },
227
- { match: { command: 'rm:*' }, policy: 'require' },
228
- { policy: 'require' },
225
+ { match: { command: 'git add:*' }, policy: 'required' },
226
+ { match: { command: 'git commit:*' }, policy: 'required' },
227
+ { match: { command: 'rm:*' }, policy: 'required' },
228
+ { policy: 'required' },
229
229
  ];
230
230
 
231
231
  // Safe commands - never
@@ -236,24 +236,24 @@ describe('InterventionChecker', () => {
236
236
  // Git commands - require
237
237
  expect(
238
238
  InterventionChecker.shouldIntervene({ config, toolArgs: { command: 'git add:.' } }),
239
- ).toBe('require');
239
+ ).toBe('required');
240
240
  expect(
241
241
  InterventionChecker.shouldIntervene({ config, toolArgs: { command: 'git commit:-m' } }),
242
- ).toBe('require');
242
+ ).toBe('required');
243
243
 
244
244
  // Dangerous commands - require
245
245
  expect(InterventionChecker.shouldIntervene({ config, toolArgs: { command: 'rm:-rf' } })).toBe(
246
- 'require',
246
+ 'required',
247
247
  );
248
248
  expect(
249
249
  InterventionChecker.shouldIntervene({ config, toolArgs: { command: 'npm install' } }),
250
- ).toBe('require');
250
+ ).toBe('required');
251
251
  });
252
252
 
253
253
  it('should handle LocalSystem tool scenario', () => {
254
254
  const config: HumanInterventionConfig = [
255
255
  { match: { path: '/Users/project/*' }, policy: 'never' },
256
- { policy: 'require' },
256
+ { policy: 'required' },
257
257
  ];
258
258
 
259
259
  // Project directory - never
@@ -267,15 +267,15 @@ describe('InterventionChecker', () => {
267
267
  // Outside project - require
268
268
  expect(
269
269
  InterventionChecker.shouldIntervene({ config, toolArgs: { path: '/tmp/file.ts' } }),
270
- ).toBe('require');
270
+ ).toBe('required');
271
271
  });
272
272
 
273
273
  it('should handle Web Browsing tool with simple policy', () => {
274
- const config: HumanInterventionConfig = 'require';
274
+ const config: HumanInterventionConfig = 'required';
275
275
 
276
276
  expect(
277
277
  InterventionChecker.shouldIntervene({ config, toolArgs: { url: 'https://example.com' } }),
278
- ).toBe('require');
278
+ ).toBe('required');
279
279
  });
280
280
  });
281
281
  });
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable sort-keys-fix/sort-keys-fix, typescript-sort-keys/interface */
2
- import { ChatToolPayload } from '@/types/message';
2
+ import { ChatToolPayload, UserInterventionConfig } from '@lobechat/types';
3
3
 
4
4
  import type { Cost, CostLimit, Usage } from './usage';
5
5
 
@@ -17,6 +17,12 @@ export interface AgentState {
17
17
  tools?: any[];
18
18
  systemRole?: string;
19
19
  toolManifestMap: Record<string, any>;
20
+
21
+ /**
22
+ * User's global intervention configuration
23
+ * Controls how tools requiring approval are handled
24
+ */
25
+ userInterventionConfig?: UserInterventionConfig;
20
26
  // --- Execution Tracking ---
21
27
  /**
22
28
  * Number of execution steps in this session.
@@ -1,5 +1 @@
1
- export const DEFAULT_TOOL_CONFIG = {
2
- dalle: {
3
- autoGenerate: false,
4
- },
5
- };
1
+ export const DEFAULT_TOOL_CONFIG = {};
@@ -1,6 +1,6 @@
1
1
  import debug from 'debug';
2
- import fs from 'node:fs/promises';
3
2
  import mammoth from 'mammoth';
3
+ import fs from 'node:fs/promises';
4
4
 
5
5
  import type { DocumentPage, FileLoaderInterface } from '../../types';
6
6