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.
Files changed (134) hide show
  1. package/README.md +232 -0
  2. package/dist/components/chat/chat-input.component.d.ts +65 -0
  3. package/dist/components/chat/chat-interface.component.d.ts +71 -0
  4. package/dist/components/chat/chat-message.component.d.ts +53 -0
  5. package/dist/components/chat/chat-settings.component.d.ts +62 -0
  6. package/dist/components/common/error-message.component.d.ts +11 -0
  7. package/dist/components/common/loading-spinner.component.d.ts +4 -0
  8. package/dist/components/security/consent-dialog.component.d.ts +11 -0
  9. package/dist/components/security/password-prompt.component.d.ts +10 -0
  10. package/dist/components/security/risk-confirm-dialog.component.d.ts +36 -0
  11. package/dist/components/settings/ai-settings-tab.component.d.ts +72 -0
  12. package/dist/components/settings/general-settings.component.d.ts +60 -0
  13. package/dist/components/settings/provider-config.component.d.ts +182 -0
  14. package/dist/components/settings/security-settings.component.d.ts +23 -0
  15. package/dist/components/terminal/ai-toolbar-button.component.d.ts +10 -0
  16. package/dist/components/terminal/command-preview.component.d.ts +15 -0
  17. package/dist/components/terminal/command-suggestion.component.d.ts +16 -0
  18. package/dist/index.d.ts +8 -0
  19. package/dist/index.js +2 -0
  20. package/dist/index.js.LICENSE.txt +18 -0
  21. package/dist/main.d.ts +8 -0
  22. package/dist/providers/tabby/ai-config.provider.d.ts +18 -0
  23. package/dist/providers/tabby/ai-hotkey.provider.d.ts +21 -0
  24. package/dist/providers/tabby/ai-settings-tab.provider.d.ts +11 -0
  25. package/dist/providers/tabby/ai-toolbar-button.provider.d.ts +17 -0
  26. package/dist/services/chat/chat-history.service.d.ts +67 -0
  27. package/dist/services/chat/chat-session.service.d.ts +58 -0
  28. package/dist/services/chat/command-generator.service.d.ts +49 -0
  29. package/dist/services/core/ai-assistant.service.d.ts +88 -0
  30. package/dist/services/core/ai-provider-manager.service.d.ts +119 -0
  31. package/dist/services/core/config-provider.service.d.ts +137 -0
  32. package/dist/services/core/logger.service.d.ts +21 -0
  33. package/dist/services/providers/anthropic-provider.service.d.ts +39 -0
  34. package/dist/services/providers/base-provider.service.d.ts +137 -0
  35. package/dist/services/providers/glm-provider.service.d.ts +91 -0
  36. package/dist/services/providers/minimax-provider.service.d.ts +93 -0
  37. package/dist/services/providers/openai-compatible.service.d.ts +39 -0
  38. package/dist/services/providers/openai-provider.service.d.ts +38 -0
  39. package/dist/services/security/consent-manager.service.d.ts +65 -0
  40. package/dist/services/security/password-manager.service.d.ts +67 -0
  41. package/dist/services/security/risk-assessment.service.d.ts +65 -0
  42. package/dist/services/security/security-validator.service.d.ts +36 -0
  43. package/dist/services/terminal/command-analyzer.service.d.ts +20 -0
  44. package/dist/services/terminal/context-menu.service.d.ts +24 -0
  45. package/dist/services/terminal/hotkey.service.d.ts +28 -0
  46. package/dist/services/terminal/terminal-context.service.d.ts +100 -0
  47. package/dist/types/ai.types.d.ts +107 -0
  48. package/dist/types/provider.types.d.ts +105 -0
  49. package/dist/types/security.types.d.ts +85 -0
  50. package/dist/types/terminal.types.d.ts +150 -0
  51. package/dist/utils/encryption.utils.d.ts +83 -0
  52. package/dist/utils/formatting.utils.d.ts +106 -0
  53. package/dist/utils/validation.utils.d.ts +83 -0
  54. package/integration-test-output.txt +50 -0
  55. package/integration-tests/api-integration.test.ts +183 -0
  56. package/jest.config.js +47 -0
  57. package/package.json +73 -0
  58. package/setup-jest.ts +37 -0
  59. package/src/components/chat/chat-input.component.html +61 -0
  60. package/src/components/chat/chat-input.component.scss +183 -0
  61. package/src/components/chat/chat-input.component.ts +149 -0
  62. package/src/components/chat/chat-interface.component.html +119 -0
  63. package/src/components/chat/chat-interface.component.scss +354 -0
  64. package/src/components/chat/chat-interface.component.ts +224 -0
  65. package/src/components/chat/chat-message.component.html +65 -0
  66. package/src/components/chat/chat-message.component.scss +178 -0
  67. package/src/components/chat/chat-message.component.ts +93 -0
  68. package/src/components/chat/chat-settings.component.html +132 -0
  69. package/src/components/chat/chat-settings.component.scss +172 -0
  70. package/src/components/chat/chat-settings.component.ts +168 -0
  71. package/src/components/common/error-message.component.ts +124 -0
  72. package/src/components/common/loading-spinner.component.ts +72 -0
  73. package/src/components/security/consent-dialog.component.ts +77 -0
  74. package/src/components/security/password-prompt.component.ts +79 -0
  75. package/src/components/security/risk-confirm-dialog.component.html +87 -0
  76. package/src/components/security/risk-confirm-dialog.component.scss +360 -0
  77. package/src/components/security/risk-confirm-dialog.component.ts +96 -0
  78. package/src/components/settings/ai-settings-tab.component.html +140 -0
  79. package/src/components/settings/ai-settings-tab.component.scss +371 -0
  80. package/src/components/settings/ai-settings-tab.component.ts +193 -0
  81. package/src/components/settings/general-settings.component.html +103 -0
  82. package/src/components/settings/general-settings.component.scss +285 -0
  83. package/src/components/settings/general-settings.component.ts +123 -0
  84. package/src/components/settings/provider-config.component.html +95 -0
  85. package/src/components/settings/provider-config.component.scss +60 -0
  86. package/src/components/settings/provider-config.component.ts +206 -0
  87. package/src/components/settings/security-settings.component.html +51 -0
  88. package/src/components/settings/security-settings.component.scss +66 -0
  89. package/src/components/settings/security-settings.component.ts +71 -0
  90. package/src/components/terminal/ai-toolbar-button.component.ts +49 -0
  91. package/src/components/terminal/command-preview.component.ts +185 -0
  92. package/src/components/terminal/command-suggestion.component.ts +128 -0
  93. package/src/index.ts +163 -0
  94. package/src/main.ts +16 -0
  95. package/src/providers/tabby/ai-config.provider.ts +70 -0
  96. package/src/providers/tabby/ai-hotkey.provider.ts +55 -0
  97. package/src/providers/tabby/ai-settings-tab.provider.ts +18 -0
  98. package/src/providers/tabby/ai-toolbar-button.provider.ts +49 -0
  99. package/src/services/chat/chat-history.service.ts +239 -0
  100. package/src/services/chat/chat-session.service.spec.ts +249 -0
  101. package/src/services/chat/chat-session.service.ts +180 -0
  102. package/src/services/chat/command-generator.service.ts +301 -0
  103. package/src/services/core/ai-assistant.service.ts +334 -0
  104. package/src/services/core/ai-provider-manager.service.ts +314 -0
  105. package/src/services/core/config-provider.service.ts +347 -0
  106. package/src/services/core/logger.service.ts +104 -0
  107. package/src/services/providers/anthropic-provider.service.ts +373 -0
  108. package/src/services/providers/base-provider.service.ts +369 -0
  109. package/src/services/providers/glm-provider.service.ts +467 -0
  110. package/src/services/providers/minimax-provider.service.ts +427 -0
  111. package/src/services/providers/openai-compatible.service.ts +394 -0
  112. package/src/services/providers/openai-provider.service.ts +376 -0
  113. package/src/services/security/consent-manager.service.ts +332 -0
  114. package/src/services/security/password-manager.service.ts +188 -0
  115. package/src/services/security/risk-assessment.service.ts +340 -0
  116. package/src/services/security/security-validator.service.ts +143 -0
  117. package/src/services/terminal/command-analyzer.service.ts +43 -0
  118. package/src/services/terminal/context-menu.service.ts +45 -0
  119. package/src/services/terminal/hotkey.service.ts +53 -0
  120. package/src/services/terminal/terminal-context.service.ts +317 -0
  121. package/src/styles/ai-assistant.scss +449 -0
  122. package/src/types/ai.types.ts +133 -0
  123. package/src/types/provider.types.ts +147 -0
  124. package/src/types/security.types.ts +103 -0
  125. package/src/types/terminal.types.ts +186 -0
  126. package/src/utils/encryption.utils.spec.ts +250 -0
  127. package/src/utils/encryption.utils.ts +271 -0
  128. package/src/utils/formatting.utils.ts +359 -0
  129. package/src/utils/validation.utils.spec.ts +225 -0
  130. package/src/utils/validation.utils.ts +314 -0
  131. package/tsconfig.json +45 -0
  132. package/webpack-docker.config.js +42 -0
  133. package/webpack.config.js +59 -0
  134. package/webpack.config.js.backup +57 -0
@@ -0,0 +1,18 @@
1
+ /*! Axios v1.13.2 Copyright (c) 2025 Matt Zabriskie and contributors */
2
+
3
+ /** @preserve
4
+ * Counter block mode compatible with Dr Brian Gladman fileenc.c
5
+ * derived from CryptoJS.mode.CTR
6
+ * Jan Hruby jhruby.web@gmail.com
7
+ */
8
+
9
+ /** @preserve
10
+ (c) 2012 by Cédric Mesnil. All rights reserved.
11
+
12
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
13
+
14
+ - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
15
+ - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
18
+ */
package/dist/main.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Tabby AI Assistant Plugin - Main Entry Point
3
+ *
4
+ * This file serves as the main entry point for the Tabby AI Assistant plugin.
5
+ * It initializes the Angular module and integrates with Tabby's plugin system.
6
+ */
7
+ import AiAssistantModule from './index';
8
+ export default AiAssistantModule;
@@ -0,0 +1,18 @@
1
+ import { ConfigProvider } from 'tabby-core';
2
+ import { ConfigProviderService } from '../../services/core/config-provider.service';
3
+ /**
4
+ * Tabby配置提供者
5
+ * 为Tabby提供AI助手配置管理
6
+ */
7
+ export declare class AiConfigProvider extends ConfigProvider {
8
+ private configService;
9
+ constructor(configService: ConfigProviderService);
10
+ /**
11
+ * 提供配置项定义
12
+ */
13
+ provideConfig(): any;
14
+ /**
15
+ * 配置就绪后的处理
16
+ */
17
+ onConfigLoaded(): Promise<void>;
18
+ }
@@ -0,0 +1,21 @@
1
+ import { HotkeyProvider, HotkeyDescription } from 'tabby-core';
2
+ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
3
+ import { AiAssistantService } from '../../services/core/ai-assistant.service';
4
+ /**
5
+ * Tabby热键提供者
6
+ * 为Tabby添加AI助手热键支持
7
+ */
8
+ export declare class AiHotkeyProvider extends HotkeyProvider {
9
+ private modal;
10
+ private aiService;
11
+ constructor(modal: NgbModal, aiService: AiAssistantService);
12
+ provide(): Promise<HotkeyDescription[]>;
13
+ /**
14
+ * 打开AI聊天界面
15
+ */
16
+ private openAiChat;
17
+ /**
18
+ * 打开命令生成功能
19
+ */
20
+ private openCommandGeneration;
21
+ }
@@ -0,0 +1,11 @@
1
+ import { SettingsTabProvider } from 'tabby-settings';
2
+ /**
3
+ * Tabby设置页面提供者
4
+ * 为Tabby添加AI助手设置页面
5
+ */
6
+ export declare class AiSettingsTabProvider extends SettingsTabProvider {
7
+ id: string;
8
+ icon: string;
9
+ title: string;
10
+ getComponentType(): any;
11
+ }
@@ -0,0 +1,17 @@
1
+ import { ToolbarButtonProvider, ToolbarButton } from 'tabby-core';
2
+ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
3
+ import { AiAssistantService } from '../../services/core/ai-assistant.service';
4
+ /**
5
+ * Tabby工具栏按钮提供者
6
+ * 为Tabby工具栏添加AI助手按钮
7
+ */
8
+ export declare class AiToolbarButtonProvider extends ToolbarButtonProvider {
9
+ private modal;
10
+ private aiService;
11
+ constructor(modal: NgbModal, aiService: AiAssistantService);
12
+ provide(): ToolbarButton[];
13
+ /**
14
+ * 打开AI聊天界面
15
+ */
16
+ private openAiChat;
17
+ }
@@ -0,0 +1,67 @@
1
+ import { Observable } from 'rxjs';
2
+ import { ChatMessage } from '../../types/ai.types';
3
+ import { LoggerService } from '../core/logger.service';
4
+ export interface SavedSession {
5
+ sessionId: string;
6
+ title: string;
7
+ messages: ChatMessage[];
8
+ createdAt: Date;
9
+ updatedAt: Date;
10
+ messageCount: number;
11
+ }
12
+ /**
13
+ * 聊天历史服务
14
+ * 持久化存储和管理聊天会话历史
15
+ */
16
+ export declare class ChatHistoryService {
17
+ private logger;
18
+ private sessionsSubject;
19
+ sessions$: Observable<SavedSession[]>;
20
+ constructor(logger: LoggerService);
21
+ /**
22
+ * 保存会话
23
+ */
24
+ saveSession(sessionId: string, messages: ChatMessage[], title?: string): void;
25
+ /**
26
+ * 加载会话
27
+ */
28
+ loadSession(sessionId: string): SavedSession | undefined;
29
+ /**
30
+ * 删除会话
31
+ */
32
+ deleteSession(sessionId: string): void;
33
+ /**
34
+ * 清空所有历史
35
+ */
36
+ clearAllHistory(): void;
37
+ /**
38
+ * 搜索会话
39
+ */
40
+ searchSessions(query: string): SavedSession[];
41
+ /**
42
+ * 获取最近的会话
43
+ */
44
+ getRecentSessions(count?: number): SavedSession[];
45
+ /**
46
+ * 获取会话统计
47
+ */
48
+ getStatistics(): {
49
+ totalSessions: number;
50
+ totalMessages: number;
51
+ averageMessagesPerSession: number;
52
+ oldestSession?: Date;
53
+ newestSession?: Date;
54
+ };
55
+ /**
56
+ * 导出所有历史
57
+ */
58
+ exportAllHistory(): string;
59
+ /**
60
+ * 导入历史
61
+ */
62
+ importHistory(data: string): void;
63
+ private loadSessions;
64
+ private saveToStorage;
65
+ private generateSessionTitle;
66
+ private trimMessages;
67
+ }
@@ -0,0 +1,58 @@
1
+ import { Observable } from 'rxjs';
2
+ import { ChatMessage } from '../../types/ai.types';
3
+ import { AiAssistantService } from '../core/ai-assistant.service';
4
+ import { LoggerService } from '../core/logger.service';
5
+ /**
6
+ * 聊天会话服务
7
+ * 管理聊天会话的生命周期、消息历史和状态
8
+ */
9
+ export declare class ChatSessionService {
10
+ private aiService;
11
+ private logger;
12
+ private currentSessionId;
13
+ private messagesSubject;
14
+ private isTypingSubject;
15
+ private errorSubject;
16
+ messages$: Observable<ChatMessage[]>;
17
+ isTyping$: Observable<boolean>;
18
+ error$: Observable<string>;
19
+ constructor(aiService: AiAssistantService, logger: LoggerService);
20
+ /**
21
+ * 创建新会话
22
+ */
23
+ createSession(): string;
24
+ /**
25
+ * 切换到指定会话
26
+ */
27
+ switchToSession(sessionId: string): void;
28
+ /**
29
+ * 发送消息
30
+ */
31
+ sendMessage(content: string, systemPrompt?: string): Promise<void>;
32
+ /**
33
+ * 清空会话历史
34
+ */
35
+ clearSession(): void;
36
+ /**
37
+ * 删除消息
38
+ */
39
+ deleteMessage(messageId: string): void;
40
+ /**
41
+ * 获取当前会话ID
42
+ */
43
+ getCurrentSessionId(): string | null;
44
+ /**
45
+ * 获取当前消息列表
46
+ */
47
+ getCurrentMessages(): ChatMessage[];
48
+ /**
49
+ * 导出会话
50
+ */
51
+ exportSession(): string;
52
+ /**
53
+ * 导入会话
54
+ */
55
+ importSession(sessionData: string): void;
56
+ private generateSessionId;
57
+ private generateMessageId;
58
+ }
@@ -0,0 +1,49 @@
1
+ import { CommandRequest, CommandResponse } from '../../types/ai.types';
2
+ import { TerminalError } from '../../types/terminal.types';
3
+ import { AiAssistantService } from '../core/ai-assistant.service';
4
+ import { TerminalContextService } from '../terminal/terminal-context.service';
5
+ import { SecurityValidatorService } from '../security/security-validator.service';
6
+ import { LoggerService } from '../core/logger.service';
7
+ export declare class CommandGeneratorService {
8
+ private aiService;
9
+ private terminalContext;
10
+ private securityValidator;
11
+ private logger;
12
+ constructor(aiService: AiAssistantService, terminalContext: TerminalContextService, securityValidator: SecurityValidatorService, logger: LoggerService);
13
+ /**
14
+ * 生成命令(基于终端上下文)
15
+ */
16
+ generateCommand(request: CommandRequest): Promise<CommandResponse>;
17
+ /**
18
+ * 从选择文本生成命令
19
+ */
20
+ generateFromSelection(selection: string): Promise<CommandResponse>;
21
+ /**
22
+ * 从错误生成修复命令
23
+ */
24
+ generateFixForError(error: TerminalError): Promise<CommandResponse>;
25
+ /**
26
+ * 生成智能建议
27
+ */
28
+ generateSuggestions(input: string): Promise<string[]>;
29
+ /**
30
+ * 构建增强提示词
31
+ */
32
+ private buildEnhancedPrompt;
33
+ /**
34
+ * 获取系统提示词
35
+ */
36
+ private getSystemPrompt;
37
+ /**
38
+ * 解析AI响应
39
+ */
40
+ private parseAiResponse;
41
+ /**
42
+ * 构建终端上下文
43
+ */
44
+ private buildTerminalContext;
45
+ /**
46
+ * 生成唯一ID
47
+ */
48
+ private generateId;
49
+ }
@@ -0,0 +1,88 @@
1
+ import { ChatRequest, ChatResponse, CommandRequest, CommandResponse, ExplainRequest, ExplainResponse } from '../../types/ai.types';
2
+ import { AiProviderManagerService } from './ai-provider-manager.service';
3
+ import { ConfigProviderService } from './config-provider.service';
4
+ import { TerminalContextService } from '../terminal/terminal-context.service';
5
+ import { LoggerService } from './logger.service';
6
+ export declare class AiAssistantService {
7
+ private providerManager;
8
+ private config;
9
+ private terminalContext;
10
+ private logger;
11
+ constructor(providerManager: AiProviderManagerService, config: ConfigProviderService, terminalContext: TerminalContextService, logger: LoggerService);
12
+ /**
13
+ * 初始化AI助手
14
+ */
15
+ initialize(): void;
16
+ /**
17
+ * 聊天功能
18
+ */
19
+ chat(request: ChatRequest): Promise<ChatResponse>;
20
+ /**
21
+ * 生成命令
22
+ */
23
+ generateCommand(request: CommandRequest): Promise<CommandResponse>;
24
+ /**
25
+ * 解释命令
26
+ */
27
+ explainCommand(request: ExplainRequest): Promise<ExplainResponse>;
28
+ /**
29
+ * 分析结果
30
+ */
31
+ analyzeResult(request: any): Promise<any>;
32
+ /**
33
+ * 从选择生成命令
34
+ */
35
+ generateCommandFromSelection(): Promise<CommandResponse | null>;
36
+ /**
37
+ * 解释当前选择
38
+ */
39
+ explainCommandFromSelection(): Promise<ExplainResponse | null>;
40
+ /**
41
+ * 打开聊天界面
42
+ */
43
+ openChatInterface(): void;
44
+ /**
45
+ * 获取提供商状态
46
+ */
47
+ getProviderStatus(): any;
48
+ /**
49
+ * 切换提供商
50
+ */
51
+ switchProvider(providerName: string): boolean;
52
+ /**
53
+ * 获取下一个提供商
54
+ */
55
+ switchToNextProvider(): boolean;
56
+ /**
57
+ * 获取上一个提供商
58
+ */
59
+ switchToPreviousProvider(): boolean;
60
+ /**
61
+ * 健康检查
62
+ */
63
+ healthCheck(): Promise<{
64
+ provider: string;
65
+ status: string;
66
+ latency?: number;
67
+ }[]>;
68
+ /**
69
+ * 验证配置
70
+ */
71
+ validateConfig(): Promise<{
72
+ name: string;
73
+ valid: boolean;
74
+ errors: string[];
75
+ }[]>;
76
+ /**
77
+ * 获取当前上下文感知提示
78
+ */
79
+ getContextAwarePrompt(basePrompt: string): string;
80
+ /**
81
+ * 获取建议命令
82
+ */
83
+ getSuggestedCommands(_input: string): Promise<string[]>;
84
+ /**
85
+ * 分析终端错误并提供修复建议
86
+ */
87
+ getErrorFix(error: any): Promise<CommandResponse | null>;
88
+ }
@@ -0,0 +1,119 @@
1
+ import { Observable } from 'rxjs';
2
+ import { BaseAiProvider, ProviderManager, ProviderInfo, ProviderEvent } from '../../types/provider.types';
3
+ import { LoggerService } from './logger.service';
4
+ /**
5
+ * AI提供商管理器
6
+ * 负责注册、管理和切换不同的AI提供商
7
+ */
8
+ export declare class AiProviderManagerService implements ProviderManager {
9
+ private logger;
10
+ private providers;
11
+ private activeProvider;
12
+ private eventSubject;
13
+ constructor(logger: LoggerService);
14
+ /**
15
+ * 注册AI提供商
16
+ */
17
+ registerProvider(provider: BaseAiProvider): void;
18
+ /**
19
+ * 注销AI提供商
20
+ */
21
+ unregisterProvider(name: string): void;
22
+ /**
23
+ * 获取指定提供商
24
+ */
25
+ getProvider(name: string): BaseAiProvider | undefined;
26
+ /**
27
+ * 获取所有提供商
28
+ */
29
+ getAllProviders(): BaseAiProvider[];
30
+ /**
31
+ * 获取当前激活的提供商
32
+ */
33
+ getActiveProvider(): BaseAiProvider | undefined;
34
+ /**
35
+ * 设置激活的提供商
36
+ */
37
+ setActiveProvider(name: string): boolean;
38
+ /**
39
+ * 获取提供商信息
40
+ */
41
+ getProviderInfo(name: string): ProviderInfo | undefined;
42
+ /**
43
+ * 获取所有提供商信息
44
+ */
45
+ getAllProviderInfo(): ProviderInfo[];
46
+ /**
47
+ * 检查提供商是否存在
48
+ */
49
+ hasProvider(name: string): boolean;
50
+ /**
51
+ * 获取提供商数量
52
+ */
53
+ getProviderCount(): number;
54
+ /**
55
+ * 获取当前激活的提供商名称
56
+ */
57
+ getActiveProviderName(): string | null;
58
+ /**
59
+ * 验证所有提供商配置
60
+ */
61
+ validateAllProviders(): Promise<{
62
+ name: string;
63
+ valid: boolean;
64
+ errors: string[];
65
+ }[]>;
66
+ /**
67
+ * 检查所有提供商健康状态
68
+ */
69
+ checkAllProvidersHealth(): Promise<{
70
+ provider: string;
71
+ status: string;
72
+ latency?: number;
73
+ }[]>;
74
+ /**
75
+ * 获取启用的提供商
76
+ */
77
+ getEnabledProviders(): BaseAiProvider[];
78
+ /**
79
+ * 获取启用的提供商名称
80
+ */
81
+ getEnabledProviderNames(): string[];
82
+ /**
83
+ * 切换到下一个启用的提供商
84
+ */
85
+ switchToNextProvider(): boolean;
86
+ /**
87
+ * 切换到上一个启用的提供商
88
+ */
89
+ switchToPreviousProvider(): boolean;
90
+ /**
91
+ * 订阅提供商事件
92
+ */
93
+ onEvent(): Observable<ProviderEvent>;
94
+ /**
95
+ * 获取所有启用的提供商中性能最好的(延迟最低)
96
+ */
97
+ getBestPerformingProvider(): Promise<BaseAiProvider | null>;
98
+ /**
99
+ * 发送事件
100
+ */
101
+ private emitEvent;
102
+ /**
103
+ * 获取提供商统计信息
104
+ */
105
+ getStats(): {
106
+ totalProviders: number;
107
+ enabledProviders: number;
108
+ activeProvider: string | null;
109
+ providers: {
110
+ name: string;
111
+ enabled: boolean;
112
+ healthy: boolean;
113
+ }[];
114
+ };
115
+ /**
116
+ * 重置所有提供商
117
+ */
118
+ reset(): void;
119
+ }
@@ -0,0 +1,137 @@
1
+ import { Observable } from 'rxjs';
2
+ import { LoggerService } from './logger.service';
3
+ import { SecurityConfig } from '../../types/security.types';
4
+ import { ProviderConfig } from '../../types/provider.types';
5
+ /**
6
+ * AI助手配置
7
+ */
8
+ export interface AiAssistantConfig {
9
+ enabled: boolean;
10
+ defaultProvider: string;
11
+ chatHistoryEnabled: boolean;
12
+ maxChatHistory: number;
13
+ autoSaveChat: boolean;
14
+ theme: 'light' | 'dark' | 'auto';
15
+ language: string;
16
+ logLevel: 'debug' | 'info' | 'warn' | 'error';
17
+ security: SecurityConfig;
18
+ providers: {
19
+ [name: string]: ProviderConfig;
20
+ };
21
+ hotkeys: {
22
+ openChat: string;
23
+ generateCommand: string;
24
+ explainCommand: string;
25
+ };
26
+ ui: {
27
+ showTooltips: boolean;
28
+ compactMode: boolean;
29
+ fontSize: number;
30
+ };
31
+ }
32
+ export declare class ConfigProviderService {
33
+ private logger;
34
+ private config;
35
+ private configChange$;
36
+ constructor(logger: LoggerService);
37
+ /**
38
+ * 加载配置
39
+ */
40
+ private loadConfig;
41
+ /**
42
+ * 保存配置
43
+ */
44
+ private saveConfig;
45
+ /**
46
+ * 获取完整配置
47
+ */
48
+ getConfig(): AiAssistantConfig;
49
+ /**
50
+ * 设置完整配置
51
+ */
52
+ setConfig(config: Partial<AiAssistantConfig>): void;
53
+ /**
54
+ * 获取指定配置项
55
+ */
56
+ get<T>(key: string, defaultValue?: T): T | undefined;
57
+ /**
58
+ * 设置指定配置项
59
+ */
60
+ set<T>(key: string, value: T): void;
61
+ /**
62
+ * 获取提供商配置
63
+ */
64
+ getProviderConfig(name: string): ProviderConfig | null;
65
+ /**
66
+ * 设置提供商配置
67
+ */
68
+ setProviderConfig(name: string, config: ProviderConfig): void;
69
+ /**
70
+ * 删除提供商配置
71
+ */
72
+ deleteProviderConfig(name: string): void;
73
+ /**
74
+ * 获取所有提供商配置
75
+ */
76
+ getAllProviderConfigs(): {
77
+ [name: string]: ProviderConfig;
78
+ };
79
+ /**
80
+ * 获取默认提供商
81
+ */
82
+ getDefaultProvider(): string;
83
+ /**
84
+ * 设置默认提供商
85
+ */
86
+ setDefaultProvider(name: string): void;
87
+ /**
88
+ * 获取安全配置
89
+ */
90
+ getSecurityConfig(): SecurityConfig;
91
+ /**
92
+ * 更新安全配置
93
+ */
94
+ updateSecurityConfig(config: Partial<SecurityConfig>): void;
95
+ /**
96
+ * 获取启用状态
97
+ */
98
+ isEnabled(): boolean;
99
+ /**
100
+ * 设置启用状态
101
+ */
102
+ setEnabled(enabled: boolean): void;
103
+ /**
104
+ * 获取日志级别
105
+ */
106
+ getLogLevel(): string;
107
+ /**
108
+ * 设置日志级别
109
+ */
110
+ setLogLevel(level: 'debug' | 'info' | 'warn' | 'error'): void;
111
+ /**
112
+ * 重置为默认配置
113
+ */
114
+ reset(): void;
115
+ /**
116
+ * 订阅配置变化
117
+ */
118
+ onConfigChange(): Observable<{
119
+ key: string;
120
+ value: any;
121
+ }>;
122
+ /**
123
+ * 导出配置
124
+ */
125
+ exportConfig(): string;
126
+ /**
127
+ * 导入配置
128
+ */
129
+ importConfig(configJson: string): void;
130
+ /**
131
+ * 验证配置
132
+ */
133
+ validateConfig(): {
134
+ valid: boolean;
135
+ errors: string[];
136
+ };
137
+ }
@@ -0,0 +1,21 @@
1
+ export declare class LoggerService {
2
+ private logLevel;
3
+ private logs;
4
+ constructor();
5
+ private loadLogLevel;
6
+ debug(message: string, data?: any): void;
7
+ info(message: string, data?: any): void;
8
+ warn(message: string, data?: any): void;
9
+ error(message: string, error?: any): void;
10
+ private shouldLog;
11
+ private log;
12
+ getLogs(): Array<{
13
+ level: string;
14
+ message: string;
15
+ timestamp: Date;
16
+ data?: any;
17
+ }>;
18
+ clearLogs(): void;
19
+ setLogLevel(level: 'debug' | 'info' | 'warn' | 'error'): void;
20
+ getLogLevel(): string;
21
+ }
@@ -0,0 +1,39 @@
1
+ import { BaseAiProvider } from './base-provider.service';
2
+ import { ProviderCapability, HealthStatus, ValidationResult } from '../../types/provider.types';
3
+ import { ChatRequest, ChatResponse, CommandRequest, CommandResponse, ExplainRequest, ExplainResponse, AnalysisRequest, AnalysisResponse } from '../../types/ai.types';
4
+ import { LoggerService } from '../core/logger.service';
5
+ /**
6
+ * Anthropic Claude AI提供商
7
+ * 基于Anthropic Claude API
8
+ */
9
+ export declare class AnthropicProviderService extends BaseAiProvider {
10
+ readonly name = "anthropic";
11
+ readonly displayName = "Anthropic Claude";
12
+ readonly capabilities: ProviderCapability[];
13
+ readonly authConfig: {
14
+ type: "bearer";
15
+ credentials: {
16
+ apiKey: string;
17
+ };
18
+ };
19
+ private client;
20
+ constructor(logger: LoggerService);
21
+ configure(config: any): void;
22
+ private initializeClient;
23
+ chat(request: ChatRequest): Promise<ChatResponse>;
24
+ generateCommand(request: CommandRequest): Promise<CommandResponse>;
25
+ explainCommand(request: ExplainRequest): Promise<ExplainResponse>;
26
+ analyzeResult(request: AnalysisRequest): Promise<AnalysisResponse>;
27
+ healthCheck(): Promise<HealthStatus>;
28
+ validateConfig(): ValidationResult;
29
+ protected getDefaultBaseURL(): string;
30
+ protected transformMessages(messages: any[]): any[];
31
+ private transformChatResponse;
32
+ private buildCommandPrompt;
33
+ private buildExplainPrompt;
34
+ private buildAnalysisPrompt;
35
+ private parseCommandResponse;
36
+ private parseExplainResponse;
37
+ private parseAnalysisResponse;
38
+ private getDefaultSystemPrompt;
39
+ }