tabby-ai-assistant 1.0.0
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 +232 -0
- package/dist/components/chat/chat-input.component.d.ts +65 -0
- package/dist/components/chat/chat-interface.component.d.ts +71 -0
- package/dist/components/chat/chat-message.component.d.ts +53 -0
- package/dist/components/chat/chat-settings.component.d.ts +62 -0
- package/dist/components/common/error-message.component.d.ts +11 -0
- package/dist/components/common/loading-spinner.component.d.ts +4 -0
- package/dist/components/security/consent-dialog.component.d.ts +11 -0
- package/dist/components/security/password-prompt.component.d.ts +10 -0
- package/dist/components/security/risk-confirm-dialog.component.d.ts +36 -0
- package/dist/components/settings/ai-settings-tab.component.d.ts +72 -0
- package/dist/components/settings/general-settings.component.d.ts +60 -0
- package/dist/components/settings/provider-config.component.d.ts +182 -0
- package/dist/components/settings/security-settings.component.d.ts +23 -0
- package/dist/components/terminal/ai-toolbar-button.component.d.ts +10 -0
- package/dist/components/terminal/command-preview.component.d.ts +15 -0
- package/dist/components/terminal/command-suggestion.component.d.ts +16 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +2 -0
- package/dist/index.js.LICENSE.txt +18 -0
- package/dist/main.d.ts +8 -0
- package/dist/providers/tabby/ai-config.provider.d.ts +18 -0
- package/dist/providers/tabby/ai-hotkey.provider.d.ts +21 -0
- package/dist/providers/tabby/ai-settings-tab.provider.d.ts +11 -0
- package/dist/providers/tabby/ai-toolbar-button.provider.d.ts +17 -0
- package/dist/services/chat/chat-history.service.d.ts +67 -0
- package/dist/services/chat/chat-session.service.d.ts +58 -0
- package/dist/services/chat/command-generator.service.d.ts +49 -0
- package/dist/services/core/ai-assistant.service.d.ts +88 -0
- package/dist/services/core/ai-provider-manager.service.d.ts +119 -0
- package/dist/services/core/config-provider.service.d.ts +137 -0
- package/dist/services/core/logger.service.d.ts +21 -0
- package/dist/services/providers/anthropic-provider.service.d.ts +39 -0
- package/dist/services/providers/base-provider.service.d.ts +137 -0
- package/dist/services/providers/glm-provider.service.d.ts +91 -0
- package/dist/services/providers/minimax-provider.service.d.ts +93 -0
- package/dist/services/providers/openai-compatible.service.d.ts +39 -0
- package/dist/services/providers/openai-provider.service.d.ts +38 -0
- package/dist/services/security/consent-manager.service.d.ts +65 -0
- package/dist/services/security/password-manager.service.d.ts +67 -0
- package/dist/services/security/risk-assessment.service.d.ts +65 -0
- package/dist/services/security/security-validator.service.d.ts +36 -0
- package/dist/services/terminal/command-analyzer.service.d.ts +20 -0
- package/dist/services/terminal/context-menu.service.d.ts +24 -0
- package/dist/services/terminal/hotkey.service.d.ts +28 -0
- package/dist/services/terminal/terminal-context.service.d.ts +100 -0
- package/dist/types/ai.types.d.ts +107 -0
- package/dist/types/provider.types.d.ts +105 -0
- package/dist/types/security.types.d.ts +85 -0
- package/dist/types/terminal.types.d.ts +150 -0
- package/dist/utils/encryption.utils.d.ts +83 -0
- package/dist/utils/formatting.utils.d.ts +106 -0
- package/dist/utils/validation.utils.d.ts +83 -0
- package/integration-test-output.txt +50 -0
- package/integration-tests/api-integration.test.ts +183 -0
- package/jest.config.js +47 -0
- package/package.json +73 -0
- package/setup-jest.ts +37 -0
- package/src/components/chat/chat-input.component.html +61 -0
- package/src/components/chat/chat-input.component.scss +183 -0
- package/src/components/chat/chat-input.component.ts +149 -0
- package/src/components/chat/chat-interface.component.html +119 -0
- package/src/components/chat/chat-interface.component.scss +354 -0
- package/src/components/chat/chat-interface.component.ts +224 -0
- package/src/components/chat/chat-message.component.html +65 -0
- package/src/components/chat/chat-message.component.scss +178 -0
- package/src/components/chat/chat-message.component.ts +93 -0
- package/src/components/chat/chat-settings.component.html +132 -0
- package/src/components/chat/chat-settings.component.scss +172 -0
- package/src/components/chat/chat-settings.component.ts +168 -0
- package/src/components/common/error-message.component.ts +124 -0
- package/src/components/common/loading-spinner.component.ts +72 -0
- package/src/components/security/consent-dialog.component.ts +77 -0
- package/src/components/security/password-prompt.component.ts +79 -0
- package/src/components/security/risk-confirm-dialog.component.html +87 -0
- package/src/components/security/risk-confirm-dialog.component.scss +360 -0
- package/src/components/security/risk-confirm-dialog.component.ts +96 -0
- package/src/components/settings/ai-settings-tab.component.html +140 -0
- package/src/components/settings/ai-settings-tab.component.scss +371 -0
- package/src/components/settings/ai-settings-tab.component.ts +193 -0
- package/src/components/settings/general-settings.component.html +103 -0
- package/src/components/settings/general-settings.component.scss +285 -0
- package/src/components/settings/general-settings.component.ts +123 -0
- package/src/components/settings/provider-config.component.html +95 -0
- package/src/components/settings/provider-config.component.scss +60 -0
- package/src/components/settings/provider-config.component.ts +206 -0
- package/src/components/settings/security-settings.component.html +51 -0
- package/src/components/settings/security-settings.component.scss +66 -0
- package/src/components/settings/security-settings.component.ts +71 -0
- package/src/components/terminal/ai-toolbar-button.component.ts +49 -0
- package/src/components/terminal/command-preview.component.ts +185 -0
- package/src/components/terminal/command-suggestion.component.ts +128 -0
- package/src/index.ts +163 -0
- package/src/main.ts +16 -0
- package/src/providers/tabby/ai-config.provider.ts +70 -0
- package/src/providers/tabby/ai-hotkey.provider.ts +55 -0
- package/src/providers/tabby/ai-settings-tab.provider.ts +18 -0
- package/src/providers/tabby/ai-toolbar-button.provider.ts +49 -0
- package/src/services/chat/chat-history.service.ts +239 -0
- package/src/services/chat/chat-session.service.spec.ts +249 -0
- package/src/services/chat/chat-session.service.ts +180 -0
- package/src/services/chat/command-generator.service.ts +301 -0
- package/src/services/core/ai-assistant.service.ts +334 -0
- package/src/services/core/ai-provider-manager.service.ts +314 -0
- package/src/services/core/config-provider.service.ts +347 -0
- package/src/services/core/logger.service.ts +104 -0
- package/src/services/providers/anthropic-provider.service.ts +373 -0
- package/src/services/providers/base-provider.service.ts +369 -0
- package/src/services/providers/glm-provider.service.ts +467 -0
- package/src/services/providers/minimax-provider.service.ts +427 -0
- package/src/services/providers/openai-compatible.service.ts +394 -0
- package/src/services/providers/openai-provider.service.ts +376 -0
- package/src/services/security/consent-manager.service.ts +332 -0
- package/src/services/security/password-manager.service.ts +188 -0
- package/src/services/security/risk-assessment.service.ts +340 -0
- package/src/services/security/security-validator.service.ts +143 -0
- package/src/services/terminal/command-analyzer.service.ts +43 -0
- package/src/services/terminal/context-menu.service.ts +45 -0
- package/src/services/terminal/hotkey.service.ts +53 -0
- package/src/services/terminal/terminal-context.service.ts +317 -0
- package/src/styles/ai-assistant.scss +449 -0
- package/src/types/ai.types.ts +133 -0
- package/src/types/provider.types.ts +147 -0
- package/src/types/security.types.ts +103 -0
- package/src/types/terminal.types.ts +186 -0
- package/src/utils/encryption.utils.spec.ts +250 -0
- package/src/utils/encryption.utils.ts +271 -0
- package/src/utils/formatting.utils.ts +359 -0
- package/src/utils/validation.utils.spec.ts +225 -0
- package/src/utils/validation.utils.ts +314 -0
- package/tsconfig.json +45 -0
- package/webpack-docker.config.js +42 -0
- package/webpack.config.js +59 -0
- package/webpack.config.js.backup +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# Tabby AI Assistant Plugin
|
|
2
|
+
|
|
3
|
+
一个强大的Tabby终端AI助手插件,支持多AI提供商(OpenAI、Anthropic、Minimax、GLM),提供智能命令生成、解释和安全验证功能。
|
|
4
|
+
|
|
5
|
+
## 🌟 特性
|
|
6
|
+
|
|
7
|
+
### 核心功能
|
|
8
|
+
- **多AI提供商支持** - 支持OpenAI、Anthropic、Minimax、GLM等多种AI服务
|
|
9
|
+
- **智能命令生成** - 自然语言转终端命令,准确率高
|
|
10
|
+
- **命令解释** - 详细解释命令含义和用法
|
|
11
|
+
- **错误修复** - 自动分析错误并提供修复建议
|
|
12
|
+
- **终端感知** - 实时感知终端状态(当前目录、运行状态、环境变量等)
|
|
13
|
+
|
|
14
|
+
### 安全特性
|
|
15
|
+
- **多级风险评估** - 自动识别危险命令(低/中/高/极风险)
|
|
16
|
+
- **用户同意管理** - 30天同意持久化,避免重复确认
|
|
17
|
+
- **密码保护** - 高风险命令需要密码验证
|
|
18
|
+
- **安全模式** - 自动阻止极危险操作
|
|
19
|
+
|
|
20
|
+
### Tabby集成
|
|
21
|
+
- **设置页面** - 专用配置标签页
|
|
22
|
+
- **工具栏按钮** - 一键打开AI助手
|
|
23
|
+
- **热键支持** - 自定义快捷键
|
|
24
|
+
- **上下文菜单** - 右键快速操作
|
|
25
|
+
|
|
26
|
+
## 🚀 支持的AI提供商
|
|
27
|
+
|
|
28
|
+
### 1. Minimax (MiniMax-M2)
|
|
29
|
+
- **API端点**: `https://api.minimaxi.com/anthropic`
|
|
30
|
+
- **兼容性**: 完全兼容Anthropic Claude API
|
|
31
|
+
- **特点**: 专为代码和Agent工作流优化
|
|
32
|
+
- **模型**: MiniMax-M2, MiniMax-M2-Stable
|
|
33
|
+
|
|
34
|
+
### 2. GLM (ChatGLM-4)
|
|
35
|
+
- **API端点**: `https://open.bigmodel.cn/api/paas/v4/`
|
|
36
|
+
- **兼容性**: OpenAI API格式
|
|
37
|
+
- **特点**: 中文优化,响应速度快
|
|
38
|
+
- **模型**: glm-4, glm-4-air, chatglm4等
|
|
39
|
+
|
|
40
|
+
### 3. OpenAI
|
|
41
|
+
- **API端点**: `https://api.openai.com/v1/`
|
|
42
|
+
- **模型**: GPT-4, GPT-3.5 Turbo
|
|
43
|
+
- **特点**: 功能全面,性能稳定
|
|
44
|
+
|
|
45
|
+
### 4. Anthropic Claude
|
|
46
|
+
- **API端点**: `https://api.anthropic.com/`
|
|
47
|
+
- **模型**: Claude-3系列
|
|
48
|
+
- **特点**: 安全性高,推理能力强
|
|
49
|
+
|
|
50
|
+
## 📦 安装
|
|
51
|
+
|
|
52
|
+
### 从源码安装
|
|
53
|
+
```bash
|
|
54
|
+
cd tabby-ai-assistant
|
|
55
|
+
npm install
|
|
56
|
+
npm run build
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 在Tabby中启用
|
|
60
|
+
1. 打开Tabby设置
|
|
61
|
+
2. 导航到"插件"标签
|
|
62
|
+
3. 找到"AI助手"插件并启用
|
|
63
|
+
4. 重启Tabby
|
|
64
|
+
|
|
65
|
+
## ⚙️ 配置
|
|
66
|
+
|
|
67
|
+
### 1. 设置API密钥
|
|
68
|
+
1. 打开Tabby设置 → AI助手
|
|
69
|
+
2. 选择AI提供商
|
|
70
|
+
3. 输入API密钥
|
|
71
|
+
4. 选择模型
|
|
72
|
+
5. 保存设置
|
|
73
|
+
|
|
74
|
+
### 2. 配置安全选项
|
|
75
|
+
- **密码保护**: 启用高风险命令密码验证
|
|
76
|
+
- **同意过期**: 设置用户同意保存天数(默认30天)
|
|
77
|
+
- **自动批准**: 低风险命令自动执行
|
|
78
|
+
|
|
79
|
+
### 3. 自定义热键
|
|
80
|
+
默认热键:
|
|
81
|
+
- `Ctrl-Shift-A`: 打开AI助手聊天
|
|
82
|
+
- `Ctrl-Shift-G`: 从选择生成命令
|
|
83
|
+
- `Ctrl-Shift-E`: 解释当前选择
|
|
84
|
+
|
|
85
|
+
## 🎯 使用指南
|
|
86
|
+
|
|
87
|
+
### 聊天模式
|
|
88
|
+
1. 点击工具栏的AI助手图标
|
|
89
|
+
2. 在聊天框中输入问题
|
|
90
|
+
3. AI将回答您的问题
|
|
91
|
+
|
|
92
|
+
### 命令生成
|
|
93
|
+
1. 在终端中输入自然语言描述
|
|
94
|
+
2. 按 `Ctrl-Shift-G`
|
|
95
|
+
3. AI会生成对应的终端命令
|
|
96
|
+
4. 预览并确认后执行
|
|
97
|
+
|
|
98
|
+
### 命令解释
|
|
99
|
+
1. 选中终端中的命令
|
|
100
|
+
2. 右键选择"用AI解释此命令"
|
|
101
|
+
3. 或按 `Ctrl-Shift-E`
|
|
102
|
+
4. 查看详细解释
|
|
103
|
+
|
|
104
|
+
### 错误修复
|
|
105
|
+
1. 当命令执行失败时
|
|
106
|
+
2. AI会自动检测错误
|
|
107
|
+
3. 提供修复建议
|
|
108
|
+
4. 生成修复命令
|
|
109
|
+
|
|
110
|
+
## 🔒 安全机制
|
|
111
|
+
|
|
112
|
+
### 风险级别
|
|
113
|
+
- **低风险** (绿色): 安全命令,如 `ls`, `cat`, `grep`
|
|
114
|
+
- **中风险** (黄色): 系统查询命令,如 `ps`, `df`, `find`
|
|
115
|
+
- **高风险** (橙色): 系统修改命令,如 `chmod`, `mv`, `rm`
|
|
116
|
+
- **极风险** (红色): 危险命令,如 `rm -rf /`, `fork(`
|
|
117
|
+
|
|
118
|
+
### 防护措施
|
|
119
|
+
1. **模式匹配**: 自动识别危险命令模式
|
|
120
|
+
2. **用户确认**: 中高风险命令需要确认
|
|
121
|
+
3. **密码验证**: 极高风险命令需要密码
|
|
122
|
+
4. **同意持久化**: 记住用户的选择(30天)
|
|
123
|
+
|
|
124
|
+
## 🏗️ 项目结构
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
tabby-ai-assistant/
|
|
128
|
+
├── src/
|
|
129
|
+
│ ├── index.ts # Angular主模块
|
|
130
|
+
│ ├── types/ # 类型定义
|
|
131
|
+
│ │ ├── ai.types.ts # AI相关类型
|
|
132
|
+
│ │ ├── provider.types.ts # 提供商类型
|
|
133
|
+
│ │ ├── security.types.ts # 安全类型
|
|
134
|
+
│ │ └── terminal.types.ts # 终端类型
|
|
135
|
+
│ ├── services/ # 服务层
|
|
136
|
+
│ │ ├── core/ # 核心服务
|
|
137
|
+
│ │ │ ├── ai-assistant.service.ts
|
|
138
|
+
│ │ │ ├── ai-provider-manager.service.ts
|
|
139
|
+
│ │ │ ├── config-provider.service.ts
|
|
140
|
+
│ │ │ └── logger.service.ts
|
|
141
|
+
│ │ ├── providers/ # AI提供商
|
|
142
|
+
│ │ │ ├── base-provider.service.ts
|
|
143
|
+
│ │ │ ├── minimax-provider.service.ts
|
|
144
|
+
│ │ │ └── glm-provider.service.ts
|
|
145
|
+
│ │ ├── security/ # 安全服务
|
|
146
|
+
│ │ │ └── risk-assessment.service.ts
|
|
147
|
+
│ │ └── terminal/ # 终端服务
|
|
148
|
+
│ │ └── terminal-context.service.ts
|
|
149
|
+
│ ├── components/ # UI组件
|
|
150
|
+
│ ├── models/ # 数据模型
|
|
151
|
+
│ └── utils/ # 工具类
|
|
152
|
+
├── webpack.config.js # Webpack配置
|
|
153
|
+
├── tsconfig.json # TypeScript配置
|
|
154
|
+
└── package.json # 依赖配置
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## 🔧 开发
|
|
158
|
+
|
|
159
|
+
### 构建
|
|
160
|
+
```bash
|
|
161
|
+
npm run build # 生产构建
|
|
162
|
+
npm run watch # 开发模式(自动重编译)
|
|
163
|
+
npm run clean # 清理构建文件
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 测试
|
|
167
|
+
```bash
|
|
168
|
+
npm test # 运行单元测试
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## 📝 API文档
|
|
172
|
+
|
|
173
|
+
### AI提供商接口
|
|
174
|
+
```typescript
|
|
175
|
+
interface BaseAiProvider {
|
|
176
|
+
name: string;
|
|
177
|
+
displayName: string;
|
|
178
|
+
capabilities: ProviderCapability[];
|
|
179
|
+
|
|
180
|
+
chat(request: ChatRequest): Promise<ChatResponse>;
|
|
181
|
+
generateCommand(request: CommandRequest): Promise<CommandResponse>;
|
|
182
|
+
explainCommand(request: ExplainRequest): Promise<ExplainResponse>;
|
|
183
|
+
analyzeResult(request: AnalysisRequest): Promise<AnalysisResponse>;
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### 终端上下文
|
|
188
|
+
```typescript
|
|
189
|
+
interface TerminalContext {
|
|
190
|
+
session: TerminalSession;
|
|
191
|
+
currentCommand?: string;
|
|
192
|
+
lastOutput?: string;
|
|
193
|
+
lastError?: string;
|
|
194
|
+
exitCode?: number;
|
|
195
|
+
isRunning: boolean;
|
|
196
|
+
recentCommands: string[];
|
|
197
|
+
systemInfo: SystemInfo;
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## 🤝 贡献
|
|
202
|
+
|
|
203
|
+
欢迎提交Issue和Pull Request!
|
|
204
|
+
|
|
205
|
+
### 开发指南
|
|
206
|
+
1. Fork本项目
|
|
207
|
+
2. 创建特性分支 (`git checkout -b feature/AmazingFeature`)
|
|
208
|
+
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
|
|
209
|
+
4. 推送到分支 (`git push origin feature/AmazingFeature`)
|
|
210
|
+
5. 打开Pull Request
|
|
211
|
+
|
|
212
|
+
## 📄 许可证
|
|
213
|
+
|
|
214
|
+
本项目采用MIT许可证 - 查看 [LICENSE](LICENSE) 文件了解详情
|
|
215
|
+
|
|
216
|
+
## 🙏 致谢
|
|
217
|
+
|
|
218
|
+
- [Tabby](https://tabby.sh/) - 强大的终端模拟器
|
|
219
|
+
- [tabby-vscode-agent](https://github.com/SteffMet/tabby-vscode-agent) - 参考架构
|
|
220
|
+
- [Anthropic Claude](https://www.anthropic.com/) - AI提供商
|
|
221
|
+
- [Minimax](https://minimaxi.com/) - AI服务
|
|
222
|
+
- [GLM](https://open.bigmodel.cn/) - 智谱AI
|
|
223
|
+
|
|
224
|
+
## 📞 联系方式
|
|
225
|
+
|
|
226
|
+
- 项目主页: https://github.com/your-username/tabby-ai-assistant
|
|
227
|
+
- 问题反馈: https://github.com/your-username/tabby-ai-assistant/issues
|
|
228
|
+
- 邮箱: your-email@example.com
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
**注意**: 使用本插件前,请确保您了解所执行命令的作用。对于危险命令,请务必备份重要数据!
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { EventEmitter, ElementRef, OnInit, OnDestroy } from '@angular/core';
|
|
2
|
+
export declare class ChatInputComponent implements OnInit, OnDestroy {
|
|
3
|
+
disabled: boolean;
|
|
4
|
+
placeholder: string;
|
|
5
|
+
send: EventEmitter<string>;
|
|
6
|
+
textInput: ElementRef<HTMLTextAreaElement>;
|
|
7
|
+
inputValue: string;
|
|
8
|
+
private inputSubject;
|
|
9
|
+
private destroy$;
|
|
10
|
+
isComposing: boolean;
|
|
11
|
+
ngOnInit(): void;
|
|
12
|
+
ngOnDestroy(): void;
|
|
13
|
+
/**
|
|
14
|
+
* 处理输入变化
|
|
15
|
+
*/
|
|
16
|
+
onInputChange(value: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* 处理键盘事件
|
|
19
|
+
*/
|
|
20
|
+
onKeydown(event: KeyboardEvent): void;
|
|
21
|
+
/**
|
|
22
|
+
* 处理输入事件
|
|
23
|
+
*/
|
|
24
|
+
onInput(event: Event): void;
|
|
25
|
+
/**
|
|
26
|
+
* 处理composition开始(输入法)
|
|
27
|
+
*/
|
|
28
|
+
onCompositionStart(): void;
|
|
29
|
+
/**
|
|
30
|
+
* 处理composition结束(输入法)
|
|
31
|
+
*/
|
|
32
|
+
onCompositionEnd(): void;
|
|
33
|
+
/**
|
|
34
|
+
* 提交消息
|
|
35
|
+
*/
|
|
36
|
+
submit(): void;
|
|
37
|
+
/**
|
|
38
|
+
* 清空输入
|
|
39
|
+
*/
|
|
40
|
+
clear(): void;
|
|
41
|
+
/**
|
|
42
|
+
* 自动调整高度
|
|
43
|
+
*/
|
|
44
|
+
private autoResize;
|
|
45
|
+
/**
|
|
46
|
+
* 获取字符计数
|
|
47
|
+
*/
|
|
48
|
+
getCharCount(): number;
|
|
49
|
+
/**
|
|
50
|
+
* 获取字符限制
|
|
51
|
+
*/
|
|
52
|
+
getCharLimit(): number;
|
|
53
|
+
/**
|
|
54
|
+
* 检查是否接近限制
|
|
55
|
+
*/
|
|
56
|
+
isNearLimit(): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* 检查是否超过限制
|
|
59
|
+
*/
|
|
60
|
+
isOverLimit(): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* 聚焦输入框
|
|
63
|
+
*/
|
|
64
|
+
focus(): void;
|
|
65
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { OnInit, OnDestroy } from '@angular/core';
|
|
2
|
+
import { ChatMessage } from '../../types/ai.types';
|
|
3
|
+
import { AiAssistantService } from '../../services/core/ai-assistant.service';
|
|
4
|
+
import { ConfigProviderService } from '../../services/core/config-provider.service';
|
|
5
|
+
import { LoggerService } from '../../services/core/logger.service';
|
|
6
|
+
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
|
7
|
+
export declare class ChatInterfaceComponent implements OnInit, OnDestroy {
|
|
8
|
+
private aiService;
|
|
9
|
+
private config;
|
|
10
|
+
private logger;
|
|
11
|
+
private modal;
|
|
12
|
+
messages: ChatMessage[];
|
|
13
|
+
isLoading: boolean;
|
|
14
|
+
currentProvider: string;
|
|
15
|
+
private destroy$;
|
|
16
|
+
constructor(aiService: AiAssistantService, config: ConfigProviderService, logger: LoggerService, modal: NgbModal);
|
|
17
|
+
ngOnInit(): void;
|
|
18
|
+
ngOnDestroy(): void;
|
|
19
|
+
/**
|
|
20
|
+
* 加载当前提供商信息
|
|
21
|
+
*/
|
|
22
|
+
private loadCurrentProvider;
|
|
23
|
+
/**
|
|
24
|
+
* 加载聊天历史
|
|
25
|
+
*/
|
|
26
|
+
private loadChatHistory;
|
|
27
|
+
/**
|
|
28
|
+
* 发送欢迎消息
|
|
29
|
+
*/
|
|
30
|
+
private sendWelcomeMessage;
|
|
31
|
+
/**
|
|
32
|
+
* 处理发送消息
|
|
33
|
+
*/
|
|
34
|
+
onSendMessage(content: string): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* 清空聊天记录
|
|
37
|
+
*/
|
|
38
|
+
clearChat(): void;
|
|
39
|
+
/**
|
|
40
|
+
* 导出聊天记录
|
|
41
|
+
*/
|
|
42
|
+
exportChat(): void;
|
|
43
|
+
/**
|
|
44
|
+
* 切换提供商
|
|
45
|
+
*/
|
|
46
|
+
switchProvider(): void;
|
|
47
|
+
/**
|
|
48
|
+
* 滚动到底部
|
|
49
|
+
*/
|
|
50
|
+
private scrollToBottom;
|
|
51
|
+
/**
|
|
52
|
+
* 保存聊天历史
|
|
53
|
+
*/
|
|
54
|
+
private saveChatHistory;
|
|
55
|
+
/**
|
|
56
|
+
* 生成唯一ID
|
|
57
|
+
*/
|
|
58
|
+
private generateId;
|
|
59
|
+
/**
|
|
60
|
+
* 获取消息时间格式
|
|
61
|
+
*/
|
|
62
|
+
formatTimestamp(timestamp: Date): string;
|
|
63
|
+
/**
|
|
64
|
+
* 检查是否为今天的消息
|
|
65
|
+
*/
|
|
66
|
+
isToday(date: Date): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* 检查是否为同一天的消息
|
|
69
|
+
*/
|
|
70
|
+
isSameDay(date1: Date, date2: Date): boolean;
|
|
71
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { EventEmitter } from '@angular/core';
|
|
2
|
+
import { ChatMessage } from '../../types/ai.types';
|
|
3
|
+
export declare class ChatMessageComponent {
|
|
4
|
+
message: ChatMessage;
|
|
5
|
+
showAvatar: boolean;
|
|
6
|
+
showTimestamp: boolean;
|
|
7
|
+
isGrouped: boolean;
|
|
8
|
+
messageClick: EventEmitter<ChatMessage>;
|
|
9
|
+
messageAction: EventEmitter<{
|
|
10
|
+
action: string;
|
|
11
|
+
message: ChatMessage;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* 处理消息点击
|
|
15
|
+
*/
|
|
16
|
+
onMessageClick(): void;
|
|
17
|
+
/**
|
|
18
|
+
* 处理消息操作
|
|
19
|
+
*/
|
|
20
|
+
onAction(action: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* 复制消息内容
|
|
23
|
+
*/
|
|
24
|
+
copyMessage(): void;
|
|
25
|
+
/**
|
|
26
|
+
* 重新生成响应
|
|
27
|
+
*/
|
|
28
|
+
regenerateResponse(): void;
|
|
29
|
+
/**
|
|
30
|
+
* 标记为有用
|
|
31
|
+
*/
|
|
32
|
+
markAsHelpful(): void;
|
|
33
|
+
/**
|
|
34
|
+
* 标记为无用
|
|
35
|
+
*/
|
|
36
|
+
markAsNotHelpful(): void;
|
|
37
|
+
/**
|
|
38
|
+
* 格式化时间
|
|
39
|
+
*/
|
|
40
|
+
formatTime(timestamp: Date): string;
|
|
41
|
+
/**
|
|
42
|
+
* 检查是否为用户消息
|
|
43
|
+
*/
|
|
44
|
+
isUserMessage(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* 检查是否为AI消息
|
|
47
|
+
*/
|
|
48
|
+
isAssistantMessage(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* 检查是否为系统消息
|
|
51
|
+
*/
|
|
52
|
+
isSystemMessage(): boolean;
|
|
53
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { OnInit } from '@angular/core';
|
|
2
|
+
import { ConfigProviderService } from '../../services/core/config-provider.service';
|
|
3
|
+
import { LoggerService } from '../../services/core/logger.service';
|
|
4
|
+
export declare class ChatSettingsComponent implements OnInit {
|
|
5
|
+
private config;
|
|
6
|
+
private logger;
|
|
7
|
+
settings: {
|
|
8
|
+
chatHistoryEnabled: boolean;
|
|
9
|
+
maxChatHistory: number;
|
|
10
|
+
autoSaveChat: boolean;
|
|
11
|
+
theme: string;
|
|
12
|
+
fontSize: number;
|
|
13
|
+
compactMode: boolean;
|
|
14
|
+
showTimestamps: boolean;
|
|
15
|
+
showAvatars: boolean;
|
|
16
|
+
enterToSend: boolean;
|
|
17
|
+
soundEnabled: boolean;
|
|
18
|
+
};
|
|
19
|
+
themes: {
|
|
20
|
+
value: string;
|
|
21
|
+
label: string;
|
|
22
|
+
}[];
|
|
23
|
+
fontSizes: number[];
|
|
24
|
+
constructor(config: ConfigProviderService, logger: LoggerService);
|
|
25
|
+
ngOnInit(): void;
|
|
26
|
+
/**
|
|
27
|
+
* 加载设置
|
|
28
|
+
*/
|
|
29
|
+
private loadSettings;
|
|
30
|
+
/**
|
|
31
|
+
* 保存设置
|
|
32
|
+
*/
|
|
33
|
+
saveSetting(key: string, value: any): void;
|
|
34
|
+
/**
|
|
35
|
+
* 更新主题
|
|
36
|
+
*/
|
|
37
|
+
updateTheme(theme: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* 应用主题
|
|
40
|
+
*/
|
|
41
|
+
private applyTheme;
|
|
42
|
+
/**
|
|
43
|
+
* 更新字体大小
|
|
44
|
+
*/
|
|
45
|
+
updateFontSize(size: number): void;
|
|
46
|
+
/**
|
|
47
|
+
* 切换紧凑模式
|
|
48
|
+
*/
|
|
49
|
+
toggleCompactMode(): void;
|
|
50
|
+
/**
|
|
51
|
+
* 清空聊天历史
|
|
52
|
+
*/
|
|
53
|
+
clearChatHistory(): void;
|
|
54
|
+
/**
|
|
55
|
+
* 导出聊天设置
|
|
56
|
+
*/
|
|
57
|
+
exportSettings(): void;
|
|
58
|
+
/**
|
|
59
|
+
* 重置为默认设置
|
|
60
|
+
*/
|
|
61
|
+
resetToDefaults(): void;
|
|
62
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EventEmitter } from '@angular/core';
|
|
2
|
+
export declare class ErrorMessageComponent {
|
|
3
|
+
type: 'error' | 'warning' | 'info' | 'success';
|
|
4
|
+
title: string;
|
|
5
|
+
message: string;
|
|
6
|
+
details: string;
|
|
7
|
+
dismissible: boolean;
|
|
8
|
+
dismissed: EventEmitter<void>;
|
|
9
|
+
getIconClass(): string;
|
|
10
|
+
onDismiss(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
|
2
|
+
import { RiskLevel } from '../../types/security.types';
|
|
3
|
+
export declare class ConsentDialogComponent {
|
|
4
|
+
activeModal: NgbActiveModal;
|
|
5
|
+
command: string;
|
|
6
|
+
riskLevel: RiskLevel;
|
|
7
|
+
rememberChoice: boolean;
|
|
8
|
+
constructor(activeModal: NgbActiveModal);
|
|
9
|
+
confirm(): void;
|
|
10
|
+
cancel(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
|
2
|
+
export declare class PasswordPromptComponent {
|
|
3
|
+
activeModal: NgbActiveModal;
|
|
4
|
+
title: string;
|
|
5
|
+
password: string;
|
|
6
|
+
errorMessage: string;
|
|
7
|
+
constructor(activeModal: NgbActiveModal);
|
|
8
|
+
submit(): void;
|
|
9
|
+
cancel(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { EventEmitter } from '@angular/core';
|
|
2
|
+
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
|
3
|
+
import { RiskLevel } from '../../types/security.types';
|
|
4
|
+
export declare class RiskConfirmDialogComponent {
|
|
5
|
+
activeModal: NgbActiveModal;
|
|
6
|
+
command: string;
|
|
7
|
+
explanation: string;
|
|
8
|
+
riskLevel: RiskLevel;
|
|
9
|
+
suggestions: string[];
|
|
10
|
+
confirmed: EventEmitter<boolean>;
|
|
11
|
+
constructor(activeModal: NgbActiveModal);
|
|
12
|
+
/**
|
|
13
|
+
* 确认执行
|
|
14
|
+
*/
|
|
15
|
+
confirm(): void;
|
|
16
|
+
/**
|
|
17
|
+
* 取消执行
|
|
18
|
+
*/
|
|
19
|
+
cancel(): void;
|
|
20
|
+
/**
|
|
21
|
+
* 获取风险级别文本
|
|
22
|
+
*/
|
|
23
|
+
getRiskLevelText(): string;
|
|
24
|
+
/**
|
|
25
|
+
* 获取风险级别颜色
|
|
26
|
+
*/
|
|
27
|
+
getRiskLevelColor(): string;
|
|
28
|
+
/**
|
|
29
|
+
* 获取风险级别图标
|
|
30
|
+
*/
|
|
31
|
+
getRiskLevelIcon(): string;
|
|
32
|
+
/**
|
|
33
|
+
* 是否为高风险
|
|
34
|
+
*/
|
|
35
|
+
isHighRisk(): boolean;
|
|
36
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { OnInit } from '@angular/core';
|
|
2
|
+
import { AiAssistantService } from '../../services/core/ai-assistant.service';
|
|
3
|
+
import { ConfigProviderService } from '../../services/core/config-provider.service';
|
|
4
|
+
import { LoggerService } from '../../services/core/logger.service';
|
|
5
|
+
export declare class AiSettingsTabComponent implements OnInit {
|
|
6
|
+
private aiService;
|
|
7
|
+
private config;
|
|
8
|
+
private logger;
|
|
9
|
+
activeTab: string;
|
|
10
|
+
isEnabled: boolean;
|
|
11
|
+
currentProvider: string;
|
|
12
|
+
providerStatus: any;
|
|
13
|
+
tabs: {
|
|
14
|
+
id: string;
|
|
15
|
+
label: string;
|
|
16
|
+
icon: string;
|
|
17
|
+
}[];
|
|
18
|
+
constructor(aiService: AiAssistantService, config: ConfigProviderService, logger: LoggerService);
|
|
19
|
+
ngOnInit(): void;
|
|
20
|
+
/**
|
|
21
|
+
* 加载设置
|
|
22
|
+
*/
|
|
23
|
+
private loadSettings;
|
|
24
|
+
/**
|
|
25
|
+
* 加载提供商状态
|
|
26
|
+
*/
|
|
27
|
+
private loadProviderStatus;
|
|
28
|
+
/**
|
|
29
|
+
* 切换标签页
|
|
30
|
+
*/
|
|
31
|
+
switchTab(tabId: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* 切换启用状态
|
|
34
|
+
*/
|
|
35
|
+
toggleEnabled(): void;
|
|
36
|
+
/**
|
|
37
|
+
* 切换提供商
|
|
38
|
+
*/
|
|
39
|
+
switchProvider(providerName: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* 刷新提供商状态
|
|
42
|
+
*/
|
|
43
|
+
refreshProviderStatus(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* 获取提供商图标类名
|
|
46
|
+
*/
|
|
47
|
+
getProviderIcon(providerName: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* 获取提供商状态颜色
|
|
50
|
+
*/
|
|
51
|
+
getProviderStatusColor(healthy: boolean): string;
|
|
52
|
+
/**
|
|
53
|
+
* 获取提供商状态文本
|
|
54
|
+
*/
|
|
55
|
+
getProviderStatusText(healthy: boolean): string;
|
|
56
|
+
/**
|
|
57
|
+
* 验证配置
|
|
58
|
+
*/
|
|
59
|
+
validateConfig(): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* 导出配置
|
|
62
|
+
*/
|
|
63
|
+
exportConfig(): void;
|
|
64
|
+
/**
|
|
65
|
+
* 导入配置
|
|
66
|
+
*/
|
|
67
|
+
importConfig(): void;
|
|
68
|
+
/**
|
|
69
|
+
* 重置为默认配置
|
|
70
|
+
*/
|
|
71
|
+
resetToDefaults(): void;
|
|
72
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { EventEmitter, OnInit } from '@angular/core';
|
|
2
|
+
import { AiAssistantService } from '../../services/core/ai-assistant.service';
|
|
3
|
+
import { ConfigProviderService } from '../../services/core/config-provider.service';
|
|
4
|
+
import { LoggerService } from '../../services/core/logger.service';
|
|
5
|
+
export declare class GeneralSettingsComponent implements OnInit {
|
|
6
|
+
private aiService;
|
|
7
|
+
private config;
|
|
8
|
+
private logger;
|
|
9
|
+
providerChanged: EventEmitter<string>;
|
|
10
|
+
availableProviders: any[];
|
|
11
|
+
selectedProvider: string;
|
|
12
|
+
isEnabled: boolean;
|
|
13
|
+
language: string;
|
|
14
|
+
theme: string;
|
|
15
|
+
languages: {
|
|
16
|
+
value: string;
|
|
17
|
+
label: string;
|
|
18
|
+
}[];
|
|
19
|
+
themes: {
|
|
20
|
+
value: string;
|
|
21
|
+
label: string;
|
|
22
|
+
}[];
|
|
23
|
+
constructor(aiService: AiAssistantService, config: ConfigProviderService, logger: LoggerService);
|
|
24
|
+
ngOnInit(): void;
|
|
25
|
+
/**
|
|
26
|
+
* 加载设置
|
|
27
|
+
*/
|
|
28
|
+
private loadSettings;
|
|
29
|
+
/**
|
|
30
|
+
* 加载可用提供商
|
|
31
|
+
*/
|
|
32
|
+
private loadProviders;
|
|
33
|
+
/**
|
|
34
|
+
* 更新默认提供商
|
|
35
|
+
*/
|
|
36
|
+
updateDefaultProvider(providerName: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* 更新启用状态
|
|
39
|
+
*/
|
|
40
|
+
updateEnabled(enabled: boolean): void;
|
|
41
|
+
/**
|
|
42
|
+
* 更新语言
|
|
43
|
+
*/
|
|
44
|
+
updateLanguage(language: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* 更新主题
|
|
47
|
+
*/
|
|
48
|
+
updateTheme(theme: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* 应用主题
|
|
51
|
+
*/
|
|
52
|
+
private applyTheme;
|
|
53
|
+
/**
|
|
54
|
+
* 获取提供商状态
|
|
55
|
+
*/
|
|
56
|
+
getProviderStatus(providerName: string): {
|
|
57
|
+
text: string;
|
|
58
|
+
color: string;
|
|
59
|
+
};
|
|
60
|
+
}
|