tabby-ai-assistant 1.0.9 → 1.0.11
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/dist/index.js +1 -1
- package/package.json +3 -3
- package/src/components/chat/ai-sidebar.component.scss +43 -0
- package/src/components/chat/ai-sidebar.component.ts +43 -1
- package/src/components/settings/ai-settings-tab.component.html +13 -5
- package/src/components/settings/ai-settings-tab.component.scss +164 -33
- package/src/components/settings/ai-settings-tab.component.ts +1 -0
- package/src/components/settings/context-settings.component.html +87 -0
- package/src/components/settings/context-settings.component.scss +133 -0
- package/src/components/settings/context-settings.component.ts +91 -0
- package/src/components/settings/provider-config.component.html +46 -12
- package/src/components/settings/provider-config.component.scss +59 -0
- package/src/components/settings/provider-config.component.ts +112 -15
- package/src/i18n/translations/en-US.ts +27 -1
- package/src/i18n/translations/ja-JP.ts +27 -1
- package/src/i18n/translations/zh-CN.ts +27 -1
- package/src/i18n/types.ts +28 -0
- package/src/index.ts +6 -0
- package/src/services/chat/chat-session.service.ts +91 -2
- package/src/services/context/manager.ts +33 -2
- package/src/services/core/ai-assistant.service.ts +35 -11
- package/src/services/core/config-provider.service.ts +66 -0
- package/src/services/core/toast.service.ts +36 -0
- package/src/services/providers/anthropic-provider.service.ts +12 -4
- package/src/services/providers/glm-provider.service.ts +12 -4
- package/src/services/providers/minimax-provider.service.ts +12 -4
- package/src/types/ai.types.ts +3 -3
- package/src/types/provider.types.ts +1 -0
- package/dist/components/chat/ai-sidebar.component.d.ts +0 -160
- package/dist/components/chat/chat-input.component.d.ts +0 -69
- package/dist/components/chat/chat-interface.component.d.ts +0 -124
- package/dist/components/chat/chat-message.component.d.ts +0 -53
- package/dist/components/chat/chat-settings.component.d.ts +0 -72
- package/dist/components/common/error-message.component.d.ts +0 -11
- package/dist/components/common/loading-spinner.component.d.ts +0 -4
- package/dist/components/security/consent-dialog.component.d.ts +0 -11
- package/dist/components/security/password-prompt.component.d.ts +0 -10
- package/dist/components/security/risk-confirm-dialog.component.d.ts +0 -36
- package/dist/components/settings/ai-settings-tab.component.d.ts +0 -82
- package/dist/components/settings/general-settings.component.d.ts +0 -94
- package/dist/components/settings/provider-config.component.d.ts +0 -273
- package/dist/components/settings/security-settings.component.d.ts +0 -33
- package/dist/components/terminal/ai-toolbar-button.component.d.ts +0 -10
- package/dist/components/terminal/command-preview.component.d.ts +0 -53
- package/dist/components/terminal/command-suggestion.component.d.ts +0 -16
- package/dist/i18n/index.d.ts +0 -48
- package/dist/i18n/translations/en-US.d.ts +0 -5
- package/dist/i18n/translations/ja-JP.d.ts +0 -5
- package/dist/i18n/translations/zh-CN.d.ts +0 -5
- package/dist/i18n/types.d.ts +0 -198
- package/dist/index-full.d.ts +0 -8
- package/dist/index-minimal.d.ts +0 -3
- package/dist/index.d.ts +0 -12
- package/dist/main.d.ts +0 -8
- package/dist/providers/tabby/ai-config.provider.d.ts +0 -70
- package/dist/providers/tabby/ai-hotkey.provider.d.ts +0 -15
- package/dist/providers/tabby/ai-settings-tab.provider.d.ts +0 -11
- package/dist/providers/tabby/ai-toolbar-button.provider.d.ts +0 -16
- package/dist/services/chat/ai-sidebar.service.d.ts +0 -111
- package/dist/services/chat/chat-history.service.d.ts +0 -145
- package/dist/services/chat/chat-session.service.d.ts +0 -113
- package/dist/services/chat/command-generator.service.d.ts +0 -49
- package/dist/services/context/compaction.d.ts +0 -90
- package/dist/services/context/manager.d.ts +0 -69
- package/dist/services/context/memory.d.ts +0 -116
- package/dist/services/context/token-budget.d.ts +0 -105
- package/dist/services/core/ai-assistant.service.d.ts +0 -127
- package/dist/services/core/ai-provider-manager.service.d.ts +0 -119
- package/dist/services/core/checkpoint.service.d.ts +0 -130
- package/dist/services/core/config-provider.service.d.ts +0 -137
- package/dist/services/core/logger.service.d.ts +0 -21
- package/dist/services/core/theme.service.d.ts +0 -53
- package/dist/services/platform/escape-sequence.service.d.ts +0 -132
- package/dist/services/platform/platform-detection.service.d.ts +0 -146
- package/dist/services/providers/anthropic-provider.service.d.ts +0 -44
- package/dist/services/providers/base-provider.service.d.ts +0 -142
- package/dist/services/providers/glm-provider.service.d.ts +0 -96
- package/dist/services/providers/minimax-provider.service.d.ts +0 -102
- package/dist/services/providers/ollama-provider.service.d.ts +0 -76
- package/dist/services/providers/openai-compatible.service.d.ts +0 -44
- package/dist/services/providers/openai-provider.service.d.ts +0 -43
- package/dist/services/providers/vllm-provider.service.d.ts +0 -82
- package/dist/services/security/consent-manager.service.d.ts +0 -65
- package/dist/services/security/password-manager.service.d.ts +0 -67
- package/dist/services/security/risk-assessment.service.d.ts +0 -65
- package/dist/services/security/security-validator.service.d.ts +0 -36
- package/dist/services/terminal/buffer-analyzer.service.d.ts +0 -128
- package/dist/services/terminal/command-analyzer.service.d.ts +0 -20
- package/dist/services/terminal/context-menu.service.d.ts +0 -24
- package/dist/services/terminal/hotkey.service.d.ts +0 -28
- package/dist/services/terminal/terminal-context.service.d.ts +0 -100
- package/dist/services/terminal/terminal-manager.service.d.ts +0 -185
- package/dist/services/terminal/terminal-tools.service.d.ts +0 -79
- package/dist/types/ai.types.d.ts +0 -199
- package/dist/types/provider.types.d.ts +0 -105
- package/dist/types/security.types.d.ts +0 -85
- package/dist/types/terminal.types.d.ts +0 -150
- package/dist/utils/encryption.utils.d.ts +0 -83
- package/dist/utils/formatting.utils.d.ts +0 -106
- package/dist/utils/validation.utils.d.ts +0 -83
- package/jest.config.js +0 -47
- package/webpack-docker.config.js +0 -42
- package/webpack.config.js +0 -81
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { LoggerService } from '../core/logger.service';
|
|
2
|
-
/**
|
|
3
|
-
* 操作系统类型
|
|
4
|
-
*/
|
|
5
|
-
export declare enum OSType {
|
|
6
|
-
LINUX = "linux",
|
|
7
|
-
WINDOWS = "windows",
|
|
8
|
-
MACOS = "macos",
|
|
9
|
-
UNKNOWN = "unknown"
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 终端类型
|
|
13
|
-
*/
|
|
14
|
-
export declare enum TerminalType {
|
|
15
|
-
XTERM = "xterm",
|
|
16
|
-
XTERM_256_COLOR = "xterm-256color",
|
|
17
|
-
LINUX_CONSOLE = "linux",
|
|
18
|
-
WINDOWS_CMD = "windows-cmd",
|
|
19
|
-
WINDOWS_POWERSHELL = "windows-powershell",
|
|
20
|
-
WINDOWS_WSL = "windows-wsl",
|
|
21
|
-
MACOS_TERMINAL = "macos-terminal",
|
|
22
|
-
ITerm2 = "iterm2",
|
|
23
|
-
UNKNOWN = "unknown"
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* 终端能力
|
|
27
|
-
*/
|
|
28
|
-
export interface TerminalCapabilities {
|
|
29
|
-
colors: number;
|
|
30
|
-
trueColor: boolean;
|
|
31
|
-
unicode: boolean;
|
|
32
|
-
mouse: boolean;
|
|
33
|
-
bracketedPaste: boolean;
|
|
34
|
-
imageSupport: boolean;
|
|
35
|
-
titleSupport: boolean;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* 平台信息
|
|
39
|
-
*/
|
|
40
|
-
export interface PlatformInfo {
|
|
41
|
-
os: OSType;
|
|
42
|
-
osVersion: string;
|
|
43
|
-
terminal: TerminalType;
|
|
44
|
-
terminalVersion?: string;
|
|
45
|
-
shell: string;
|
|
46
|
-
shellVersion?: string;
|
|
47
|
-
capabilities: TerminalCapabilities;
|
|
48
|
-
environment: Record<string, string>;
|
|
49
|
-
arch: string;
|
|
50
|
-
isVirtualTerminal: boolean;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* 环境分析结果
|
|
54
|
-
*/
|
|
55
|
-
export interface EnvironmentAnalysis {
|
|
56
|
-
platformInfo: PlatformInfo;
|
|
57
|
-
features: {
|
|
58
|
-
supportsAnsiColors: boolean;
|
|
59
|
-
supportsUnicode: boolean;
|
|
60
|
-
supportsTrueColor: boolean;
|
|
61
|
-
supportsMouseEvents: boolean;
|
|
62
|
-
supportsImages: boolean;
|
|
63
|
-
};
|
|
64
|
-
recommendations: string[];
|
|
65
|
-
compatibility: {
|
|
66
|
-
score: number;
|
|
67
|
-
issues: string[];
|
|
68
|
-
workarounds: string[];
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* 平台检测服务
|
|
73
|
-
* 提供跨平台终端环境检测、兼容性分析和能力检测功能
|
|
74
|
-
*/
|
|
75
|
-
export declare class PlatformDetectionService {
|
|
76
|
-
private logger;
|
|
77
|
-
private platformInfo;
|
|
78
|
-
private analysisCache;
|
|
79
|
-
constructor(logger: LoggerService);
|
|
80
|
-
/**
|
|
81
|
-
* 检测操作系统
|
|
82
|
-
*/
|
|
83
|
-
detectOS(): OSType;
|
|
84
|
-
/**
|
|
85
|
-
* 检测终端类型
|
|
86
|
-
*/
|
|
87
|
-
detectTerminal(): TerminalType;
|
|
88
|
-
/**
|
|
89
|
-
* 检查终端能力
|
|
90
|
-
*/
|
|
91
|
-
checkCapabilities(): TerminalCapabilities;
|
|
92
|
-
/**
|
|
93
|
-
* 分析环境
|
|
94
|
-
*/
|
|
95
|
-
analyzeEnvironment(): EnvironmentAnalysis;
|
|
96
|
-
/**
|
|
97
|
-
* 获取版本信息
|
|
98
|
-
*/
|
|
99
|
-
getVersionInfo(): {
|
|
100
|
-
osVersion: string;
|
|
101
|
-
terminalVersion?: string;
|
|
102
|
-
shellVersion?: string;
|
|
103
|
-
nodeVersion: string;
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* 获取完整的平台信息
|
|
107
|
-
*/
|
|
108
|
-
getPlatformInfo(): PlatformInfo;
|
|
109
|
-
/**
|
|
110
|
-
* 检查是否支持特定功能
|
|
111
|
-
*/
|
|
112
|
-
supportsFeature(feature: 'ansiColors' | 'unicode' | 'trueColor' | 'mouse' | 'images'): boolean;
|
|
113
|
-
/**
|
|
114
|
-
* 获取终端颜色数(公共方法)
|
|
115
|
-
*/
|
|
116
|
-
getTerminalColorCount(): number;
|
|
117
|
-
/**
|
|
118
|
-
* 检查是否为Windows WSL环境
|
|
119
|
-
*/
|
|
120
|
-
isWSL(): boolean;
|
|
121
|
-
/**
|
|
122
|
-
* 检查是否通过SSH连接
|
|
123
|
-
*/
|
|
124
|
-
isSSH(): boolean;
|
|
125
|
-
/**
|
|
126
|
-
* 清理缓存并重新检测
|
|
127
|
-
*/
|
|
128
|
-
refresh(): void;
|
|
129
|
-
private detectPlatform;
|
|
130
|
-
private getColorCount;
|
|
131
|
-
private supportsTrueColor;
|
|
132
|
-
private supportsUnicode;
|
|
133
|
-
private supportsMouse;
|
|
134
|
-
private supportsBracketedPaste;
|
|
135
|
-
private supportsImages;
|
|
136
|
-
private supportsTitle;
|
|
137
|
-
private analyzeFeatures;
|
|
138
|
-
private generateRecommendations;
|
|
139
|
-
private analyzeCompatibility;
|
|
140
|
-
private getOSVersion;
|
|
141
|
-
private getTerminalVersion;
|
|
142
|
-
private getActiveShell;
|
|
143
|
-
private getShellVersion;
|
|
144
|
-
private isVirtualTerminal;
|
|
145
|
-
private filterEnvVariables;
|
|
146
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { BaseAiProvider } from './base-provider.service';
|
|
3
|
-
import { ProviderCapability, HealthStatus, ValidationResult } from '../../types/provider.types';
|
|
4
|
-
import { ChatRequest, ChatResponse, CommandRequest, CommandResponse, ExplainRequest, ExplainResponse, AnalysisRequest, AnalysisResponse } from '../../types/ai.types';
|
|
5
|
-
import { LoggerService } from '../core/logger.service';
|
|
6
|
-
/**
|
|
7
|
-
* Anthropic Claude AI提供商
|
|
8
|
-
* 基于Anthropic Claude API
|
|
9
|
-
*/
|
|
10
|
-
export declare class AnthropicProviderService extends BaseAiProvider {
|
|
11
|
-
readonly name = "anthropic";
|
|
12
|
-
readonly displayName = "Anthropic Claude";
|
|
13
|
-
readonly capabilities: ProviderCapability[];
|
|
14
|
-
readonly authConfig: {
|
|
15
|
-
type: "bearer";
|
|
16
|
-
credentials: {
|
|
17
|
-
apiKey: string;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
private client;
|
|
21
|
-
constructor(logger: LoggerService);
|
|
22
|
-
configure(config: any): void;
|
|
23
|
-
private initializeClient;
|
|
24
|
-
chat(request: ChatRequest): Promise<ChatResponse>;
|
|
25
|
-
/**
|
|
26
|
-
* 流式聊天功能 - 暂未实现,回退到非流式
|
|
27
|
-
*/
|
|
28
|
-
chatStream(request: ChatRequest): Observable<any>;
|
|
29
|
-
generateCommand(request: CommandRequest): Promise<CommandResponse>;
|
|
30
|
-
explainCommand(request: ExplainRequest): Promise<ExplainResponse>;
|
|
31
|
-
analyzeResult(request: AnalysisRequest): Promise<AnalysisResponse>;
|
|
32
|
-
healthCheck(): Promise<HealthStatus>;
|
|
33
|
-
validateConfig(): ValidationResult;
|
|
34
|
-
protected getDefaultBaseURL(): string;
|
|
35
|
-
protected transformMessages(messages: any[]): any[];
|
|
36
|
-
private transformChatResponse;
|
|
37
|
-
private buildCommandPrompt;
|
|
38
|
-
private buildExplainPrompt;
|
|
39
|
-
private buildAnalysisPrompt;
|
|
40
|
-
private parseCommandResponse;
|
|
41
|
-
private parseExplainResponse;
|
|
42
|
-
private parseAnalysisResponse;
|
|
43
|
-
private getDefaultSystemPrompt;
|
|
44
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { BaseAiProvider as IBaseAiProvider, ProviderConfig, AuthConfig, ProviderCapability, HealthStatus, ValidationResult } from '../../types/provider.types';
|
|
3
|
-
import { ChatRequest, ChatResponse, CommandRequest, CommandResponse, ExplainRequest, ExplainResponse, AnalysisRequest, AnalysisResponse, StreamEvent } from '../../types/ai.types';
|
|
4
|
-
import { LoggerService } from '../core/logger.service';
|
|
5
|
-
/**
|
|
6
|
-
* 基础AI提供商抽象类
|
|
7
|
-
* 所有AI提供商都应该继承此类
|
|
8
|
-
*/
|
|
9
|
-
export declare abstract class BaseAiProvider extends IBaseAiProvider {
|
|
10
|
-
protected logger: LoggerService;
|
|
11
|
-
abstract readonly name: string;
|
|
12
|
-
abstract readonly displayName: string;
|
|
13
|
-
abstract readonly capabilities: ProviderCapability[];
|
|
14
|
-
abstract readonly authConfig: AuthConfig;
|
|
15
|
-
protected config: ProviderConfig | null;
|
|
16
|
-
protected isInitialized: boolean;
|
|
17
|
-
protected lastHealthCheck: {
|
|
18
|
-
status: HealthStatus;
|
|
19
|
-
timestamp: Date;
|
|
20
|
-
} | null;
|
|
21
|
-
constructor(logger: LoggerService);
|
|
22
|
-
/**
|
|
23
|
-
* 配置提供商
|
|
24
|
-
*/
|
|
25
|
-
configure(config: ProviderConfig): void;
|
|
26
|
-
/**
|
|
27
|
-
* 聊天功能 - 必须由子类实现
|
|
28
|
-
*/
|
|
29
|
-
abstract chat(request: ChatRequest): Promise<ChatResponse>;
|
|
30
|
-
/**
|
|
31
|
-
* 流式聊天功能 - 必须由子类实现
|
|
32
|
-
*/
|
|
33
|
-
abstract chatStream(request: ChatRequest): Observable<StreamEvent>;
|
|
34
|
-
/**
|
|
35
|
-
* 生成命令 - 必须由子类实现
|
|
36
|
-
*/
|
|
37
|
-
abstract generateCommand(request: CommandRequest): Promise<CommandResponse>;
|
|
38
|
-
/**
|
|
39
|
-
* 解释命令 - 必须由子类实现
|
|
40
|
-
*/
|
|
41
|
-
abstract explainCommand(request: ExplainRequest): Promise<ExplainResponse>;
|
|
42
|
-
/**
|
|
43
|
-
* 分析结果 - 必须由子类实现
|
|
44
|
-
*/
|
|
45
|
-
abstract analyzeResult(request: AnalysisRequest): Promise<AnalysisResponse>;
|
|
46
|
-
/**
|
|
47
|
-
* 健康检查 - 默认实现,子类可以重写
|
|
48
|
-
*/
|
|
49
|
-
healthCheck(): Promise<HealthStatus>;
|
|
50
|
-
/**
|
|
51
|
-
* 验证配置 - 默认实现,子类可以重写
|
|
52
|
-
*/
|
|
53
|
-
validateConfig(): ValidationResult;
|
|
54
|
-
/**
|
|
55
|
-
* 检查是否支持指定能力
|
|
56
|
-
*/
|
|
57
|
-
supportsCapability(capability: ProviderCapability): boolean;
|
|
58
|
-
/**
|
|
59
|
-
* 获取提供商信息
|
|
60
|
-
*/
|
|
61
|
-
getInfo(): any;
|
|
62
|
-
/**
|
|
63
|
-
* 获取当前配置
|
|
64
|
-
*/
|
|
65
|
-
getConfig(): ProviderConfig | null;
|
|
66
|
-
/**
|
|
67
|
-
* 检查是否已配置
|
|
68
|
-
*/
|
|
69
|
-
isConfigured(): boolean;
|
|
70
|
-
/**
|
|
71
|
-
* 检查是否启用
|
|
72
|
-
*/
|
|
73
|
-
isEnabled(): boolean;
|
|
74
|
-
/**
|
|
75
|
-
* 获取认证头
|
|
76
|
-
*/
|
|
77
|
-
protected getAuthHeaders(): Record<string, string>;
|
|
78
|
-
/**
|
|
79
|
-
* 获取请求超时时间
|
|
80
|
-
*/
|
|
81
|
-
protected getTimeout(): number;
|
|
82
|
-
/**
|
|
83
|
-
* 获取重试次数
|
|
84
|
-
*/
|
|
85
|
-
protected getRetries(): number;
|
|
86
|
-
/**
|
|
87
|
-
* 执行重试逻辑
|
|
88
|
-
*/
|
|
89
|
-
protected withRetry<T>(operation: () => Promise<T>): Promise<T>;
|
|
90
|
-
/**
|
|
91
|
-
* 记录请求
|
|
92
|
-
*/
|
|
93
|
-
protected logRequest(request: any): void;
|
|
94
|
-
/**
|
|
95
|
-
* 记录响应
|
|
96
|
-
*/
|
|
97
|
-
protected logResponse(response: any): void;
|
|
98
|
-
/**
|
|
99
|
-
* 记录错误
|
|
100
|
-
*/
|
|
101
|
-
protected logError(error: any, context?: any): void;
|
|
102
|
-
/**
|
|
103
|
-
* 清理请求数据(移除敏感信息)
|
|
104
|
-
*/
|
|
105
|
-
protected sanitizeRequest(request: any): any;
|
|
106
|
-
/**
|
|
107
|
-
* 清理响应数据
|
|
108
|
-
*/
|
|
109
|
-
protected sanitizeResponse(response: any): any;
|
|
110
|
-
/**
|
|
111
|
-
* 获取基础URL
|
|
112
|
-
*/
|
|
113
|
-
protected getBaseURL(): string;
|
|
114
|
-
/**
|
|
115
|
-
* 获取默认基础URL - 子类必须实现
|
|
116
|
-
*/
|
|
117
|
-
protected abstract getDefaultBaseURL(): string;
|
|
118
|
-
/**
|
|
119
|
-
* 获取默认模型 - 子类可以重写
|
|
120
|
-
*/
|
|
121
|
-
protected getDefaultModel(): string;
|
|
122
|
-
/**
|
|
123
|
-
* 转换聊天消息格式 - 子类可以重写
|
|
124
|
-
*/
|
|
125
|
-
protected transformMessages(messages: any[]): any[];
|
|
126
|
-
/**
|
|
127
|
-
* 转换响应格式 - 子类可以重写
|
|
128
|
-
*/
|
|
129
|
-
protected transformResponse(response: any): ChatResponse;
|
|
130
|
-
/**
|
|
131
|
-
* 生成唯一ID
|
|
132
|
-
*/
|
|
133
|
-
protected generateId(): string;
|
|
134
|
-
/**
|
|
135
|
-
* 检查响应是否成功
|
|
136
|
-
*/
|
|
137
|
-
protected isSuccessfulResponse(response: any): boolean;
|
|
138
|
-
/**
|
|
139
|
-
* 提取错误信息
|
|
140
|
-
*/
|
|
141
|
-
protected extractError(response: any): string;
|
|
142
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { BaseAiProvider } from './base-provider.service';
|
|
3
|
-
import { ProviderCapability, HealthStatus, ValidationResult } from '../../types/provider.types';
|
|
4
|
-
import { ChatRequest, ChatResponse, CommandRequest, CommandResponse, ExplainRequest, ExplainResponse, AnalysisRequest, AnalysisResponse } from '../../types/ai.types';
|
|
5
|
-
import { LoggerService } from '../core/logger.service';
|
|
6
|
-
/**
|
|
7
|
-
* GLM (ChatGLM) AI提供商
|
|
8
|
-
* 基于Anthropic兼容API格式
|
|
9
|
-
*/
|
|
10
|
-
export declare class GlmProviderService extends BaseAiProvider {
|
|
11
|
-
readonly name = "glm";
|
|
12
|
-
readonly displayName = "GLM (ChatGLM-4.6)";
|
|
13
|
-
readonly capabilities: ProviderCapability[];
|
|
14
|
-
readonly authConfig: {
|
|
15
|
-
type: "bearer";
|
|
16
|
-
credentials: {
|
|
17
|
-
apiKey: string;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
private client;
|
|
21
|
-
constructor(logger: LoggerService);
|
|
22
|
-
/**
|
|
23
|
-
* 配置提供商
|
|
24
|
-
*/
|
|
25
|
-
configure(config: any): void;
|
|
26
|
-
/**
|
|
27
|
-
* 初始化HTTP客户端
|
|
28
|
-
*/
|
|
29
|
-
private initializeClient;
|
|
30
|
-
/**
|
|
31
|
-
* 聊天功能
|
|
32
|
-
*/
|
|
33
|
-
chat(request: ChatRequest): Promise<ChatResponse>;
|
|
34
|
-
/**
|
|
35
|
-
* 流式聊天功能 - 暂未实现,回退到非流式
|
|
36
|
-
*/
|
|
37
|
-
chatStream(request: ChatRequest): Observable<any>;
|
|
38
|
-
/**
|
|
39
|
-
* 生成命令
|
|
40
|
-
*/
|
|
41
|
-
generateCommand(request: CommandRequest): Promise<CommandResponse>;
|
|
42
|
-
/**
|
|
43
|
-
* 解释命令
|
|
44
|
-
*/
|
|
45
|
-
explainCommand(request: ExplainRequest): Promise<ExplainResponse>;
|
|
46
|
-
/**
|
|
47
|
-
* 分析结果
|
|
48
|
-
*/
|
|
49
|
-
analyzeResult(request: AnalysisRequest): Promise<AnalysisResponse>;
|
|
50
|
-
/**
|
|
51
|
-
* 健康检查
|
|
52
|
-
*/
|
|
53
|
-
healthCheck(): Promise<HealthStatus>;
|
|
54
|
-
/**
|
|
55
|
-
* 验证配置
|
|
56
|
-
*/
|
|
57
|
-
validateConfig(): ValidationResult;
|
|
58
|
-
/**
|
|
59
|
-
* 获取默认基础URL
|
|
60
|
-
* GLM提供与Anthropic兼容的API端点
|
|
61
|
-
*/
|
|
62
|
-
protected getDefaultBaseURL(): string;
|
|
63
|
-
/**
|
|
64
|
-
* 转换消息格式(Anthropic兼容)
|
|
65
|
-
*/
|
|
66
|
-
protected transformMessages(messages: any[]): any[];
|
|
67
|
-
/**
|
|
68
|
-
* 转换聊天响应
|
|
69
|
-
*/
|
|
70
|
-
private transformChatResponse;
|
|
71
|
-
/**
|
|
72
|
-
* 构建命令生成提示
|
|
73
|
-
*/
|
|
74
|
-
private buildCommandPrompt;
|
|
75
|
-
/**
|
|
76
|
-
* 构建命令解释提示
|
|
77
|
-
*/
|
|
78
|
-
private buildExplainPrompt;
|
|
79
|
-
/**
|
|
80
|
-
* 构建结果分析提示
|
|
81
|
-
*/
|
|
82
|
-
private buildAnalysisPrompt;
|
|
83
|
-
/**
|
|
84
|
-
* 解析命令响应
|
|
85
|
-
*/
|
|
86
|
-
private parseCommandResponse;
|
|
87
|
-
/**
|
|
88
|
-
* 解析解释响应
|
|
89
|
-
*/
|
|
90
|
-
private parseExplainResponse;
|
|
91
|
-
/**
|
|
92
|
-
* 解析分析响应
|
|
93
|
-
*/
|
|
94
|
-
private parseAnalysisResponse;
|
|
95
|
-
private getDefaultSystemPrompt;
|
|
96
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { BaseAiProvider } from './base-provider.service';
|
|
3
|
-
import { ProviderCapability, HealthStatus, ValidationResult } from '../../types/provider.types';
|
|
4
|
-
import { ChatRequest, ChatResponse, CommandRequest, CommandResponse, ExplainRequest, ExplainResponse, AnalysisRequest, AnalysisResponse, StreamEvent } from '../../types/ai.types';
|
|
5
|
-
import { LoggerService } from '../core/logger.service';
|
|
6
|
-
/**
|
|
7
|
-
* Minimax AI提供商
|
|
8
|
-
* 基于Anthropic Claude API,完全兼容Anthropic格式
|
|
9
|
-
*/
|
|
10
|
-
export declare class MinimaxProviderService extends BaseAiProvider {
|
|
11
|
-
readonly name = "minimax";
|
|
12
|
-
readonly displayName = "Minimax (MiniMax-M2)";
|
|
13
|
-
readonly capabilities: ProviderCapability[];
|
|
14
|
-
readonly authConfig: {
|
|
15
|
-
type: "bearer";
|
|
16
|
-
credentials: {
|
|
17
|
-
apiKey: string;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
private client;
|
|
21
|
-
constructor(logger: LoggerService);
|
|
22
|
-
/**
|
|
23
|
-
* 配置提供商
|
|
24
|
-
*/
|
|
25
|
-
configure(config: any): void;
|
|
26
|
-
/**
|
|
27
|
-
* 初始化Anthropic客户端
|
|
28
|
-
*/
|
|
29
|
-
private initializeClient;
|
|
30
|
-
/**
|
|
31
|
-
* 聊天功能
|
|
32
|
-
*/
|
|
33
|
-
chat(request: ChatRequest): Promise<ChatResponse>;
|
|
34
|
-
/**
|
|
35
|
-
* 流式聊天功能
|
|
36
|
-
*/
|
|
37
|
-
chatStream(request: ChatRequest): Observable<StreamEvent>;
|
|
38
|
-
/**
|
|
39
|
-
* 生成命令
|
|
40
|
-
*/
|
|
41
|
-
generateCommand(request: CommandRequest): Promise<CommandResponse>;
|
|
42
|
-
/**
|
|
43
|
-
* 解释命令
|
|
44
|
-
*/
|
|
45
|
-
explainCommand(request: ExplainRequest): Promise<ExplainResponse>;
|
|
46
|
-
/**
|
|
47
|
-
* 分析结果
|
|
48
|
-
*/
|
|
49
|
-
analyzeResult(request: AnalysisRequest): Promise<AnalysisResponse>;
|
|
50
|
-
/**
|
|
51
|
-
* 健康检查
|
|
52
|
-
*/
|
|
53
|
-
healthCheck(): Promise<HealthStatus>;
|
|
54
|
-
/**
|
|
55
|
-
* 验证配置
|
|
56
|
-
*/
|
|
57
|
-
validateConfig(): ValidationResult;
|
|
58
|
-
/**
|
|
59
|
-
* 获取默认基础URL
|
|
60
|
-
*/
|
|
61
|
-
protected getDefaultBaseURL(): string;
|
|
62
|
-
/**
|
|
63
|
-
* 转换消息格式
|
|
64
|
-
* Anthropic API 支持两种格式:
|
|
65
|
-
* 1. 简单字符串: { role: 'user', content: 'Hello' }
|
|
66
|
-
* 2. 内容块数组: { role: 'user', content: [{ type: 'text', text: 'Hello' }] }
|
|
67
|
-
* 使用简单字符串格式以确保兼容性
|
|
68
|
-
*/
|
|
69
|
-
protected transformMessages(messages: any[]): any[];
|
|
70
|
-
/**
|
|
71
|
-
* 转换聊天响应
|
|
72
|
-
*/
|
|
73
|
-
private transformChatResponse;
|
|
74
|
-
/**
|
|
75
|
-
* 构建命令生成提示
|
|
76
|
-
*/
|
|
77
|
-
private buildCommandPrompt;
|
|
78
|
-
/**
|
|
79
|
-
* 构建命令解释提示
|
|
80
|
-
*/
|
|
81
|
-
private buildExplainPrompt;
|
|
82
|
-
/**
|
|
83
|
-
* 构建结果分析提示
|
|
84
|
-
*/
|
|
85
|
-
private buildAnalysisPrompt;
|
|
86
|
-
/**
|
|
87
|
-
* 解析命令响应
|
|
88
|
-
*/
|
|
89
|
-
private parseCommandResponse;
|
|
90
|
-
/**
|
|
91
|
-
* 解析解释响应
|
|
92
|
-
*/
|
|
93
|
-
private parseExplainResponse;
|
|
94
|
-
/**
|
|
95
|
-
* 解析分析响应
|
|
96
|
-
*/
|
|
97
|
-
private parseAnalysisResponse;
|
|
98
|
-
/**
|
|
99
|
-
* 获取默认系统提示
|
|
100
|
-
*/
|
|
101
|
-
private getDefaultSystemPrompt;
|
|
102
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { BaseAiProvider } from './base-provider.service';
|
|
3
|
-
import { ProviderCapability, HealthStatus, ValidationResult } from '../../types/provider.types';
|
|
4
|
-
import { ChatRequest, ChatResponse, StreamEvent, CommandRequest, CommandResponse, ExplainRequest, ExplainResponse, AnalysisRequest, AnalysisResponse } from '../../types/ai.types';
|
|
5
|
-
import { LoggerService } from '../core/logger.service';
|
|
6
|
-
/**
|
|
7
|
-
* Ollama 本地 AI 提供商
|
|
8
|
-
* 兼容 OpenAI API 格式,默认端口 11434
|
|
9
|
-
*/
|
|
10
|
-
export declare class OllamaProviderService extends BaseAiProvider {
|
|
11
|
-
readonly name = "ollama";
|
|
12
|
-
readonly displayName = "Ollama (\u672C\u5730)";
|
|
13
|
-
readonly capabilities: ProviderCapability[];
|
|
14
|
-
readonly authConfig: {
|
|
15
|
-
type: "none";
|
|
16
|
-
credentials: {};
|
|
17
|
-
};
|
|
18
|
-
constructor(logger: LoggerService);
|
|
19
|
-
protected getDefaultBaseURL(): string;
|
|
20
|
-
/**
|
|
21
|
-
* 非流式聊天
|
|
22
|
-
*/
|
|
23
|
-
chat(request: ChatRequest): Promise<ChatResponse>;
|
|
24
|
-
/**
|
|
25
|
-
* 流式聊天
|
|
26
|
-
*/
|
|
27
|
-
chatStream(request: ChatRequest): Observable<StreamEvent>;
|
|
28
|
-
/**
|
|
29
|
-
* 健康检查 - 检测 Ollama 服务是否运行
|
|
30
|
-
*/
|
|
31
|
-
healthCheck(): Promise<HealthStatus>;
|
|
32
|
-
/**
|
|
33
|
-
* 验证配置 - 本地服务无需 API Key
|
|
34
|
-
*/
|
|
35
|
-
validateConfig(): ValidationResult;
|
|
36
|
-
/**
|
|
37
|
-
* 生成命令
|
|
38
|
-
*/
|
|
39
|
-
generateCommand(request: CommandRequest): Promise<CommandResponse>;
|
|
40
|
-
/**
|
|
41
|
-
* 解释命令
|
|
42
|
-
*/
|
|
43
|
-
explainCommand(request: ExplainRequest): Promise<ExplainResponse>;
|
|
44
|
-
/**
|
|
45
|
-
* 分析结果
|
|
46
|
-
*/
|
|
47
|
-
analyzeResult(request: AnalysisRequest): Promise<AnalysisResponse>;
|
|
48
|
-
/**
|
|
49
|
-
* 转换消息格式
|
|
50
|
-
*/
|
|
51
|
-
protected transformMessages(messages: any[]): any[];
|
|
52
|
-
/**
|
|
53
|
-
* 构建命令生成提示
|
|
54
|
-
*/
|
|
55
|
-
private buildCommandPrompt;
|
|
56
|
-
/**
|
|
57
|
-
* 构建命令解释提示
|
|
58
|
-
*/
|
|
59
|
-
private buildExplainPrompt;
|
|
60
|
-
/**
|
|
61
|
-
* 构建结果分析提示
|
|
62
|
-
*/
|
|
63
|
-
private buildAnalysisPrompt;
|
|
64
|
-
/**
|
|
65
|
-
* 解析命令响应
|
|
66
|
-
*/
|
|
67
|
-
private parseCommandResponse;
|
|
68
|
-
/**
|
|
69
|
-
* 解析解释响应
|
|
70
|
-
*/
|
|
71
|
-
private parseExplainResponse;
|
|
72
|
-
/**
|
|
73
|
-
* 解析分析响应
|
|
74
|
-
*/
|
|
75
|
-
private parseAnalysisResponse;
|
|
76
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { BaseAiProvider } from './base-provider.service';
|
|
3
|
-
import { ProviderCapability, HealthStatus, ValidationResult } from '../../types/provider.types';
|
|
4
|
-
import { ChatRequest, ChatResponse, CommandRequest, CommandResponse, ExplainRequest, ExplainResponse, AnalysisRequest, AnalysisResponse } from '../../types/ai.types';
|
|
5
|
-
import { LoggerService } from '../core/logger.service';
|
|
6
|
-
/**
|
|
7
|
-
* OpenAI兼容AI提供商
|
|
8
|
-
* 支持LocalAI、Ollama、OpenRouter等OpenAI API兼容服务
|
|
9
|
-
*/
|
|
10
|
-
export declare class OpenAiCompatibleProviderService extends BaseAiProvider {
|
|
11
|
-
readonly name = "openai-compatible";
|
|
12
|
-
readonly displayName = "OpenAI Compatible";
|
|
13
|
-
readonly capabilities: ProviderCapability[];
|
|
14
|
-
readonly authConfig: {
|
|
15
|
-
type: "bearer";
|
|
16
|
-
credentials: {
|
|
17
|
-
apiKey: string;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
private client;
|
|
21
|
-
private supportedModels;
|
|
22
|
-
constructor(logger: LoggerService);
|
|
23
|
-
configure(config: any): void;
|
|
24
|
-
private initializeClient;
|
|
25
|
-
chat(request: ChatRequest): Promise<ChatResponse>;
|
|
26
|
-
/**
|
|
27
|
-
* 流式聊天功能 - 暂未实现,回退到非流式
|
|
28
|
-
*/
|
|
29
|
-
chatStream(request: ChatRequest): Observable<any>;
|
|
30
|
-
generateCommand(request: CommandRequest): Promise<CommandResponse>;
|
|
31
|
-
explainCommand(request: ExplainRequest): Promise<ExplainResponse>;
|
|
32
|
-
analyzeResult(request: AnalysisRequest): Promise<AnalysisResponse>;
|
|
33
|
-
healthCheck(): Promise<HealthStatus>;
|
|
34
|
-
validateConfig(): ValidationResult;
|
|
35
|
-
protected getDefaultBaseURL(): string;
|
|
36
|
-
protected transformMessages(messages: any[]): any[];
|
|
37
|
-
private transformChatResponse;
|
|
38
|
-
private buildCommandPrompt;
|
|
39
|
-
private buildExplainPrompt;
|
|
40
|
-
private buildAnalysisPrompt;
|
|
41
|
-
private parseCommandResponse;
|
|
42
|
-
private parseExplainResponse;
|
|
43
|
-
private parseAnalysisResponse;
|
|
44
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { BaseAiProvider } from './base-provider.service';
|
|
3
|
-
import { ProviderCapability, HealthStatus, ValidationResult } from '../../types/provider.types';
|
|
4
|
-
import { ChatRequest, ChatResponse, CommandRequest, CommandResponse, ExplainRequest, ExplainResponse, AnalysisRequest, AnalysisResponse } from '../../types/ai.types';
|
|
5
|
-
import { LoggerService } from '../core/logger.service';
|
|
6
|
-
/**
|
|
7
|
-
* OpenAI AI提供商
|
|
8
|
-
* 基于OpenAI API格式
|
|
9
|
-
*/
|
|
10
|
-
export declare class OpenAiProviderService extends BaseAiProvider {
|
|
11
|
-
readonly name = "openai";
|
|
12
|
-
readonly displayName = "OpenAI (GPT-4)";
|
|
13
|
-
readonly capabilities: ProviderCapability[];
|
|
14
|
-
readonly authConfig: {
|
|
15
|
-
type: "bearer";
|
|
16
|
-
credentials: {
|
|
17
|
-
apiKey: string;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
private client;
|
|
21
|
-
constructor(logger: LoggerService);
|
|
22
|
-
configure(config: any): void;
|
|
23
|
-
private initializeClient;
|
|
24
|
-
chat(request: ChatRequest): Promise<ChatResponse>;
|
|
25
|
-
/**
|
|
26
|
-
* 流式聊天功能 - 暂未实现,回退到非流式
|
|
27
|
-
*/
|
|
28
|
-
chatStream(request: ChatRequest): Observable<any>;
|
|
29
|
-
generateCommand(request: CommandRequest): Promise<CommandResponse>;
|
|
30
|
-
explainCommand(request: ExplainRequest): Promise<ExplainResponse>;
|
|
31
|
-
analyzeResult(request: AnalysisRequest): Promise<AnalysisResponse>;
|
|
32
|
-
healthCheck(): Promise<HealthStatus>;
|
|
33
|
-
validateConfig(): ValidationResult;
|
|
34
|
-
protected getDefaultBaseURL(): string;
|
|
35
|
-
protected transformMessages(messages: any[]): any[];
|
|
36
|
-
private transformChatResponse;
|
|
37
|
-
private buildCommandPrompt;
|
|
38
|
-
private buildExplainPrompt;
|
|
39
|
-
private buildAnalysisPrompt;
|
|
40
|
-
private parseCommandResponse;
|
|
41
|
-
private parseExplainResponse;
|
|
42
|
-
private parseAnalysisResponse;
|
|
43
|
-
}
|